]> code.delx.au - gnu-emacs/blobdiff - lisp/custom.el
*** empty log message ***
[gnu-emacs] / lisp / custom.el
index c0169812d36ceca8c71f457d1e33c875f50ce722..d53951793d24f49c43beca2b45b63c034a574ff5 100644 (file)
@@ -1,7 +1,7 @@
 ;;; custom.el --- tools for declaring and initializing options
 ;;
 ;; Copyright (C) 1996, 1997, 1999, 2001, 2002, 2003, 2004,
-;;   2005, 2006 Free Software Foundation, Inc.
+;;   2005, 2006, 2007 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Maintainer: FSF
@@ -210,11 +210,11 @@ The following keywords are meaningful:
        `custom-initialize-reset'.
 :set   VALUE should be a function to set the value of the symbol.
        It takes two arguments, the symbol to set and the value to
-       give it.  The default choice of function is `custom-set-default'.
+       give it.  The default choice of function is `set-default'.
 :get   VALUE should be a function to extract the value of symbol.
        The function takes one argument, a symbol, and should return
        the current value for that symbol.  The default choice of function
-       is `custom-default-value'.
+       is `default-value'.
 :require
        VALUE should be a feature symbol.  If you save a value
        for this option, then when your `.emacs' file loads the value,
@@ -536,6 +536,7 @@ For other custom types, this has no effect."
   (let ((options (get symbol 'custom-options)))
     (unless (member option options)
       (put symbol 'custom-options (cons option options)))))
+(defalias 'custom-add-frequent-value 'custom-add-option)
 
 (defun custom-add-link (symbol widget)
   "To the custom option SYMBOL add the link WIDGET."
@@ -558,9 +559,10 @@ LOAD should be either a library file name, or a feature name."
     (unless (member load loads)
       (put symbol 'custom-loads (cons (purecopy load) loads)))))
 
-(defun custom-autoload (symbol load)
-  "Mark SYMBOL as autoloaded custom variable and add dependency LOAD."
-  (put symbol 'custom-autoload t)
+(defun custom-autoload (symbol load &optional noset)
+  "Mark SYMBOL as autoloaded custom variable and add dependency LOAD.
+If NOSET is non-nil, don't bother autoloading LOAD when setting the variable."
+  (put symbol 'custom-autoload (if noset 'noset t))
   (custom-add-load symbol load))
 
 ;; This test is also in the C code of `user-variable-p'.
@@ -699,10 +701,10 @@ Return non-nil iff the `customized-value' property actually changed."
         (customized (get symbol 'customized-value))
         (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
     ;; Mark default value as set iff different from old value.
-    (if (or (null old)
-           (not (equal value (condition-case nil
-                                 (eval (car old))
-                               (error nil)))))
+    (if (not (and old
+                  (equal value (condition-case nil
+                                   (eval (car old))
+                                 (error nil)))))
        (progn (put symbol 'customized-value (list (custom-quote value)))
               (custom-push-theme 'theme-value symbol 'user 'set
                                  (custom-quote value)))
@@ -827,13 +829,9 @@ See `custom-known-themes' for a list of known themes."
            (if (and (eq prop 'theme-value)
                     (boundp symbol))
                (let ((sv (get symbol 'standard-value)))
-                 (when (and (null sv) (custom-variable-p symbol))
-                   (custom-load-symbol symbol)
-                   (setq sv (get symbol 'standard-value)))
-                 (if (or (null sv)
-                         (not (equal (eval (car (get symbol 'standard-value)))
-                                     (symbol-value symbol))))
-                     (setq old (list (list 'changed (symbol-value symbol))))))
+                 (unless (and sv
+                               (equal (eval (car sv)) (symbol-value symbol)))
+                    (setq old (list (list 'changed (symbol-value symbol))))))
              (if (and (facep symbol)
                       (not (face-spec-match-p symbol (get symbol 'face-defface-spec))))
                  (setq old (list (list 'changed (list
@@ -877,6 +875,18 @@ COMMENT is a comment string about SYMBOL.
 EXP itself is saved unevaluated as SYMBOL property `saved-value' and
 in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
   (custom-check-theme theme)
+  ;; Process all the needed autoloads before anything else, so that the
+  ;; subsequent code has all the info it needs (e.g. which var corresponds
+  ;; to a minor mode), regardless of the ordering of the variables.
+  (dolist (entry args)
+    (let* ((symbol (indirect-variable (nth 0 entry))))
+      (unless (or (get symbol 'standard-value)
+                  (memq (get symbol 'custom-autoload) '(nil noset)))
+        ;; This symbol needs to be autoloaded, even just for a `set'.
+        (custom-load-symbol symbol))))
+  ;; Move minor modes and variables with explicit requires to the end.
   (setq args
        (sort args
              (lambda (a1 a2)
@@ -926,6 +936,8 @@ in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
            (setq args (cdr args))
            (and (or now (default-boundp symbol))
                 (put symbol 'variable-comment comment)))
+        ;; I believe this is dead-code, because the `sort' code above would
+        ;; have burped before we could get here.  --Stef
        ;; Old format, a plist of SYMBOL VALUE pairs.
        (message "Warning: old format `custom-set-variables'")
        (ding)