]> code.delx.au - gnu-emacs/blobdiff - lisp/cus-edit.el
(customize-save-customized): Renamed from custom-save-customized.
[gnu-emacs] / lisp / cus-edit.el
index b6f4dff616ce8931e1802eed108c3fe7b2d4fc6d..433308c3f3e4022ea91d88de665c8648a8d37066 100644 (file)
 ;; 
 ;; See `custom.el'.
 
+;; No commands should have names starting with `custom-' because
+;; that interferes with completion.  Use `customize-' for commands
+;; that the user will run with M-x, and `Custom-' for interactive commands.
+
 ;;; Code:
 
 (require 'cus-face)
@@ -579,8 +583,6 @@ A and B should be members of a `custom-group' property."
        (t
         (not (eq (nth 1 a) 'custom-group) ))))
 
-(defalias 'custom-browse-sort-predicate 'ignore)
-
 (defun custom-menu-sort-predicate (a b)
   "Return t iff A should come before B in a customization menu.
 A and B should be members of a `custom-group' property."
@@ -600,7 +602,7 @@ A and B should be members of a `custom-group' property."
 (defvar custom-options nil
   "Customization widgets in the current buffer.")
 
-(defun custom-set ()
+(defun Custom-set ()
   "Set changes in all modified options."
   (interactive)
   (let ((children custom-options))
@@ -609,7 +611,7 @@ A and B should be members of a `custom-group' property."
                (widget-apply child :custom-set)))
            children)))
 
-(defun custom-save ()
+(defun Custom-save ()
   "Set all modified group members and save them."
   (interactive)
   (let ((children custom-options))
@@ -620,9 +622,9 @@ A and B should be members of a `custom-group' property."
   (custom-save-all))
 
 (defvar custom-reset-menu 
-  '(("Current" . custom-reset-current)
-    ("Saved" . custom-reset-saved)
-    ("Standard Settings" . custom-reset-standard))
+  '(("Current" . Custom-reset-current)
+    ("Saved" . Custom-reset-saved)
+    ("Standard Settings" . 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
 lisp function taking the widget as an element which will be called
@@ -637,7 +639,7 @@ when the action is chosen.")
     (if answer
        (funcall answer))))
 
-(defun custom-reset-current (&rest ignore)
+(defun Custom-reset-current (&rest ignore)
   "Reset all modified group members to their current value."
   (interactive)
   (let ((children custom-options))
@@ -646,7 +648,7 @@ when the action is chosen.")
                (widget-apply child :custom-reset-current)))
            children)))
 
-(defun custom-reset-saved (&rest ignore)
+(defun Custom-reset-saved (&rest ignore)
   "Reset all modified or set group members to their saved value."
   (interactive)
   (let ((children custom-options))
@@ -655,7 +657,7 @@ when the action is chosen.")
                (widget-apply child :custom-reset-saved)))
            children)))
 
-(defun custom-reset-standard (&rest ignore)
+(defun Custom-reset-standard (&rest ignore)
   "Reset all modified, set, or saved group members to their standard settings."
   (interactive)
   (let ((children custom-options))
@@ -701,7 +703,7 @@ If the variable has a `custom-type' property, it must be a widget and the
                   (eval-minibuffer prompt)))))))
 
 ;;;###autoload
-(defun custom-set-value (var val)
+(defun customize-set-value (var val)
   "Set VARIABLE to VALUE.  VALUE is a Lisp object.
 
 If VARIABLE has a `variable-interactive' property, that is used as if
@@ -715,7 +717,7 @@ If VARIABLE has a `custom-type' property, it must be a widget and the
   (set var val))
 
 ;;;###autoload
-(defun custom-set-variable (var val)
+(defun customize-set-variable (var val)
   "Set the default for VARIABLE to VALUE.  VALUE is a Lisp object.
 
 If VARIABLE has a `custom-set' property, that is used for setting
@@ -979,25 +981,27 @@ This button will have a menu with all three reset operations."
   (message "Creating customization buffer...")
   (custom-mode)
   (widget-insert "This is a customization buffer.
-Push RET or click mouse-2 on the word ")
+Square brackets show active fields; type RET or click mouse-2
+on an active field to invoke its action.  Invoke ")
   (widget-create 'info-link 
-                :tag "help"
+                :tag "Help"
                 :help-echo "Read the online help."
                 "(emacs)Easy Customization")
   (widget-insert " for more information.\n\n")
   (message "Creating customization buttons...")
+  (widget-insert "Operate on everything in this buffer:\n ")
   (widget-create 'push-button
                 :tag "Set"
                 :help-echo "Set all modifications for this session."
                 :action (lambda (widget &optional event)
-                          (custom-set)))
+                          (Custom-set)))
   (widget-insert " ")
   (widget-create 'push-button
                 :tag "Save"
                 :help-echo "\
 Make the modifications default for future sessions."
                 :action (lambda (widget &optional event)
-                          (custom-save)))
+                          (Custom-save)))
   (widget-insert " ")
   (if custom-reset-button-menu
       (widget-create 'push-button
@@ -1010,22 +1014,22 @@ Make the modifications default for future sessions."
                   :tag "Reset"
                   :help-echo "\
 Reset all visible items in this buffer to their current settings."
-                  :action 'custom-reset-current)
+                  :action 'Custom-reset-current)
     (widget-insert " ")
     (widget-create 'push-button
                   :tag "Reset to Saved"
                   :help-echo "\
 Reset all visible items in this buffer to their saved settings."
-                  :action 'custom-reset-saved)
+                  :action 'Custom-reset-saved)
     (widget-insert " ")
     (widget-create 'push-button
                   :tag "Reset to Standard"
                   :help-echo "\
 Reset all visible items in this buffer to their standard settings."
-                  :action 'custom-reset-standard))
-  (widget-insert " ")
+                  :action 'Custom-reset-standard))
+  (widget-insert "   ")
   (widget-create 'push-button
-                :tag "Done"
+                :tag "Bury Buffer"
                 :help-echo "Bury the buffer."
                 :action (lambda (widget &optional event)
                           (bury-buffer)))
@@ -1077,7 +1081,7 @@ Reset all visible items in this buffer to their standard settings."
   (custom-mode)
   (widget-insert "\
 Invoke [+] below to expand items, and [-] to collapse items.
-Invoke the [group], [face], and [option] buttons below to edit that
+Invoke the [Group], [Face], and [Option] buttons below to edit that
 item in another window.\n\n")
   (let ((custom-buffer-style 'tree))
     (widget-create 'custom-group 
@@ -1100,7 +1104,7 @@ item in another window.\n\n")
 
 (define-widget 'custom-tree-group-tag 'push-button
   "Show parent in other window when activated."
-  :tag "group"
+  :tag "Group"
   :action 'custom-tree-group-tag-action)
 
 (defun custom-tree-group-tag-action (widget &rest ignore)
@@ -1109,7 +1113,7 @@ item in another window.\n\n")
 
 (define-widget 'custom-tree-variable-tag 'push-button
   "Show parent in other window when activated."
-  :tag "option"
+  :tag "Option"
   :action 'custom-tree-variable-tag-action)
 
 (defun custom-tree-variable-tag-action (widget &rest ignore)
@@ -1118,7 +1122,7 @@ item in another window.\n\n")
 
 (define-widget 'custom-tree-face-tag 'push-button
   "Show parent in other window when activated."
-  :tag "face"
+  :tag "Face"
   :action 'custom-tree-face-tag-action)
 
 (defun custom-tree-face-tag-action (widget &rest ignore)
@@ -1527,15 +1531,16 @@ Insert PREFIX first if non-nil."
               (insert ", "))))
       (widget-put widget :buttons buttons))))
 
-(defun custom-add-parent-links (widget)
-  "Add `Parent groups: ...' to WIDGET.
-The value if non-nil if there are parents."
+(defun custom-add-parent-links (widget &optional initial-string)
+  "Add \"Parent groups: ...\" to WIDGET if the group has parents.
+The value if non-nil if any parents were found.
+If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
   (let ((name (widget-value widget))
        (type (widget-type widget))
        (buttons (widget-get widget :buttons))
        (start (point))
        found)
-    (insert "Parent groups:")
+    (insert (or initial-string "Parent groups:"))
     (mapatoms (lambda (symbol)
                (let ((group (get symbol 'custom-group)))
                  (when (assq name group)
@@ -2395,6 +2400,16 @@ and so forth.  The remaining group tags are shown with
   (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
       'custom-group-tag-face))
 
+(define-widget 'custom-group-visibility 'visibility
+  "An indicator and manipulator for hidden group contents."
+  :create 'custom-group-visibility-create)
+
+(defun custom-group-visibility-create (widget)
+  (let ((visible (widget-value widget)))
+    (if visible
+       (insert "--------")))
+  (widget-default-create widget))
+
 (defun custom-group-value-create (widget)
   "Insert a customize group for WIDGET in the current buffer."
   (let ((state (widget-get widget :custom-state))
@@ -2445,8 +2460,7 @@ and so forth.  The remaining group tags are shown with
             (insert " " tag "\n")
             (widget-put widget :buttons buttons)
             (message "Creating group...")
-            (let* ((members (sort (copy-sequence (get symbol 'custom-group))
-                                  'custom-browse-sort-predicate))
+            (let* ((members (copy-sequence (get symbol 'custom-group)))
                    (prefixes (widget-get widget :custom-prefixes))
                    (custom-prefix-list (custom-prefix-add symbol prefixes))
                    (length (length members))
@@ -2513,7 +2527,8 @@ and so forth.  The remaining group tags are shown with
           (if t    ;;; This should test that the buffer
                    ;;; was made to display a group.
               (when (eq level 1)
-                (if (custom-add-parent-links widget)
+                (if (custom-add-parent-links widget
+                                             "Go to parent group:")
                     (insert "\n"))))
           ;; Create level indicator.
           (insert-char ?\  (* custom-buffer-indent (1- level)))
@@ -2796,7 +2811,7 @@ Leave point at the location of the call, or after the last expression."
        (princ "\n")))))
 
 ;;;###autoload
-(defun custom-save-customized ()
+(defun customize-save-customized ()
   "Save all user options which have been set in this session."
   (interactive)
   (mapatoms (lambda (symbol)
@@ -2827,7 +2842,7 @@ Leave point at the location of the call, or after the last expression."
 (unless (string-match "XEmacs" emacs-version)
   (defconst custom-help-menu
     '("Customize"
-      ["Update menu..." custom-menu-update t]
+      ["Update menu..." Custom-menu-update t]
       ["Group..." customize-group t]
       ["Variable..." customize-variable t]
       ["Face..." customize-face t]
@@ -2849,7 +2864,7 @@ Leave point at the location of the call, or after the last expression."
            (easy-menu-create-keymaps (car custom-help-menu)
                                      (cdr custom-help-menu)))))
 
-  (defun custom-menu-update (event)
+  (defun Custom-menu-update (event)
     "Update customize menu."
     (interactive "e")
     (add-hook 'custom-define-hook 'custom-menu-reset)
@@ -2958,16 +2973,16 @@ The format is suitable for use with `easy-menu-define'."
   (suppress-keymap custom-mode-map)
   (define-key custom-mode-map "q" 'bury-buffer))
 
-(easy-menu-define custom-mode-menu 
+(easy-menu-define Custom-mode-menu 
     custom-mode-map
   "Menu used in customization buffers."
   `("Custom"
     ,(customize-menu-create 'customize)
-    ["Set" custom-set t]
-    ["Save" custom-save t]
-    ["Reset to Current" custom-reset-current t]
-    ["Reset to Saved" custom-reset-saved t]
-    ["Reset to Standard Settings" custom-reset-standard t]
+    ["Set" Custom-set t]
+    ["Save" Custom-save t]
+    ["Reset to Current" Custom-reset-current t]
+    ["Reset to Saved" Custom-reset-saved t]
+    ["Reset to Standard Settings" Custom-reset-standard t]
     ["Info" (Info-goto-node "(custom)The Customization Buffer") t]))
 
 (defcustom custom-mode-hook nil
@@ -2975,6 +2990,9 @@ The format is suitable for use with `easy-menu-define'."
   :type 'hook
   :group 'custom-buffer )
 
+(defun custom-state-buffer-message ()
+  (message "To set the value, invoke [State] and choose the Set operation"))
+
 (defun custom-mode ()
   "Major mode for editing customization buffers.
 
@@ -2984,11 +3002,11 @@ Move to next button or editable field.     \\[widget-forward]
 Move to previous button or editable field. \\[widget-backward]
 Invoke button under the mouse pointer.     \\[widget-button-click]
 Invoke button under point.                \\[widget-button-press]
-Set all modifications.                    \\[custom-set]
-Make all modifications default.                   \\[custom-save]
-Reset all modified options.               \\[custom-reset-current]
-Reset all modified or set options.        \\[custom-reset-saved]
-Reset all options.                        \\[custom-reset-standard]
+Set all modifications.                    \\[Custom-set]
+Make all modifications default.                   \\[Custom-save]
+Reset all modified options.               \\[Custom-reset-current]
+Reset all modified or set options.        \\[Custom-reset-saved]
+Reset all options.                        \\[Custom-reset-standard]
 
 Entry to this mode calls the value of `custom-mode-hook'
 if that value is non-nil."
@@ -2996,8 +3014,10 @@ if that value is non-nil."
   (setq major-mode 'custom-mode
        mode-name "Custom")
   (use-local-map custom-mode-map)
-  (easy-menu-add custom-mode-menu)
+  (easy-menu-add Custom-mode-menu)
   (make-local-variable 'custom-options)
+  (make-local-hook 'widget-edit-hook)
+  (add-hook 'widget-edit-hook 'custom-state-buffer-message nil t)
   (run-hooks 'custom-mode-hook))
 
 ;;; The End.