annotate lisp/custom.el @ 249:83b3d10dcba9 r20-5b23

Import from CVS: tag r20-5b23
author cvs
date Mon, 13 Aug 2007 10:19:09 +0200
parents 0e522484dd2a
children a4f53d9b3154
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
1 ;;; custom.el -- Tools for declaring and initializing options.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
2
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
4
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
6 ;; Maintainer: Hrvoje Niksic <hniksic@srce.hr>
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
7 ;; Keywords: help, faces, dumped
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
8 ;; Version: 1.9960-x
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
10
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
12
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
16 ;; any later version.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
17
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
22
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
27
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
28 ;;; Commentary:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
29
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
31
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
32 ;; This file only contain the code needed to declare and initialize
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
33 ;; user options. The code to customize options is autoloaded from
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
34 ;; `cus-edit.el'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
35 ;;
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
36 ;; The code implementing face declarations is in `cus-face.el'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
37
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
38 ;;; Code:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
39
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
40 (require 'widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
41
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
42 (defvar custom-define-hook nil
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
43 ;; Customize information for this option is in `cus-edit.el'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
44 "Hook called after defining each customize option.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
45
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
46 ;;; The `defcustom' Macro.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
47
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
48 (defun custom-initialize-default (symbol value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
49 "Initialize SYMBOL with VALUE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
50 This will do nothing if symbol already has a default binding.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
51 Otherwise, if symbol has a `saved-value' property, it will evaluate
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
52 the car of that and used as the default binding for symbol.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
53 Otherwise, VALUE will be evaluated and used as the default binding for
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
54 symbol."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
55 (unless (default-boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
56 ;; Use the saved value if it exists, otherwise the standard setting.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
57 (set-default symbol (if (get symbol 'saved-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
58 (eval (car (get symbol 'saved-value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
59 (eval value)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
60
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
61 (defun custom-initialize-set (symbol value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
62 "Initialize SYMBOL with VALUE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
63 Like `custom-initialize-default', but use the function specified by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
64 `:set' to initialize SYMBOL."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
65 (unless (default-boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
66 (funcall (or (get symbol 'custom-set) 'set-default)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
67 symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
68 (if (get symbol 'saved-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
69 (eval (car (get symbol 'saved-value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
70 (eval value)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
71
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
72 (defun custom-initialize-reset (symbol value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
73 "Initialize SYMBOL with VALUE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
74 Like `custom-initialize-set', but use the function specified by
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
75 `:get' to reinitialize SYMBOL if it is already bound."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
76 (funcall (or (get symbol 'custom-set) 'set-default)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
77 symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
78 (cond ((default-boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
79 (funcall (or (get symbol 'custom-get) 'default-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
80 symbol))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
81 ((get symbol 'saved-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
82 (eval (car (get symbol 'saved-value))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
83 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
84 (eval value)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
85
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
86 (defun custom-initialize-changed (symbol value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
87 "Initialize SYMBOL with VALUE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
88 Like `custom-initialize-reset', but only use the `:set' function if the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
89 not using the standard setting. Otherwise, use the `set-default'."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
90 (cond ((default-boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
91 (funcall (or (get symbol 'custom-set) 'set-default)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
92 symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
93 (funcall (or (get symbol 'custom-get) 'default-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
94 symbol)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
95 ((get symbol 'saved-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
96 (funcall (or (get symbol 'custom-set) 'set-default)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
97 symbol
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
98 (eval (car (get symbol 'saved-value)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
99 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
100 (set-default symbol (eval value)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
101
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
102 (defun custom-declare-variable (symbol value doc &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
103 "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
104 ;; Remember the standard setting.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
105 (put symbol 'standard-value (list value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
106 ;; Maybe this option was rogue in an earlier version. It no longer is.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
107 (when (get symbol 'force-value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
108 ;; It no longer is.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
109 (put symbol 'force-value nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
110 (when doc
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
111 (put symbol 'variable-documentation doc))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
112 (let ((initialize 'custom-initialize-reset)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
113 (requests nil))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
114 (while args
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
115 (let ((arg (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
116 (setq args (cdr args))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
117 (check-argument-type 'keywordp arg)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
118 (let ((keyword arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
119 (value (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
120 (unless args
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
121 (signal 'error (list "Keyword is missing an argument" keyword)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
122 (setq args (cdr args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
123 (cond ((eq keyword :initialize)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
124 (setq initialize value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
125 ((eq keyword :set)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
126 (put symbol 'custom-set value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
127 ((eq keyword :get)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
128 (put symbol 'custom-get value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
129 ((eq keyword :require)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
130 (setq requests (cons value requests)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
131 ((eq keyword :type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
132 (put symbol 'custom-type value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
133 ((eq keyword :options)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
134 (if (get symbol 'custom-options)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
135 ;; Slow safe code to avoid duplicates.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
136 (mapc (lambda (option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
137 (custom-add-option symbol option))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
138 value)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
139 ;; Fast code for the common case.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
140 (put symbol 'custom-options (copy-sequence value))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
141 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
142 (custom-handle-keyword symbol keyword value
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
143 'custom-variable))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
144 (put symbol 'custom-requests requests)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
145 ;; Do the actual initialization.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
146 (funcall initialize symbol value))
217
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 209
diff changeset
147 ;; #### This is a rough equivalent of LOADHIST_ATTACH. However,
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 209
diff changeset
148 ;; LOADHIST_ATTACH also checks for `initialized'.
d44af0c54775 Import from CVS: tag r20-4b7
cvs
parents: 209
diff changeset
149 (push symbol current-load-list)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
150 (run-hooks 'custom-define-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
151 symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
152
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
153 (defmacro defcustom (symbol value doc &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
154 "Declare SYMBOL as a customizable variable that defaults to VALUE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
155 DOC is the variable documentation.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
156
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
157 Neither SYMBOL nor VALUE needs to be quoted.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
158 If SYMBOL is not already bound, initialize it to VALUE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
159 The remaining arguments should have the form
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
160
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
161 [KEYWORD VALUE]...
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
162
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
163 The following KEYWORD's are defined:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
164
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
165 :type VALUE should be a widget type for editing the symbols value.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
166 The default is `sexp'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
167 :options VALUE should be a list of valid members of the widget type.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
168 :group VALUE should be a customization group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
169 Add SYMBOL to that group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
170 :initialize VALUE should be a function used to initialize the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
171 variable. It takes two arguments, the symbol and value
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
172 given in the `defcustom' call. The default is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
173 `custom-initialize-set'
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
174 :set VALUE should be a function to set the value of the symbol.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
175 It takes two arguments, the symbol to set and the value to
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
176 give it. The default is `set-default'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
177 :get VALUE should be a function to extract the value of symbol.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
178 The function takes one argument, a symbol, and should return
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
179 the current value for that symbol. The default is
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
180 `default-value'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
181 :require VALUE should be a feature symbol. Each feature will be
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
182 required after initialization, of the the user have saved this
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
183 option.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
184
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
185 Read the section about customization in the Emacs Lisp manual for more
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
186 information."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
187 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
188
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
189 ;;; The `defface' Macro.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
190
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
191 (defmacro defface (face spec doc &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
192 "Declare FACE as a customizable face that defaults to SPEC.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
193 FACE does not need to be quoted.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
194
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
195 Third argument DOC is the face documentation.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
196
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
197 If FACE has been set with `custom-set-face', set the face attributes
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
198 as specified by that function, otherwise set the face attributes
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
199 according to SPEC.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
200
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
201 The remaining arguments should have the form
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
202
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
203 [KEYWORD VALUE]...
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
204
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
205 The following KEYWORDs are defined:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
206
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
207 :group VALUE should be a customization group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
208 Add FACE to that group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
210 SPEC should be an alist of the form ((DISPLAY ATTS)...).
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
211
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
212 ATTS is a list of face attributes and their values. The possible
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
213 attributes are defined in the variable `custom-face-attributes'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
214
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
215 The ATTS of the first entry in SPEC where the DISPLAY matches the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
216 frame should take effect in that frame. DISPLAY can either be the
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
217 symbol t, which will match all frames, or an alist of the form
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
218 \((REQ ITEM...)...)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
219
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
220 For the DISPLAY to match a FRAME, the REQ property of the frame must
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
221 match one of the ITEM. The following REQ are defined:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
222
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
223 `type' (the value of `window-system')
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
224 Should be one of `x' or `tty'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
225
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
226 `class' (the frame's color support)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
227 Should be one of `color', `grayscale', or `mono'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
228
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
229 `background' (what color is used for the background text)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
230 Should be one of `light' or `dark'.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
231
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
232 Read the section about customization in the Emacs Lisp manual for more
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
233 information."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
234 `(custom-declare-face (quote ,face) ,spec ,doc ,@args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
235
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
236 ;;; The `defgroup' Macro.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
237
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
238 (defun custom-declare-group (symbol members doc &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
239 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
240 (while members
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
241 (apply 'custom-add-to-group symbol (car members))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
242 (pop members))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
243 (put symbol 'custom-group (nconc members (get symbol 'custom-group)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
244 (when doc
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
245 (put symbol 'group-documentation doc))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
246 (while args
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
247 (let ((arg (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
248 (setq args (cdr args))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
249 (check-argument-type 'keywordp arg)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
250 (let ((keyword arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
251 (value (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
252 (unless args
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
253 (signal 'error (list "Keyword is missing an argument" keyword)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
254 (setq args (cdr args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
255 (cond ((eq keyword :prefix)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
256 (put symbol 'custom-prefix value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
257 (t
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
258 (custom-handle-keyword symbol keyword value
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
259 'custom-group))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
260 (run-hooks 'custom-define-hook)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
261 symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
262
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
263 (defmacro defgroup (symbol members doc &rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
264 "Declare SYMBOL as a customization group containing MEMBERS.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
265 SYMBOL does not need to be quoted.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
266
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
267 Third arg DOC is the group documentation.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
268
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
269 MEMBERS should be an alist of the form ((NAME WIDGET)...) where NAME
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
270 is a symbol and WIDGET is a widget for editing that symbol. Useful
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
271 widgets are `custom-variable' for editing variables, `custom-face' for
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
272 edit faces, and `custom-group' for editing groups.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
273
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
274 The remaining arguments should have the form
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
275
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
276 [KEYWORD VALUE]...
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
277
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
278 The following KEYWORD's are defined:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
279
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
280 :group VALUE should be a customization group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
281 Add SYMBOL to that group.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
282
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
283 Read the section about customization in the Emacs Lisp manual for more
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
284 information."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
285 `(custom-declare-group (quote ,symbol) ,members ,doc ,@args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
286
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
287 ;; This is preloaded very early, so we avoid using CL features.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
288 (defvar custom-group-hash-table (make-hashtable 300 'eq)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
289 "Hash-table of non-empty groups.")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
290
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
291 (defun custom-add-to-group (group option widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
292 "To existing GROUP add a new OPTION of type WIDGET.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
293 If there already is an entry for that option, overwrite it."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
294 (let* ((members (get group 'custom-group))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
295 (old (assq option members)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
296 (if old
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
297 (setcar (cdr old) widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
298 (put group 'custom-group (nconc members (list (list option widget))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
299 (puthash group t custom-group-hash-table))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
300
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
301 ;;; Properties.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
302
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
303 (defun custom-handle-all-keywords (symbol args type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
304 "For customization option SYMBOL, handle keyword arguments ARGS.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
305 Third argument TYPE is the custom option type."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
306 (while args
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
307 (let ((arg (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
308 (setq args (cdr args))
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
309 (check-argument-type 'keywordp arg)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
310 (let ((keyword arg)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
311 (value (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
312 (unless args
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
313 (signal 'error (list "Keyword is missing an argument" keyword)))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
314 (setq args (cdr args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
315 (custom-handle-keyword symbol keyword value type)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
316
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
317 (defun custom-handle-keyword (symbol keyword value type)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
318 "For customization option SYMBOL, handle KEYWORD with VALUE.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
319 Fourth argument TYPE is the custom option type."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
320 (cond ((eq keyword :group)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
321 (custom-add-to-group value symbol type))
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 217
diff changeset
322 ((eq keyword :version)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 217
diff changeset
323 (custom-add-version symbol value))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
324 ((eq keyword :link)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
325 (custom-add-link symbol value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
326 ((eq keyword :load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
327 (custom-add-load symbol value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
328 ((eq keyword :tag)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
329 (put symbol 'custom-tag value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
330 (t
227
0e522484dd2a Import from CVS: tag r20-5b12
cvs
parents: 223
diff changeset
331 (signal 'error (list "Unknown keyword" keyword)))))
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
332
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
333 (defun custom-add-option (symbol option)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
334 "To the variable SYMBOL add OPTION.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
335
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
336 If SYMBOL is a hook variable, OPTION should be a hook member.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
337 For other types variables, the effect is undefined."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
338 (let ((options (get symbol 'custom-options)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
339 (unless (member option options)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
340 (put symbol 'custom-options (cons option options)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
341
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
342 (defun custom-add-link (symbol widget)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
343 "To the custom option SYMBOL add the link WIDGET."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
344 (let ((links (get symbol 'custom-links)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
345 (unless (member widget links)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
346 (put symbol 'custom-links (cons widget links)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
347
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 217
diff changeset
348 (defun custom-add-version (symbol version)
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 217
diff changeset
349 "To the custom option SYMBOL add the version VERSION."
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 217
diff changeset
350 (put symbol 'custom-version version))
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 217
diff changeset
351
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
352 (defun custom-add-load (symbol load)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
353 "To the custom option SYMBOL add the dependency LOAD.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
354 LOAD should be either a library file name, or a feature name."
223
2c611d1463a6 Import from CVS: tag r20-4b10
cvs
parents: 217
diff changeset
355 (puthash symbol t custom-group-hash-table)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
356 (let ((loads (get symbol 'custom-loads)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
357 (unless (member load loads)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
358 (put symbol 'custom-loads (cons load loads)))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
359
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
360 ;;; Initializing.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
361
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
362 (defun custom-set-variables (&rest args)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
363 "Initialize variables according to user preferences.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
364
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
365 The arguments should be a list where each entry has the form:
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
366
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
367 (SYMBOL VALUE [NOW])
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
368
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
369 The unevaluated VALUE is stored as the saved value for SYMBOL.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
370 If NOW is present and non-nil, VALUE is also evaluated and bound as
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
371 the default value for the SYMBOL."
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
372 (while args
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
373 (let ((entry (car args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
374 (if (listp entry)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
375 (let* ((symbol (nth 0 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
376 (value (nth 1 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
377 (now (nth 2 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
378 (requests (nth 3 entry))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
379 (set (or (get symbol 'custom-set) 'set-default)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
380 (put symbol 'saved-value (list value))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
381 (cond (now
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
382 ;; Rogue variable, set it now.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
383 (put symbol 'force-value t)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
384 (funcall set symbol (eval value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
385 ((default-boundp symbol)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
386 ;; Something already set this, overwrite it.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
387 (funcall set symbol (eval value))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
388 (when requests
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
389 (put symbol 'custom-requests requests)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
390 (mapc 'require requests))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
391 (setq args (cdr args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
392 ;; Old format, a plist of SYMBOL VALUE pairs.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
393 (message "Warning: old format `custom-set-variables'")
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
394 (ding)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
395 (sit-for 2)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
396 (let ((symbol (nth 0 args))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
397 (value (nth 1 args)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
398 (put symbol 'saved-value (list value)))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
399 (setq args (cdr (cdr args)))))))
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
400
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
401 ;;; The End.
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
402
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
403 (provide 'custom)
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
404
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents:
diff changeset
405 ;; custom.el ends here