]> code.delx.au - gnu-emacs/blobdiff - lisp/custom.el
Customized.
[gnu-emacs] / lisp / custom.el
index b56c5af3aaf979d071634a9774cf9d0dae0905b7..285723c4180f393ed8d53f52e0a47c71dc4e1ba9 100644 (file)
@@ -62,9 +62,11 @@ symbol."
                          (eval value)))))
 
 (defun custom-initialize-set (symbol value)
                          (eval value)))))
 
 (defun custom-initialize-set (symbol value)
-  "Initialize SYMBOL with VALUE.
-Like `custom-initialize-default', but use the function specified by
-`:set' to initialize SYMBOL."
+  "Initialize SYMBOL based on VALUE.
+If the symbol doesn't have a default binding already,
+then set it using its `:set' function (or `set-default' if it has none).
+The value is either the value in the symbol's `saved-value' property,
+if any, or VALUE."
   (unless (default-boundp symbol)
     (funcall (or (get symbol 'custom-set) 'set-default)
             symbol 
   (unless (default-boundp symbol)
     (funcall (or (get symbol 'custom-set) 'set-default)
             symbol 
@@ -73,9 +75,12 @@ Like `custom-initialize-default', but use the function specified by
               (eval value)))))
 
 (defun custom-initialize-reset (symbol value)
               (eval value)))))
 
 (defun custom-initialize-reset (symbol value)
-  "Initialize SYMBOL with VALUE.
-Like `custom-initialize-set', but use the function specified by
-`:get' to reinitialize SYMBOL if it is already bound."
+  "Initialize SYMBOL based on VALUE.
+Set the symbol, using its `:set' function (or `set-default' if it has none).
+The value is either the symbol's current value
+ \(as obtained using the `:get' function), if any,
+or the value in the symbol's `saved-value' property if any,
+or (last of all) VALUE."
     (funcall (or (get symbol 'custom-set) 'set-default)
             symbol 
             (cond ((default-boundp symbol)
     (funcall (or (get symbol 'custom-set) 'set-default)
             symbol 
             (cond ((default-boundp symbol)
@@ -89,7 +94,8 @@ Like `custom-initialize-set', but use the function specified by
 (defun custom-initialize-changed (symbol value)
   "Initialize SYMBOL with VALUE.
 Like `custom-initialize-reset', but only use the `:set' function if the 
 (defun custom-initialize-changed (symbol value)
   "Initialize SYMBOL with VALUE.
 Like `custom-initialize-reset', but only use the `:set' function if the 
-not using the standard setting.  Otherwise, use the `set-default'."
+not using the standard setting.
+For the standard setting, use the `set-default'."
   (cond ((default-boundp symbol)
         (funcall (or (get symbol 'custom-set) 'set-default)
                  symbol
   (cond ((default-boundp symbol)
         (funcall (or (get symbol 'custom-set) 'set-default)
                  symbol
@@ -102,17 +108,19 @@ not using the standard setting.  Otherwise, use the `set-default'."
        (t
         (set-default symbol (eval value)))))
 
        (t
         (set-default symbol (eval value)))))
 
-(defun custom-declare-variable (symbol value doc &rest args)
-  "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments."
+(defun custom-declare-variable (symbol default doc &rest args)
+  "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments.
+DEFAULT should be an expression to evaluate to compute the default value,
+not the default value itself."
   ;; Remember the standard setting.
   ;; Remember the standard setting.
-  (put symbol 'standard-value (list value))
+  (put symbol 'standard-value (list default))
   ;; Maybe this option was rogue in an earlier version.  It no longer is.
   (when (get symbol 'force-value)
     ;; It no longer is.    
     (put symbol 'force-value nil))
   (when doc
     (put symbol 'variable-documentation doc))
   ;; Maybe this option was rogue in an earlier version.  It no longer is.
   (when (get symbol 'force-value)
     ;; It no longer is.    
     (put symbol 'force-value nil))
   (when doc
     (put symbol 'variable-documentation doc))
-  (let ((initialize 'custom-initialize-set)
+  (let ((initialize 'custom-initialize-reset)
        (requests nil))
     (while args 
       (let ((arg (car args)))
        (requests nil))
     (while args 
       (let ((arg (car args)))
@@ -147,7 +155,7 @@ not using the standard setting.  Otherwise, use the `set-default'."
                                        'custom-variable))))))
     (put symbol 'custom-requests requests)
     ;; Do the actual initialization.
                                        'custom-variable))))))
     (put symbol 'custom-requests requests)
     ;; Do the actual initialization.
-    (funcall initialize symbol value))
+    (funcall initialize symbol default))
   (run-hooks 'custom-define-hook)
   symbol)
 
   (run-hooks 'custom-define-hook)
   symbol)
 
@@ -272,8 +280,8 @@ SYMBOL does not need to be quoted.
 Third arg DOC is the group documentation.
 
 MEMBERS should be an alist of the form ((NAME WIDGET)...) where
 Third arg DOC is the group documentation.
 
 MEMBERS should be an alist of the form ((NAME WIDGET)...) where
-NAME is a symbol and WIDGET is a widget is a widget for editing that
-symbol.  Useful widgets are `custom-variable' for editing variables,
+NAME is a symbol and WIDGET is a widget for editing that symbol.
+Useful widgets are `custom-variable' for editing variables,
 `custom-face' for edit faces, and `custom-group' for editing groups.
 
 The remaining arguments should have the form
 `custom-face' for edit faces, and `custom-group' for editing groups.
 
 The remaining arguments should have the form
@@ -320,6 +328,8 @@ Third argument TYPE is the custom option type."
 Fourth argument TYPE is the custom option type."
   (cond ((eq keyword :group)
         (custom-add-to-group value symbol type))
 Fourth argument TYPE is the custom option type."
   (cond ((eq keyword :group)
         (custom-add-to-group value symbol type))
+       ((eq keyword :version)
+        (custom-add-version symbol value))
        ((eq keyword :link)
         (custom-add-link symbol value))
        ((eq keyword :load)
        ((eq keyword :link)
         (custom-add-link symbol value))
        ((eq keyword :load)
@@ -344,6 +354,10 @@ For other types variables, the effect is undefined."
     (unless (member widget links)
       (put symbol 'custom-links (cons widget links)))))
 
     (unless (member widget links)
       (put symbol 'custom-links (cons widget links)))))
 
+(defun custom-add-version (symbol version)
+  "To the custom option SYMBOL add the version VERSION."
+  (put symbol 'custom-version 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."
 (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."