1 ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages
3 ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
8 ;; Keywords: help, faces
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; This file implements the code to create and edit customize buffers.
33 ;; No commands should have names starting with `custom-' because
34 ;; that interferes with completion. Use `customize-' for commands
35 ;; that the user will run with M-x, and `Custom-' for interactive commands.
37 ;; The identity of a customize option is represented by a Lisp symbol.
38 ;; The following values are associated with an option.
40 ;; 0. The current value.
42 ;; This is the value of the option as seen by "the rest of Emacs".
44 ;; Usually extracted by 'default-value', but can be extracted with
45 ;; different means if the option symbol has the 'custom-get'
46 ;; property. Similarly, set-default (or the 'custom-set' property)
49 ;; 1. The widget value.
51 ;; This is the value shown in the widget in a customize buffer.
53 ;; 2. The customized value.
55 ;; This is the last value given to the option through customize.
57 ;; It is stored in the 'customized-value' property of the option, in a
58 ;; cons-cell whose car evaluates to the customized value.
60 ;; 3. The saved value.
62 ;; This is last value saved from customize.
64 ;; It is stored in the 'saved-value' property of the option, in a
65 ;; cons-cell whose car evaluates to the saved value.
67 ;; 4. The standard value.
69 ;; This is the value given in the 'defcustom' declaration.
71 ;; It is stored in the 'standard-value' property of the option, in a
72 ;; cons-cell whose car evaluates to the standard value.
74 ;; 5. The "think" value.
76 ;; This is what customize thinks the current value should be.
78 ;; This is the customized value, if any such value exists, otherwise
79 ;; the saved value, if that exists, and as a last resort the standard
82 ;; The reason for storing values unevaluated: This is so you can have
83 ;; values that depend on the environment. For example, you can have a
84 ;; variable that has one value when Emacs is running under a window
85 ;; system, and another value on a tty. Since the evaluation is only done
86 ;; when the variable is first initialized, this is only relevant for the
87 ;; saved (and standard) values, but affect others values for
90 ;; You can see (and modify and save) this unevaluated value by selecting
91 ;; "Show Saved Lisp Expression" from the Lisp interface. This will
92 ;; give you the unevaluated saved value, if any, otherwise the
93 ;; unevaluated standard value.
95 ;; The possible states for a customize widget are:
99 ;; The state has not been determined yet.
103 ;; The widget value is different from the current value.
107 ;; The current value is different from the "think" value.
111 ;; The "think" value is the customized value.
115 ;; The "think" value is the saved value.
119 ;; The "think" value is the standard value.
123 ;; There is no standard value. This means that the variable was
124 ;; not defined with defcustom, nor handled in cus-start.el. Most
125 ;; standard interactive Custom commands do not let you create a
126 ;; Custom buffer containing such variables. However, such Custom
127 ;; buffers can be created, for instance, by calling
128 ;; `customize-apropos' with a prefix arg or by calling
129 ;; `customize-option' non-interactively.
133 ;; There is no widget value.
137 ;; The widget value is not valid member of the :type specified for the
145 (defvar custom-versions-load-alist
) ; from cus-load
146 (defvar recentf-exclude
)) ; from recentf.el
156 (put 'custom-define-hook
'custom-type
'hook
)
157 (put 'custom-define-hook
'standard-value
'(nil))
158 (custom-add-to-group 'customize
'custom-define-hook
'custom-variable
)
160 ;;; Customization Groups.
163 "Customization of the One True Editor."
164 :link
'(custom-manual "(emacs)Top"))
166 ;; Most of these groups are stolen from `finder.el',
167 (defgroup editing nil
168 "Basic text editing facilities."
172 "Abbreviation handling, typing shortcuts, macros."
176 (defgroup matching nil
177 "Various sorts of searching and matching."
180 (defgroup emulations nil
181 "Emulations of other editors."
182 :link
'(custom-manual "(emacs)Emulation")
189 (defgroup outlines nil
190 "Support for hierarchical outlining."
193 (defgroup external nil
194 "Interfacing to external utilities."
197 (defgroup processes nil
198 "Process, subshell, compilation, and job control support."
202 (defgroup convenience nil
203 "Convenience features for faster editing."
206 (defgroup programming nil
207 "Support for programming in other languages."
210 (defgroup languages nil
211 "Specialized modes for editing programming languages."
215 "Lisp support, including Emacs Lisp."
216 :link
'(custom-group-link :tag
"Font Lock Faces group" font-lock-faces
)
221 "Support for the C language and related languages."
222 :link
'(custom-group-link :tag
"Font Lock Faces group" font-lock-faces
)
223 :link
'(custom-manual "(ccmode)")
231 "Support for object-oriented programming."
234 (defgroup applications nil
235 "Applications written in Emacs."
238 (defgroup calendar nil
239 "Calendar and time management support."
240 :group
'applications
)
243 "Modes for electronic-mail handling."
244 :group
'applications
)
247 "Support for netnews reading and posting."
248 :link
'(custom-manual "(gnus)")
249 :group
'applications
)
252 "Games, jokes and amusements."
253 :group
'applications
)
255 (defgroup development nil
256 "Support for further development of Emacs."
260 "Support for Emacs documentation."
263 (defgroup extensions nil
264 "Emacs Lisp language extensions."
267 (defgroup internal nil
268 "Code for Emacs internals, build process, defaults."
272 "Maintenance aids for the Emacs development group."
276 (defgroup environment nil
277 "Fitting Emacs with its environment."
281 "Communications, networking, remote access to files."
285 (defgroup hardware nil
286 "Support for interfacing with exotic hardware."
289 (defgroup terminals nil
290 "Support for terminal types."
294 "Front-ends/assistants for, or emulators of, UNIX features."
298 "Support code for vms."
302 "Internationalization and alternate character-set support."
303 :link
'(custom-manual "(emacs)International")
308 "The X Window system."
312 "Support for Emacs frames and window systems."
316 "Support editing files of data."
320 "Support editing files."
328 "Code related to the TeX formatter."
329 :link
'(custom-group-link :tag
"Font Lock Faces group" font-lock-faces
)
333 "Support for multiple fonts."
336 (defgroup hypermedia nil
337 "Support for links between text or other media types."
341 "Support for on-line help systems."
344 (defgroup multimedia nil
345 "Non-textual support, specifically images and sound."
349 "Code local to your site."
352 (defgroup customize
'((widgets custom-group
))
353 "Customization of the Customization support."
357 (defgroup custom-faces nil
358 "Faces used by customize."
362 (defgroup custom-browse nil
363 "Control customize browser."
367 (defgroup custom-buffer nil
368 "Control customize buffers."
372 (defgroup custom-menu nil
373 "Control customize menus."
377 (defgroup abbrev-mode nil
378 "Word abbreviations mode."
379 :link
'(custom-manual "(emacs)Abbrevs")
383 "Storage allocation and gc for GNU Emacs Lisp interpreter."
384 :tag
"Storage Allocation"
388 "Undoing changes in buffers."
389 :link
'(custom-manual "(emacs)Undo")
392 (defgroup modeline nil
393 "Content of the modeline."
396 (defgroup editing-basics nil
397 "Most basic editing facilities."
400 (defgroup display nil
401 "How characters are displayed in buffers."
404 (defgroup execute nil
405 "Executing external commands."
408 (defgroup installation nil
409 "The Emacs installation."
417 "Internal Emacs limits."
421 "Debugging Emacs itself."
424 (defgroup minibuffer nil
425 "Controling the behavior of the minibuffer."
426 :link
'(custom-manual "(emacs)Minibuffer")
429 (defgroup keyboard nil
430 "Input from the keyboard."
434 "Input from the mouse."
438 "Input from the menus."
442 "Handling data from drag and drop."
445 (defgroup auto-save nil
446 "Preventing accidential loss of data."
449 (defgroup processes-basics nil
450 "Basic stuff dealing with processes."
454 "MULE Emacs internationalization."
457 (defgroup windows nil
458 "Windows within a frame."
459 :link
'(custom-manual "(emacs)Windows")
463 "Mac specific features."
464 :link
'(custom-manual "(emacs)Mac OS")
471 (defun custom-split-regexp-maybe (regexp)
472 "If REGEXP is a string, split it to a list at `\\|'.
473 You can get the original back with from the result with:
474 (mapconcat 'identity result \"\\|\")
476 IF REGEXP is not a string, return it unchanged."
480 (while (string-match "\\\\|" regexp start
)
481 (setq all
(cons (substring regexp start
(match-beginning 0)) all
)
482 start
(match-end 0)))
483 (nreverse (cons (substring regexp start
) all
)))
486 (defun custom-variable-prompt ()
487 "Prompt for a custom variable, defaulting to the variable at point.
488 Return a list suitable for use in `interactive'."
489 (let* ((v (variable-at-point))
490 (default (and (symbolp v
) (custom-variable-p v
) (symbol-name v
)))
491 (enable-recursive-minibuffers t
)
493 (setq val
(completing-read
494 (if default
(format "Customize variable (default %s): " default
)
495 "Customize variable: ")
496 obarray
'custom-variable-p t nil nil default
))
497 (list (if (equal val
"")
498 (if (symbolp v
) v nil
)
501 (defun custom-menu-filter (menu widget
)
502 "Convert MENU to the form used by `widget-choose'.
503 MENU should be in the same format as `custom-variable-menu'.
504 WIDGET is the widget to apply the filter entries of MENU on."
506 current name action filter
)
508 (setq current
(car menu
)
510 action
(nth 1 current
)
511 filter
(nth 2 current
)
513 (if (or (null filter
) (funcall filter widget
))
514 (push (cons name action
) result
)
520 (defvar custom-prefix-list nil
521 "List of prefixes that should be ignored by `custom-unlispify'.")
523 (defcustom custom-unlispify-menu-entries t
524 "Display menu entries as words instead of symbols if non nil."
528 (defcustom custom-unlispify-remove-prefixes nil
529 "Non-nil means remove group prefixes from option names in buffer."
531 :group
'custom-buffer
534 (defun custom-unlispify-menu-entry (symbol &optional no-suffix
)
535 "Convert SYMBOL into a menu entry."
536 (cond ((not custom-unlispify-menu-entries
)
537 (symbol-name symbol
))
538 ((get symbol
'custom-tag
)
540 (get symbol
'custom-tag
)
541 (concat (get symbol
'custom-tag
) "...")))
543 (with-current-buffer (get-buffer-create " *Custom-Work*")
545 (princ symbol
(current-buffer))
546 (goto-char (point-min))
547 ;; FIXME: Boolean variables are not predicates, so they shouldn't
548 ;; end with `-p'. -stef
549 ;; (when (and (eq (get symbol 'custom-type) 'boolean)
550 ;; (re-search-forward "-p\\'" nil t))
551 ;; (replace-match "" t t)
552 ;; (goto-char (point-min)))
553 (if custom-unlispify-remove-prefixes
554 (let ((prefixes custom-prefix-list
)
557 (setq prefix
(car prefixes
))
558 (if (search-forward prefix
(+ (point) (length prefix
)) t
)
561 (delete-region (point-min) (point)))
562 (setq prefixes
(cdr prefixes
))))))
563 (subst-char-in-region (point-min) (point-max) ?- ?\ t
)
564 (capitalize-region (point-min) (point-max))
566 (goto-char (point-max))
570 (defcustom custom-unlispify-tag-names t
571 "Display tag names as words instead of symbols if non nil."
572 :group
'custom-buffer
575 (defun custom-unlispify-tag-name (symbol)
576 "Convert SYMBOL into a menu entry."
577 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names
))
578 (custom-unlispify-menu-entry symbol t
)))
580 (defun custom-prefix-add (symbol prefixes
)
581 "Add SYMBOL to list of ignored PREFIXES."
582 (cons (or (get symbol
'custom-prefix
)
583 (concat (symbol-name symbol
) "-"))
588 (defcustom custom-guess-name-alist
594 ("-function\\'" function
)
595 ("-functions\\'" (repeat function
))
596 ("-list\\'" (repeat sexp
))
597 ("-alist\\'" (repeat (cons sexp sexp
))))
598 "Alist of (MATCH TYPE).
600 MATCH should be a regexp matching the name of a symbol, and TYPE should
601 be a widget suitable for editing the value of that symbol. The TYPE
602 of the first entry where MATCH matches the name of the symbol will be
605 This is used for guessing the type of variables not declared with
607 :type
'(repeat (group (regexp :tag
"Match") (sexp :tag
"Type")))
608 :group
'custom-buffer
)
610 (defcustom custom-guess-doc-alist
611 '(("\\`\\*?Non-nil " boolean
))
612 "Alist of (MATCH TYPE).
614 MATCH should be a regexp matching a documentation string, and TYPE
615 should be a widget suitable for editing the value of a variable with
616 that documentation string. The TYPE of the first entry where MATCH
617 matches the name of the symbol will be used.
619 This is used for guessing the type of variables not declared with
621 :type
'(repeat (group (regexp :tag
"Match") (sexp :tag
"Type")))
622 :group
'custom-buffer
)
624 (defun custom-guess-type (symbol)
625 "Guess a widget suitable for editing the value of SYMBOL.
626 This is done by matching SYMBOL with `custom-guess-name-alist' and
627 if that fails, the doc string with `custom-guess-doc-alist'."
628 (let ((name (symbol-name symbol
))
629 (names custom-guess-name-alist
)
632 (setq current
(car names
)
634 (when (string-match (nth 0 current
) name
)
635 (setq found
(nth 1 current
)
638 (let ((doc (documentation-property symbol
'variable-documentation
))
639 (docs custom-guess-doc-alist
))
642 (setq current
(car docs
)
644 (when (string-match (nth 0 current
) doc
)
645 (setq found
(nth 1 current
)
651 (defcustom custom-browse-sort-alphabetically nil
652 "If non-nil, sort members of each customization group alphabetically."
654 :group
'custom-browse
)
656 (defcustom custom-browse-order-groups nil
657 "If non-nil, order group members within each customization group.
658 If `first', order groups before non-groups.
659 If `last', order groups after non-groups."
660 :type
'(choice (const first
)
662 (const :tag
"none" nil
))
663 :group
'custom-browse
)
665 (defcustom custom-browse-only-groups nil
666 "If non-nil, show group members only within each customization group."
668 :group
'custom-browse
)
670 (defcustom custom-buffer-sort-alphabetically nil
671 "If non-nil, sort members of each customization group alphabetically."
673 :group
'custom-buffer
)
675 (defcustom custom-buffer-order-groups
'last
676 "If non-nil, order group members within each customization group.
677 If `first', order groups before non-groups.
678 If `last', order groups after non-groups."
679 :type
'(choice (const first
)
681 (const :tag
"none" nil
))
682 :group
'custom-buffer
)
684 (defcustom custom-menu-sort-alphabetically nil
685 "If non-nil, sort members of each customization group alphabetically."
689 (defcustom custom-menu-order-groups
'first
690 "If non-nil, order group members within each customization group.
691 If `first', order groups before non-groups.
692 If `last', order groups after non-groups."
693 :type
'(choice (const first
)
695 (const :tag
"none" nil
))
698 ;;;###autoload (add-hook 'same-window-regexps "\\`\\*Customiz.*\\*\\'")
700 (defun custom-sort-items (items sort-alphabetically order-groups
)
701 "Return a sorted copy of ITEMS.
702 ITEMS should be a `custom-group' property.
703 If SORT-ALPHABETICALLY non-nil, sort alphabetically.
704 If ORDER-GROUPS is `first' order groups before non-groups, if `last' order
705 groups after non-groups, if nil do not order groups at all."
706 (sort (copy-sequence items
)
708 (let ((typea (nth 1 a
)) (typeb (nth 1 b
))
709 (namea (nth 0 a
)) (nameb (nth 0 b
)))
710 (cond ((not order-groups
)
711 ;; Since we don't care about A and B order, maybe sort.
712 (when sort-alphabetically
713 (string-lessp namea nameb
)))
714 ((eq typea
'custom-group
)
715 ;; If B is also a group, maybe sort. Otherwise, order A and B.
716 (if (eq typeb
'custom-group
)
717 (when sort-alphabetically
718 (string-lessp namea nameb
))
719 (eq order-groups
'first
)))
720 ((eq typeb
'custom-group
)
721 ;; Since A cannot be a group, order A and B.
722 (eq order-groups
'last
))
724 ;; Since A and B cannot be groups, sort.
725 (string-lessp namea nameb
)))))))
727 ;;; Custom Mode Commands.
729 (defvar custom-options nil
730 "Customization widgets in the current buffer.")
733 "Set the current value of all edited settings in the buffer."
735 (let ((children custom-options
))
736 (if (or (and (= 1 (length children
))
737 (memq (widget-type (car children
))
738 '(custom-variable custom-face
)))
739 (y-or-n-p "Set all values according to this buffer? "))
740 (mapc (lambda (child)
741 (when (eq (widget-get child
:custom-state
) 'modified
)
742 (widget-apply child
:custom-set
)))
744 (message "Aborted"))))
746 (defun Custom-save ()
747 "Set all edited settings, then save all settings that have been set.
748 If a setting was edited and set before, this saves it.
749 If a setting was merely edited before, this sets it then saves it."
751 (let ((children custom-options
))
752 (if (or (and (= 1 (length children
))
753 (memq (widget-type (car children
))
754 '(custom-variable custom-face
)))
755 (yes-or-no-p "Save all settings in this buffer? "))
757 (mapc (lambda (child)
758 (when (memq (widget-get child
:custom-state
)
759 '(modified set changed rogue
))
760 (widget-apply child
:custom-save
)))
763 (message "Aborted"))))
765 (defvar custom-reset-menu
766 '(("Undo Edits" . Custom-reset-current
)
767 ("Reset to Saved" . Custom-reset-saved
)
768 ("Erase Customization (use standard values)" . Custom-reset-standard
))
769 "Alist of actions for the `Reset' button.
770 The key is a string containing the name of the action, the value is a
771 Lisp function taking the widget as an element which will be called
772 when the action is chosen.")
774 (defun custom-reset (event)
775 "Select item from reset menu."
776 (let* ((completion-ignore-case t
)
777 (answer (widget-choose "Reset settings"
783 (defun Custom-reset-current (&rest ignore
)
784 "Reset all edited settings in the buffer to show their current values."
786 (let ((children custom-options
))
787 (if (or (and (= 1 (length children
))
788 (memq (widget-type (car children
))
789 '(custom-variable custom-face
)))
790 (y-or-n-p "Reset all settings' buffer text to show current values? "))
791 (mapc (lambda (widget)
792 (if (memq (widget-get widget
:custom-state
)
794 (widget-apply widget
:custom-reset-current
)))
796 (message "Aborted"))))
798 (defun Custom-reset-saved (&rest ignore
)
799 "Reset all edited or set settings in the buffer to their saved value.
800 This also shows the saved values in the buffer."
802 (let ((children custom-options
))
803 (if (or (and (= 1 (length children
))
804 (memq (widget-type (car children
))
805 '(custom-variable custom-face
)))
806 (y-or-n-p "Reset all settings (current values and buffer text) to saved values? "))
807 (mapc (lambda (widget)
808 (if (memq (widget-get widget
:custom-state
)
809 '(modified set changed rogue
))
810 (widget-apply widget
:custom-reset-saved
)))
812 (message "Aborted"))))
814 (defun Custom-reset-standard (&rest ignore
)
815 "Erase all customization (either current or saved) for the group members.
816 The immediate result is to restore them to their standard values.
817 This operation eliminates any saved values for the group members,
818 making them as if they had never been customized at all."
820 (let ((children custom-options
))
821 (if (or (and (= 1 (length children
))
822 (memq (widget-type (car children
))
823 '(custom-variable custom-face
)))
824 (yes-or-no-p "Erase all customizations for settings in this buffer? "))
825 (mapc (lambda (widget)
826 (and (if (widget-get widget
:custom-standard-value
)
827 (widget-apply widget
:custom-standard-value
)
829 (memq (widget-get widget
:custom-state
)
830 '(modified set changed saved rogue
))
831 (widget-apply widget
:custom-reset-standard
)))
833 (message "Aborted"))))
835 ;;; The Customize Commands
837 (defun custom-prompt-variable (prompt-var prompt-val
&optional comment
)
838 "Prompt for a variable and a value and return them as a list.
839 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the
840 prompt for the value. The %s escape in PROMPT-VAL is replaced with
841 the name of the variable.
843 If the variable has a `variable-interactive' property, that is used as if
844 it were the arg to `interactive' (which see) to interactively read the value.
846 If the variable has a `custom-type' property, it must be a widget and the
847 `:prompt-value' property of that widget will be used for reading the value.
849 If optional COMMENT argument is non nil, also prompt for a comment and return
850 it as the third element in the list."
851 (let* ((var (read-variable prompt-var
))
852 (minibuffer-help-form '(describe-variable var
))
854 (let ((prop (get var
'variable-interactive
))
855 (type (get var
'custom-type
))
856 (prompt (format prompt-val var
)))
858 (setq type
(list type
)))
860 ;; Use VAR's `variable-interactive' property
861 ;; as an interactive spec for prompting.
862 (call-interactively (list 'lambda
'(arg)
863 (list 'interactive prop
)
866 (widget-prompt-value type
872 (eval-minibuffer prompt
))))))
875 (read-string "Comment: " (get var
'variable-comment
)))
879 (defun customize-set-value (variable value
&optional comment
)
880 "Set VARIABLE to VALUE, and return VALUE. VALUE is a Lisp object.
882 If VARIABLE has a `variable-interactive' property, that is used as if
883 it were the arg to `interactive' (which see) to interactively read the value.
885 If VARIABLE has a `custom-type' property, it must be a widget and the
886 `:prompt-value' property of that widget will be used for reading the value.
888 If given a prefix (or a COMMENT argument), also prompt for a comment."
889 (interactive (custom-prompt-variable "Set variable: "
893 (cond ((string= comment
"")
894 (put variable
'variable-comment nil
))
896 (put variable
'variable-comment comment
)))
897 (set variable value
))
900 (defun customize-set-variable (variable value
&optional comment
)
901 "Set the default for VARIABLE to VALUE, and return VALUE.
902 VALUE is a Lisp object.
904 If VARIABLE has a `custom-set' property, that is used for setting
905 VARIABLE, otherwise `set-default' is used.
907 The `customized-value' property of the VARIABLE will be set to a list
908 with a quoted VALUE as its sole list member.
910 If VARIABLE has a `variable-interactive' property, that is used as if
911 it were the arg to `interactive' (which see) to interactively read the value.
913 If VARIABLE has a `custom-type' property, it must be a widget and the
914 `:prompt-value' property of that widget will be used for reading the value.
916 If given a prefix (or a COMMENT argument), also prompt for a comment."
917 (interactive (custom-prompt-variable "Set variable: "
918 "Set customized value for %s to: "
920 (custom-load-symbol variable
)
921 (custom-push-theme 'theme-value variable
'user
'set
(custom-quote value
))
922 (funcall (or (get variable
'custom-set
) 'set-default
) variable value
)
923 (put variable
'customized-value
(list (custom-quote value
)))
924 (cond ((string= comment
"")
925 (put variable
'variable-comment nil
)
926 (put variable
'customized-variable-comment nil
))
928 (put variable
'variable-comment comment
)
929 (put variable
'customized-variable-comment comment
)))
933 (defun customize-save-variable (variable value
&optional comment
)
934 "Set the default for VARIABLE to VALUE, and save it for future sessions.
937 If VARIABLE has a `custom-set' property, that is used for setting
938 VARIABLE, otherwise `set-default' is used.
940 The `customized-value' property of the VARIABLE will be set to a list
941 with a quoted VALUE as its sole list member.
943 If VARIABLE has a `variable-interactive' property, that is used as if
944 it were the arg to `interactive' (which see) to interactively read the value.
946 If VARIABLE has a `custom-type' property, it must be a widget and the
947 `:prompt-value' property of that widget will be used for reading the value.
949 If given a prefix (or a COMMENT argument), also prompt for a comment."
950 (interactive (custom-prompt-variable "Set and save variable: "
951 "Set and save value for %s as: "
953 (funcall (or (get variable
'custom-set
) 'set-default
) variable value
)
954 (put variable
'saved-value
(list (custom-quote value
)))
955 (custom-push-theme 'theme-value variable
'user
'set
(custom-quote value
))
956 (cond ((string= comment
"")
957 (put variable
'variable-comment nil
)
958 (put variable
'saved-variable-comment nil
))
960 (put variable
'variable-comment comment
)
961 (put variable
'saved-variable-comment comment
)))
967 "Select a customization buffer which you can use to set user options.
968 User options are structured into \"groups\".
969 Initially the top-level group `Emacs' and its immediate subgroups
970 are shown; the contents of those subgroups are initially hidden."
972 (customize-group 'emacs
))
975 (defun customize-mode (mode)
976 "Customize options related to the current major mode.
977 If a prefix \\[universal-argument] was given (or if the current major mode has no known group),
978 then prompt for the MODE to customize."
981 (let ((completion-regexp-list '("-mode\\'"))
982 (group (custom-group-of-mode major-mode
)))
983 (if (and group
(not current-prefix-arg
))
986 (completing-read (if group
987 (format "Major mode (default %s): " major-mode
)
990 'custom-group-of-mode
991 t nil nil
(if group
(symbol-name major-mode
))))))))
992 (customize-group (custom-group-of-mode mode
)))
996 (defun customize-group (group)
997 "Customize GROUP, which must be a customization group."
999 (list (let ((completion-ignore-case t
))
1000 (completing-read "Customize group (default emacs): "
1003 (or (and (get symbol
'custom-loads
)
1004 (not (get symbol
'custom-autoload
)))
1005 (get symbol
'custom-group
)))
1007 (when (stringp group
)
1008 (if (string-equal "" group
)
1010 (setq group
(intern group
))))
1011 (let ((name (format "*Customize Group: %s*"
1012 (custom-unlispify-tag-name group
))))
1013 (if (get-buffer name
)
1014 (pop-to-buffer name
)
1015 (custom-buffer-create (list (list group
'custom-group
))
1017 (concat " for group "
1018 (custom-unlispify-tag-name group
))))))
1021 (defun customize-group-other-window (group)
1022 "Customize GROUP, which must be a customization group."
1024 (list (let ((completion-ignore-case t
))
1025 (completing-read "Customize group (default emacs): "
1028 (or (and (get symbol
'custom-loads
)
1029 (not (get symbol
'custom-autoload
)))
1030 (get symbol
'custom-group
)))
1032 (when (stringp group
)
1033 (if (string-equal "" group
)
1035 (setq group
(intern group
))))
1036 (let ((name (format "*Customize Group: %s*"
1037 (custom-unlispify-tag-name group
))))
1038 (if (get-buffer name
)
1040 ;; Copied from `custom-buffer-create-other-window'.
1042 (same-window-buffer-names nil
)
1043 (same-window-regexps nil
))
1044 (pop-to-buffer name
))
1045 (custom-buffer-create-other-window
1046 (list (list group
'custom-group
))
1048 (concat " for group "
1049 (custom-unlispify-tag-name group
))))))
1052 (defalias 'customize-variable
'customize-option
)
1055 (defun customize-option (symbol)
1056 "Customize SYMBOL, which must be a user option variable."
1057 (interactive (custom-variable-prompt))
1059 (error "No variable specified"))
1060 (let ((basevar (indirect-variable symbol
)))
1061 (custom-buffer-create (list (list basevar
'custom-variable
))
1062 (format "*Customize Option: %s*"
1063 (custom-unlispify-tag-name basevar
)))
1064 (unless (eq symbol basevar
)
1065 (message "`%s' is an alias for `%s'" symbol basevar
))))
1068 (defalias 'customize-variable-other-window
'customize-option-other-window
)
1071 (defun customize-option-other-window (symbol)
1072 "Customize SYMBOL, which must be a user option variable.
1073 Show the buffer in another window, but don't select it."
1074 (interactive (custom-variable-prompt))
1076 (error "No variable specified"))
1077 (let ((basevar (indirect-variable symbol
)))
1078 (custom-buffer-create-other-window
1079 (list (list basevar
'custom-variable
))
1080 (format "*Customize Option: %s*" (custom-unlispify-tag-name basevar
)))
1081 (unless (eq symbol basevar
)
1082 (message "`%s' is an alias for `%s'" symbol basevar
))))
1084 (defvar customize-changed-options-previous-release
"21.1"
1085 "Version for `customize-changed-options' to refer back to by default.")
1087 ;; Packages will update this variable, so make it available.
1089 (defvar customize-package-emacs-version-alist nil
1090 "Alist mapping versions of Emacs to versions of a package.
1091 These package versions are listed in the :package-version
1092 keyword used in `defcustom', `defgroup', and `defface'. Its
1093 elements look like this:
1095 (PACKAGE (PVERSION . EVERSION)...)
1097 For each PACKAGE, which is a symbol, there are one or more
1098 elements that contain a package version PVERSION with an
1099 associated Emacs version EVERSION. These versions are strings.
1100 For example, the MH-E package updates this alist with the
1103 (add-to-list 'customize-package-emacs-version-alist
1104 '(MH-E (\"6.0\" . \"22.1\") (\"6.1\" . \"22.1\")
1105 (\"7.0\" . \"22.1\") (\"7.1\" . \"22.1\")
1106 (\"7.2\" . \"22.1\") (\"7.3\" . \"22.1\")
1107 (\"7.4\" . \"22.1\") (\"8.0\" . \"22.1\")))
1109 The value of PACKAGE needs to be unique and it needs to match the
1110 PACKAGE value appearing in the :package-version keyword. Since
1111 the user might see the value in a error message, a good choice is
1112 the official name of the package, such as MH-E or Gnus.")
1115 (defalias 'customize-changed
'customize-changed-options
)
1118 (defun customize-changed-options (since-version)
1119 "Customize all settings whose meanings have changed in Emacs itself.
1120 This includes new user option variables and faces, and new
1121 customization groups, as well as older options and faces whose meanings
1122 or default values have changed since the previous major Emacs release.
1124 With argument SINCE-VERSION (a string), customize all settings
1125 that were added or redefined since that version."
1129 (read-from-minibuffer
1130 (format "Customize options changed, since version (default %s): "
1131 customize-changed-options-previous-release
))))
1132 (if (equal since-version
"")
1133 (setq since-version nil
)
1134 (unless (condition-case nil
1135 (numberp (read since-version
))
1137 (signal 'wrong-type-argument
(list 'numberp since-version
))))
1138 (unless since-version
1139 (setq since-version customize-changed-options-previous-release
))
1141 ;; Load the information for versions since since-version. We use
1142 ;; custom-load-symbol for this.
1143 (put 'custom-versions-load-alist
'custom-loads nil
)
1144 (dolist (elt custom-versions-load-alist
)
1145 (if (customize-version-lessp since-version
(car elt
))
1146 (dolist (load (cdr elt
))
1147 (custom-add-load 'custom-versions-load-alist load
))))
1148 (custom-load-symbol 'custom-versions-load-alist
)
1149 (put 'custom-versions-load-alist
'custom-loads nil
)
1154 (let* ((package-version (get symbol
'custom-package-version
))
1156 (or (and package-version
1157 (customize-package-emacs-version symbol
1159 (get symbol
'custom-version
))))
1161 (when (customize-version-lessp since-version version
)
1162 (if (or (get symbol
'custom-group
)
1163 (get symbol
'group-documentation
))
1164 (push (list symbol
'custom-group
) found
))
1165 (if (custom-variable-p symbol
)
1166 (push (list symbol
'custom-variable
) found
))
1167 (if (custom-facep symbol
)
1168 (push (list symbol
'custom-face
) found
)))))))
1170 (custom-buffer-create (custom-sort-items found t
'first
)
1171 "*Customize Changed Options*")
1172 (error "No user option defaults have been changed since Emacs %s"
1175 (defun customize-package-emacs-version (symbol package-version
)
1176 "Return Emacs version of SYMBOL.
1177 PACKAGE-VERSION has the form (PACKAGE . VERSION). The VERSION of
1178 PACKAGE is looked up in the associated list
1179 `customize-package-emacs-version-alist' to find the version of
1180 Emacs that is associated with it."
1181 (let (package-versions emacs-version
)
1182 ;; Use message instead of error since we want user to be able to
1183 ;; see the rest of the symbols even if a package author has
1184 ;; botched things up.
1185 (cond ((not (listp package-version
))
1186 (message "Invalid package-version value for %s" symbol
))
1187 ((setq package-versions
(assq (car package-version
)
1188 customize-package-emacs-version-alist
))
1190 (cdr (assoc (cdr package-version
) package-versions
)))
1191 (unless emacs-version
1192 (message "%s version %s not found in %s" symbol
1193 (cdr package-version
)
1194 "customize-package-emacs-version-alist")))
1196 (message "Package %s neglected to update %s"
1197 (car package-version
)
1198 "customize-package-emacs-version-alist")))
1201 (defun customize-version-lessp (version1 version2
)
1202 ;; Why are the versions strings, and given that they are, why aren't
1203 ;; they converted to numbers and compared as such here? -- fx
1205 ;; In case someone made a mistake and left out the quotes
1206 ;; in the :version value.
1207 (if (numberp version2
)
1208 (setq version2
(prin1-to-string version2
)))
1209 (let (major1 major2 minor1 minor2
)
1210 (string-match "\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?" version1
)
1211 (setq major1
(read (or (match-string 1 version1
)
1213 (setq minor1
(read (or (match-string 3 version1
)
1215 (string-match "\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?" version2
)
1216 (setq major2
(read (or (match-string 1 version2
)
1218 (setq minor2
(read (or (match-string 3 version2
)
1220 (or (< major1 major2
)
1221 (and (= major1 major2
)
1222 (< minor1 minor2
)))))
1225 (defun customize-face (&optional face
)
1226 "Customize FACE, which should be a face name or nil.
1227 If FACE is nil, customize all faces. If FACE is actually a
1228 face-alias, customize the face it is aliased to.
1230 Interactively, when point is on text which has a face specified,
1231 suggest to customize that face, if it's customizable."
1233 (list (read-face-name "Customize face" "all faces" t
)))
1234 (if (member face
'(nil ""))
1235 (setq face
(face-list)))
1236 (if (and (listp face
) (null (cdr face
)))
1237 (setq face
(car face
)))
1239 (custom-buffer-create (custom-sort-items
1241 (list s
'custom-face
))
1244 "*Customize Faces*")
1245 ;; If FACE is actually an alias, customize the face it is aliased to.
1246 (if (get face
'face-alias
)
1247 (setq face
(get face
'face-alias
)))
1248 (unless (facep face
)
1249 (error "Invalid face %S" face
))
1250 (custom-buffer-create (list (list face
'custom-face
))
1251 (format "*Customize Face: %s*"
1252 (custom-unlispify-tag-name face
)))))
1255 (defun customize-face-other-window (&optional face
)
1256 "Show customization buffer for face FACE in other window.
1257 If FACE is actually a face-alias, customize the face it is aliased to.
1259 Interactively, when point is on text which has a face specified,
1260 suggest to customize that face, if it's customizable."
1262 (list (read-face-name "Customize face" "all faces" t
)))
1263 (if (member face
'(nil ""))
1264 (setq face
(face-list)))
1265 (if (and (listp face
) (null (cdr face
)))
1266 (setq face
(car face
)))
1268 (custom-buffer-create-other-window
1271 (list s
'custom-face
))
1274 "*Customize Faces*")
1275 (if (get face
'face-alias
)
1276 (setq face
(get face
'face-alias
)))
1277 (unless (facep face
)
1278 (error "Invalid face %S" face
))
1279 (custom-buffer-create-other-window
1280 (list (list face
'custom-face
))
1281 (format "*Customize Face: %s*"
1282 (custom-unlispify-tag-name face
)))))
1285 (defun customize-customized ()
1286 "Customize all user options set since the last save in this session."
1289 (mapatoms (lambda (symbol)
1290 (and (or (get symbol
'customized-face
)
1291 (get symbol
'customized-face-comment
))
1292 (custom-facep symbol
)
1293 (push (list symbol
'custom-face
) found
))
1294 (and (or (get symbol
'customized-value
)
1295 (get symbol
'customized-variable-comment
))
1297 (push (list symbol
'custom-variable
) found
))))
1299 (error "No customized user options")
1300 (custom-buffer-create (custom-sort-items found t nil
)
1301 "*Customize Customized*"))))
1304 (defun customize-rogue ()
1305 "Customize all user variables modified outside customize."
1308 (mapatoms (lambda (symbol)
1309 (let ((cval (or (get symbol
'customized-value
)
1310 (get symbol
'saved-value
)
1311 (get symbol
'standard-value
))))
1312 (when (and cval
;Declared with defcustom.
1313 (default-boundp symbol
) ;Has a value.
1314 (not (equal (eval (car cval
))
1315 ;; Which does not match customize.
1316 (default-value symbol
))))
1317 (push (list symbol
'custom-variable
) found
)))))
1319 (error "No rogue user options")
1320 (custom-buffer-create (custom-sort-items found t nil
)
1321 "*Customize Rogue*"))))
1323 (defun customize-saved ()
1324 "Customize all already saved user options."
1327 (mapatoms (lambda (symbol)
1328 (and (or (get symbol
'saved-face
)
1329 (get symbol
'saved-face-comment
))
1330 (custom-facep symbol
)
1331 (push (list symbol
'custom-face
) found
))
1332 (and (or (get symbol
'saved-value
)
1333 (get symbol
'saved-variable-comment
))
1335 (push (list symbol
'custom-variable
) found
))))
1337 (error "No saved user options")
1338 (custom-buffer-create (custom-sort-items found t nil
)
1339 "*Customize Saved*"))))
1342 (defun customize-apropos (regexp &optional all
)
1343 "Customize all loaded options, faces and groups matching REGEXP.
1344 If ALL is `options', include only options.
1345 If ALL is `faces', include only faces.
1346 If ALL is `groups', include only groups.
1347 If ALL is t (interactively, with prefix arg), include variables
1348 that are not customizable options, as well as faces and groups
1349 \(but we recommend using `apropos-variable' instead)."
1350 (interactive "sCustomize regexp: \nP")
1352 (mapatoms (lambda (symbol)
1353 (when (string-match regexp
(symbol-name symbol
))
1354 (when (and (not (memq all
'(faces options
)))
1355 (get symbol
'custom-group
))
1356 (push (list symbol
'custom-group
) found
))
1357 (when (and (not (memq all
'(options groups
)))
1358 (custom-facep symbol
))
1359 (push (list symbol
'custom-face
) found
))
1360 (when (and (not (memq all
'(groups faces
)))
1362 (eq (indirect-variable symbol
) symbol
)
1363 (or (get symbol
'saved-value
)
1364 (custom-variable-p symbol
)
1365 (and (not (memq all
'(nil options
)))
1366 (get symbol
'variable-documentation
))))
1367 (push (list symbol
'custom-variable
) found
)))))
1369 (error "No customizable items matching %s" regexp
)
1370 (custom-buffer-create
1371 (custom-sort-items found t custom-buffer-order-groups
)
1372 "*Customize Apropos*"))))
1375 (defun customize-apropos-options (regexp &optional arg
)
1376 "Customize all loaded customizable options matching REGEXP.
1377 With prefix arg, include variables that are not customizable options
1378 \(but we recommend using `apropos-variable' instead)."
1379 (interactive "sCustomize regexp: \nP")
1380 (customize-apropos regexp
(or arg
'options
)))
1383 (defun customize-apropos-faces (regexp)
1384 "Customize all loaded faces matching REGEXP."
1385 (interactive "sCustomize regexp: \n")
1386 (customize-apropos regexp
'faces
))
1389 (defun customize-apropos-groups (regexp)
1390 "Customize all loaded groups matching REGEXP."
1391 (interactive "sCustomize regexp: \n")
1392 (customize-apropos regexp
'groups
))
1396 (defcustom custom-buffer-style
'links
1397 "Control the presentation style for customization buffers.
1398 The value should be a symbol, one of:
1400 brackets: groups nest within each other with big horizontal brackets.
1401 links: groups have links to subgroups."
1402 :type
'(radio (const brackets
)
1404 :group
'custom-buffer
)
1406 (defcustom custom-buffer-done-kill nil
1407 "*Non-nil means exiting a Custom buffer should kill it."
1410 :group
'custom-buffer
)
1412 (defcustom custom-buffer-indent
3
1413 "Number of spaces to indent nested groups."
1415 :group
'custom-buffer
)
1417 (defun custom-get-fresh-buffer (name)
1418 "Get a fresh new buffer with name NAME.
1419 If the buffer already exist, clean it up to be like new.
1420 Beware: it's not quite like new. Good enough for custom, but maybe
1422 ;; To be more complete, we should also kill all permanent-local variables,
1423 ;; but it's not needed for custom.
1424 (let ((buf (get-buffer name
)))
1425 (when (and buf
(buffer-local-value 'buffer-file-name buf
))
1426 ;; This will check if the file is not saved.
1430 (get-buffer-create name
)
1431 (with-current-buffer buf
1432 (kill-all-local-variables)
1433 (run-hooks 'kill-buffer-hook
)
1434 ;; Delete overlays before erasing the buffer so the overlay hooks
1435 ;; don't get run spuriously when we erase the buffer.
1436 (let ((ols (overlay-lists)))
1437 (dolist (ol (nconc (car ols
) (cdr ols
)))
1438 (delete-overlay ol
)))
1443 (defun custom-buffer-create (options &optional name description
)
1444 "Create a buffer containing OPTIONS.
1445 Optional NAME is the name of the buffer.
1446 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
1447 SYMBOL is a customization option, and WIDGET is a widget for editing
1449 (pop-to-buffer (custom-get-fresh-buffer (or name
"*Customization*")))
1450 (custom-buffer-create-internal options description
))
1453 (defun custom-buffer-create-other-window (options &optional name description
)
1454 "Create a buffer containing OPTIONS, and display it in another window.
1455 The result includes selecting that window.
1456 Optional NAME is the name of the buffer.
1457 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
1458 SYMBOL is a customization option, and WIDGET is a widget for editing
1460 (unless name
(setq name
"*Customization*"))
1461 (let ((pop-up-windows t
)
1462 (same-window-buffer-names nil
)
1463 (same-window-regexps nil
))
1464 (pop-to-buffer (custom-get-fresh-buffer name
))
1465 (custom-buffer-create-internal options description
)))
1467 (defcustom custom-reset-button-menu nil
1468 "If non-nil, only show a single reset button in customize buffers.
1469 This button will have a menu with all three reset operations."
1471 :group
'custom-buffer
)
1473 (defcustom custom-buffer-verbose-help t
1474 "If non-nil, include explanatory text in the customization buffer."
1476 :group
'custom-buffer
)
1478 (defun Custom-buffer-done (&rest ignore
)
1479 "Exit current Custom buffer according to `custom-buffer-done-kill'."
1481 (quit-window custom-buffer-done-kill
))
1483 (defvar custom-button nil
1484 "Face used for buttons in customization buffers.")
1486 (defvar custom-button-mouse nil
1487 "Mouse face used for buttons in customization buffers.")
1489 (defvar custom-button-pressed nil
1490 "Face used for pressed buttons in customization buffers.")
1492 (defcustom custom-raised-buttons
(not (equal (face-valid-attribute-values :box
)
1493 '(("unspecified" . unspecified
))))
1494 "If non-nil, indicate active buttons in a `raised-button' style.
1495 Otherwise use brackets."
1498 :group
'custom-buffer
1499 :set
(lambda (variable value
)
1500 (custom-set-default variable value
)
1502 (if value
'custom-button
'custom-button-unraised
))
1503 (setq custom-button-mouse
1504 (if value
'custom-button-mouse
'highlight
))
1505 (setq custom-button-pressed
1507 'custom-button-pressed
1508 'custom-button-pressed-unraised
))))
1510 (defun custom-buffer-create-internal (options &optional description
)
1512 (if custom-buffer-verbose-help
1514 (widget-insert "This is a customization buffer")
1516 (widget-insert description
))
1517 (widget-insert (format ".
1518 %s buttons; type RET or click mouse-1 to actuate one.
1519 Editing a setting changes only the text in the buffer.
1520 Use the setting's State button to set it or save changes in it.
1521 Saving a change normally works by editing your Emacs init file.
1523 (if custom-raised-buttons
1524 "`Raised' text indicates"
1525 "Square brackets indicate")))
1526 (widget-create 'custom-manual
1528 "(emacs)Saving Customizations")
1530 " for information on how to save in a different file.\n
1532 (widget-create 'custom-manual
1534 :help-echo
"Read the online help."
1535 "(emacs)Easy Customization")
1536 (widget-insert " for more information.\n\n")
1537 (widget-insert "Operate on all settings in this buffer that \
1538 are not marked HIDDEN:\n "))
1539 (widget-insert " "))
1540 (widget-create 'push-button
1541 :tag
"Set for Current Session"
1543 Make your editing in this buffer take effect for this session."
1544 :action
(lambda (widget &optional event
)
1546 (if (not custom-buffer-verbose-help
)
1549 (widget-create 'custom-manual
1551 :help-echo
"Read the online help."
1552 "(emacs)Easy Customization")))
1553 (when (or custom-file user-init-file
)
1555 (widget-create 'push-button
1556 :tag
"Save for Future Sessions"
1558 Make your editing in this buffer take effect for future Emacs sessions.
1559 This updates your Emacs initialization file or creates a new one."
1560 :action
(lambda (widget &optional event
)
1562 (if custom-reset-button-menu
1565 (widget-create 'push-button
1567 :help-echo
"Show a menu with reset operations."
1568 :mouse-down-action
(lambda (&rest junk
) t
)
1569 :action
(lambda (widget &optional event
)
1570 (custom-reset event
))))
1571 (widget-insert "\n ")
1572 (widget-create 'push-button
1575 Reset all edited text in this buffer to reflect current values."
1576 :action
'Custom-reset-current
)
1578 (widget-create 'push-button
1579 :tag
"Reset to Saved"
1581 Reset all settings in this buffer to their saved values."
1582 :action
'Custom-reset-saved
)
1584 (when (or custom-file user-init-file
)
1585 (widget-create 'push-button
1586 :tag
"Erase Customization"
1588 Un-customize all settings in this buffer and save them with standard values."
1589 :action
'Custom-reset-standard
)))
1591 (widget-create 'push-button
1594 (lambda (&rest ignore
)
1595 (if custom-buffer-done-kill
1597 "Bury this buffer"))
1598 :action
#'Custom-buffer-done
)
1599 (widget-insert "\n\n")
1600 (message "Creating customization items...")
1601 (buffer-disable-undo)
1602 (setq custom-options
1603 (if (= (length options
) 1)
1604 (mapcar (lambda (entry)
1605 (widget-create (nth 1 entry
)
1606 :documentation-shown t
1607 :custom-state
'unknown
1608 :tag
(custom-unlispify-tag-name
1610 :value
(nth 0 entry
)))
1613 (length (length options
)))
1614 (mapcar (lambda (entry)
1616 (message "Creating customization items ...%2d%%"
1617 (/ (* 100.0 count
) length
))
1618 (widget-create (nth 1 entry
)
1619 :tag
(custom-unlispify-tag-name
1621 :value
(nth 0 entry
))
1622 (setq count
(1+ count
))
1623 (unless (eq (preceding-char) ?
\n)
1624 (widget-insert "\n"))
1625 (widget-insert "\n")))
1627 (unless (eq (preceding-char) ?
\n)
1628 (widget-insert "\n"))
1629 (message "Creating customization items ...done")
1630 (message "Resetting customization items...")
1631 (unless (eq custom-buffer-style
'tree
)
1632 (mapc 'custom-magic-reset custom-options
))
1633 (message "Resetting customization items...done")
1634 (message "Creating customization setup...")
1636 (buffer-enable-undo)
1637 (goto-char (point-min))
1638 (message "Creating customization setup...done"))
1640 ;;; The Tree Browser.
1643 (defun customize-browse (&optional group
)
1644 "Create a tree browser for the customize hierarchy."
1647 (setq group
'emacs
))
1648 (let ((name "*Customize Browser*"))
1649 (pop-to-buffer (custom-get-fresh-buffer name
)))
1651 (widget-insert (format "\
1652 %s buttons; type RET or click mouse-1
1653 on a button to invoke its action.
1654 Invoke [+] to expand a group, and [-] to collapse an expanded group.\n"
1655 (if custom-raised-buttons
1656 "`Raised' text indicates"
1657 "Square brackets indicate")))
1660 (if custom-browse-only-groups
1662 Invoke the [Group] button below to edit that item in another window.\n\n")
1663 (widget-insert "Invoke the ")
1664 (widget-create 'item
1667 :tag-glyph
"folder")
1668 (widget-insert ", ")
1669 (widget-create 'item
1673 (widget-insert ", and ")
1674 (widget-create 'item
1677 :tag-glyph
"option")
1678 (widget-insert " buttons below to edit that
1679 item in another window.\n\n"))
1680 (let ((custom-buffer-style 'tree
))
1681 (widget-create 'custom-group
1683 :custom-state
'unknown
1684 :tag
(custom-unlispify-tag-name group
)
1687 (goto-char (point-min)))
1689 (define-widget 'custom-browse-visibility
'item
1690 "Control visibility of items in the customize tree browser."
1692 :action
'custom-browse-visibility-action
)
1694 (defun custom-browse-visibility-action (widget &rest ignore
)
1695 (let ((custom-buffer-style 'tree
))
1696 (custom-toggle-parent widget
)))
1698 (define-widget 'custom-browse-group-tag
'custom-group-link
1699 "Show parent in other window when activated."
1702 :action
'custom-browse-group-tag-action
)
1704 (defun custom-browse-group-tag-action (widget &rest ignore
)
1705 (let ((parent (widget-get widget
:parent
)))
1706 (customize-group-other-window (widget-value parent
))))
1708 (define-widget 'custom-browse-variable-tag
'custom-group-link
1709 "Show parent in other window when activated."
1712 :action
'custom-browse-variable-tag-action
)
1714 (defun custom-browse-variable-tag-action (widget &rest ignore
)
1715 (let ((parent (widget-get widget
:parent
)))
1716 (customize-variable-other-window (widget-value parent
))))
1718 (define-widget 'custom-browse-face-tag
'custom-group-link
1719 "Show parent in other window when activated."
1722 :action
'custom-browse-face-tag-action
)
1724 (defun custom-browse-face-tag-action (widget &rest ignore
)
1725 (let ((parent (widget-get widget
:parent
)))
1726 (customize-face-other-window (widget-value parent
))))
1728 (defconst custom-browse-alist
'((" " "space")
1734 (defun custom-browse-insert-prefix (prefix)
1735 "Insert PREFIX. On XEmacs convert it to line graphics."
1736 ;; Fixme: do graphics.
1737 (if nil
; (string-match "XEmacs" emacs-version)
1740 (while (not (string-equal prefix
""))
1741 (let ((entry (substring prefix
0 3)))
1742 (setq prefix
(substring prefix
3))
1743 (let ((overlay (make-overlay (1- (point)) (point) nil t nil
))
1744 (name (nth 1 (assoc entry custom-browse-alist
))))
1745 (overlay-put overlay
'end-glyph
(widget-glyph-find name entry
))
1746 (overlay-put overlay
'start-open t
)
1747 (overlay-put overlay
'end-open t
)))))
1750 ;;; Modification of Basic Widgets.
1752 ;; We add extra properties to the basic widgets needed here. This is
1753 ;; fine, as long as we are careful to stay within out own namespace.
1755 ;; We want simple widgets to be displayed by default, but complex
1756 ;; widgets to be hidden.
1758 (widget-put (get 'item
'widget-type
) :custom-show t
)
1759 (widget-put (get 'editable-field
'widget-type
)
1760 :custom-show
(lambda (widget value
)
1761 (let ((pp (pp-to-string value
)))
1762 (cond ((string-match "\n" pp
)
1767 (widget-put (get 'menu-choice
'widget-type
) :custom-show t
)
1769 ;;; The `custom-manual' Widget.
1771 (define-widget 'custom-manual
'info-link
1772 "Link to the manual entry for this customization option."
1773 :help-echo
"Read the manual entry for this option."
1774 :button-face
'custom-link
1775 :mouse-face
'highlight
1776 :pressed-face
'highlight
1779 ;;; The `custom-magic' Widget.
1781 (defgroup custom-magic-faces nil
1782 "Faces used by the magic button."
1783 :group
'custom-faces
1784 :group
'custom-buffer
)
1786 (defface custom-invalid
'((((class color
))
1787 (:foreground
"yellow1" :background
"red1"))
1789 (:weight bold
:slant italic
:underline t
)))
1790 "Face used when the customize item is invalid."
1791 :group
'custom-magic-faces
)
1792 ;; backward-compatibility alias
1793 (put 'custom-invalid-face
'face-alias
'custom-invalid
)
1795 (defface custom-rogue
'((((class color
))
1796 (:foreground
"pink" :background
"black"))
1799 "Face used when the customize item is not defined for customization."
1800 :group
'custom-magic-faces
)
1801 ;; backward-compatibility alias
1802 (put 'custom-rogue-face
'face-alias
'custom-rogue
)
1804 (defface custom-modified
'((((min-colors 88) (class color
))
1805 (:foreground
"white" :background
"blue1"))
1807 (:foreground
"white" :background
"blue"))
1809 (:slant italic
:bold
)))
1810 "Face used when the customize item has been modified."
1811 :group
'custom-magic-faces
)
1812 ;; backward-compatibility alias
1813 (put 'custom-modified-face
'face-alias
'custom-modified
)
1815 (defface custom-set
'((((min-colors 88) (class color
))
1816 (:foreground
"blue1" :background
"white"))
1818 (:foreground
"blue" :background
"white"))
1821 "Face used when the customize item has been set."
1822 :group
'custom-magic-faces
)
1823 ;; backward-compatibility alias
1824 (put 'custom-set-face
'face-alias
'custom-set
)
1826 (defface custom-changed
'((((min-colors 88) (class color
))
1827 (:foreground
"white" :background
"blue1"))
1829 (:foreground
"white" :background
"blue"))
1832 "Face used when the customize item has been changed."
1833 :group
'custom-magic-faces
)
1834 ;; backward-compatibility alias
1835 (put 'custom-changed-face
'face-alias
'custom-changed
)
1837 (defface custom-themed
'((((min-colors 88) (class color
))
1838 (:foreground
"white" :background
"blue1"))
1840 (:foreground
"white" :background
"blue"))
1843 "Face used when the customize item has been set by a theme."
1844 :group
'custom-magic-faces
)
1846 (defface custom-saved
'((t (:underline t
)))
1847 "Face used when the customize item has been saved."
1848 :group
'custom-magic-faces
)
1849 ;; backward-compatibility alias
1850 (put 'custom-saved-face
'face-alias
'custom-saved
)
1852 (defconst custom-magic-alist
1853 '((nil "#" underline
"\
1854 UNINITIALIZED, you should not see this.")
1855 (unknown "?" italic
"\
1856 UNKNOWN, you should not see this.")
1857 (hidden "-" default
"\
1858 HIDDEN, invoke \"Show\" in the previous line to show." "\
1859 group now hidden, invoke \"Show\", above, to show contents.")
1860 (invalid "x" custom-invalid
"\
1861 INVALID, the displayed value cannot be set.")
1862 (modified "*" custom-modified
"\
1863 EDITED, shown value does not take effect until you set or save it." "\
1864 something in this group has been edited but not set.")
1865 (set "+" custom-set
"\
1866 SET for current session only." "\
1867 something in this group has been set but not saved.")
1868 (changed ":" custom-changed
"\
1869 CHANGED outside Customize; operating on it here may be unreliable." "\
1870 something in this group has been changed outside customize.")
1871 (saved "!" custom-saved
"\
1873 something in this group has been set and saved.")
1874 (themed "o" custom-themed
"\
1876 visible group members are all at standard values.")
1877 (rogue "@" custom-rogue
"\
1878 NO CUSTOMIZATION DATA; not intended to be customized." "\
1879 something in this group is not prepared for customization.")
1880 (standard " " nil
"\
1882 visible group members are all at standard values."))
1883 "Alist of customize option states.
1884 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
1886 STATE is one of the following symbols:
1889 For internal use, should never occur.
1891 For internal use, should never occur.
1893 This item is not being displayed.
1895 This item is modified, but has an invalid form.
1897 This item is modified, and has a valid form.
1899 This item has been set but not saved.
1901 The current value of this item has been changed outside Customize.
1903 This item is marked for saving.
1905 This item has no customization information.
1907 This item is unchanged from the standard setting.
1909 MAGIC is a string used to present that state.
1911 FACE is a face used to present the state.
1913 ITEM-DESC is a string describing the state for options.
1915 GROUP-DESC is a string describing the state for groups. If this is
1916 left out, ITEM-DESC will be used.
1918 The string %c in either description will be replaced with the
1919 category of the item. These are `group'. `option', and `face'.
1921 The list should be sorted most significant first.")
1923 (defcustom custom-magic-show
'long
1924 "If non-nil, show textual description of the state.
1925 If `long', show a full-line description, not just one word."
1926 :type
'(choice (const :tag
"no" nil
)
1928 (other :tag
"short" short
))
1929 :group
'custom-buffer
)
1931 (defcustom custom-magic-show-hidden
'(option face
)
1932 "Control whether the State button is shown for hidden items.
1933 The value should be a list with the custom categories where the State
1934 button should be visible. Possible categories are `group', `option',
1936 :type
'(set (const group
) (const option
) (const face
))
1937 :group
'custom-buffer
)
1939 (defcustom custom-magic-show-button nil
1940 "Show a \"magic\" button indicating the state of each customization option."
1942 :group
'custom-buffer
)
1944 (define-widget 'custom-magic
'default
1945 "Show and manipulate state for a customization option."
1947 :action
'widget-parent-action
1950 :value-create
'custom-magic-value-create
1951 :value-delete
'widget-children-value-delete
)
1953 (defun widget-magic-mouse-down-action (widget &optional event
)
1954 ;; Non-nil unless hidden.
1955 (not (eq (widget-get (widget-get (widget-get widget
:parent
) :parent
)
1959 (defun custom-magic-value-create (widget)
1960 "Create compact status report for WIDGET."
1961 (let* ((parent (widget-get widget
:parent
))
1962 (state (widget-get parent
:custom-state
))
1963 (hidden (eq state
'hidden
))
1964 (entry (assq state custom-magic-alist
))
1965 (magic (nth 1 entry
))
1966 (face (nth 2 entry
))
1967 (category (widget-get parent
:custom-category
))
1968 (text (or (and (eq category
'group
)
1971 (form (widget-get parent
:custom-form
))
1973 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text
)
1974 (setq text
(concat (match-string 1 text
)
1975 (symbol-name category
)
1976 (match-string 2 text
))))
1977 (when (and custom-magic-show
1979 (memq category custom-magic-show-hidden
)))
1981 (when (and (eq category
'group
)
1982 (not (and (eq custom-buffer-style
'links
)
1983 (> (widget-get parent
:custom-level
) 1))))
1984 (insert-char ?\
(* custom-buffer-indent
1985 (widget-get parent
:custom-level
))))
1986 (push (widget-create-child-and-convert
1988 :help-echo
"Change the state of this item."
1989 :format
(if hidden
"%t" "%[%t%]")
1990 :button-prefix
'widget-push-button-prefix
1991 :button-suffix
'widget-push-button-suffix
1992 :mouse-down-action
'widget-magic-mouse-down-action
1996 (let ((start (point)))
1997 (if (eq custom-magic-show
'long
)
1999 (insert (symbol-name state
)))
2000 (cond ((eq form
'lisp
)
2002 ((eq form
'mismatch
)
2003 (insert " (mismatch)")))
2004 (put-text-property start
(point) 'face
'custom-state
))
2006 (when (and (eq category
'group
)
2007 (not (and (eq custom-buffer-style
'links
)
2008 (> (widget-get parent
:custom-level
) 1))))
2009 (insert-char ?\
(* custom-buffer-indent
2010 (widget-get parent
:custom-level
))))
2011 (when custom-magic-show-button
2012 (when custom-magic-show
2013 (let ((indent (widget-get parent
:indent
)))
2015 (insert-char ? indent
))))
2016 (push (widget-create-child-and-convert
2018 :mouse-down-action
'widget-magic-mouse-down-action
2022 :help-echo
"Change the state."
2023 :format
(if hidden
"%t" "%[%t%]")
2024 :tag
(if (memq form
'(lisp mismatch
))
2025 (concat "(" magic
")")
2026 (concat "[" magic
"]")))
2029 (widget-put widget
:children children
)))
2031 (defun custom-magic-reset (widget)
2032 "Redraw the :custom-magic property of WIDGET."
2033 (let ((magic (widget-get widget
:custom-magic
)))
2034 (widget-value-set magic
(widget-value magic
))))
2036 ;;; The `custom' Widget.
2038 (defface custom-button
2039 '((((type x w32 mac
) (class color
)) ; Like default modeline
2040 (:box
(:line-width
2 :style released-button
)
2041 :background
"lightgrey" :foreground
"black"))
2044 "Face for custom buffer buttons if `custom-raised-buttons' is non-nil."
2046 :group
'custom-faces
)
2047 ;; backward-compatibility alias
2048 (put 'custom-button-face
'face-alias
'custom-button
)
2050 (defface custom-button-mouse
2051 '((((type x w32 mac
) (class color
))
2052 (:box
(:line-width
2 :style released-button
)
2053 :background
"grey90" :foreground
"black"))
2056 "Mouse face for custom buffer buttons if `custom-raised-buttons' is non-nil."
2058 :group
'custom-faces
)
2060 (defface custom-button-unraised
2061 '((t :inherit underline
))
2062 "Face for custom buffer buttons if `custom-raised-buttons' is nil."
2064 :group
'custom-faces
)
2067 (if custom-raised-buttons
'custom-button
'custom-button-unraised
))
2069 (setq custom-button-mouse
2070 (if custom-raised-buttons
'custom-button-mouse
'highlight
))
2072 (defface custom-button-pressed
2073 '((((type x w32 mac
) (class color
))
2074 (:box
(:line-width
2 :style pressed-button
)
2075 :background
"lightgrey" :foreground
"black"))
2077 (:inverse-video t
)))
2078 "Face for pressed custom buttons if `custom-raised-buttons' is non-nil."
2080 :group
'custom-faces
)
2081 ;; backward-compatibility alias
2082 (put 'custom-button-pressed-face
'face-alias
'custom-button-pressed
)
2084 (defface custom-button-pressed-unraised
2085 '((default :inherit custom-button-unraised
)
2086 (((class color
) (background light
)) :foreground
"magenta4")
2087 (((class color
) (background dark
)) :foreground
"violet"))
2088 "Face for pressed custom buttons if `custom-raised-buttons' is nil."
2090 :group
'custom-faces
)
2092 (setq custom-button-pressed
2093 (if custom-raised-buttons
2094 'custom-button-pressed
2095 'custom-button-pressed-unraised
))
2097 (defface custom-documentation
'((t nil
))
2098 "Face used for documentation strings in customization buffers."
2099 :group
'custom-faces
)
2100 ;; backward-compatibility alias
2101 (put 'custom-documentation-face
'face-alias
'custom-documentation
)
2103 (defface custom-state
'((((class color
)
2105 (:foreground
"lime green"))
2108 (:foreground
"dark green"))
2110 "Face used for State descriptions in the customize buffer."
2111 :group
'custom-faces
)
2112 ;; backward-compatibility alias
2113 (put 'custom-state-face
'face-alias
'custom-state
)
2115 (defface custom-link
2116 '((t :inherit link
))
2117 "Face for links in customization buffers."
2119 :group
'custom-faces
)
2121 (define-widget 'custom
'default
2122 "Customize a user option."
2124 :convert-widget
'custom-convert-widget
2125 :notify
'custom-notify
2128 :custom-state
'hidden
2129 :documentation-property
'widget-subclass-responsibility
2130 :value-create
'widget-subclass-responsibility
2131 :value-delete
'widget-children-value-delete
2132 :value-get
'widget-value-value-get
2133 :validate
'widget-children-validate
2134 :match
(lambda (widget value
) (symbolp value
)))
2136 (defun custom-convert-widget (widget)
2137 "Initialize :value and :tag from :args in WIDGET."
2138 (let ((args (widget-get widget
:args
)))
2140 (widget-put widget
:value
(widget-apply widget
2141 :value-to-internal
(car args
)))
2142 (widget-put widget
:tag
(custom-unlispify-tag-name (car args
)))
2143 (widget-put widget
:args nil
)))
2146 (defun custom-notify (widget &rest args
)
2147 "Keep track of changes."
2148 (let ((state (widget-get widget
:custom-state
)))
2149 (unless (eq state
'modified
)
2150 (unless (memq state
'(nil unknown hidden
))
2151 (widget-put widget
:custom-state
'modified
))
2152 (custom-magic-reset widget
)
2153 (apply 'widget-default-notify widget args
))))
2155 (defun custom-redraw (widget)
2156 "Redraw WIDGET with current settings."
2157 (let ((line (count-lines (point-min) (point)))
2158 (column (current-column))
2160 (from (marker-position (widget-get widget
:from
)))
2161 (to (marker-position (widget-get widget
:to
))))
2163 (widget-value-set widget
(widget-value widget
))
2164 (custom-redraw-magic widget
))
2165 (when (and (>= pos from
) (<= pos to
))
2170 (goto-line (1+ line
)))
2171 (move-to-column column
))
2174 (defun custom-redraw-magic (widget)
2175 "Redraw WIDGET state with current settings."
2177 (let ((magic (widget-get widget
:custom-magic
)))
2179 (widget-value-set magic
(widget-value magic
))
2180 (when (setq widget
(widget-get widget
:group
))
2181 (custom-group-state-update widget
)))
2183 (setq widget nil
)))))
2186 (defun custom-show (widget value
)
2187 "Non-nil if WIDGET should be shown with VALUE by default."
2188 (let ((show (widget-get widget
:custom-show
)))
2194 (funcall show widget value
)))))
2196 (defun custom-load-widget (widget)
2197 "Load all dependencies for WIDGET."
2198 (custom-load-symbol (widget-value widget
)))
2200 (defun custom-unloaded-symbol-p (symbol)
2201 "Return non-nil if the dependencies of SYMBOL have not yet been loaded."
2203 (loads (get symbol
'custom-loads
))
2206 (setq load
(car loads
)
2208 (cond ((symbolp load
)
2209 (unless (featurep load
)
2211 ((assoc load load-history
))
2212 ((assoc (locate-library load
) load-history
)
2218 (defun custom-unloaded-widget-p (widget)
2219 "Return non-nil if the dependencies of WIDGET have not yet been loaded."
2220 (custom-unloaded-symbol-p (widget-value widget
)))
2222 (defun custom-toggle-hide (widget)
2223 "Toggle visibility of WIDGET."
2224 (custom-load-widget widget
)
2225 (let ((state (widget-get widget
:custom-state
)))
2226 (cond ((memq state
'(invalid modified
))
2227 (error "There are unset changes"))
2229 (widget-put widget
:custom-state
'unknown
))
2231 (widget-put widget
:documentation-shown nil
)
2232 (widget-put widget
:custom-state
'hidden
)))
2233 (custom-redraw widget
)
2236 (defun custom-toggle-parent (widget &rest ignore
)
2237 "Toggle visibility of parent of WIDGET."
2238 (custom-toggle-hide (widget-get widget
:parent
)))
2240 (defun custom-add-see-also (widget &optional prefix
)
2241 "Add `See also ...' to WIDGET if there are any links.
2242 Insert PREFIX first if non-nil."
2243 (let* ((symbol (widget-get widget
:value
))
2244 (links (get symbol
'custom-links
))
2245 (many (> (length links
) 2))
2246 (buttons (widget-get widget
:buttons
))
2247 (indent (widget-get widget
:indent
)))
2250 (insert-char ?\ indent
))
2253 (insert "See also ")
2255 (push (widget-create-child-and-convert
2257 :button-face
'custom-link
2258 :mouse-face
'highlight
2259 :pressed-face
'highlight
)
2261 (setq links
(cdr links
))
2270 (widget-put widget
:buttons buttons
))))
2272 (defun custom-add-parent-links (widget &optional initial-string
)
2273 "Add \"Parent groups: ...\" to WIDGET if the group has parents.
2274 The value is non-nil if any parents were found.
2275 If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
2276 (let ((name (widget-value widget
))
2277 (type (widget-type widget
))
2278 (buttons (widget-get widget
:buttons
))
2281 (insert (or initial-string
"Parent groups:"))
2282 (mapatoms (lambda (symbol)
2283 (when (member (list name type
) (get symbol
'custom-group
))
2285 (push (widget-create-child-and-convert
2286 widget
'custom-group-link
2287 :tag
(custom-unlispify-tag-name symbol
)
2290 (setq parents
(cons symbol parents
)))))
2291 (and (null (get name
'custom-links
)) ;No links of its own.
2292 (= (length parents
) 1) ;A single parent.
2293 (let* ((links (delq nil
(mapcar (lambda (w)
2294 (unless (eq (widget-type w
)
2297 (get (car parents
) 'custom-links
))))
2298 (many (> (length links
) 2)))
2300 (insert "\nParent documentation: ")
2302 (push (widget-create-child-and-convert
2304 :button-face
'custom-link
2305 :mouse-face
'highlight
2306 :pressed-face
'highlight
)
2308 (setq links
(cdr links
))
2319 (delete-region start
(point)))
2320 (widget-put widget
:buttons buttons
)
2323 ;;; The `custom-comment' Widget.
2325 ;; like the editable field
2326 (defface custom-comment
'((((type tty
))
2327 :background
"yellow3"
2328 :foreground
"black")
2329 (((class grayscale color
)
2331 :background
"gray85")
2332 (((class grayscale color
)
2334 :background
"dim gray")
2337 "Face used for comments on variables or faces"
2339 :group
'custom-faces
)
2340 ;; backward-compatibility alias
2341 (put 'custom-comment-face
'face-alias
'custom-comment
)
2343 ;; like font-lock-comment-face
2344 (defface custom-comment-tag
2345 '((((class color
) (background dark
)) (:foreground
"gray80"))
2346 (((class color
) (background light
)) (:foreground
"blue4"))
2347 (((class grayscale
) (background light
))
2348 (:foreground
"DimGray" :weight bold
:slant italic
))
2349 (((class grayscale
) (background dark
))
2350 (:foreground
"LightGray" :weight bold
:slant italic
))
2352 "Face used for variables or faces comment tags"
2353 :group
'custom-faces
)
2354 ;; backward-compatibility alias
2355 (put 'custom-comment-tag-face
'face-alias
'custom-comment-tag
)
2357 (define-widget 'custom-comment
'string
2360 :help-echo
"Edit a comment here."
2361 :sample-face
'custom-comment-tag-face
2362 :value-face
'custom-comment-face
2364 :create
'custom-comment-create
)
2366 (defun custom-comment-create (widget)
2367 (let* ((null-comment (equal "" (widget-value widget
))))
2368 (if (or (widget-get (widget-get widget
:parent
) :comment-shown
)
2370 (widget-default-create widget
)
2371 ;; `widget-default-delete' expects markers in these slots --
2372 ;; maybe it shouldn't.
2373 (widget-put widget
:from
(point-marker))
2374 (widget-put widget
:to
(point-marker)))))
2376 (defun custom-comment-hide (widget)
2377 (widget-put (widget-get widget
:parent
) :comment-shown nil
))
2379 ;; Those functions are for the menu. WIDGET is NOT the comment widget. It's
2380 ;; the global custom one
2381 (defun custom-comment-show (widget)
2382 (widget-put widget
:comment-shown t
)
2383 (custom-redraw widget
)
2386 (defun custom-comment-invisible-p (widget)
2387 (let ((val (widget-value (widget-get widget
:comment-widget
))))
2389 (not (widget-get widget
:comment-shown
)))))
2391 ;;; The `custom-variable' Widget.
2393 ;; When this was underlined blue, users confused it with a
2394 ;; Mosaic-style hyperlink...
2395 (defface custom-variable-tag
2398 (:foreground
"light blue" :weight bold
:height
1.2 :inherit variable-pitch
))
2399 (((min-colors 88) (class color
)
2401 (:foreground
"blue1" :weight bold
:height
1.2 :inherit variable-pitch
))
2404 (:foreground
"blue" :weight bold
:height
1.2 :inherit variable-pitch
))
2406 "Face used for unpushable variable tags."
2407 :group
'custom-faces
)
2408 ;; backward-compatibility alias
2409 (put 'custom-variable-tag-face
'face-alias
'custom-variable-tag
)
2411 (defface custom-variable-button
'((t (:underline t
:weight bold
)))
2412 "Face used for pushable variable tags."
2413 :group
'custom-faces
)
2414 ;; backward-compatibility alias
2415 (put 'custom-variable-button-face
'face-alias
'custom-variable-button
)
2417 (defcustom custom-variable-default-form
'edit
2418 "Default form of displaying variable values."
2419 :type
'(choice (const edit
)
2421 :group
'custom-buffer
2424 (defun custom-variable-documentation (variable)
2425 "Return documentation of VARIABLE for use in Custom buffer.
2426 Normally just return the docstring. But if VARIABLE automatically
2427 becomes buffer local when set, append a message to that effect."
2428 (if (and (local-variable-if-set-p variable
)
2429 (or (not (local-variable-p variable
))
2431 (local-variable-if-set-p variable
))))
2432 (concat (documentation-property variable
'variable-documentation
)
2434 This variable automatically becomes buffer-local when set outside Custom.
2435 However, setting it through Custom sets the default value.")
2436 (documentation-property variable
'variable-documentation
)))
2438 (define-widget 'custom-variable
'custom
2439 "Customize variable."
2441 :help-echo
"Set or reset this variable."
2442 :documentation-property
#'custom-variable-documentation
2443 :custom-category
'option
2445 :custom-menu
'custom-variable-menu-create
2446 :custom-form nil
; defaults to value of `custom-variable-default-form'
2447 :value-create
'custom-variable-value-create
2448 :action
'custom-variable-action
2449 :custom-set
'custom-variable-set
2450 :custom-save
'custom-variable-save
2451 :custom-reset-current
'custom-redraw
2452 :custom-reset-saved
'custom-variable-reset-saved
2453 :custom-reset-standard
'custom-variable-reset-standard
2454 :custom-standard-value
'custom-variable-standard-value
)
2456 (defun custom-variable-type (symbol)
2457 "Return a widget suitable for editing the value of SYMBOL.
2458 If SYMBOL has a `custom-type' property, use that.
2459 Otherwise, look up symbol in `custom-guess-type-alist'."
2460 (let* ((type (or (get symbol
'custom-type
)
2461 (and (not (get symbol
'standard-value
))
2462 (custom-guess-type symbol
))
2464 (options (get symbol
'custom-options
))
2465 (tmp (if (listp type
)
2466 (copy-sequence type
)
2469 (widget-put tmp
:options options
))
2472 (defun custom-variable-value-create (widget)
2473 "Here is where you edit the variable's value."
2474 (custom-load-widget widget
)
2475 (unless (widget-get widget
:custom-form
)
2476 (widget-put widget
:custom-form custom-variable-default-form
))
2477 (let* ((buttons (widget-get widget
:buttons
))
2478 (children (widget-get widget
:children
))
2479 (form (widget-get widget
:custom-form
))
2480 (state (widget-get widget
:custom-state
))
2481 (symbol (widget-get widget
:value
))
2482 (tag (widget-get widget
:tag
))
2483 (type (custom-variable-type symbol
))
2484 (conv (widget-convert type
))
2485 (get (or (get symbol
'custom-get
) 'default-value
))
2486 (prefix (widget-get widget
:custom-prefix
))
2487 (last (widget-get widget
:custom-last
))
2488 (value (if (default-boundp symbol
)
2489 (funcall get symbol
)
2490 (widget-get conv
:value
))))
2491 ;; If the widget is new, the child determines whether it is hidden.
2493 ((custom-show type value
)
2494 (setq state
'unknown
))
2496 (setq state
'hidden
)))
2497 ;; If we don't know the state, see if we need to edit it in lisp form.
2498 (when (eq state
'unknown
)
2499 (unless (widget-apply conv
:match value
)
2500 ;; (widget-apply (widget-convert type) :match value)
2501 (setq form
'mismatch
)))
2502 ;; Now we can create the child widget.
2503 (cond ((eq custom-buffer-style
'tree
)
2504 (insert prefix
(if last
" `--- " " |--- "))
2505 (push (widget-create-child-and-convert
2506 widget
'custom-browse-variable-tag
)
2508 (insert " " tag
"\n")
2509 (widget-put widget
:buttons buttons
))
2511 ;; Indicate hidden value.
2512 (push (widget-create-child-and-convert
2515 :sample-face
'custom-variable-tag-face
2519 (push (widget-create-child-and-convert
2521 :help-echo
"Show the value of this option."
2523 :action
'custom-toggle-parent
2526 ((memq form
'(lisp mismatch
))
2527 ;; In lisp mode edit the saved value when possible.
2528 (let* ((value (cond ((get symbol
'saved-value
)
2529 (car (get symbol
'saved-value
)))
2530 ((get symbol
'standard-value
)
2531 (car (get symbol
'standard-value
)))
2532 ((default-boundp symbol
)
2533 (custom-quote (funcall get symbol
)))
2535 (custom-quote (widget-get conv
:value
))))))
2536 (insert (symbol-name symbol
) ": ")
2537 (push (widget-create-child-and-convert
2539 :help-echo
"Hide the value of this option."
2542 :action
'custom-toggle-parent
2546 (push (widget-create-child-and-convert
2548 :button-face
'custom-variable-button-face
2550 :tag
(symbol-name symbol
)
2556 (let* ((format (widget-get type
:format
))
2557 tag-format value-format
)
2558 (unless (string-match ":" format
)
2559 (error "Bad format"))
2560 (setq tag-format
(substring format
0 (match-end 0)))
2561 (setq value-format
(substring format
(match-end 0)))
2562 (push (widget-create-child-and-convert
2565 :action
'custom-tag-action
2566 :help-echo
"Change value of this option."
2567 :mouse-down-action
'custom-tag-mouse-down-action
2568 :button-face
'custom-variable-button-face
2569 :sample-face
'custom-variable-tag-face
2573 (push (widget-create-child-and-convert
2575 :help-echo
"Hide the value of this option."
2578 :action
'custom-toggle-parent
2581 (push (widget-create-child-and-convert
2583 :format value-format
2586 (unless (eq custom-buffer-style
'tree
)
2587 (unless (eq (preceding-char) ?
\n)
2588 (widget-insert "\n"))
2589 ;; Create the magic button.
2590 (let ((magic (widget-create-child-and-convert
2591 widget
'custom-magic nil
)))
2592 (widget-put widget
:custom-magic magic
)
2593 (push magic buttons
))
2594 ;; ### NOTE: this is ugly!!!! I need to update the :buttons property
2595 ;; before the call to `widget-default-format-handler'. Otherwise, I
2596 ;; loose my current `buttons'. This function shouldn't be called like
2597 ;; this anyway. The doc string widget should be added like the others.
2599 (widget-put widget
:buttons buttons
)
2601 ;; Insert documentation.
2602 (widget-default-format-handler widget ?h
)
2604 ;; The comment field
2605 (unless (eq state
'hidden
)
2606 (let* ((comment (get symbol
'variable-comment
))
2608 (widget-create-child-and-convert
2609 widget
'custom-comment
2611 :value
(or comment
""))))
2612 (widget-put widget
:comment-widget comment-widget
)
2613 ;; Don't push it !!! Custom assumes that the first child is the
2615 (setq children
(append children
(list comment-widget
)))))
2616 ;; Update the rest of the properties properties.
2617 (widget-put widget
:custom-form form
)
2618 (widget-put widget
:children children
)
2619 ;; Now update the state.
2620 (if (eq state
'hidden
)
2621 (widget-put widget
:custom-state state
)
2622 (custom-variable-state-set widget
))
2624 (unless (eq state
'hidden
)
2625 (when (eq (widget-get widget
:custom-level
) 1)
2626 (custom-add-parent-links widget
))
2627 (custom-add-see-also widget
)))))
2629 (defun custom-tag-action (widget &rest args
)
2630 "Pass :action to first child of WIDGET's parent."
2631 (apply 'widget-apply
(car (widget-get (widget-get widget
:parent
) :children
))
2634 (defun custom-tag-mouse-down-action (widget &rest args
)
2635 "Pass :mouse-down-action to first child of WIDGET's parent."
2636 (apply 'widget-apply
(car (widget-get (widget-get widget
:parent
) :children
))
2637 :mouse-down-action args
))
2639 (defun custom-variable-state-set (widget)
2640 "Set the state of WIDGET."
2641 (let* ((symbol (widget-value widget
))
2642 (get (or (get symbol
'custom-get
) 'default-value
))
2643 (value (if (default-boundp symbol
)
2644 (funcall get symbol
)
2645 (widget-get widget
:value
)))
2646 (comment (get symbol
'variable-comment
))
2649 (state (cond ((progn (setq tmp
(get symbol
'customized-value
))
2651 (get symbol
'customized-variable-comment
))
2653 (if (condition-case nil
2654 (and (equal value
(eval (car tmp
)))
2655 (equal comment temp
))
2659 ((progn (setq tmp
(get symbol
'theme-value
))
2660 (setq temp
(get symbol
'saved-variable-comment
))
2662 (if (condition-case nil
2663 (and (equal comment temp
)
2666 (car (custom-variable-theme-value
2670 ((eq (caar tmp
) 'user
) 'saved
)
2671 ((eq (caar tmp
) 'changed
) 'changed
)
2674 ((setq tmp
(get symbol
'standard-value
))
2675 (if (condition-case nil
2676 (and (equal value
(eval (car tmp
)))
2677 (equal comment nil
))
2682 (widget-put widget
:custom-state state
)))
2684 (defun custom-variable-standard-value (widget)
2685 (get (widget-value widget
) 'standard-value
))
2687 (defvar custom-variable-menu
2688 `(("Set for Current Session" custom-variable-set
2690 (eq (widget-get widget
:custom-state
) 'modified
)))
2691 ,@(when (or custom-file user-init-file
)
2692 '(("Save for Future Sessions" custom-variable-save
2694 (memq (widget-get widget
:custom-state
)
2695 '(modified set changed rogue
))))))
2696 ("Undo Edits" custom-redraw
2698 (and (default-boundp (widget-value widget
))
2699 (memq (widget-get widget
:custom-state
) '(modified changed
)))))
2700 ("Reset to Saved" custom-variable-reset-saved
2702 (and (or (get (widget-value widget
) 'saved-value
)
2703 (get (widget-value widget
) 'saved-variable-comment
))
2704 (memq (widget-get widget
:custom-state
)
2705 '(modified set changed rogue
)))))
2706 ,@(when (or custom-file user-init-file
)
2707 '(("Erase Customization" custom-variable-reset-standard
2709 (and (get (widget-value widget
) 'standard-value
)
2710 (memq (widget-get widget
:custom-state
)
2711 '(modified set changed saved rogue
)))))))
2712 ("Set to Backup Value" custom-variable-reset-backup
2714 (get (widget-value widget
) 'backup-value
)))
2715 ("---" ignore ignore
)
2716 ("Add Comment" custom-comment-show custom-comment-invisible-p
)
2717 ("---" ignore ignore
)
2718 ("Show Current Value" custom-variable-edit
2720 (eq (widget-get widget
:custom-form
) 'lisp
)))
2721 ("Show Saved Lisp Expression" custom-variable-edit-lisp
2723 (eq (widget-get widget
:custom-form
) 'edit
))))
2724 "Alist of actions for the `custom-variable' widget.
2725 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
2726 the menu entry, ACTION is the function to call on the widget when the
2727 menu is selected, and FILTER is a predicate which takes a `custom-variable'
2728 widget as an argument, and returns non-nil if ACTION is valid on that
2729 widget. If FILTER is nil, ACTION is always valid.")
2731 (defun custom-variable-action (widget &optional event
)
2732 "Show the menu for `custom-variable' WIDGET.
2733 Optional EVENT is the location for the menu."
2734 (if (eq (widget-get widget
:custom-state
) 'hidden
)
2735 (custom-toggle-hide widget
)
2736 (unless (eq (widget-get widget
:custom-state
) 'modified
)
2737 (custom-variable-state-set widget
))
2738 (custom-redraw-magic widget
)
2739 (let* ((completion-ignore-case t
)
2740 (answer (widget-choose (concat "Operation on "
2741 (custom-unlispify-tag-name
2742 (widget-get widget
:value
)))
2743 (custom-menu-filter custom-variable-menu
2747 (funcall answer widget
)))))
2749 (defun custom-variable-edit (widget)
2750 "Edit value of WIDGET."
2751 (widget-put widget
:custom-state
'unknown
)
2752 (widget-put widget
:custom-form
'edit
)
2753 (custom-redraw widget
))
2755 (defun custom-variable-edit-lisp (widget)
2756 "Edit the Lisp representation of the value of WIDGET."
2757 (widget-put widget
:custom-state
'unknown
)
2758 (widget-put widget
:custom-form
'lisp
)
2759 (custom-redraw widget
))
2761 (defun custom-variable-set (widget)
2762 "Set the current value for the variable being edited by WIDGET."
2763 (let* ((form (widget-get widget
:custom-form
))
2764 (state (widget-get widget
:custom-state
))
2765 (child (car (widget-get widget
:children
)))
2766 (symbol (widget-value widget
))
2767 (set (or (get symbol
'custom-set
) 'set-default
))
2768 (comment-widget (widget-get widget
:comment-widget
))
2769 (comment (widget-value comment-widget
))
2771 (cond ((eq state
'hidden
)
2772 (error "Cannot set hidden variable"))
2773 ((setq val
(widget-apply child
:validate
))
2774 (goto-char (widget-get val
:from
))
2775 (error "%s" (widget-get val
:error
)))
2776 ((memq form
'(lisp mismatch
))
2777 (when (equal comment
"")
2779 ;; Make the comment invisible by hand if it's empty
2780 (custom-comment-hide comment-widget
))
2781 (custom-variable-backup-value widget
)
2782 (custom-push-theme 'theme-value symbol
'user
2783 'set
(custom-quote (widget-value child
)))
2784 (funcall set symbol
(eval (setq val
(widget-value child
))))
2785 (put symbol
'customized-value
(list val
))
2786 (put symbol
'variable-comment comment
)
2787 (put symbol
'customized-variable-comment comment
))
2789 (when (equal comment
"")
2791 ;; Make the comment invisible by hand if it's empty
2792 (custom-comment-hide comment-widget
))
2793 (custom-variable-backup-value widget
)
2794 (custom-push-theme 'theme-value symbol
'user
2795 'set
(custom-quote (widget-value child
)))
2796 (funcall set symbol
(setq val
(widget-value child
)))
2797 (put symbol
'customized-value
(list (custom-quote val
)))
2798 (put symbol
'variable-comment comment
)
2799 (put symbol
'customized-variable-comment comment
)))
2800 (custom-variable-state-set widget
)
2801 (custom-redraw-magic widget
)))
2803 (defun custom-variable-save (widget)
2804 "Set and save the value for the variable being edited by WIDGET."
2805 (let* ((form (widget-get widget
:custom-form
))
2806 (state (widget-get widget
:custom-state
))
2807 (child (car (widget-get widget
:children
)))
2808 (symbol (widget-value widget
))
2809 (set (or (get symbol
'custom-set
) 'set-default
))
2810 (comment-widget (widget-get widget
:comment-widget
))
2811 (comment (widget-value comment-widget
))
2813 (cond ((eq state
'hidden
)
2814 (error "Cannot set hidden variable"))
2815 ((setq val
(widget-apply child
:validate
))
2816 (goto-char (widget-get val
:from
))
2817 (error "Saving %s: %s" symbol
(widget-get val
:error
)))
2818 ((memq form
'(lisp mismatch
))
2819 (when (equal comment
"")
2821 ;; Make the comment invisible by hand if it's empty
2822 (custom-comment-hide comment-widget
))
2823 (put symbol
'saved-value
(list (widget-value child
)))
2824 (custom-push-theme 'theme-value symbol
'user
2825 'set
(custom-quote (widget-value child
)))
2826 (funcall set symbol
(eval (widget-value child
)))
2827 (put symbol
'variable-comment comment
)
2828 (put symbol
'saved-variable-comment comment
))
2830 (when (equal comment
"")
2832 ;; Make the comment invisible by hand if it's empty
2833 (custom-comment-hide comment-widget
))
2834 (put symbol
'saved-value
2835 (list (custom-quote (widget-value child
))))
2836 (custom-push-theme 'theme-value symbol
'user
2837 'set
(custom-quote (widget-value child
)))
2838 (funcall set symbol
(widget-value child
))
2839 (put symbol
'variable-comment comment
)
2840 (put symbol
'saved-variable-comment comment
)))
2841 (put symbol
'customized-value nil
)
2842 (put symbol
'customized-variable-comment nil
)
2844 (custom-variable-state-set widget
)
2845 (custom-redraw-magic widget
)))
2847 (defun custom-variable-reset-saved (widget)
2848 "Restore the saved value for the variable being edited by WIDGET.
2849 This also updates the buffer to show that value.
2850 The value that was current before this operation
2851 becomes the backup value, so you can get it again."
2852 (let* ((symbol (widget-value widget
))
2853 (set (or (get symbol
'custom-set
) 'set-default
))
2854 (value (get symbol
'saved-value
))
2855 (comment (get symbol
'saved-variable-comment
)))
2856 (cond ((or value comment
)
2857 (put symbol
'variable-comment comment
)
2858 (custom-variable-backup-value widget
)
2859 (custom-push-theme 'theme-value symbol
'user
'set
(car-safe value
))
2861 (funcall set symbol
(eval (car value
)))
2864 (error "No saved value for %s" symbol
)))
2865 (put symbol
'customized-value nil
)
2866 (put symbol
'customized-variable-comment nil
)
2867 (widget-put widget
:custom-state
'unknown
)
2868 ;; This call will possibly make the comment invisible
2869 (custom-redraw widget
)))
2871 (defun custom-variable-reset-standard (widget)
2872 "Restore the standard setting for the variable being edited by WIDGET.
2873 This operation eliminates any saved setting for the variable,
2874 restoring it to the state of a variable that has never been customized.
2875 The value that was current before this operation
2876 becomes the backup value, so you can get it again."
2877 (let* ((symbol (widget-value widget
)))
2878 (if (get symbol
'standard-value
)
2879 (custom-variable-backup-value widget
)
2880 (error "No standard setting known for %S" symbol
))
2881 (put symbol
'variable-comment nil
)
2882 (put symbol
'customized-value nil
)
2883 (put symbol
'customized-variable-comment nil
)
2884 (custom-push-theme 'theme-value symbol
'user
'reset
)
2885 (custom-theme-recalc-variable symbol
)
2886 (when (or (get symbol
'saved-value
) (get symbol
'saved-variable-comment
))
2887 (put symbol
'saved-value nil
)
2888 (put symbol
'saved-variable-comment nil
)
2890 (widget-put widget
:custom-state
'unknown
)
2891 ;; This call will possibly make the comment invisible
2892 (custom-redraw widget
)))
2894 (defun custom-variable-backup-value (widget)
2895 "Back up the current value for WIDGET's variable.
2896 The backup value is kept in the car of the `backup-value' property."
2897 (let* ((symbol (widget-value widget
))
2898 (get (or (get symbol
'custom-get
) 'default-value
))
2899 (type (custom-variable-type symbol
))
2900 (conv (widget-convert type
))
2901 (value (if (default-boundp symbol
)
2902 (funcall get symbol
)
2903 (widget-get conv
:value
))))
2904 (put symbol
'backup-value
(list value
))))
2906 (defun custom-variable-reset-backup (widget)
2907 "Restore the backup value for the variable being edited by WIDGET.
2908 The value that was current before this operation
2909 becomes the backup value, so you can use this operation repeatedly
2910 to switch between two values."
2911 (let* ((symbol (widget-value widget
))
2912 (set (or (get symbol
'custom-set
) 'set-default
))
2913 (value (get symbol
'backup-value
))
2914 (comment-widget (widget-get widget
:comment-widget
))
2915 (comment (widget-value comment-widget
)))
2918 (custom-variable-backup-value widget
)
2919 (custom-push-theme 'theme-value symbol
'user
'set value
)
2921 (funcall set symbol
(car value
))
2923 (error "No backup value for %s" symbol
))
2924 (put symbol
'customized-value
(list (car value
)))
2925 (put symbol
'variable-comment comment
)
2926 (put symbol
'customized-variable-comment comment
)
2927 (custom-variable-state-set widget
)
2928 ;; This call will possibly make the comment invisible
2929 (custom-redraw widget
)))
2931 ;;; The `custom-face-edit' Widget.
2933 (define-widget 'custom-face-edit
'checklist
2934 "Edit face attributes."
2938 :button-args
'(:help-echo
"Control whether this attribute has any effect.")
2939 :value-to-internal
'custom-face-edit-fix-value
2940 :match
(lambda (widget value
)
2941 (widget-checklist-match widget
2942 (custom-face-edit-fix-value widget value
)))
2943 :convert-widget
'custom-face-edit-convert-widget
2944 :args
(mapcar (lambda (att)
2947 :sibling-args
(widget-get (nth 1 att
) :sibling-args
)
2948 (list 'const
:format
"" :value
(nth 0 att
))
2950 custom-face-attributes
))
2952 (defun custom-face-edit-fix-value (widget value
)
2953 "Ignoring WIDGET, convert :bold and :italic in VALUE to new form.
2954 Also change :reverse-video to :inverse-video."
2958 (let ((key (car value
))
2959 (val (car (cdr value
))))
2960 (cond ((eq key
:italic
)
2961 (push :slant result
)
2962 (push (if val
'italic
'normal
) result
))
2964 (push :weight result
)
2965 (push (if val
'bold
'normal
) result
))
2966 ((eq key
:reverse-video
)
2967 (push :inverse-video result
)
2971 (push val result
))))
2972 (setq value
(cdr (cdr value
))))
2973 (setq result
(nreverse result
))
2977 (defun custom-face-edit-convert-widget (widget)
2978 "Convert :args as widget types in WIDGET."
2981 :args
(mapcar (lambda (arg)
2983 :deactivate
'custom-face-edit-deactivate
2984 :activate
'custom-face-edit-activate
2985 :delete
'custom-face-edit-delete
))
2986 (widget-get widget
:args
)))
2989 (defun custom-face-edit-deactivate (widget)
2990 "Make face widget WIDGET inactive for user modifications."
2991 (unless (widget-get widget
:inactive
)
2992 (let ((tag (custom-face-edit-attribute-tag widget
))
2993 (from (copy-marker (widget-get widget
:from
)))
2994 (value (widget-value widget
))
2995 (inhibit-read-only t
)
2996 (inhibit-modification-hooks t
))
2999 (widget-default-delete widget
)
3000 (insert tag
": *\n")
3001 (widget-put widget
:inactive
3002 (cons value
(cons from
(- (point) from
))))))))
3004 (defun custom-face-edit-activate (widget)
3005 "Make face widget WIDGET inactive for user modifications."
3006 (let ((inactive (widget-get widget
:inactive
))
3007 (inhibit-read-only t
)
3008 (inhibit-modification-hooks t
))
3009 (when (consp inactive
)
3011 (goto-char (car (cdr inactive
)))
3012 (delete-region (point) (+ (point) (cdr (cdr inactive
))))
3013 (widget-put widget
:inactive nil
)
3014 (widget-apply widget
:create
)
3015 (widget-value-set widget
(car inactive
))
3018 (defun custom-face-edit-delete (widget)
3019 "Remove WIDGET from the buffer."
3020 (let ((inactive (widget-get widget
:inactive
))
3021 (inhibit-read-only t
)
3022 (inhibit-modification-hooks t
))
3024 ;; Widget is alive, we don't have to do anything special
3025 (widget-default-delete widget
)
3026 ;; WIDGET is already deleted because we did so to inactivate it;
3027 ;; now just get rid of the label we put in its place.
3028 (delete-region (car (cdr inactive
))
3029 (+ (car (cdr inactive
)) (cdr (cdr inactive
))))
3030 (widget-put widget
:inactive nil
))))
3033 (defun custom-face-edit-attribute-tag (widget)
3034 "Returns the first :tag property in WIDGET or one of its children."
3035 (let ((tag (widget-get widget
:tag
)))
3036 (or (and (not (equal tag
"")) tag
)
3037 (let ((children (widget-get widget
:children
)))
3038 (while (and (null tag
) children
)
3039 (setq tag
(custom-face-edit-attribute-tag (pop children
))))
3042 ;;; The `custom-display' Widget.
3044 (define-widget 'custom-display
'menu-choice
3045 "Select a display type."
3048 :help-echo
"Specify frames where the face attributes should be used."
3049 :args
'((const :tag
"all" t
)
3050 (const :tag
"defaults" default
)
3054 :args
((group :sibling-args
(:help-echo
"\
3055 Only match the specified window systems.")
3056 (const :format
"Type: "
3058 (checklist :inline t
3061 :sibling-args
(:help-echo
"\
3062 The X11 Window System.")
3064 (const :format
"PM "
3065 :sibling-args
(:help-echo
"\
3066 OS/2 Presentation Manager.")
3068 (const :format
"W32 "
3069 :sibling-args
(:help-echo
"\
3072 (const :format
"MAC "
3073 :sibling-args
(:help-echo
"\
3076 (const :format
"DOS "
3077 :sibling-args
(:help-echo
"\
3080 (const :format
"TTY%n"
3081 :sibling-args
(:help-echo
"\
3082 Plain text terminals.")
3084 (group :sibling-args
(:help-echo
"\
3085 Only match the frames with the specified color support.")
3086 (const :format
"Class: "
3088 (checklist :inline t
3090 (const :format
"Color "
3091 :sibling-args
(:help-echo
"\
3092 Match color frames.")
3094 (const :format
"Grayscale "
3095 :sibling-args
(:help-echo
"\
3096 Match grayscale frames.")
3098 (const :format
"Monochrome%n"
3099 :sibling-args
(:help-echo
"\
3100 Match frames with no color support.")
3102 (group :sibling-args
(:help-echo
"\
3103 The minimum number of colors the frame should support.")
3104 (const :format
"" min-colors
)
3105 (integer :tag
"Minimum number of colors" ))
3106 (group :sibling-args
(:help-echo
"\
3107 Only match frames with the specified intensity.")
3109 Background brightness: "
3111 (checklist :inline t
3113 (const :format
"Light "
3114 :sibling-args
(:help-echo
"\
3115 Match frames with light backgrounds.")
3117 (const :format
"Dark\n"
3118 :sibling-args
(:help-echo
"\
3119 Match frames with dark backgrounds.")
3121 (group :sibling-args
(:help-echo
"\
3122 Only match frames that support the specified face attributes.")
3123 (const :format
"Supports attributes:" supports
)
3124 (custom-face-edit :inline t
:format
"%n%v"))))))
3126 ;;; The `custom-face' Widget.
3128 (defface custom-face-tag
3129 `((t (:weight bold
:height
1.2 :inherit variable-pitch
)))
3130 "Face used for face tags."
3131 :group
'custom-faces
)
3132 ;; backward-compatibility alias
3133 (put 'custom-face-tag-face
'face-alias
'custom-face-tag
)
3135 (defcustom custom-face-default-form
'selected
3136 "Default form of displaying face definition."
3137 :type
'(choice (const all
)
3140 :group
'custom-buffer
3143 (define-widget 'custom-face
'custom
3145 :sample-face
'custom-face-tag-face
3146 :help-echo
"Set or reset this face."
3147 :documentation-property
#'face-doc-string
3148 :value-create
'custom-face-value-create
3149 :action
'custom-face-action
3150 :custom-category
'face
3151 :custom-form nil
; defaults to value of `custom-face-default-form'
3152 :custom-set
'custom-face-set
3153 :custom-save
'custom-face-save
3154 :custom-reset-current
'custom-redraw
3155 :custom-reset-saved
'custom-face-reset-saved
3156 :custom-reset-standard
'custom-face-reset-standard
3157 :custom-standard-value
'custom-face-standard-value
3158 :custom-menu
'custom-face-menu-create
)
3160 (define-widget 'custom-face-all
'editable-list
3161 "An editable list of display specifications and attributes."
3162 :entry-format
"%i %d %v"
3163 :insert-button-args
'(:help-echo
"Insert new display specification here.")
3164 :append-button-args
'(:help-echo
"Append new display specification here.")
3165 :delete-button-args
'(:help-echo
"Delete this display specification.")
3166 :args
'((group :format
"%v" custom-display custom-face-edit
)))
3168 (defconst custom-face-all
(widget-convert 'custom-face-all
)
3169 "Converted version of the `custom-face-all' widget.")
3171 (define-widget 'custom-display-unselected
'item
3172 "A display specification that doesn't match the selected display."
3173 :match
'custom-display-unselected-match
)
3175 (defun custom-display-unselected-match (widget value
)
3176 "Non-nil if VALUE is an unselected display specification."
3177 (not (face-spec-set-match-display value
(selected-frame))))
3179 (define-widget 'custom-face-selected
'group
3180 "Edit the attributes of the selected display in a face specification."
3181 :args
'((choice :inline t
3182 (group :tag
"With Defaults" :inline t
3183 (group (const :tag
"" default
)
3184 (custom-face-edit :tag
" Default\n Attributes"))
3187 (group custom-display-unselected sexp
))
3188 (group (sexp :format
"")
3189 (custom-face-edit :tag
" Overriding\n Attributes"))
3193 (group :tag
"No Defaults" :inline t
3196 (group custom-display-unselected sexp
))
3197 (group (sexp :format
"")
3198 (custom-face-edit :tag
"\n Attributes"))
3205 (defconst custom-face-selected
(widget-convert 'custom-face-selected
)
3206 "Converted version of the `custom-face-selected' widget.")
3208 (defun custom-filter-face-spec (spec filter-index
&optional default-filter
)
3209 "Return a canonicalized version of SPEC using.
3210 FILTER-INDEX is the index in the entry for each attribute in
3211 `custom-face-attributes' at which the appropriate filter function can be
3212 found, and DEFAULT-FILTER is the filter to apply for attributes that
3214 (mapcar (lambda (entry)
3215 ;; Filter a single face-spec entry
3216 (let ((tests (car entry
))
3218 ;; Handle both old- and new-style attribute syntax
3219 (if (listp (car (cdr entry
)))
3222 (filtered-attrs nil
))
3223 ;; Filter each face attribute
3224 (while unfiltered-attrs
3225 (let* ((attr (pop unfiltered-attrs
))
3226 (pre-filtered-value (pop unfiltered-attrs
))
3228 (or (nth filter-index
(assq attr custom-face-attributes
))
3232 (funcall filter pre-filtered-value
)
3233 pre-filtered-value
)))
3234 (push filtered-value filtered-attrs
)
3235 (push attr filtered-attrs
)))
3237 (list tests filtered-attrs
)))
3240 (defun custom-pre-filter-face-spec (spec)
3241 "Return SPEC changed as necessary for editing by the face customization widget.
3242 SPEC must be a full face spec."
3243 (custom-filter-face-spec spec
2))
3245 (defun custom-post-filter-face-spec (spec)
3246 "Return the customized SPEC in a form suitable for setting the face."
3247 (custom-filter-face-spec spec
3))
3249 (defun custom-face-value-create (widget)
3250 "Create a list of the display specifications for WIDGET."
3251 (let ((buttons (widget-get widget
:buttons
))
3253 (symbol (widget-get widget
:value
))
3254 (tag (widget-get widget
:tag
))
3255 (state (widget-get widget
:custom-state
))
3257 (is-last (widget-get widget
:custom-last
))
3258 (prefix (widget-get widget
:custom-prefix
)))
3260 (setq tag
(prin1-to-string symbol
)))
3261 (cond ((eq custom-buffer-style
'tree
)
3262 (insert prefix
(if is-last
" `--- " " |--- "))
3263 (push (widget-create-child-and-convert
3264 widget
'custom-browse-face-tag
)
3266 (insert " " tag
"\n")
3267 (widget-put widget
:buttons buttons
))
3271 (widget-specify-sample widget begin
(point))
3272 (if (eq custom-buffer-style
'face
)
3274 (if (string-match "face\\'" tag
)
3276 (insert " face: ")))
3278 (push (widget-create-child-and-convert widget
'item
3285 (push (widget-create-child-and-convert
3287 :help-echo
"Hide or show this face."
3290 :action
'custom-toggle-parent
3291 (not (eq state
'hidden
)))
3295 (let ((magic (widget-create-child-and-convert
3296 widget
'custom-magic nil
)))
3297 (widget-put widget
:custom-magic magic
)
3298 (push magic buttons
))
3300 (widget-put widget
:buttons buttons
)
3301 ;; Insert documentation.
3302 (widget-default-format-handler widget ?h
)
3303 ;; The comment field
3304 (unless (eq state
'hidden
)
3305 (let* ((comment (get symbol
'face-comment
))
3307 (widget-create-child-and-convert
3308 widget
'custom-comment
3310 :value
(or comment
""))))
3311 (widget-put widget
:comment-widget comment-widget
)
3312 (push comment-widget children
)))
3314 (unless (eq state
'hidden
)
3315 (when (eq (widget-get widget
:custom-level
) 1)
3316 (custom-add-parent-links widget
))
3317 (custom-add-see-also widget
))
3319 (unless (eq (preceding-char) ?
\n)
3321 (unless (eq state
'hidden
)
3322 (message "Creating face editor...")
3323 (custom-load-widget widget
)
3324 (unless (widget-get widget
:custom-form
)
3325 (widget-put widget
:custom-form custom-face-default-form
))
3326 (let* ((symbol (widget-value widget
))
3327 (spec (or (get symbol
'customized-face
)
3328 (get symbol
'saved-face
)
3329 (get symbol
'face-defface-spec
)
3330 ;; Attempt to construct it.
3331 (list (list t
(custom-face-attributes-get
3332 symbol
(selected-frame))))))
3333 (form (widget-get widget
:custom-form
))
3334 (indent (widget-get widget
:indent
))
3336 ;; If the user has changed this face in some other way,
3337 ;; edit it as the user has specified it.
3338 (if (not (face-spec-match-p symbol spec
(selected-frame)))
3339 (setq spec
(list (list t
(face-attr-construct symbol
(selected-frame))))))
3340 (setq spec
(custom-pre-filter-face-spec spec
))
3341 (setq edit
(widget-create-child-and-convert
3343 (cond ((and (eq form
'selected
)
3344 (widget-apply custom-face-selected
3346 (when indent
(insert-char ?\ indent
))
3347 'custom-face-selected
)
3348 ((and (not (eq form
'lisp
))
3349 (widget-apply custom-face-all
3353 (when indent
(insert-char ?\ indent
))
3356 (custom-face-state-set widget
)
3357 (push edit children
)
3358 (widget-put widget
:children children
))
3359 (message "Creating face editor...done"))))))
3361 (defvar custom-face-menu
3362 `(("Set for Current Session" custom-face-set
)
3363 ,@(when (or custom-file user-init-file
)
3364 '(("Save for Future Sessions" custom-face-save
)))
3365 ("Undo Edits" custom-redraw
3367 (memq (widget-get widget
:custom-state
) '(modified changed
))))
3368 ("Reset to Saved" custom-face-reset-saved
3370 (or (get (widget-value widget
) 'saved-face
)
3371 (get (widget-value widget
) 'saved-face-comment
))))
3372 ,@(when (or custom-file user-init-file
)
3373 '(("Erase Customization" custom-face-reset-standard
3375 (get (widget-value widget
) 'face-defface-spec
)))))
3376 ("---" ignore ignore
)
3377 ("Add Comment" custom-comment-show custom-comment-invisible-p
)
3378 ("---" ignore ignore
)
3379 ("For Current Display" custom-face-edit-selected
3381 (not (eq (widget-get widget
:custom-form
) 'selected
))))
3382 ("For All Kinds of Displays" custom-face-edit-all
3384 (not (eq (widget-get widget
:custom-form
) 'all
))))
3385 ("Show Lisp Expression" custom-face-edit-lisp
3387 (not (eq (widget-get widget
:custom-form
) 'lisp
)))))
3388 "Alist of actions for the `custom-face' widget.
3389 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3390 the menu entry, ACTION is the function to call on the widget when the
3391 menu is selected, and FILTER is a predicate which takes a `custom-face'
3392 widget as an argument, and returns non-nil if ACTION is valid on that
3393 widget. If FILTER is nil, ACTION is always valid.")
3395 (defun custom-face-edit-selected (widget)
3396 "Edit selected attributes of the value of WIDGET."
3397 (widget-put widget
:custom-state
'unknown
)
3398 (widget-put widget
:custom-form
'selected
)
3399 (custom-redraw widget
))
3401 (defun custom-face-edit-all (widget)
3402 "Edit all attributes of the value of WIDGET."
3403 (widget-put widget
:custom-state
'unknown
)
3404 (widget-put widget
:custom-form
'all
)
3405 (custom-redraw widget
))
3407 (defun custom-face-edit-lisp (widget)
3408 "Edit the Lisp representation of the value of WIDGET."
3409 (widget-put widget
:custom-state
'unknown
)
3410 (widget-put widget
:custom-form
'lisp
)
3411 (custom-redraw widget
))
3413 (defun custom-face-state-set (widget)
3414 "Set the state of WIDGET."
3415 (let* ((symbol (widget-value widget
))
3416 (comment (get symbol
'face-comment
))
3420 (setq tmp
(get symbol
'customized-face
))
3421 (setq temp
(get symbol
'customized-face-comment
))
3423 (if (equal temp comment
)
3427 (setq tmp
(get symbol
'saved-face
))
3428 (setq temp
(get symbol
'saved-face-comment
))
3430 (if (equal temp comment
)
3432 ((eq 'user
(caar (get symbol
'theme-face
)))
3434 ((eq 'changed
(caar (get symbol
'theme-face
)))
3438 ((get symbol
'face-defface-spec
)
3439 (if (equal comment nil
)
3444 ;; If the user called set-face-attribute to change the default
3445 ;; for new frames, this face is "set outside of Customize".
3446 (if (and (not (eq state
'rogue
))
3447 (get symbol
'face-modified
))
3448 (setq state
'changed
))
3449 (widget-put widget
:custom-state state
)))
3451 (defun custom-face-action (widget &optional event
)
3452 "Show the menu for `custom-face' WIDGET.
3453 Optional EVENT is the location for the menu."
3454 (if (eq (widget-get widget
:custom-state
) 'hidden
)
3455 (custom-toggle-hide widget
)
3456 (let* ((completion-ignore-case t
)
3457 (symbol (widget-get widget
:value
))
3458 (answer (widget-choose (concat "Operation on "
3459 (custom-unlispify-tag-name symbol
))
3460 (custom-menu-filter custom-face-menu
3464 (funcall answer widget
)))))
3466 (defun custom-face-set (widget)
3467 "Make the face attributes in WIDGET take effect."
3468 (let* ((symbol (widget-value widget
))
3469 (child (car (widget-get widget
:children
)))
3470 (value (custom-post-filter-face-spec (widget-value child
)))
3471 (comment-widget (widget-get widget
:comment-widget
))
3472 (comment (widget-value comment-widget
)))
3473 (when (equal comment
"")
3475 ;; Make the comment invisible by hand if it's empty
3476 (custom-comment-hide comment-widget
))
3477 (put symbol
'customized-face value
)
3478 (custom-push-theme 'theme-face symbol
'user
'set value
)
3479 (if (face-spec-choose value
)
3480 (face-spec-set symbol value
)
3481 ;; face-set-spec ignores empty attribute lists, so just give it
3482 ;; something harmless instead.
3483 (face-spec-set symbol
'((t :foreground unspecified
))))
3484 (put symbol
'customized-face-comment comment
)
3485 (put symbol
'face-comment comment
)
3486 (custom-face-state-set widget
)
3487 (custom-redraw-magic widget
)))
3489 (defun custom-face-save (widget)
3490 "Save in `.emacs' the face attributes in WIDGET."
3491 (let* ((symbol (widget-value widget
))
3492 (child (car (widget-get widget
:children
)))
3493 (value (custom-post-filter-face-spec (widget-value child
)))
3494 (comment-widget (widget-get widget
:comment-widget
))
3495 (comment (widget-value comment-widget
)))
3496 (when (equal comment
"")
3498 ;; Make the comment invisible by hand if it's empty
3499 (custom-comment-hide comment-widget
))
3500 (custom-push-theme 'theme-face symbol
'user
'set value
)
3501 (if (face-spec-choose value
)
3502 (face-spec-set symbol value
)
3503 ;; face-set-spec ignores empty attribute lists, so just give it
3504 ;; something harmless instead.
3505 (face-spec-set symbol
'((t :foreground unspecified
))))
3506 (unless (eq (widget-get widget
:custom-state
) 'standard
)
3507 (put symbol
'saved-face value
))
3508 (put symbol
'customized-face nil
)
3509 (put symbol
'face-comment comment
)
3510 (put symbol
'customized-face-comment nil
)
3511 (put symbol
'saved-face-comment comment
)
3513 (custom-face-state-set widget
)
3514 (custom-redraw-magic widget
)))
3516 ;; For backward compatibility.
3517 (define-obsolete-function-alias 'custom-face-save-command
'custom-face-save
3520 (defun custom-face-reset-saved (widget)
3521 "Restore WIDGET to the face's default attributes."
3522 (let* ((symbol (widget-value widget
))
3523 (child (car (widget-get widget
:children
)))
3524 (value (get symbol
'saved-face
))
3525 (comment (get symbol
'saved-face-comment
))
3526 (comment-widget (widget-get widget
:comment-widget
)))
3527 (unless (or value comment
)
3528 (error "No saved value for this face"))
3529 (put symbol
'customized-face nil
)
3530 (put symbol
'customized-face-comment nil
)
3531 (custom-push-theme 'theme-face symbol
'user
'set value
)
3532 (face-spec-set symbol value
)
3533 (put symbol
'face-comment comment
)
3534 (widget-value-set child value
)
3535 ;; This call manages the comment visibility
3536 (widget-value-set comment-widget
(or comment
""))
3537 (custom-face-state-set widget
)
3538 (custom-redraw-magic widget
)))
3540 (defun custom-face-standard-value (widget)
3541 (get (widget-value widget
) 'face-defface-spec
))
3543 (defun custom-face-reset-standard (widget)
3544 "Restore WIDGET to the face's standard attribute values.
3545 This operation eliminates any saved attributes for the face,
3546 restoring it to the state of a face that has never been customized."
3547 (let* ((symbol (widget-value widget
))
3548 (child (car (widget-get widget
:children
)))
3549 (value (get symbol
'face-defface-spec
))
3550 (comment-widget (widget-get widget
:comment-widget
)))
3552 (error "No standard setting for this face"))
3553 (put symbol
'customized-face nil
)
3554 (put symbol
'customized-face-comment nil
)
3555 (custom-push-theme 'theme-face symbol
'user
'reset
)
3556 (face-spec-set symbol value
)
3557 (custom-theme-recalc-face symbol
)
3558 (when (or (get symbol
'saved-face
) (get symbol
'saved-face-comment
))
3559 (put symbol
'saved-face nil
)
3560 (put symbol
'saved-face-comment nil
)
3562 (put symbol
'face-comment nil
)
3563 (widget-value-set child
3564 (custom-pre-filter-face-spec
3565 (list (list t
(custom-face-attributes-get
3567 ;; This call manages the comment visibility
3568 (widget-value-set comment-widget
"")
3569 (custom-face-state-set widget
)
3570 (custom-redraw-magic widget
)))
3572 ;;; The `face' Widget.
3574 (defvar widget-face-prompt-value-history nil
3575 "History of input to `widget-face-prompt-value'.")
3577 (define-widget 'face
'symbol
3578 "A Lisp face name (with sample)."
3579 :format
"%{%t%}: (%{sample%}) %v"
3582 :sample-face-get
'widget-face-sample-face-get
3583 :notify
'widget-face-notify
3584 :match
(lambda (widget value
) (facep value
))
3585 :complete-function
(lambda ()
3587 (lisp-complete-symbol 'facep
))
3588 :prompt-match
'facep
3589 :prompt-history
'widget-face-prompt-value-history
3590 :validate
(lambda (widget)
3591 (unless (facep (widget-value widget
))
3593 :error
(format "Invalid face: %S"
3594 (widget-value widget
)))
3597 (defun widget-face-sample-face-get (widget)
3598 (let ((value (widget-value widget
)))
3603 (defun widget-face-notify (widget child
&optional event
)
3604 "Update the sample, and notify the parent."
3605 (overlay-put (widget-get widget
:sample-overlay
)
3606 'face
(widget-apply widget
:sample-face-get
))
3607 (widget-default-notify widget child event
))
3610 ;;; The `hook' Widget.
3612 (define-widget 'hook
'list
3614 :value-to-internal
(lambda (widget value
)
3615 (if (and value
(symbolp value
))
3618 :match
(lambda (widget value
)
3620 (widget-group-match widget value
)))
3621 ;; Avoid adding undefined functions to the hook, especially for
3622 ;; things like `find-file-hook' or even more basic ones, to avoid
3624 :set
(lambda (symbol value
)
3627 (add-hook symbol elt
))))
3628 :convert-widget
'custom-hook-convert-widget
3631 (defun custom-hook-convert-widget (widget)
3632 ;; Handle `:options'.
3633 (let* ((options (widget-get widget
:options
))
3634 (other `(editable-list :inline t
3635 :entry-format
"%i %d%v"
3636 (function :format
" %v")))
3638 (list `(checklist :inline t
3639 ,@(mapcar (lambda (entry)
3640 `(function-item ,entry
))
3644 (widget-put widget
:args args
)
3647 ;;; The `custom-group-link' Widget.
3649 (define-widget 'custom-group-link
'link
3650 "Show parent in other window when activated."
3651 :button-face
'custom-link
3652 :mouse-face
'highlight
3653 :pressed-face
'highlight
3654 :help-echo
"Create customization buffer for this group."
3655 :action
'custom-group-link-action
)
3657 (defun custom-group-link-action (widget &rest ignore
)
3658 (customize-group (widget-value widget
)))
3660 ;;; The `custom-group' Widget.
3662 (defcustom custom-group-tag-faces nil
3663 ;; In XEmacs, this ought to play games with font size.
3664 ;; Fixme: make it do so in Emacs.
3665 "Face used for group tags.
3666 The first member is used for level 1 groups, the second for level 2,
3667 and so forth. The remaining group tags are shown with `custom-group-tag'."
3668 :type
'(repeat face
)
3669 :group
'custom-faces
)
3671 (defface custom-group-tag-1
3674 (:foreground
"pink" :weight bold
:height
1.2 :inherit variable-pitch
))
3675 (((min-colors 88) (class color
)
3677 (:foreground
"red1" :weight bold
:height
1.2 :inherit variable-pitch
))
3680 (:foreground
"red" :weight bold
:height
1.2 :inherit variable-pitch
))
3682 "Face used for group tags."
3683 :group
'custom-faces
)
3684 ;; backward-compatibility alias
3685 (put 'custom-group-tag-face-1
'face-alias
'custom-group-tag-1
)
3687 (defface custom-group-tag
3690 (:foreground
"light blue" :weight bold
:height
1.2))
3691 (((min-colors 88) (class color
)
3693 (:foreground
"blue1" :weight bold
:height
1.2))
3696 (:foreground
"blue" :weight bold
:height
1.2))
3698 "Face used for low level group tags."
3699 :group
'custom-faces
)
3700 ;; backward-compatibility alias
3701 (put 'custom-group-tag-face
'face-alias
'custom-group-tag
)
3703 (define-widget 'custom-group
'custom
3706 :sample-face-get
'custom-group-sample-face-get
3707 :documentation-property
'group-documentation
3708 :help-echo
"Set or reset all members of this group."
3709 :value-create
'custom-group-value-create
3710 :action
'custom-group-action
3711 :custom-category
'group
3712 :custom-set
'custom-group-set
3713 :custom-save
'custom-group-save
3714 :custom-reset-current
'custom-group-reset-current
3715 :custom-reset-saved
'custom-group-reset-saved
3716 :custom-reset-standard
'custom-group-reset-standard
3717 :custom-menu
'custom-group-menu-create
)
3719 (defun custom-group-sample-face-get (widget)
3720 ;; Use :sample-face.
3721 (or (nth (1- (widget-get widget
:custom-level
)) custom-group-tag-faces
)
3724 (define-widget 'custom-group-visibility
'visibility
3725 "An indicator and manipulator for hidden group contents."
3726 :create
'custom-group-visibility-create
)
3728 (defun custom-group-visibility-create (widget)
3729 (let ((visible (widget-value widget
)))
3731 (insert "--------")))
3732 (widget-default-create widget
))
3734 (defun custom-group-members (symbol groups-only
)
3735 "Return SYMBOL's custom group members.
3736 If GROUPS-ONLY non-nil, return only those members that are groups."
3737 (if (not groups-only
)
3738 (get symbol
'custom-group
)
3740 (dolist (entry (get symbol
'custom-group
))
3741 (when (eq (nth 1 entry
) 'custom-group
)
3742 (push entry members
)))
3743 (nreverse members
))))
3745 (defun custom-group-value-create (widget)
3746 "Insert a customize group for WIDGET in the current buffer."
3747 (unless (eq (widget-get widget
:custom-state
) 'hidden
)
3748 (custom-load-widget widget
))
3749 (let* ((state (widget-get widget
:custom-state
))
3750 (level (widget-get widget
:custom-level
))
3751 ;; (indent (widget-get widget :indent))
3752 (prefix (widget-get widget
:custom-prefix
))
3753 (buttons (widget-get widget
:buttons
))
3754 (tag (widget-get widget
:tag
))
3755 (symbol (widget-value widget
))
3756 (members (custom-group-members symbol
3757 (and (eq custom-buffer-style
'tree
)
3758 custom-browse-only-groups
))))
3759 (cond ((and (eq custom-buffer-style
'tree
)
3761 (or members
(custom-unloaded-widget-p widget
)))
3762 (custom-browse-insert-prefix prefix
)
3763 (push (widget-create-child-and-convert
3764 widget
'custom-browse-visibility
3765 ;; :tag-glyph "plus"
3769 ;; (widget-glyph-insert nil "-- " "horizontal")
3770 (push (widget-create-child-and-convert
3771 widget
'custom-browse-group-tag
)
3773 (insert " " tag
"\n")
3774 (widget-put widget
:buttons buttons
))
3775 ((and (eq custom-buffer-style
'tree
)
3776 (zerop (length members
)))
3777 (custom-browse-insert-prefix prefix
)
3779 ;; (widget-glyph-insert nil "[ ]" "empty")
3780 ;; (widget-glyph-insert nil "-- " "horizontal")
3781 (push (widget-create-child-and-convert
3782 widget
'custom-browse-group-tag
)
3784 (insert " " tag
"\n")
3785 (widget-put widget
:buttons buttons
))
3786 ((eq custom-buffer-style
'tree
)
3787 (custom-browse-insert-prefix prefix
)
3788 (if (zerop (length members
))
3790 (custom-browse-insert-prefix prefix
)
3792 ;; (widget-glyph-insert nil "[ ]" "empty")
3793 ;; (widget-glyph-insert nil "-- " "horizontal")
3794 (push (widget-create-child-and-convert
3795 widget
'custom-browse-group-tag
)
3797 (insert " " tag
"\n")
3798 (widget-put widget
:buttons buttons
))
3799 (push (widget-create-child-and-convert
3800 widget
'custom-browse-visibility
3801 ;; :tag-glyph "minus"
3805 ;; (widget-glyph-insert nil "-\\ " "top")
3806 (push (widget-create-child-and-convert
3807 widget
'custom-browse-group-tag
)
3809 (insert " " tag
"\n")
3810 (widget-put widget
:buttons buttons
)
3811 (message "Creating group...")
3812 (let* ((members (custom-sort-items members
3813 custom-browse-sort-alphabetically
3814 custom-browse-order-groups
))
3815 (prefixes (widget-get widget
:custom-prefixes
))
3816 (custom-prefix-list (custom-prefix-add symbol prefixes
))
3817 (extra-prefix (if (widget-get widget
:custom-last
)
3820 (prefix (concat prefix extra-prefix
))
3823 (setq entry
(car members
)
3824 members
(cdr members
))
3825 (push (widget-create-child-and-convert
3826 widget
(nth 1 entry
)
3828 :tag
(custom-unlispify-tag-name (nth 0 entry
))
3829 :custom-prefixes custom-prefix-list
3830 :custom-level
(1+ level
)
3831 :custom-last
(null members
)
3832 :value
(nth 0 entry
)
3833 :custom-prefix prefix
)
3835 (widget-put widget
:children
(reverse children
)))
3836 (message "Creating group...done")))
3839 ;; Create level indicator.
3840 (unless (eq custom-buffer-style
'links
)
3841 (insert-char ?\
(* custom-buffer-indent
(1- level
)))
3844 (let ((begin (point)))
3846 (widget-specify-sample widget begin
(point)))
3848 ;; Create link/visibility indicator.
3849 (if (eq custom-buffer-style
'links
)
3850 (push (widget-create-child-and-convert
3851 widget
'custom-group-link
3855 (push (widget-create-child-and-convert
3856 widget
'custom-group-visibility
3857 :help-echo
"Show members of this group."
3858 :action
'custom-toggle-parent
3859 (not (eq state
'hidden
)))
3862 ;; Create magic button.
3863 (let ((magic (widget-create-child-and-convert
3864 widget
'custom-magic nil
)))
3865 (widget-put widget
:custom-magic magic
)
3866 (push magic buttons
))
3868 (widget-put widget
:buttons buttons
)
3869 ;; Insert documentation.
3870 (if (and (eq custom-buffer-style
'links
) (> level
1))
3871 (widget-put widget
:documentation-indent
0))
3872 (widget-default-format-handler widget ?h
))
3875 ;; Add parent groups references above the group.
3876 (if t
;;; This should test that the buffer
3877 ;;; was made to display a group.
3879 (if (custom-add-parent-links widget
3880 "Go to parent group:")
3882 ;; Create level indicator.
3883 (insert-char ?\
(* custom-buffer-indent
(1- level
)))
3886 (let ((start (point)))
3888 (widget-specify-sample widget start
(point)))
3890 ;; Create visibility indicator.
3891 (unless (eq custom-buffer-style
'links
)
3893 (push (widget-create-child-and-convert
3895 :help-echo
"Hide members of this group."
3896 :action
'custom-toggle-parent
3897 (not (eq state
'hidden
)))
3900 ;; Create more dashes.
3901 ;; Use 76 instead of 75 to compensate for the temporary "<"
3902 ;; added by `widget-insert'.
3903 (insert-char ?-
(- 76 (current-column)
3904 (* custom-buffer-indent level
)))
3906 ;; Create magic button.
3907 (let ((magic (widget-create-child-and-convert
3908 widget
'custom-magic
3911 (widget-put widget
:custom-magic magic
)
3912 (push magic buttons
))
3914 (widget-put widget
:buttons buttons
)
3915 ;; Insert documentation.
3916 (widget-default-format-handler widget ?h
)
3918 (if nil
;;; This should test that the buffer
3919 ;;; was not made to display a group.
3921 (insert-char ?\ custom-buffer-indent
)
3922 (custom-add-parent-links widget
)))
3923 (custom-add-see-also widget
3924 (make-string (* custom-buffer-indent level
)
3927 (message "Creating group...")
3928 (let* ((members (custom-sort-items members
3929 custom-buffer-sort-alphabetically
3930 custom-buffer-order-groups
))
3931 (prefixes (widget-get widget
:custom-prefixes
))
3932 (custom-prefix-list (custom-prefix-add symbol prefixes
))
3933 (length (length members
))
3935 (children (mapcar (lambda (entry)
3936 (widget-insert "\n")
3938 Creating group members... %2d%%"
3939 (/ (* 100.0 count
) length
))
3940 (setq count
(1+ count
))
3942 (widget-create-child-and-convert
3943 widget
(nth 1 entry
)
3945 :tag
(custom-unlispify-tag-name
3947 :custom-prefixes custom-prefix-list
3948 :custom-level
(1+ level
)
3949 :value
(nth 0 entry
))
3950 (unless (eq (preceding-char) ?
\n)
3951 (widget-insert "\n"))))
3953 (message "Creating group magic...")
3954 (mapc 'custom-magic-reset children
)
3955 (message "Creating group state...")
3956 (widget-put widget
:children children
)
3957 (custom-group-state-update widget
)
3958 (message "Creating group... done"))
3961 (insert-char ?\
(* custom-buffer-indent
(1- level
)))
3962 (insert "\\- " (widget-get widget
:tag
) " group end ")
3963 (insert-char ?-
(- 75 (current-column) (* custom-buffer-indent level
)))
3966 (defvar custom-group-menu
3967 `(("Set for Current Session" custom-group-set
3969 (eq (widget-get widget
:custom-state
) 'modified
)))
3970 ,@(when (or custom-file user-init-file
)
3971 '(("Save for Future Sessions" custom-group-save
3973 (memq (widget-get widget
:custom-state
) '(modified set
))))))
3974 ("Undo Edits" custom-group-reset-current
3976 (memq (widget-get widget
:custom-state
) '(modified))))
3977 ("Reset to Saved" custom-group-reset-saved
3979 (memq (widget-get widget
:custom-state
) '(modified set
))))
3980 ,@(when (or custom-file user-init-file
)
3981 '(("Erase Customization" custom-group-reset-standard
3983 (memq (widget-get widget
:custom-state
) '(modified set saved
)))))))
3984 "Alist of actions for the `custom-group' widget.
3985 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3986 the menu entry, ACTION is the function to call on the widget when the
3987 menu is selected, and FILTER is a predicate which takes a `custom-group'
3988 widget as an argument, and returns non-nil if ACTION is valid on that
3989 widget. If FILTER is nil, ACTION is always valid.")
3991 (defun custom-group-action (widget &optional event
)
3992 "Show the menu for `custom-group' WIDGET.
3993 Optional EVENT is the location for the menu."
3994 (if (eq (widget-get widget
:custom-state
) 'hidden
)
3995 (custom-toggle-hide widget
)
3996 (let* ((completion-ignore-case t
)
3997 (answer (widget-choose (concat "Operation on "
3998 (custom-unlispify-tag-name
3999 (widget-get widget
:value
)))
4000 (custom-menu-filter custom-group-menu
4004 (funcall answer widget
)))))
4006 (defun custom-group-set (widget)
4007 "Set changes in all modified group members."
4008 (let ((children (widget-get widget
:children
)))
4009 (mapc (lambda (child)
4010 (when (eq (widget-get child
:custom-state
) 'modified
)
4011 (widget-apply child
:custom-set
)))
4014 (defun custom-group-save (widget)
4015 "Save all modified group members."
4016 (let ((children (widget-get widget
:children
)))
4017 (mapc (lambda (child)
4018 (when (memq (widget-get child
:custom-state
) '(modified set
))
4019 (widget-apply child
:custom-save
)))
4022 (defun custom-group-reset-current (widget)
4023 "Reset all modified group members."
4024 (let ((children (widget-get widget
:children
)))
4025 (mapc (lambda (child)
4026 (when (eq (widget-get child
:custom-state
) 'modified
)
4027 (widget-apply child
:custom-reset-current
)))
4030 (defun custom-group-reset-saved (widget)
4031 "Reset all modified or set group members."
4032 (let ((children (widget-get widget
:children
)))
4033 (mapc (lambda (child)
4034 (when (memq (widget-get child
:custom-state
) '(modified set
))
4035 (widget-apply child
:custom-reset-saved
)))
4038 (defun custom-group-reset-standard (widget)
4039 "Reset all modified, set, or saved group members."
4040 (let ((children (widget-get widget
:children
)))
4041 (mapc (lambda (child)
4042 (when (memq (widget-get child
:custom-state
)
4043 '(modified set saved
))
4044 (widget-apply child
:custom-reset-standard
)))
4047 (defun custom-group-state-update (widget)
4049 (unless (eq (widget-get widget
:custom-state
) 'hidden
)
4050 (let* ((children (widget-get widget
:children
))
4051 (states (mapcar (lambda (child)
4052 (widget-get child
:custom-state
))
4054 (magics custom-magic-alist
)
4057 (let ((magic (car (car magics
))))
4058 (if (and (not (eq magic
'hidden
))
4059 (memq magic states
))
4062 (setq magics
(cdr magics
)))))
4063 (widget-put widget
:custom-state found
)))
4064 (custom-magic-reset widget
))
4066 ;;; Reading and writing the custom file.
4069 (defcustom custom-file nil
4070 "File used for storing customization information.
4071 The default is nil, which means to use your init file
4072 as specified by `user-init-file'. If the value is not nil,
4073 it should be an absolute file name.
4075 You can set this option through Custom, if you carefully read the
4076 last paragraph below. However, usually it is simpler to write
4077 something like the following in your init file:
4079 \(setq custom-file \"~/.emacs-custom.el\")
4082 Note that both lines are necessary: the first line tells Custom to
4083 save all customizations in this file, but does not load it.
4085 When you change this variable outside Custom, look in the
4086 previous custom file \(usually your init file) for the
4087 forms `(custom-set-variables ...)' and `(custom-set-faces ...)',
4088 and copy them (whichever ones you find) to the new custom file.
4089 This will preserve your existing customizations.
4091 If you save this option using Custom, Custom will write all
4092 currently saved customizations, including the new one for this
4093 option itself, into the file you specify, overwriting any
4094 `custom-set-variables' and `custom-set-faces' forms already
4095 present in that file. It will not delete any customizations from
4096 the old custom file. You should do that manually if that is what you
4097 want. You also have to put something like `\(load \"CUSTOM-FILE\")
4098 in your init file, where CUSTOM-FILE is the actual name of the
4099 file. Otherwise, Emacs will not load the file when it starts up,
4100 and hence will not set `custom-file' to that file either."
4101 :type
'(choice (const :tag
"Your Emacs init file" nil
)
4102 (file :format
"%t:%v%d"
4104 "Please read entire docstring below before setting \
4105 this through Custom.
4106 Click om \"More\" \(or position point there and press RETURN)
4107 if only the first line of the docstring is shown."))
4110 (defun custom-file ()
4111 "Return the file name for saving customizations."
4114 (let ((user-init-file user-init-file
)
4116 (if (eq system-type
'ms-dos
) "~/_emacs" "~/.emacs")))
4117 (when (null user-init-file
)
4118 (if (or (file-exists-p default-init-file
)
4119 (and (eq system-type
'windows-nt
)
4120 (file-exists-p "~/_emacs")))
4121 ;; Started with -q, i.e. the file containing
4122 ;; Custom settings hasn't been read. Saving
4123 ;; settings there would overwrite other settings.
4124 (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
4125 (setq user-init-file default-init-file
))
4129 (defun custom-save-all ()
4130 "Save all customizations in `custom-file'."
4131 (let* ((filename (custom-file))
4132 (recentf-exclude (if recentf-mode
4134 (regexp-quote (custom-file))
4137 (old-buffer (find-buffer-visiting filename
)))
4138 (with-current-buffer (or old-buffer
(find-file-noselect filename
))
4139 (let ((inhibit-read-only t
))
4140 (custom-save-variables)
4141 (custom-save-faces))
4142 (let ((file-precious-flag t
))
4145 (kill-buffer (current-buffer))))))
4148 (defun customize-save-customized ()
4149 "Save all user options which have been set in this session."
4151 (mapatoms (lambda (symbol)
4152 (let ((face (get symbol
'customized-face
))
4153 (value (get symbol
'customized-value
))
4154 (face-comment (get symbol
'customized-face-comment
))
4156 (get symbol
'customized-variable-comment
)))
4158 (put symbol
'saved-face face
)
4159 (custom-push-theme 'theme-face symbol
'user
'set value
)
4160 (put symbol
'customized-face nil
))
4162 (put symbol
'saved-value value
)
4163 (custom-push-theme 'theme-value symbol
'user
'set value
)
4164 (put symbol
'customized-value nil
))
4165 (when variable-comment
4166 (put symbol
'saved-variable-comment variable-comment
)
4167 (put symbol
'customized-variable-comment nil
))
4169 (put symbol
'saved-face-comment face-comment
)
4170 (put symbol
'customized-face-comment nil
)))))
4171 ;; We really should update all custom buffers here.
4174 ;; Editing the custom file contents in a buffer.
4176 (defun custom-save-delete (symbol)
4177 "Delete all calls to SYMBOL from the contents of the current buffer.
4178 Leave point at the old location of the first such call,
4179 or (if there were none) at the end of the buffer.
4181 This function does not save the buffer."
4182 (goto-char (point-min))
4183 ;; Skip all whitespace and comments.
4184 (while (forward-comment 1))
4186 (save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors.
4189 (while t
;; We exit this loop only via throw.
4190 ;; Skip all whitespace and comments.
4191 (while (forward-comment 1))
4192 (let ((start (point))
4193 (sexp (condition-case nil
4194 (read (current-buffer))
4195 (end-of-file (throw 'found nil
)))))
4196 (when (and (listp sexp
)
4197 (eq (car sexp
) symbol
))
4198 (delete-region start
(point))
4200 (setq first
(point)))))))
4203 ;; Move in front of local variables, otherwise long Custom
4204 ;; entries would make them ineffective.
4205 (let ((pos (point-max))
4206 (case-fold-search t
))
4208 (goto-char (point-max))
4209 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min))
4211 (when (search-forward "Local Variables:" nil t
)
4212 (setq pos
(line-beginning-position))))
4215 (defun custom-save-variables ()
4216 "Save all customized variables in `custom-file'."
4218 (custom-save-delete 'custom-set-variables
)
4219 (let ((standard-output (current-buffer))
4220 (saved-list (make-list 1 0))
4222 ;; First create a sorted list of saved variables.
4225 (if (and (get symbol
'saved-value
)
4226 ;; ignore theme values
4227 (or (null (get symbol
'theme-value
))
4228 (eq 'user
(caar (get symbol
'theme-value
)))))
4229 (nconc saved-list
(list symbol
)))))
4230 (setq saved-list
(sort (cdr saved-list
) 'string
<))
4233 (princ "(custom-set-variables
4234 ;; custom-set-variables was added by Custom.
4235 ;; If you edit it by hand, you could mess it up, so be careful.
4236 ;; Your init file should contain only one such instance.
4237 ;; If there is more than one, they won't work right.\n")
4238 (dolist (symbol saved-list
)
4239 (let ((spec (car-safe (get symbol
'theme-value
)))
4240 (value (get symbol
'saved-value
))
4241 (requests (get symbol
'custom-requests
))
4242 (now (not (or (custom-variable-p symbol
)
4243 (and (not (boundp symbol
))
4244 (not (eq (get symbol
'force-value
)
4246 (comment (get symbol
'saved-variable-comment
)))
4247 ;; Check `requests'.
4248 (dolist (request requests
)
4249 (when (and (symbolp request
) (not (featurep request
)))
4250 (message "Unknown requested feature: %s" request
)
4251 (setq requests
(delq request requests
))))
4252 (when (or (and spec
(eq (car spec
) 'user
))
4254 (and (null spec
) (get symbol
'saved-value
)))
4261 (when (or now requests comment
)
4264 (when (or requests comment
)
4274 (unless (looking-at "\n")
4277 (defun custom-save-faces ()
4278 "Save all customized faces in `custom-file'."
4280 (custom-save-delete 'custom-reset-faces
)
4281 (custom-save-delete 'custom-set-faces
)
4282 (let ((standard-output (current-buffer))
4283 (saved-list (make-list 1 0))
4285 ;; First create a sorted list of saved faces.
4288 (if (and (get symbol
'saved-face
)
4289 (eq 'user
(car (car-safe (get symbol
'theme-face
)))))
4290 (nconc saved-list
(list symbol
)))))
4291 (setq saved-list
(sort (cdr saved-list
) 'string
<))
4292 ;; The default face must be first, since it affects the others.
4293 (if (memq 'default saved-list
)
4294 (setq saved-list
(cons 'default
(delq 'default saved-list
))))
4297 (princ "(custom-set-faces
4298 ;; custom-set-faces was added by Custom.
4299 ;; If you edit it by hand, you could mess it up, so be careful.
4300 ;; Your init file should contain only one such instance.
4301 ;; If there is more than one, they won't work right.\n")
4302 (dolist (symbol saved-list
)
4303 (let ((spec (car-safe (get symbol
'theme-face
)))
4304 (value (get symbol
'saved-face
))
4305 (now (not (or (get symbol
'face-defface-spec
)
4306 (and (not (custom-facep symbol
))
4307 (not (get symbol
'force-face
))))))
4308 (comment (get symbol
'saved-face-comment
)))
4309 (when (or (and spec
(eq (nth 0 spec
) 'user
))
4311 (and (null spec
) (get symbol
'saved-face
)))
4312 ;; Don't print default face here.
4319 (when (or now comment
)
4329 (unless (looking-at "\n")
4332 ;;; The Customize Menu.
4336 (defcustom custom-menu-nesting
2
4337 "Maximum nesting in custom menus."
4339 :group
'custom-menu
)
4341 (defun custom-face-menu-create (widget symbol
)
4342 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
4343 (vector (custom-unlispify-menu-entry symbol
)
4344 `(customize-face ',symbol
)
4347 (defun custom-variable-menu-create (widget symbol
)
4348 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
4349 (let ((type (get symbol
'custom-type
)))
4350 (unless (listp type
)
4351 (setq type
(list type
)))
4352 (if (and type
(widget-get type
:custom-menu
))
4353 (widget-apply type
:custom-menu symbol
)
4354 (vector (custom-unlispify-menu-entry symbol
)
4355 `(customize-variable ',symbol
)
4358 ;; Add checkboxes to boolean variable entries.
4359 (widget-put (get 'boolean
'widget-type
)
4360 :custom-menu
(lambda (widget symbol
)
4361 (vector (custom-unlispify-menu-entry symbol
)
4362 `(customize-variable ',symbol
)
4364 ':selected symbol
)))
4366 (defun custom-group-menu-create (widget symbol
)
4367 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
4368 `( ,(custom-unlispify-menu-entry symbol t
)
4369 :filter
(lambda (&rest junk
)
4370 (let ((menu (custom-menu-create ',symbol
)))
4371 (if (consp menu
) (cdr menu
) menu
)))))
4374 (defun custom-menu-create (symbol)
4375 "Create menu for customization group SYMBOL.
4376 The menu is in a format applicable to `easy-menu-define'."
4377 (let* ((item (vector (custom-unlispify-menu-entry symbol
)
4378 `(customize-group ',symbol
)
4380 (if (and (or (not (boundp 'custom-menu-nesting
))
4381 (>= custom-menu-nesting
0))
4383 (custom-load-symbol symbol
)
4384 (< (length (get symbol
'custom-group
)) widget-menu-max-size
)))
4385 (let ((custom-prefix-list (custom-prefix-add symbol
4386 custom-prefix-list
))
4387 (members (custom-sort-items (get symbol
'custom-group
)
4388 custom-menu-sort-alphabetically
4389 custom-menu-order-groups
)))
4390 `(,(custom-unlispify-menu-entry symbol t
)
4393 ,@(mapcar (lambda (entry)
4394 (widget-apply (if (listp (nth 1 entry
))
4396 (list (nth 1 entry
)))
4397 :custom-menu
(nth 0 entry
)))
4402 (defun customize-menu-create (symbol &optional name
)
4403 "Return a customize menu for customization group SYMBOL.
4404 If optional NAME is given, use that as the name of the menu.
4405 Otherwise the menu will be named `Customize'.
4406 The format is suitable for use with `easy-menu-define'."
4408 (setq name
"Customize"))
4410 :filter
(lambda (&rest junk
)
4411 (let ((menu (custom-menu-create ',symbol
)))
4412 (if (consp menu
) (cdr menu
) menu
)))))
4414 ;;; The Custom Mode.
4416 (defvar custom-mode-map
4417 ;; This keymap should be dense, but a dense keymap would prevent inheriting
4418 ;; "\r" bindings from the parent map.
4419 ;; Actually, this misfeature of dense keymaps was fixed on 2001-11-26.
4420 (let ((map (make-keymap)))
4421 (set-keymap-parent map widget-keymap
)
4422 (suppress-keymap map
)
4423 (define-key map
" " 'scroll-up
)
4424 (define-key map
"\177" 'scroll-down
)
4425 (define-key map
"\C-c\C-c" 'Custom-set
)
4426 (define-key map
"\C-x\C-s" 'Custom-save
)
4427 (define-key map
"q" 'Custom-buffer-done
)
4428 (define-key map
"u" 'Custom-goto-parent
)
4429 (define-key map
"n" 'widget-forward
)
4430 (define-key map
"p" 'widget-backward
)
4432 "Keymap for `custom-mode'.")
4434 (easy-menu-define Custom-mode-menu
4436 "Menu used in customization buffers."
4438 ,(customize-menu-create 'customize
)
4439 ["Set" Custom-set t
]
4440 ["Save" Custom-save t
]
4441 ["Undo Edits" Custom-reset-current t
]
4442 ["Reset to Saved" Custom-reset-saved t
]
4443 ["Erase Customization" Custom-reset-standard t
]
4444 ["Info" (info "(emacs)Easy Customization") t
]))
4446 (defvar custom-field-keymap
4447 (let ((map (copy-keymap widget-field-keymap
)))
4448 (define-key map
"\C-c\C-c" 'Custom-set
)
4449 (define-key map
"\C-x\C-s" 'Custom-save
)
4451 "Keymap used inside editable fields in customization buffers.")
4453 (widget-put (get 'editable-field
'widget-type
) :keymap custom-field-keymap
)
4455 (defun Custom-goto-parent ()
4456 "Go to the parent group listed at the top of this buffer.
4457 If several parents are listed, go to the first of them."
4460 (goto-char (point-min))
4461 (if (search-forward "\nGo to parent group: " nil t
)
4462 (let* ((button (get-char-property (point) 'button
))
4463 (parent (downcase (widget-get button
:tag
))))
4464 (customize-group parent
)))))
4466 (defcustom custom-mode-hook nil
4467 "Hook called when entering Custom mode."
4469 :group
'custom-buffer
)
4471 (defun custom-state-buffer-message (widget)
4472 (if (eq (widget-get (widget-get widget
:parent
) :custom-state
) 'modified
)
4473 (message "To install your edits, invoke [State] and choose the Set operation")))
4475 (defun custom-mode ()
4476 "Major mode for editing customization buffers.
4478 The following commands are available:
4481 Move to next button, link or editable field. \\[widget-forward]
4482 Move to previous button, link or editable field. \\[advertised-widget-backward]
4483 \\<custom-field-keymap>\
4484 Complete content of editable text field. \\[widget-complete]
4485 \\<custom-mode-map>\
4486 Invoke button under the mouse pointer. \\[widget-button-click]
4487 Invoke button under point. \\[widget-button-press]
4488 Set all options from current text. \\[Custom-set]
4489 Make values in current text permanent. \\[Custom-save]
4490 Make text match actual option values. \\[Custom-reset-current]
4491 Reset options to permanent settings. \\[Custom-reset-saved]
4492 Erase customizations; set options
4493 and buffer text to the standard values. \\[Custom-reset-standard]
4495 Entry to this mode calls the value of `custom-mode-hook'
4496 if that value is non-nil."
4497 (kill-all-local-variables)
4498 (setq major-mode
'custom-mode
4500 (use-local-map custom-mode-map
)
4501 (easy-menu-add Custom-mode-menu
)
4502 (make-local-variable 'custom-options
)
4503 (make-local-variable 'custom-local-buffer
)
4504 (make-local-variable 'widget-documentation-face
)
4505 (setq widget-documentation-face
'custom-documentation
)
4506 (make-local-variable 'widget-button-face
)
4507 (setq widget-button-face custom-button
)
4508 (set (make-local-variable 'widget-button-pressed-face
) custom-button-pressed
)
4509 (set (make-local-variable 'widget-mouse-face
) custom-button-mouse
)
4511 ;; When possible, use relief for buttons, not bracketing. This test
4512 ;; may not be optimal.
4513 (when custom-raised-buttons
4514 (set (make-local-variable 'widget-push-button-prefix
) "")
4515 (set (make-local-variable 'widget-push-button-suffix
) "")
4516 (set (make-local-variable 'widget-link-prefix
) "")
4517 (set (make-local-variable 'widget-link-suffix
) ""))
4518 (add-hook 'widget-edit-functions
'custom-state-buffer-message nil t
)
4519 (run-mode-hooks 'custom-mode-hook
))
4521 (put 'custom-mode
'mode-class
'special
)
4524 '("^No user option defaults have been changed since Emacs "
4526 "^No \\(?:customized\\|rogue\\|saved\\) user options"
4527 "^No customizable items matching "
4528 "^There are unset changes"
4529 "^Cannot set hidden variable"
4530 "^No \\(?:saved\\|backup\\) value for "
4531 "^No standard setting known for "
4532 "^No standard setting for this face"
4533 "^Saving settings from \"emacs -q\" would overwrite existing customizations"))
4534 (add-to-list 'debug-ignored-errors regexp
))
4540 ;; arch-tag: 64533aa4-1b1a-48c3-8812-f9dc718e8a6f
4541 ;;; cus-edit.el ends here