]> code.delx.au - gnu-emacs/blobdiff - lisp/custom.el
*** empty log message ***
[gnu-emacs] / lisp / custom.el
index fe2829e644ac40f0483b024ce99aa8b28dff7aee..c0169812d36ceca8c71f457d1e33c875f50ce722 100644 (file)
@@ -203,8 +203,27 @@ The following keywords are meaningful:
 
 :type  VALUE should be a widget type for editing the symbol's value.
 :options VALUE should be a list of valid members of the widget type.
+:initialize
+       VALUE should be a function used to initialize the
+       variable.  It takes two arguments, the symbol and value
+       given in the `defcustom' call.  The default is
+       `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'.
+: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'.
+:require
+       VALUE should be a feature symbol.  If you save a value
+       for this option, then when your `.emacs' file loads the value,
+       it does (require VALUE) first.
+
+The following common keywords are also meaningful.
+
 :group  VALUE should be a customization group.
-        Add SYMBOL to that group.
+        Add SYMBOL (or FACE with `defface') to that group.
 :link LINK-DATA
         Include an external link after the documentation string for this
         item.  This is a sentence containing an active field which
@@ -248,26 +267,19 @@ The following keywords are meaningful:
 
         An item can have more than one external link; however, most items
         have none at all.
-:initialize
-       VALUE should be a function used to initialize the
-       variable.  It takes two arguments, the symbol and value
-       given in the `defcustom' call.  The default is
-       `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'.
-: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'.
-:require
-       VALUE should be a feature symbol.  If you save a value
-       for this option, then when your `.emacs' file loads the value,
-       it does (require VALUE) first.
 :version
         VALUE should be a string specifying that the variable was
         first introduced, or its default value was changed, in Emacs
         version VERSION.
+:package-version
+        VALUE should be a list with the form (PACKAGE . VERSION)
+        specifying that the variable was first introduced, or its
+        default value was changed, in PACKAGE version VERSION.  This
+        keyword takes priority over :version.  The PACKAGE and VERSION
+        must appear in the alist `customize-package-emacs-version-alist'.
+        Since PACKAGE must be unique and the user might see it in an
+        error message, a good choice is the official name of the
+        package, such as MH-E or Gnus.
 :tag LABEL
         Use LABEL, a string, instead of the item's name, to label the item
         in customization menus and buffers.
@@ -286,8 +298,8 @@ to load a file defining variables with this form, or with
 _outside_ any bindings for these variables.  \(`defvar' and
 `defconst' behave similarly in this respect.)
 
-Read the section about customization in the Emacs Lisp manual for more
-information."
+See Info node `(elisp) Customization' in the Emacs Lisp manual
+for more information."
   (declare (doc-string 3))
   ;; It is better not to use backquote in this file,
   ;; because that makes a bootstrapping problem
@@ -314,10 +326,8 @@ The remaining arguments should have the form
 
    [KEYWORD VALUE]...
 
-The following KEYWORDs are defined:
-
-:group  VALUE should be a customization group.
-        Add FACE to that group.
+For a list of valid keywords, see the common keywords listed in
+`defcustom'.
 
 SPEC should be an alist of the form ((DISPLAY ATTS)...).
 
@@ -368,8 +378,8 @@ corresponding ITEMs.  These are the defined REQ values:
   the function `display-supports-face-attributes-p' for more
   information on exactly how testing is done.
 
-Read the section about customization in the Emacs Lisp manual for more
-information."
+See Info node `(elisp) Customization' in the Emacs Lisp manual
+for more information."
   (declare (doc-string 3))
   ;; It is better not to use backquote in this file,
   ;; because that makes a bootstrapping problem
@@ -426,16 +436,11 @@ The remaining arguments should have the form
 
    [KEYWORD VALUE]...
 
-The following KEYWORDs are defined:
-
-:group   VALUE should be a customization group.
-         Add SYMBOL to that group.
-
-:version VALUE should be a string specifying that the group was introduced
-         in Emacs version VERSION.
+For a list of valid keywords, see the common keywords listed in
+`defcustom'.
 
-Read the section about customization in the Emacs Lisp manual for more
-information."
+See Info node `(elisp) Customization' in the Emacs Lisp manual
+for more information."
   (declare (doc-string 3))
   ;; It is better not to use backquote in this file,
   ;; because that makes a bootstrapping problem
@@ -489,6 +494,8 @@ Fourth argument TYPE is the custom option type."
         (custom-add-to-group value symbol type))
        ((eq keyword :version)
         (custom-add-version symbol value))
+       ((eq keyword :package-version)
+        (custom-add-package-version symbol value))
        ((eq keyword :link)
         (custom-add-link symbol value))
        ((eq keyword :load)
@@ -540,6 +547,10 @@ For other custom types, this has no effect."
   "To the custom option SYMBOL add the version VERSION."
   (put symbol 'custom-version (purecopy version)))
 
+(defun custom-add-package-version (symbol version)
+  "To the custom option SYMBOL add the package version VERSION."
+  (put symbol 'custom-package-version (purecopy version)))
+
 (defun custom-add-load (symbol load)
   "To the custom option SYMBOL add the dependency LOAD.
 LOAD should be either a library file name, or a feature name."
@@ -682,6 +693,7 @@ or else if it is different from the standard value, set the
 default value.  Otherwise, set it to nil.
 
 Return non-nil iff the `customized-value' property actually changed."
+  (custom-load-symbol symbol)
   (let* ((get (or (get symbol 'custom-get) 'default-value))
         (value (funcall get symbol))
         (customized (get symbol 'customized-value))
@@ -691,7 +703,9 @@ Return non-nil iff the `customized-value' property actually changed."
            (not (equal value (condition-case nil
                                  (eval (car old))
                                (error nil)))))
-       (put symbol 'customized-value (list (custom-quote value)))
+       (progn (put symbol 'customized-value (list (custom-quote value)))
+              (custom-push-theme 'theme-value symbol 'user 'set
+                                 (custom-quote value)))
       (put symbol 'customized-value nil))
     ;; Changed?
     (not (equal customized (get symbol 'customized-value)))))
@@ -811,12 +825,17 @@ See `custom-known-themes' for a list of known themes."
        ;; theme is later disabled.
        (if (null old)
            (if (and (eq prop 'theme-value)
-                    (boundp symbol)
-                    (or (null (get symbol 'standard-value))
-                        (not (equal (eval (car (get symbol 'standard-value)))
-                                    (symbol-value symbol)))))
-               (setq old (list (list 'changed (symbol-value symbol))))
-             (if (facep symbol)
+                    (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))))))
+             (if (and (facep symbol)
+                      (not (face-spec-match-p symbol (get symbol 'face-defface-spec))))
                  (setq old (list (list 'changed (list
                    (append '(t) (custom-face-attributes-get symbol nil)))))))))
        (put symbol prop (cons (list theme value) old))