;;
;; 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)
(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."
(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))
(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))
(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
(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))
(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))
(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))
(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
(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
(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
: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)))
(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
(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)
(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)
(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)
(insert ", "))))
(widget-put widget :buttons buttons))))
-(defun custom-add-parent-links (widget)
- "Add `Parent groups: ...' to WIDGET."
+(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)
buttons)
(setq found t))))))
(widget-put widget :buttons buttons)
- (unless found
- (insert " (none)"))
- (insert "\n")))
+ (if found
+ (insert "\n")
+ (delete-region start (point)))
+ found))
;;; The `custom-variable' Widget.
(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))
(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))
(widget-default-format-handler widget ?h))
;; Nested style.
(t ;Visible.
+ ;; Add parent groups references above the group.
+ (if t ;;; This should test that the buffer
+ ;;; was made to display a group.
+ (when (eq level 1)
+ (if (custom-add-parent-links widget
+ "Go to parent group:")
+ (insert "\n"))))
;; Create level indicator.
(insert-char ?\ (* custom-buffer-indent (1- level)))
(insert "/- ")
(widget-put widget :buttons buttons)
;; Insert documentation.
(widget-default-format-handler widget ?h)
- ;; Parents and See also.
- (when (eq level 1)
- (insert-char ?\ custom-buffer-indent)
- (custom-add-parent-links widget))
+ ;; Parent groups.
+ (if nil ;;; This should test that the buffer
+ ;;; was not made to display a group.
+ (when (eq level 1)
+ (insert-char ?\ custom-buffer-indent)
+ (custom-add-parent-links widget)))
(custom-add-see-also widget
(make-string (* custom-buffer-indent level)
?\ ))
(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)
(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]
(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)
(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
: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.
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."
(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.