]> code.delx.au - gnu-emacs/blobdiff - lisp/cus-edit.el
*** empty log message ***
[gnu-emacs] / lisp / cus-edit.el
index 2928080ca4e3af81718c76cc0faabd9338c55f5c..763b4b8c57f432b0647ef6fe93501fa44ba6633f 100644 (file)
@@ -88,7 +88,7 @@
 ;; compatibility.
 
 ;; You can see (and modify and save) this unevaluated value by selecting
-;; "Show initial Lisp expression" from the Lisp interface.  This will
+;; "Show Saved Lisp Expression" from the Lisp interface.  This will
 ;; give you the unevaluated saved value, if any, otherwise the
 ;; unevaluated standard value.
 
@@ -746,32 +746,39 @@ groups after non-groups, if nil do not order groups at all."
 (defun Custom-set ()
   "Set the current value of all edited settings in the buffer."
   (interactive)
-  (if (y-or-n-p "Set all values according to this buffer? ")
-      (let ((children custom-options))
+  (let ((children custom-options))
+    (if (or (and (= 1 (length children))
+                (memq (widget-type (car children))
+                      '(custom-variable custom-face)))
+           (y-or-n-p "Set all values according to this buffer? "))
        (mapc (lambda (child)
                (when (eq (widget-get child :custom-state) 'modified)
                  (widget-apply child :custom-set)))
-             children))
-    (message "Aborted")))
+             children)
+      (message "Aborted"))))
 
 (defun Custom-save ()
   "Set all edited settings, then save all settings that have been set.
 If a setting was edited and set before, this saves it.
 If a setting was merely edited before, this sets it then saves it."
   (interactive)
-  (if (yes-or-no-p "Save all settings in this buffer? ")
-      (let ((children custom-options))
-       (mapc (lambda (child)
-               (when (memq (widget-get child :custom-state)
-                           '(modified set changed rogue))
-                 (widget-apply child :custom-save)))
-             children)
-       (custom-save-all))
-    (message "Aborted")))
+  (let ((children custom-options))
+    (if (or (and (= 1 (length children))
+                (memq (widget-type (car children))
+                      '(custom-variable custom-face)))
+           (yes-or-no-p "Save all settings in this buffer? "))
+       (progn
+         (mapc (lambda (child)
+                 (when (memq (widget-get child :custom-state)
+                             '(modified set changed rogue))
+                   (widget-apply child :custom-save)))
+               children)
+         (custom-save-all))
+      (message "Aborted"))))
 
 (defvar custom-reset-menu
-  '(("Reset to current settings" . Custom-reset-current)
-    ("Reset to saved settings" . Custom-reset-saved)
+  '(("Undo Edits" . Custom-reset-current)
+    ("Reset to Saved" . Custom-reset-saved)
     ("Erase Customization (use standard values)" . Custom-reset-standard))
   "Alist of actions for the `Reset' button.
 The key is a string containing the name of the action, the value is a
@@ -790,27 +797,33 @@ when the action is chosen.")
 (defun Custom-reset-current (&rest ignore)
   "Reset all edited settings in the buffer to show their current values."
   (interactive)
-  (if (y-or-n-p "Reset all settings' buffer text to show current values? ")
-      (let ((children custom-options))
+  (let ((children custom-options))
+    (if (or (and (= 1 (length children))
+                (memq (widget-type (car children))
+                      '(custom-variable custom-face)))
+           (y-or-n-p "Reset all settings' buffer text to show current values?  "))
        (mapc (lambda (widget)
                (if (memq (widget-get widget :custom-state)
                          '(modified changed))
                    (widget-apply widget :custom-reset-current)))
-             children))
-    (message "Aborted")))
+             children)
+      (message "Aborted"))))
 
 (defun Custom-reset-saved (&rest ignore)
   "Reset all edited or set settings in the buffer to their saved value.
 This also shows the saved values in the buffer."
   (interactive)
-  (if (y-or-n-p "Reset all settings (current values and buffer text) to saved values? ")
-      (let ((children custom-options))
+  (let ((children custom-options))
+    (if (or (and (= 1 (length children))
+                (memq (widget-type (car children))
+                      '(custom-variable custom-face)))
+           (y-or-n-p "Reset all settings (current values and buffer text) to saved values? "))
        (mapc (lambda (widget)
                (if (memq (widget-get widget :custom-state)
                          '(modified set changed rogue))
                    (widget-apply widget :custom-reset-saved)))
-             children))
-    (message "Aborted")))
+             children)
+      (message "Aborted"))))
 
 (defun Custom-reset-standard (&rest ignore)
   "Erase all customization (either current or saved) for the group members.
@@ -1236,7 +1249,7 @@ suggest to customize that face, if it's customizable."
 
 ;;;###autoload
 (defun customize-rogue ()
-  "Customize all user variable modified outside customize."
+  "Customize all user variables modified outside customize."
   (interactive)
   (let ((found nil))
     (mapatoms (lambda (symbol)
@@ -1457,22 +1470,19 @@ See "
                               (if custom-raised-buttons
                                   "`Raised' text indicates"
                                 "Square brackets indicate")))
-       (widget-create 'info-link
+       (widget-create 'custom-manual
                       :tag "Custom file"
-                      :button-face 'custom-link
-                      :mouse-face 'highlight
                       "(emacs)Saving Customizations")
        (widget-insert
         " for information on how to save in a different file.\n
 See ")
-       (widget-create 'info-link
+       (widget-create 'custom-manual
                       :tag "Help"
-                      :button-face 'custom-link
-                      :mouse-face 'highlight
                       :help-echo "Read the online help."
                       "(emacs)Easy Customization")
        (widget-insert " for more information.\n\n")
-       (widget-insert "Operate on everything in this buffer:\n "))
+       (widget-insert "Operate on all settings in this buffer that \
+are not marked HIDDEN:\n "))
     (widget-insert " "))
   (widget-create 'push-button
                 :tag "Set for Current Session"
@@ -1483,10 +1493,8 @@ Make your editing in this buffer take effect for this session."
   (if (not custom-buffer-verbose-help)
       (progn
        (widget-insert " ")
-       (widget-create 'info-link
+       (widget-create 'custom-manual
                       :tag "Help"
-                      :button-face 'custom-link
-                      :mouse-face 'highlight
                       :help-echo "Read the online help."
                       "(emacs)Easy Customization")))
   (when (or custom-file user-init-file)
@@ -1509,7 +1517,7 @@ This updates your Emacs initialization file or creates a new one."
                                 (custom-reset event))))
     (widget-insert "\n ")
     (widget-create 'push-button
-                  :tag "Reset to Current"
+                  :tag "Undo Edits"
                   :help-echo "\
 Reset all edited text in this buffer to reflect current values."
                   :action 'Custom-reset-current)
@@ -1634,7 +1642,7 @@ item in another window.\n\n"))
   (let ((custom-buffer-style 'tree))
     (custom-toggle-parent widget)))
 
-(define-widget 'custom-browse-group-tag 'push-button
+(define-widget 'custom-browse-group-tag 'custom-group-link
   "Show parent in other window when activated."
   :tag "Group"
   :tag-glyph "folder"
@@ -1644,7 +1652,7 @@ item in another window.\n\n"))
   (let ((parent (widget-get widget :parent)))
     (customize-group-other-window (widget-value parent))))
 
-(define-widget 'custom-browse-variable-tag 'push-button
+(define-widget 'custom-browse-variable-tag 'custom-group-link
   "Show parent in other window when activated."
   :tag "Option"
   :tag-glyph "option"
@@ -1654,7 +1662,7 @@ item in another window.\n\n"))
   (let ((parent (widget-get widget :parent)))
     (customize-variable-other-window (widget-value parent))))
 
-(define-widget 'custom-browse-face-tag 'push-button
+(define-widget 'custom-browse-face-tag 'custom-group-link
   "Show parent in other window when activated."
   :tag "Face"
   :tag-glyph "face"
@@ -1996,13 +2004,7 @@ and `face'."
   :group 'custom-faces)
 
 (defface custom-button-unraised
-  '((((min-colors 88)
-      (class color) (background light)) :foreground "blue1" :underline t)
-    (((class color) (background light)) :foreground "blue" :underline t)
-    (((min-colors 88)
-      (class color) (background dark)) :foreground "cyan1" :underline t)
-    (((class color) (background dark)) :foreground "cyan" :underline t)
-    (t :underline t))
+  '((t :inherit underline))
   "Face for custom buffer buttons if `custom-raised-buttons' is nil."
   :version "22.1"
   :group 'custom-faces)
@@ -2057,15 +2059,10 @@ and `face'."
 (put 'custom-state-face 'face-alias 'custom-state)
 
 (defface custom-link
-  '((((min-colors 88)
-      (class color) (background light)) :foreground "blue1" :underline t)
-    (((class color) (background light)) :foreground "blue" :underline t)
-    (((min-colors 88)
-      (class color) (background dark)) :foreground "cyan1" :underline t)
-    (((class color) (background dark)) :foreground "cyan" :underline t)
-    (t :underline t))
-  "Face for Info links in customization buffers."
-  :group 'info)
+  '((t :inherit link))
+  "Face for links in customization buffers."
+  :version "22.1"
+  :group 'custom-faces)
 
 (define-widget 'custom 'default
   "Customize a user option."
@@ -2201,7 +2198,10 @@ Insert PREFIX first if non-nil."
        (insert prefix))
       (insert "See also ")
       (while links
-       (push (widget-create-child-and-convert widget (car links))
+       (push (widget-create-child-and-convert
+              widget (car links)
+              :button-face 'custom-link
+              :mouse-face 'highlight)
              buttons)
        (setq links (cdr links))
        (cond ((null links)
@@ -2229,8 +2229,6 @@ If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
                  (insert " ")
                  (push (widget-create-child-and-convert
                         widget 'custom-group-link
-                        :button-face 'custom-link
-                        :mouse-face 'highlight
                         :tag (custom-unlispify-tag-name symbol)
                         symbol)
                        buttons)
@@ -2246,7 +2244,10 @@ If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
            (when links
              (insert "\nParent documentation: ")
              (while links
-               (push (widget-create-child-and-convert widget (car links))
+               (push (widget-create-child-and-convert
+                     widget (car links)
+                     :button-face 'custom-link
+                     :mouse-face 'highlight)
                      buttons)
                (setq links (cdr links))
                (cond ((null links)
@@ -2628,40 +2629,40 @@ Otherwise, look up symbol in `custom-guess-type-alist'."
   (get (widget-value widget) 'standard-value))
 
 (defvar custom-variable-menu
-  `(("Set for current session" custom-variable-set
+  `(("Set for Current Session" custom-variable-set
      (lambda (widget)
        (eq (widget-get widget :custom-state) 'modified)))
     ,@(when (or custom-file user-init-file)
-       '(("Save for future sessions" custom-variable-save
+       '(("Save for Future Sessions" custom-variable-save
           (lambda (widget)
             (memq (widget-get widget :custom-state)
                   '(modified set changed rogue))))))
-    ("---" ignore ignore)
-    ("Reset to current value" custom-redraw
+    ("Undo Edits" custom-redraw
      (lambda (widget)
        (and (default-boundp (widget-value widget))
            (memq (widget-get widget :custom-state) '(modified changed)))))
-    ("Reset to saved value" custom-variable-reset-saved
+    ("Reset to Saved" custom-variable-reset-saved
      (lambda (widget)
        (and (or (get (widget-value widget) 'saved-value)
                (get (widget-value widget) 'saved-variable-comment))
            (memq (widget-get widget :custom-state)
                  '(modified set changed rogue)))))
-    ("Reset to backup value" custom-variable-reset-backup
-     (lambda (widget)
-       (get (widget-value widget) 'backup-value)))
     ,@(when (or custom-file user-init-file)
-       '(("Erase customization" custom-variable-reset-standard
+       '(("Erase Customization" custom-variable-reset-standard
           (lambda (widget)
             (and (get (widget-value widget) 'standard-value)
                  (memq (widget-get widget :custom-state)
                        '(modified set changed saved rogue)))))))
+    ("Set to Backup Value" custom-variable-reset-backup
+     (lambda (widget)
+       (get (widget-value widget) 'backup-value)))
+    ("---" ignore ignore)
+    ("Add Comment" custom-comment-show custom-comment-invisible-p)
     ("---" ignore ignore)
-    ("Add comment" custom-comment-show custom-comment-invisible-p)
-    ("Show value widget" custom-variable-edit
+    ("Show Current Value" custom-variable-edit
      (lambda (widget)
        (eq (widget-get widget :custom-form) 'lisp)))
-    ("Show Lisp expression" custom-variable-edit-lisp
+    ("Show Saved Lisp Expression" custom-variable-edit-lisp
      (lambda (widget)
        (eq (widget-get widget :custom-form) 'edit))))
   "Alist of actions for the `custom-variable' widget.
@@ -3302,27 +3303,30 @@ SPEC must be a full face spec."
             (message "Creating face editor...done"))))))
 
 (defvar custom-face-menu
-  `(("Set for current session" custom-face-set)
+  `(("Set for Current Session" custom-face-set)
     ,@(when (or custom-file user-init-file)
-       '(("Save for future sessions" custom-face-save-command)))
-    ("---" ignore ignore)
-    ("Reset to saved face" custom-face-reset-saved
+       '(("Save for Future Sessions" custom-face-save)))
+    ("Undo Edits" custom-redraw
+     (lambda (widget)
+       (memq (widget-get widget :custom-state) '(modified changed))))
+    ("Reset to Saved" custom-face-reset-saved
      (lambda (widget)
        (or (get (widget-value widget) 'saved-face)
           (get (widget-value widget) 'saved-face-comment))))
     ,@(when (or custom-file user-init-file)
-       '(("Erase customization" custom-face-reset-standard
+       '(("Erase Customization" custom-face-reset-standard
           (lambda (widget)
             (get (widget-value widget) 'face-defface-spec)))))
     ("---" ignore ignore)
-    ("Add comment" custom-comment-show custom-comment-invisible-p)
-    ("Show all attributes" custom-face-edit-all
-     (lambda (widget)
-       (not (eq (widget-get widget :custom-form) 'all))))
-    ("Show current attributes" custom-face-edit-selected
+    ("Add Comment" custom-comment-show custom-comment-invisible-p)
+    ("---" ignore ignore)
+    ("For Current Display" custom-face-edit-selected
      (lambda (widget)
        (not (eq (widget-get widget :custom-form) 'selected))))
-    ("Show Lisp expression" custom-face-edit-lisp
+    ("For All Kinds of Displays" custom-face-edit-all
+     (lambda (widget)
+       (not (eq (widget-get widget :custom-form) 'all))))
+    ("Show Lisp Expression" custom-face-edit-lisp
      (lambda (widget)
        (not (eq (widget-get widget :custom-form) 'lisp)))))
   "Alist of actions for the `custom-face' widget.
@@ -3426,13 +3430,8 @@ Optional EVENT is the location for the menu."
     (custom-face-state-set widget)
     (custom-redraw-magic widget)))
 
-(defun custom-face-save-command (widget)
-  "Save in `.emacs' the face attributes in WIDGET."
-  (custom-face-save widget)
-  (custom-save-all))
-
 (defun custom-face-save (widget)
-  "Prepare for saving WIDGET's face attributes, but don't write `.emacs'."
+  "Save in `.emacs' the face attributes in WIDGET."
   (let* ((symbol (widget-value widget))
         (child (car (widget-get widget :children)))
         (value (custom-post-filter-face-spec (widget-value child)))
@@ -3458,6 +3457,10 @@ Optional EVENT is the location for the menu."
     (custom-face-state-set widget)
     (custom-redraw-magic widget)))
 
+;; For backward compatibility.
+(define-obsolete-function-alias 'custom-face-save-command 'custom-face-save
+  "22.1")
+
 (defun custom-face-reset-saved (widget)
   "Restore WIDGET to the face's default attributes."
   (let* ((symbol (widget-value widget))
@@ -3585,6 +3588,8 @@ restoring it to the state of a face that has never been customized."
 
 (define-widget 'custom-group-link 'link
   "Show parent in other window when activated."
+  :button-face 'custom-link
+  :mouse-face 'highlight
   :help-echo "Create customization buffer for this group."
   :action 'custom-group-link-action)
 
@@ -3783,8 +3788,6 @@ If GROUPS-ONLY non-nil, return only those members that are groups."
           (if (eq custom-buffer-style 'links)
               (push (widget-create-child-and-convert
                      widget 'custom-group-link
-                     :button-face 'custom-link
-                     :mouse-face 'highlight
                      :tag "Go to Group"
                      symbol)
                     buttons)
@@ -3900,22 +3903,21 @@ Creating group members... %2d%%"
           (insert "/\n")))))
 
 (defvar custom-group-menu
-  `(("Set for current session" custom-group-set
+  `(("Set for Current Session" custom-group-set
      (lambda (widget)
        (eq (widget-get widget :custom-state) 'modified)))
     ,@(when (or custom-file user-init-file)
-       '(("Save for future sessions" custom-group-save
+       '(("Save for Future Sessions" custom-group-save
           (lambda (widget)
             (memq (widget-get widget :custom-state) '(modified set))))))
-    ("---" ignore ignore)
-    ("Reset to current settings" custom-group-reset-current
+    ("Undo Edits" custom-group-reset-current
      (lambda (widget)
        (memq (widget-get widget :custom-state) '(modified))))
-    ("Reset to saved settings" custom-group-reset-saved
+    ("Reset to Saved" custom-group-reset-saved
      (lambda (widget)
        (memq (widget-get widget :custom-state) '(modified set))))
     ,@(when (or custom-file user-init-file)
-       '(("Reset to standard settings" custom-group-reset-standard
+       '(("Erase Customization" custom-group-reset-standard
           (lambda (widget)
             (memq (widget-get widget :custom-state) '(modified set saved)))))))
   "Alist of actions for the `custom-group' widget.
@@ -4374,11 +4376,20 @@ The format is suitable for use with `easy-menu-define'."
     ,(customize-menu-create 'customize)
     ["Set" Custom-set t]
     ["Save" Custom-save t]
-    ["Reset to current settings" Custom-reset-current t]
-    ["Reset to saved settings" Custom-reset-saved t]
-    ["Erase customizations" Custom-reset-standard t]
+    ["Undo Edits" Custom-reset-current t]
+    ["Reset to Saved" Custom-reset-saved t]
+    ["Erase Customization" Custom-reset-standard t]
     ["Info" (info "(emacs)Easy Customization") t]))
 
+(defvar custom-field-keymap
+  (let ((map (copy-keymap widget-field-keymap)))
+    (define-key map "\C-c\C-c" 'Custom-set)
+    (define-key map "\C-x\C-s" 'Custom-save)
+    map)
+  "Keymap used inside editable fields in customization buffers.")
+
+(widget-put (get 'editable-field 'widget-type) :keymap custom-field-keymap)
+
 (defun Custom-goto-parent ()
   "Go to the parent group listed at the top of this buffer.
 If several parents are listed, go to the first of them."
@@ -4404,17 +4415,18 @@ If several parents are listed, go to the first of them."
 
 The following commands are available:
 
-Move to next button or editable field.     \\[widget-forward]
-Move to previous button or editable field. \\[widget-backward]
-\\<widget-field-keymap>\
+\\<widget-keymap>\
+Move to next button, link or editable field.     \\[widget-forward]
+Move to previous button, link or editable field. \\[advertised-widget-backward]
+\\<custom-field-keymap>\
 Complete content of editable text field.   \\[widget-complete]
 \\<custom-mode-map>\
-Invoke button under the mouse pointer.     \\[Custom-move-and-invoke]
-Invoke button under point.                \\[widget-button-press]
+Invoke button under the mouse pointer.     \\[widget-move-and-invoke]
+Invoke button under point.                 \\[widget-button-press]
 Set all options from current text.         \\[Custom-set]
 Make values in current text permanent.     \\[Custom-save]
-Make text match actual option values.     \\[Custom-reset-current]
-Reset options to permanent settings.      \\[Custom-reset-saved]
+Make text match actual option values.      \\[Custom-reset-current]
+Reset options to permanent settings.       \\[Custom-reset-saved]
 Erase customizations; set options
   and buffer text to the standard values.  \\[Custom-reset-standard]