]> code.delx.au - gnu-emacs/blobdiff - lisp/custom.el
Minor fixes for text of help-echo in some options.
[gnu-emacs] / lisp / custom.el
index 3999902a8697b6a216d5148f7544c5dbf125bcb6..43c3184469da73e492da62a4e5d6a7b4290ff77d 100644 (file)
@@ -1,6 +1,6 @@
-;;; custom.el -- Tools for declaring and initializing options.
+;;; custom.el --- tools for declaring and initializing options
 ;;
-;; Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1999, 2001 Free Software Foundation, Inc.
 ;;
 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 ;; Maintainer: FSF
@@ -86,9 +86,9 @@ or (last of all) VALUE."
 
 (defun custom-initialize-changed (symbol value)
   "Initialize SYMBOL with VALUE.
-Like `custom-initialize-reset', but only use the `:set' function if the
+Like `custom-initialize-reset', but only use the `:set' function if
 not using the standard setting.
-For the standard setting, use the `set-default'."
+For the standard setting, use `set-default'."
   (cond ((default-boundp symbol)
         (funcall (or (get symbol 'custom-set) 'set-default)
                  symbol
@@ -137,8 +137,8 @@ not the default value itself."
                ((eq keyword :options)
                 (if (get symbol 'custom-options)
                     ;; Slow safe code to avoid duplicates.
-                    (mapcar (lambda (option)
-                              (custom-add-option symbol option))
+                    (mapc (lambda (option)
+                            (custom-add-option symbol option))
                             value)
                   ;; Fast code for the common case.
                   (put symbol 'custom-options (copy-sequence value))))
@@ -165,7 +165,6 @@ The remaining arguments should have the form
 The following keywords are meaningful:
 
 :type  VALUE should be a widget type for editing the symbols value.
-       The default is `sexp'.
 :options VALUE should be a list of valid members of the widget type.
 :group  VALUE should be a customization group.
         Add SYMBOL to that group.
@@ -173,7 +172,7 @@ The following keywords are meaningful:
        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-default'
+       `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'.
@@ -185,6 +184,13 @@ The following keywords are meaningful:
        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.
+:set-after VARIABLE
+       Specifies that SYMBOL should be set after VARIABLE when
+       both have been customized.
 
 Read the section about customization in the Emacs Lisp manual for more
 information."
@@ -298,10 +304,13 @@ The remaining arguments should have the form
 
    [KEYWORD VALUE]...
 
-The following KEYWORD's are defined:
+The following KEYWORDs are defined:
 
-:group  VALUE should be a customization group.
-        Add SYMBOL to that group.
+: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.
 
 Read the section about customization in the Emacs Lisp manual for more
 information."
@@ -312,12 +321,11 @@ information."
 
 (defun custom-add-to-group (group option widget)
   "To existing GROUP add a new OPTION of type WIDGET.
-If there already is an entry for that option, overwrite it."
-  (let* ((members (get group 'custom-group))
-        (old (assq option members)))
-    (if old
-       (setcar (cdr old) widget)
-      (put group 'custom-group (nconc members (list (list option widget)))))))
+If there already is an entry for OPTION and WIDGET, nothing is done."
+  (let ((members (get group 'custom-group))
+       (entry (list option widget)))
+    (unless (member entry members)
+      (put group 'custom-group (nconc members (list entry))))))
 
 ;;; Properties.
 
@@ -433,8 +441,17 @@ COMMENT is a comment string about SYMBOL."
                  (cond ((and 1-then-2 2-then-1)
                         (error "Circular custom dependency between `%s' and `%s'"
                                sym1 sym2))
+                       (1-then-2 t)
                        (2-then-1 nil)
-                       (t t))))))
+                       ;; Put symbols with :require last.  The macro
+                       ;; define-minor-mode generates a defcustom
+                       ;; with a :require and a :set, where the
+                       ;; setter function calls the mode function.
+                       ;; Putting symbols with :require last ensures
+                       ;; that the mode function will see other
+                       ;; customized values rather than default
+                       ;; values.
+                       (t (nth 3 a2)))))))
   (while args
     (let ((entry (car args)))
       (if (listp entry)
@@ -446,13 +463,13 @@ COMMENT is a comment string about SYMBOL."
                 set)
            (when requests
              (put symbol 'custom-requests requests)
-             (mapcar 'require requests))
+             (mapc 'require requests))
            (setq set (or (get symbol 'custom-set) 'custom-set-default))
            (put symbol 'saved-value (list value))
            (put symbol 'saved-variable-comment comment)
            ;; Allow for errors in the case where the setter has
-           ;; changed between versions, say.
-           (condition-case nil
+           ;; changed between versions, say, but let the user know.
+           (condition-case data
                (cond (now
                       ;; Rogue variable, set it now.
                       (put symbol 'force-value t)
@@ -460,7 +477,8 @@ COMMENT is a comment string about SYMBOL."
                      ((default-boundp symbol)
                       ;; Something already set this, overwrite it.
                       (funcall set symbol (eval value))))
-             (error nil))
+             (error 
+              (message "Error setting %s: %s" symbol data)))
            (setq args (cdr args))
            (and (or now (default-boundp symbol))
                 (put symbol 'variable-comment comment)))