(add-to-invisibility-spec): If it was t, start it out at (t).
[emacs.git] / lisp / custom.el
blob2f1b7ab9f1ec58c39f0ebee00e90885377b85140
1 ;;; custom.el --- tools for declaring and initializing options
2 ;;
3 ;; Copyright (C) 1996, 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Maintainer: FSF
7 ;; Keywords: help, faces
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
26 ;;; Commentary:
28 ;; This file only contains the code needed to declare and initialize
29 ;; user options. The code to customize options is autoloaded from
30 ;; `cus-edit.el' and is documented in the Emacs Lisp Reference manual.
32 ;; The code implementing face declarations is in `cus-face.el'.
34 ;;; Code:
36 (require 'widget)
38 (defvar custom-define-hook nil
39 ;; Customize information for this option is in `cus-edit.el'.
40 "Hook called after defining each customize option.")
42 (defvar custom-dont-initialize nil
43 "Non-nil means `defcustom' should not initialize the variable.
44 That is used for the sake of `custom-make-dependencies'.
45 Users should not set it.")
47 (defvar custom-current-group-alist nil
48 "Alist of (FILE . GROUP) indicating the current group to use for FILE.")
50 ;;; The `defcustom' Macro.
52 (defun custom-initialize-default (symbol value)
53 "Initialize SYMBOL with VALUE.
54 This will do nothing if symbol already has a default binding.
55 Otherwise, if symbol has a `saved-value' property, it will evaluate
56 the car of that and used as the default binding for symbol.
57 Otherwise, VALUE will be evaluated and used as the default binding for
58 symbol."
59 (unless (default-boundp symbol)
60 ;; Use the saved value if it exists, otherwise the standard setting.
61 (set-default symbol (if (get symbol 'saved-value)
62 (eval (car (get symbol 'saved-value)))
63 (eval value)))))
65 (defun custom-initialize-set (symbol value)
66 "Initialize SYMBOL based on VALUE.
67 If the symbol doesn't have a default binding already,
68 then set it using its `:set' function (or `set-default' if it has none).
69 The value is either the value in the symbol's `saved-value' property,
70 if any, or VALUE."
71 (unless (default-boundp symbol)
72 (funcall (or (get symbol 'custom-set) 'set-default)
73 symbol
74 (if (get symbol 'saved-value)
75 (eval (car (get symbol 'saved-value)))
76 (eval value)))))
78 (defun custom-initialize-reset (symbol value)
79 "Initialize SYMBOL based on VALUE.
80 Set the symbol, using its `:set' function (or `set-default' if it has none).
81 The value is either the symbol's current value
82 \(as obtained using the `:get' function), if any,
83 or the value in the symbol's `saved-value' property if any,
84 or (last of all) VALUE."
85 (funcall (or (get symbol 'custom-set) 'set-default)
86 symbol
87 (cond ((default-boundp symbol)
88 (funcall (or (get symbol 'custom-get) 'default-value)
89 symbol))
90 ((get symbol 'saved-value)
91 (eval (car (get symbol 'saved-value))))
93 (eval value)))))
95 (defun custom-initialize-changed (symbol value)
96 "Initialize SYMBOL with VALUE.
97 Like `custom-initialize-reset', but only use the `:set' function if
98 not using the standard setting.
99 For the standard setting, use `set-default'."
100 (cond ((default-boundp symbol)
101 (funcall (or (get symbol 'custom-set) 'set-default)
102 symbol
103 (funcall (or (get symbol 'custom-get) 'default-value)
104 symbol)))
105 ((get symbol 'saved-value)
106 (funcall (or (get symbol 'custom-set) 'set-default)
107 symbol
108 (eval (car (get symbol 'saved-value)))))
110 (set-default symbol (eval value)))))
112 (defun custom-declare-variable (symbol default doc &rest args)
113 "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments.
114 DEFAULT should be an expression to evaluate to compute the default value,
115 not the default value itself."
116 ;; Remember the standard setting.
117 (put symbol 'standard-value (list default))
118 ;; Maybe this option was rogue in an earlier version. It no longer is.
119 (when (get symbol 'force-value)
120 (put symbol 'force-value nil))
121 (when doc
122 (put symbol 'variable-documentation doc))
123 (let ((initialize 'custom-initialize-reset)
124 (requests nil))
125 (unless (memq :group args)
126 (custom-add-to-group (custom-current-group) symbol 'custom-variable))
127 (while args
128 (let ((arg (car args)))
129 (setq args (cdr args))
130 (unless (symbolp arg)
131 (error "Junk in args %S" args))
132 (let ((keyword arg)
133 (value (car args)))
134 (unless args
135 (error "Keyword %s is missing an argument" keyword))
136 (setq args (cdr args))
137 (cond ((eq keyword :initialize)
138 (setq initialize value))
139 ((eq keyword :set)
140 (put symbol 'custom-set value))
141 ((eq keyword :get)
142 (put symbol 'custom-get value))
143 ((eq keyword :require)
144 (push value requests))
145 ((eq keyword :type)
146 (put symbol 'custom-type (purecopy value)))
147 ((eq keyword :options)
148 (if (get symbol 'custom-options)
149 ;; Slow safe code to avoid duplicates.
150 (mapc (lambda (option)
151 (custom-add-option symbol option))
152 value)
153 ;; Fast code for the common case.
154 (put symbol 'custom-options (copy-sequence value))))
156 (custom-handle-keyword symbol keyword value
157 'custom-variable))))))
158 (put symbol 'custom-requests requests)
159 ;; Do the actual initialization.
160 (unless custom-dont-initialize
161 (funcall initialize symbol default)))
162 (push (cons 'defvar symbol) current-load-list)
163 (run-hooks 'custom-define-hook)
164 symbol)
166 (defmacro defcustom (symbol value doc &rest args)
167 "Declare SYMBOL as a customizable variable that defaults to VALUE.
168 DOC is the variable documentation.
170 Neither SYMBOL nor VALUE needs to be quoted.
171 If SYMBOL is not already bound, initialize it to VALUE.
172 The remaining arguments should have the form
174 [KEYWORD VALUE]...
176 The following keywords are meaningful:
178 :type VALUE should be a widget type for editing the symbol's value.
179 :options VALUE should be a list of valid members of the widget type.
180 :group VALUE should be a customization group.
181 Add SYMBOL to that group.
182 :link LINK-DATA
183 Include an external link after the documentation string for this
184 item. This is a sentence containing an active field which
185 references some other documentation.
187 There are three alternatives you can use for LINK-DATA:
189 (custom-manual INFO-NODE)
190 Link to an Info node; INFO-NODE is a string which specifies
191 the node name, as in \"(emacs)Top\". The link appears as
192 `[manual]' in the customization buffer.
194 (info-link INFO-NODE)
195 Like `custom-manual' except that the link appears in the
196 customization buffer with the Info node name.
198 (url-link URL)
199 Link to a web page; URL is a string which specifies the URL.
200 The link appears in the customization buffer as URL.
202 You can specify the text to use in the customization buffer by
203 adding `:tag NAME' after the first element of the LINK-DATA; for
204 example, (info-link :tag \"foo\" \"(emacs)Top\") makes a link to the
205 Emacs manual which appears in the buffer as `foo'.
207 An item can have more than one external link; however, most items
208 have none at all.
209 :initialize
210 VALUE should be a function used to initialize the
211 variable. It takes two arguments, the symbol and value
212 given in the `defcustom' call. The default is
213 `custom-initialize-reset'.
214 :set VALUE should be a function to set the value of the symbol.
215 It takes two arguments, the symbol to set and the value to
216 give it. The default choice of function is `custom-set-default'.
217 :get VALUE should be a function to extract the value of symbol.
218 The function takes one argument, a symbol, and should return
219 the current value for that symbol. The default choice of function
220 is `custom-default-value'.
221 :require
222 VALUE should be a feature symbol. If you save a value
223 for this option, then when your `.emacs' file loads the value,
224 it does (require VALUE) first.
225 :version
226 VALUE should be a string specifying that the variable was
227 first introduced, or its default value was changed, in Emacs
228 version VERSION.
229 :tag LABEL
230 Use LABEL, a string, instead of the item's name, to label the item
231 in customization menus and buffers.
232 :load FILE
233 Load file FILE (a string) before displaying this customization
234 item. Loading is done with `load', and only if the file is
235 not already loaded.
236 :set-after VARIABLES
237 Specifies that SYMBOL should be set after the list of variables
238 VARIABLES when both have been customized.
240 Read the section about customization in the Emacs Lisp manual for more
241 information."
242 ;; It is better not to use backquote in this file,
243 ;; because that makes a bootstrapping problem
244 ;; if you need to recompile all the Lisp files using interpreted code.
245 (nconc (list 'custom-declare-variable
246 (list 'quote symbol)
247 (list 'quote value)
248 doc)
249 args))
251 ;;; The `defface' Macro.
253 (defmacro defface (face spec doc &rest args)
254 "Declare FACE as a customizable face that defaults to SPEC.
255 FACE does not need to be quoted.
257 Third argument DOC is the face documentation.
259 If FACE has been set with `custom-set-face', set the face attributes
260 as specified by that function, otherwise set the face attributes
261 according to SPEC.
263 The remaining arguments should have the form
265 [KEYWORD VALUE]...
267 The following KEYWORDs are defined:
269 :group VALUE should be a customization group.
270 Add FACE to that group.
272 SPEC should be an alist of the form ((DISPLAY ATTS)...).
274 The first element of SPEC where the DISPLAY matches the frame
275 is the one that takes effect in that frame. The ATTRs in this
276 element take effect; the other elements are ignored, on that frame.
278 ATTS is a list of face attributes followed by their values:
279 (ATTR VALUE ATTR VALUE...)
281 The possible attributes are `:family', `:width', `:height', `:weight',
282 `:slant', `:underline', `:overline', `:strike-through', `:box',
283 `:foreground', `:background', `:stipple', `:inverse-video', and `:inherit'.
285 DISPLAY can either be the symbol t, which will match all frames, or an
286 alist of the form \((REQ ITEM...)...). For the DISPLAY to match a
287 FRAME, the REQ property of the frame must match one of the ITEM. The
288 following REQ are defined:
290 `type' (the value of `window-system')
291 Under X, in addition to the values `window-system' can take,
292 `motif', `lucid' and `x-toolkit' are allowed, and match when
293 the Motif toolkit, Lucid toolkit, or any X toolkit is in use.
295 `class' (the frame's color support)
296 Should be one of `color', `grayscale', or `mono'.
298 `background' (what color is used for the background text)
299 Should be one of `light' or `dark'.
301 Read the section about customization in the Emacs Lisp manual for more
302 information."
303 ;; It is better not to use backquote in this file,
304 ;; because that makes a bootstrapping problem
305 ;; if you need to recompile all the Lisp files using interpreted code.
306 (nconc (list 'custom-declare-face (list 'quote face) spec doc) args))
308 ;;; The `defgroup' Macro.
310 (defun custom-current-group ()
311 (cdr (assoc load-file-name custom-current-group-alist)))
313 (defun custom-declare-group (symbol members doc &rest args)
314 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
315 (while members
316 (apply 'custom-add-to-group symbol (car members))
317 (setq members (cdr members)))
318 (when doc
319 ;; This text doesn't get into DOC.
320 (put symbol 'group-documentation (purecopy doc)))
321 (while args
322 (let ((arg (car args)))
323 (setq args (cdr args))
324 (unless (symbolp arg)
325 (error "Junk in args %S" args))
326 (let ((keyword arg)
327 (value (car args)))
328 (unless args
329 (error "Keyword %s is missing an argument" keyword))
330 (setq args (cdr args))
331 (cond ((eq keyword :prefix)
332 (put symbol 'custom-prefix value))
334 (custom-handle-keyword symbol keyword value
335 'custom-group))))))
336 ;; Record the group on the `current' list.
337 (let ((elt (assoc load-file-name custom-current-group-alist)))
338 (if elt (setcdr elt symbol)
339 (push (cons load-file-name symbol) custom-current-group-alist)))
340 (run-hooks 'custom-define-hook)
341 symbol)
343 (defmacro defgroup (symbol members doc &rest args)
344 "Declare SYMBOL as a customization group containing MEMBERS.
345 SYMBOL does not need to be quoted.
347 Third arg DOC is the group documentation.
349 MEMBERS should be an alist of the form ((NAME WIDGET)...) where
350 NAME is a symbol and WIDGET is a widget for editing that symbol.
351 Useful widgets are `custom-variable' for editing variables,
352 `custom-face' for edit faces, and `custom-group' for editing groups.
354 The remaining arguments should have the form
356 [KEYWORD VALUE]...
358 The following KEYWORDs are defined:
360 :group VALUE should be a customization group.
361 Add SYMBOL to that group.
363 :version VALUE should be a string specifying that the group was introduced
364 in Emacs version VERSION.
366 Read the section about customization in the Emacs Lisp manual for more
367 information."
368 ;; It is better not to use backquote in this file,
369 ;; because that makes a bootstrapping problem
370 ;; if you need to recompile all the Lisp files using interpreted code.
371 (nconc (list 'custom-declare-group (list 'quote symbol) members doc) args))
373 (defun custom-add-to-group (group option widget)
374 "To existing GROUP add a new OPTION of type WIDGET.
375 If there already is an entry for OPTION and WIDGET, nothing is done."
376 (let ((members (get group 'custom-group))
377 (entry (list option widget)))
378 (unless (member entry members)
379 (put group 'custom-group (nconc members (list entry))))))
381 (defun custom-group-of-mode (mode)
382 "Return the custom group corresponding to the major or minor MODE.
383 If no such group is found, return nil."
384 (or (get mode 'custom-mode-group)
385 (if (or (get mode 'custom-group)
386 (and (string-match "-mode\\'" (symbol-name mode))
387 (get (setq mode (intern (substring (symbol-name mode)
388 0 (match-beginning 0))))
389 'custom-group)))
390 mode)))
392 ;;; Properties.
394 (defun custom-handle-all-keywords (symbol args type)
395 "For customization option SYMBOL, handle keyword arguments ARGS.
396 Third argument TYPE is the custom option type."
397 (unless (memq :group args)
398 (custom-add-to-group (custom-current-group) symbol type))
399 (while args
400 (let ((arg (car args)))
401 (setq args (cdr args))
402 (unless (symbolp arg)
403 (error "Junk in args %S" args))
404 (let ((keyword arg)
405 (value (car args)))
406 (unless args
407 (error "Keyword %s is missing an argument" keyword))
408 (setq args (cdr args))
409 (custom-handle-keyword symbol keyword value type)))))
411 (defun custom-handle-keyword (symbol keyword value type)
412 "For customization option SYMBOL, handle KEYWORD with VALUE.
413 Fourth argument TYPE is the custom option type."
414 (if purify-flag
415 (setq value (purecopy value)))
416 (cond ((eq keyword :group)
417 (custom-add-to-group value symbol type))
418 ((eq keyword :version)
419 (custom-add-version symbol value))
420 ((eq keyword :link)
421 (custom-add-link symbol value))
422 ((eq keyword :load)
423 (custom-add-load symbol value))
424 ((eq keyword :tag)
425 (put symbol 'custom-tag value))
426 ((eq keyword :set-after)
427 (custom-add-dependencies symbol value))
429 (error "Unknown keyword %s" keyword))))
431 (defun custom-add-dependencies (symbol value)
432 "To the custom option SYMBOL, add dependencies specified by VALUE.
433 VALUE should be a list of symbols. For each symbol in that list,
434 this specifies that SYMBOL should be set after the specified symbol, if
435 both appear in constructs like `custom-set-variables'."
436 (unless (listp value)
437 (error "Invalid custom dependency `%s'" value))
438 (let* ((deps (get symbol 'custom-dependencies))
439 (new-deps deps))
440 (while value
441 (let ((dep (car value)))
442 (unless (symbolp dep)
443 (error "Invalid custom dependency `%s'" dep))
444 (unless (memq dep new-deps)
445 (setq new-deps (cons dep new-deps)))
446 (setq value (cdr value))))
447 (unless (eq deps new-deps)
448 (put symbol 'custom-dependencies new-deps))))
450 (defun custom-add-option (symbol option)
451 "To the variable SYMBOL add OPTION.
453 If SYMBOL is a hook variable, OPTION should be a hook member.
454 For other types variables, the effect is undefined."
455 (let ((options (get symbol 'custom-options)))
456 (unless (member option options)
457 (put symbol 'custom-options (cons option options)))))
459 (defun custom-add-link (symbol widget)
460 "To the custom option SYMBOL add the link WIDGET."
461 (let ((links (get symbol 'custom-links)))
462 (unless (member widget links)
463 (put symbol 'custom-links (cons (purecopy widget) links)))))
465 (defun custom-add-version (symbol version)
466 "To the custom option SYMBOL add the version VERSION."
467 (put symbol 'custom-version (purecopy version)))
469 (defun custom-add-load (symbol load)
470 "To the custom option SYMBOL add the dependency LOAD.
471 LOAD should be either a library file name, or a feature name."
472 (let ((loads (get symbol 'custom-loads)))
473 (unless (member load loads)
474 (put symbol 'custom-loads (cons (purecopy load) loads)))))
476 ;;; Loading files needed to customize a symbol.
477 ;;; This is in custom.el because menu-bar.el needs it for toggle cmds.
479 (defvar custom-load-recursion nil
480 "Hack to avoid recursive dependencies.")
482 (defun custom-load-symbol (symbol)
483 "Load all dependencies for SYMBOL."
484 (unless custom-load-recursion
485 (let ((custom-load-recursion t))
486 (dolist (load (get symbol 'custom-loads))
487 (cond ((symbolp load) (condition-case nil (require load) (error nil)))
488 ;; This is subsumed by the test below, but it's much faster.
489 ((assoc load load-history))
490 ;; This was just (assoc (locate-library load) load-history)
491 ;; but has been optimized not to load locate-library
492 ;; if not necessary.
493 ((let ((regexp (concat "\\(\\`\\|/\\)" (regexp-quote load)
494 "\\(\\'\\|\\.\\)"))
495 (found nil))
496 (dolist (loaded load-history)
497 (and (stringp (car loaded))
498 (string-match regexp (car loaded))
499 (setq found t)))
500 found))
501 ;; Without this, we would load cus-edit recursively.
502 ;; We are still loading it when we call this,
503 ;; and it is not in load-history yet.
504 ((equal load "cus-edit"))
505 (t (condition-case nil (load load) (error nil))))))))
507 ;;; Initializing.
509 (defvar custom-local-buffer nil
510 "Non-nil, in a Customization buffer, means customize a specific buffer.
511 If this variable is non-nil, it should be a buffer,
512 and it means customize the local bindings of that buffer.
513 This variable is a permanent local, and it normally has a local binding
514 in every Customization buffer.")
515 (put 'custom-local-buffer 'permanent-local t)
517 (defun custom-set-variables (&rest args)
518 "Initialize variables according to user preferences.
520 The arguments should each be a list of the form:
522 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]])
524 The unevaluated VALUE is stored as the saved value for SYMBOL.
525 If NOW is present and non-nil, VALUE is also evaluated and bound as
526 the default value for the SYMBOL.
527 REQUEST is a list of features we must require for SYMBOL.
528 COMMENT is a comment string about SYMBOL."
529 (setq args
530 (sort args
531 (lambda (a1 a2)
532 (let* ((sym1 (car a1))
533 (sym2 (car a2))
534 (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
535 (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
536 (cond ((and 1-then-2 2-then-1)
537 (error "Circular custom dependency between `%s' and `%s'"
538 sym1 sym2))
539 (1-then-2 t)
540 (2-then-1 nil)
541 ;; Put symbols with :require last. The macro
542 ;; define-minor-mode generates a defcustom
543 ;; with a :require and a :set, where the
544 ;; setter function calls the mode function.
545 ;; Putting symbols with :require last ensures
546 ;; that the mode function will see other
547 ;; customized values rather than default
548 ;; values.
549 (t (nth 3 a2)))))))
550 (while args
551 (let ((entry (car args)))
552 (if (listp entry)
553 (let* ((symbol (nth 0 entry))
554 (value (nth 1 entry))
555 (now (nth 2 entry))
556 (requests (nth 3 entry))
557 (comment (nth 4 entry))
558 set)
559 (when requests
560 (put symbol 'custom-requests requests)
561 (mapc 'require requests))
562 (setq set (or (get symbol 'custom-set) 'custom-set-default))
563 (put symbol 'saved-value (list value))
564 (put symbol 'saved-variable-comment comment)
565 ;; Allow for errors in the case where the setter has
566 ;; changed between versions, say, but let the user know.
567 (condition-case data
568 (cond (now
569 ;; Rogue variable, set it now.
570 (put symbol 'force-value t)
571 (funcall set symbol (eval value)))
572 ((default-boundp symbol)
573 ;; Something already set this, overwrite it.
574 (funcall set symbol (eval value))))
575 (error
576 (message "Error setting %s: %s" symbol data)))
577 (setq args (cdr args))
578 (and (or now (default-boundp symbol))
579 (put symbol 'variable-comment comment)))
580 ;; Old format, a plist of SYMBOL VALUE pairs.
581 (message "Warning: old format `custom-set-variables'")
582 (ding)
583 (sit-for 2)
584 (let ((symbol (nth 0 args))
585 (value (nth 1 args)))
586 (put symbol 'saved-value (list value)))
587 (setq args (cdr (cdr args)))))))
589 (defun custom-set-default (variable value)
590 "Default :set function for a customizable variable.
591 Normally, this sets the default value of VARIABLE to VALUE,
592 but if `custom-local-buffer' is non-nil,
593 this sets the local binding in that buffer instead."
594 (if custom-local-buffer
595 (with-current-buffer custom-local-buffer
596 (set variable value))
597 (set-default variable value)))
599 (defun custom-quote (sexp)
600 "Quote SEXP iff it is not self quoting."
601 (if (or (memq sexp '(t nil))
602 (keywordp sexp)
603 (and (listp sexp)
604 (memq (car sexp) '(lambda)))
605 (stringp sexp)
606 (numberp sexp)
607 (vectorp sexp)
608 ;;; (and (fboundp 'characterp)
609 ;;; (characterp sexp))
611 sexp
612 (list 'quote sexp)))
614 (defun customize-mark-to-save (symbol)
615 "Mark SYMBOL for later saving.
617 If the default value of SYMBOL is different from the standard value,
618 set the `saved-value' property to a list whose car evaluates to the
619 default value. Otherwise, set it til nil.
621 To actually save the value, call `custom-save-all'.
623 Return non-nil iff the `saved-value' property actually changed."
624 (let* ((get (or (get symbol 'custom-get) 'default-value))
625 (value (funcall get symbol))
626 (saved (get symbol 'saved-value))
627 (standard (get symbol 'standard-value))
628 (comment (get symbol 'customized-variable-comment)))
629 ;; Save default value iff different from standard value.
630 (if (or (null standard)
631 (not (equal value (condition-case nil
632 (eval (car standard))
633 (error nil)))))
634 (put symbol 'saved-value (list (custom-quote value)))
635 (put symbol 'saved-value nil))
636 ;; Clear customized information (set, but not saved).
637 (put symbol 'customized-value nil)
638 ;; Save any comment that might have been set.
639 (when comment
640 (put symbol 'saved-variable-comment comment))
641 (not (equal saved (get symbol 'saved-value)))))
643 (defun customize-mark-as-set (symbol)
644 "Mark current value of SYMBOL as being set from customize.
646 If the default value of SYMBOL is different from the saved value if any,
647 or else if it is different from the standard value, set the
648 `customized-value' property to a list whose car evaluates to the
649 default value. Otherwise, set it til nil.
651 Return non-nil iff the `customized-value' property actually changed."
652 (let* ((get (or (get symbol 'custom-get) 'default-value))
653 (value (funcall get symbol))
654 (customized (get symbol 'customized-value))
655 (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
656 ;; Mark default value as set iff different from old value.
657 (if (or (null old)
658 (not (equal value (condition-case nil
659 (eval (car old))
660 (error nil)))))
661 (put symbol 'customized-value (list (custom-quote value)))
662 (put symbol 'customized-value nil))
663 ;; Changed?
664 (not (equal customized (get symbol 'customized-value)))))
666 ;;; The End.
668 ;; Process the defcustoms for variables loaded before this file.
669 (while custom-declare-variable-list
670 (apply 'custom-declare-variable (car custom-declare-variable-list))
671 (setq custom-declare-variable-list (cdr custom-declare-variable-list)))
673 (provide 'custom)
675 ;;; custom.el ends here