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
593 ("-function\\'" function
)
594 ("-functions\\'" (repeat function
))
595 ("-list\\'" (repeat sexp
))
596 ("-alist\\'" (repeat (cons sexp sexp
))))
597 "Alist of (MATCH TYPE).
599 MATCH should be a regexp matching the name of a symbol, and TYPE should
600 be a widget suitable for editing the value of that symbol. The TYPE
601 of the first entry where MATCH matches the name of the symbol will be
604 This is used for guessing the type of variables not declared with
606 :type
'(repeat (group (regexp :tag
"Match") (sexp :tag
"Type")))
607 :group
'custom-buffer
)
609 (defcustom custom-guess-doc-alist
610 '(("\\`\\*?Non-nil " boolean
))
611 "Alist of (MATCH TYPE).
613 MATCH should be a regexp matching a documentation string, and TYPE
614 should be a widget suitable for editing the value of a variable with
615 that documentation string. The TYPE of the first entry where MATCH
616 matches the name of the symbol will be used.
618 This is used for guessing the type of variables not declared with
620 :type
'(repeat (group (regexp :tag
"Match") (sexp :tag
"Type")))
621 :group
'custom-buffer
)
623 (defun custom-guess-type (symbol)
624 "Guess a widget suitable for editing the value of SYMBOL.
625 This is done by matching SYMBOL with `custom-guess-name-alist' and
626 if that fails, the doc string with `custom-guess-doc-alist'."
627 (let ((name (symbol-name symbol
))
628 (names custom-guess-name-alist
)
631 (setq current
(car names
)
633 (when (string-match (nth 0 current
) name
)
634 (setq found
(nth 1 current
)
637 (let ((doc (documentation-property symbol
'variable-documentation
))
638 (docs custom-guess-doc-alist
))
641 (setq current
(car docs
)
643 (when (string-match (nth 0 current
) doc
)
644 (setq found
(nth 1 current
)
650 (defcustom custom-browse-sort-alphabetically nil
651 "If non-nil, sort members of each customization group alphabetically."
653 :group
'custom-browse
)
655 (defcustom custom-browse-order-groups nil
656 "If non-nil, order group members within each customization group.
657 If `first', order groups before non-groups.
658 If `last', order groups after non-groups."
659 :type
'(choice (const first
)
661 (const :tag
"none" nil
))
662 :group
'custom-browse
)
664 (defcustom custom-browse-only-groups nil
665 "If non-nil, show group members only within each customization group."
667 :group
'custom-browse
)
669 (defcustom custom-buffer-sort-alphabetically nil
670 "If non-nil, sort members of each customization group alphabetically."
672 :group
'custom-buffer
)
674 (defcustom custom-buffer-order-groups
'last
675 "If non-nil, order group members within each customization group.
676 If `first', order groups before non-groups.
677 If `last', order groups after non-groups."
678 :type
'(choice (const first
)
680 (const :tag
"none" nil
))
681 :group
'custom-buffer
)
683 (defcustom custom-menu-sort-alphabetically nil
684 "If non-nil, sort members of each customization group alphabetically."
688 (defcustom custom-menu-order-groups
'first
689 "If non-nil, order group members within each customization group.
690 If `first', order groups before non-groups.
691 If `last', order groups after non-groups."
692 :type
'(choice (const first
)
694 (const :tag
"none" nil
))
697 ;;;###autoload (add-hook 'same-window-regexps "\\`\\*Customiz.*\\*\\'")
699 (defun custom-sort-items (items sort-alphabetically order-groups
)
700 "Return a sorted copy of ITEMS.
701 ITEMS should be a `custom-group' property.
702 If SORT-ALPHABETICALLY non-nil, sort alphabetically.
703 If ORDER-GROUPS is `first' order groups before non-groups, if `last' order
704 groups after non-groups, if nil do not order groups at all."
705 (sort (copy-sequence items
)
707 (let ((typea (nth 1 a
)) (typeb (nth 1 b
))
708 (namea (nth 0 a
)) (nameb (nth 0 b
)))
709 (cond ((not order-groups
)
710 ;; Since we don't care about A and B order, maybe sort.
711 (when sort-alphabetically
712 (string-lessp namea nameb
)))
713 ((eq typea
'custom-group
)
714 ;; If B is also a group, maybe sort. Otherwise, order A and B.
715 (if (eq typeb
'custom-group
)
716 (when sort-alphabetically
717 (string-lessp namea nameb
))
718 (eq order-groups
'first
)))
719 ((eq typeb
'custom-group
)
720 ;; Since A cannot be a group, order A and B.
721 (eq order-groups
'last
))
723 ;; Since A and B cannot be groups, sort.
724 (string-lessp namea nameb
)))))))
726 ;;; Custom Mode Commands.
728 (defvar custom-options nil
729 "Customization widgets in the current buffer.")
732 "Set the current value of all edited settings in the buffer."
734 (let ((children custom-options
))
735 (if (or (and (= 1 (length children
))
736 (memq (widget-type (car children
))
737 '(custom-variable custom-face
)))
738 (y-or-n-p "Set all values according to this buffer? "))
739 (mapc (lambda (child)
740 (when (eq (widget-get child
:custom-state
) 'modified
)
741 (widget-apply child
:custom-set
)))
743 (message "Aborted"))))
745 (defun Custom-save ()
746 "Set all edited settings, then save all settings that have been set.
747 If a setting was edited and set before, this saves it.
748 If a setting was merely edited before, this sets it then saves it."
750 (let ((children custom-options
))
751 (if (or (and (= 1 (length children
))
752 (memq (widget-type (car children
))
753 '(custom-variable custom-face
)))
754 (yes-or-no-p "Save all settings in this buffer? "))
756 (mapc (lambda (child)
757 (when (memq (widget-get child
:custom-state
)
758 '(modified set changed rogue
))
759 (widget-apply child
:custom-save
)))
762 (message "Aborted"))))
764 (defvar custom-reset-menu
765 '(("Undo Edits" . Custom-reset-current
)
766 ("Reset to Saved" . Custom-reset-saved
)
767 ("Erase Customization (use standard values)" . Custom-reset-standard
))
768 "Alist of actions for the `Reset' button.
769 The key is a string containing the name of the action, the value is a
770 Lisp function taking the widget as an element which will be called
771 when the action is chosen.")
773 (defun custom-reset (event)
774 "Select item from reset menu."
775 (let* ((completion-ignore-case t
)
776 (answer (widget-choose "Reset settings"
782 (defun Custom-reset-current (&rest ignore
)
783 "Reset all edited settings in the buffer to show their current values."
785 (let ((children custom-options
))
786 (if (or (and (= 1 (length children
))
787 (memq (widget-type (car children
))
788 '(custom-variable custom-face
)))
789 (y-or-n-p "Reset all settings' buffer text to show current values? "))
790 (mapc (lambda (widget)
791 (if (memq (widget-get widget
:custom-state
)
793 (widget-apply widget
:custom-reset-current
)))
795 (message "Aborted"))))
797 (defun Custom-reset-saved (&rest ignore
)
798 "Reset all edited or set settings in the buffer to their saved value.
799 This also shows the saved values in the buffer."
801 (let ((children custom-options
))
802 (if (or (and (= 1 (length children
))
803 (memq (widget-type (car children
))
804 '(custom-variable custom-face
)))
805 (y-or-n-p "Reset all settings (current values and buffer text) to saved values? "))
806 (mapc (lambda (widget)
807 (if (memq (widget-get widget
:custom-state
)
808 '(modified set changed rogue
))
809 (widget-apply widget
:custom-reset-saved
)))
811 (message "Aborted"))))
813 (defun Custom-reset-standard (&rest ignore
)
814 "Erase all customization (either current or saved) for the group members.
815 The immediate result is to restore them to their standard values.
816 This operation eliminates any saved values for the group members,
817 making them as if they had never been customized at all."
819 (let ((children custom-options
))
820 (if (or (and (= 1 (length children
))
821 (memq (widget-type (car children
))
822 '(custom-variable custom-face
)))
823 (yes-or-no-p "Erase all customizations for settings in this buffer? "))
824 (mapc (lambda (widget)
825 (and (if (widget-get widget
:custom-standard-value
)
826 (widget-apply widget
:custom-standard-value
)
828 (memq (widget-get widget
:custom-state
)
829 '(modified set changed saved rogue
))
830 (widget-apply widget
:custom-reset-standard
)))
832 (message "Aborted"))))
834 ;;; The Customize Commands
836 (defun custom-prompt-variable (prompt-var prompt-val
&optional comment
)
837 "Prompt for a variable and a value and return them as a list.
838 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the
839 prompt for the value. The %s escape in PROMPT-VAL is replaced with
840 the name of the variable.
842 If the variable has a `variable-interactive' property, that is used as if
843 it were the arg to `interactive' (which see) to interactively read the value.
845 If the variable has a `custom-type' property, it must be a widget and the
846 `:prompt-value' property of that widget will be used for reading the value.
848 If optional COMMENT argument is non nil, also prompt for a comment and return
849 it as the third element in the list."
850 (let* ((var (read-variable prompt-var
))
851 (minibuffer-help-form '(describe-variable var
))
853 (let ((prop (get var
'variable-interactive
))
854 (type (get var
'custom-type
))
855 (prompt (format prompt-val var
)))
857 (setq type
(list type
)))
859 ;; Use VAR's `variable-interactive' property
860 ;; as an interactive spec for prompting.
861 (call-interactively (list 'lambda
'(arg)
862 (list 'interactive prop
)
865 (widget-prompt-value type
871 (eval-minibuffer prompt
))))))
874 (read-string "Comment: " (get var
'variable-comment
)))
878 (defun customize-set-value (variable value
&optional comment
)
879 "Set VARIABLE to VALUE, and return VALUE. VALUE is a Lisp object.
881 If VARIABLE has a `variable-interactive' property, that is used as if
882 it were the arg to `interactive' (which see) to interactively read the value.
884 If VARIABLE has a `custom-type' property, it must be a widget and the
885 `:prompt-value' property of that widget will be used for reading the value.
887 If given a prefix (or a COMMENT argument), also prompt for a comment."
888 (interactive (custom-prompt-variable "Set variable: "
892 (cond ((string= comment
"")
893 (put variable
'variable-comment nil
))
895 (put variable
'variable-comment comment
)))
896 (set variable value
))
899 (defun customize-set-variable (variable value
&optional comment
)
900 "Set the default for VARIABLE to VALUE, and return VALUE.
901 VALUE is a Lisp object.
903 If VARIABLE has a `custom-set' property, that is used for setting
904 VARIABLE, otherwise `set-default' is used.
906 The `customized-value' property of the VARIABLE will be set to a list
907 with a quoted VALUE as its sole list member.
909 If VARIABLE has a `variable-interactive' property, that is used as if
910 it were the arg to `interactive' (which see) to interactively read the value.
912 If VARIABLE has a `custom-type' property, it must be a widget and the
913 `:prompt-value' property of that widget will be used for reading the value.
915 If given a prefix (or a COMMENT argument), also prompt for a comment."
916 (interactive (custom-prompt-variable "Set variable: "
917 "Set customized value for %s to: "
919 (custom-load-symbol variable
)
920 (custom-push-theme 'theme-value variable
'user
'set
(custom-quote value
))
921 (funcall (or (get variable
'custom-set
) 'set-default
) variable value
)
922 (put variable
'customized-value
(list (custom-quote value
)))
923 (cond ((string= comment
"")
924 (put variable
'variable-comment nil
)
925 (put variable
'customized-variable-comment nil
))
927 (put variable
'variable-comment comment
)
928 (put variable
'customized-variable-comment comment
)))
932 (defun customize-save-variable (variable value
&optional comment
)
933 "Set the default for VARIABLE to VALUE, and save it for future sessions.
936 If VARIABLE has a `custom-set' property, that is used for setting
937 VARIABLE, otherwise `set-default' is used.
939 The `customized-value' property of the VARIABLE will be set to a list
940 with a quoted VALUE as its sole list member.
942 If VARIABLE has a `variable-interactive' property, that is used as if
943 it were the arg to `interactive' (which see) to interactively read the value.
945 If VARIABLE has a `custom-type' property, it must be a widget and the
946 `:prompt-value' property of that widget will be used for reading the value.
948 If given a prefix (or a COMMENT argument), also prompt for a comment."
949 (interactive (custom-prompt-variable "Set and save variable: "
950 "Set and save value for %s as: "
952 (funcall (or (get variable
'custom-set
) 'set-default
) variable value
)
953 (put variable
'saved-value
(list (custom-quote value
)))
954 (custom-push-theme 'theme-value variable
'user
'set
(custom-quote value
))
955 (cond ((string= comment
"")
956 (put variable
'variable-comment nil
)
957 (put variable
'saved-variable-comment nil
))
959 (put variable
'variable-comment comment
)
960 (put variable
'saved-variable-comment comment
)))
966 "Select a customization buffer which you can use to set user options.
967 User options are structured into \"groups\".
968 Initially the top-level group `Emacs' and its immediate subgroups
969 are shown; the contents of those subgroups are initially hidden."
971 (customize-group 'emacs
))
974 (defun customize-mode (mode)
975 "Customize options related to the current major mode.
976 If a prefix \\[universal-argument] was given (or if the current major mode has no known group),
977 then prompt for the MODE to customize."
980 (let ((completion-regexp-list '("-mode\\'"))
981 (group (custom-group-of-mode major-mode
)))
982 (if (and group
(not current-prefix-arg
))
985 (completing-read (if group
986 (format "Major mode (default %s): " major-mode
)
989 'custom-group-of-mode
990 t nil nil
(if group
(symbol-name major-mode
))))))))
991 (customize-group (custom-group-of-mode mode
)))
995 (defun customize-group (group)
996 "Customize GROUP, which must be a customization group."
998 (list (let ((completion-ignore-case t
))
999 (completing-read "Customize group (default emacs): "
1002 (or (and (get symbol
'custom-loads
)
1003 (not (get symbol
'custom-autoload
)))
1004 (get symbol
'custom-group
)))
1006 (when (stringp group
)
1007 (if (string-equal "" group
)
1009 (setq group
(intern group
))))
1010 (let ((name (format "*Customize Group: %s*"
1011 (custom-unlispify-tag-name group
))))
1012 (if (get-buffer name
)
1013 (pop-to-buffer name
)
1014 (custom-buffer-create (list (list group
'custom-group
))
1016 (concat " for group "
1017 (custom-unlispify-tag-name group
))))))
1020 (defun customize-group-other-window (group)
1021 "Customize GROUP, which must be a customization group."
1023 (list (let ((completion-ignore-case t
))
1024 (completing-read "Customize group (default emacs): "
1027 (or (and (get symbol
'custom-loads
)
1028 (not (get symbol
'custom-autoload
)))
1029 (get symbol
'custom-group
)))
1031 (when (stringp group
)
1032 (if (string-equal "" group
)
1034 (setq group
(intern group
))))
1035 (let ((name (format "*Customize Group: %s*"
1036 (custom-unlispify-tag-name group
))))
1037 (if (get-buffer name
)
1039 ;; Copied from `custom-buffer-create-other-window'.
1041 (same-window-buffer-names nil
)
1042 (same-window-regexps nil
))
1043 (pop-to-buffer name
))
1044 (custom-buffer-create-other-window
1045 (list (list group
'custom-group
))
1047 (concat " for group "
1048 (custom-unlispify-tag-name group
))))))
1051 (defalias 'customize-variable
'customize-option
)
1054 (defun customize-option (symbol)
1055 "Customize SYMBOL, which must be a user option variable."
1056 (interactive (custom-variable-prompt))
1057 (let ((basevar (indirect-variable symbol
)))
1058 (custom-buffer-create (list (list basevar
'custom-variable
))
1059 (format "*Customize Option: %s*"
1060 (custom-unlispify-tag-name basevar
)))
1061 (unless (eq symbol basevar
)
1062 (message "`%s' is an alias for `%s'" symbol basevar
))))
1065 (defalias 'customize-variable-other-window
'customize-option-other-window
)
1068 (defun customize-option-other-window (symbol)
1069 "Customize SYMBOL, which must be a user option variable.
1070 Show the buffer in another window, but don't select it."
1071 (interactive (custom-variable-prompt))
1072 (let ((basevar (indirect-variable symbol
)))
1073 (custom-buffer-create-other-window
1074 (list (list basevar
'custom-variable
))
1075 (format "*Customize Option: %s*" (custom-unlispify-tag-name basevar
)))
1076 (unless (eq symbol basevar
)
1077 (message "`%s' is an alias for `%s'" symbol basevar
))))
1079 (defvar customize-changed-options-previous-release
"21.1"
1080 "Version for `customize-changed-options' to refer back to by default.")
1082 ;; Packages will update this variable, so make it available.
1084 (defvar customize-package-emacs-version-alist nil
1085 "Alist mapping versions of Emacs to versions of a package.
1086 These package versions are listed in the :package-version
1087 keyword used in `defcustom', `defgroup', and `defface'. Its
1088 elements look like this:
1090 (PACKAGE (PVERSION . EVERSION)...)
1092 For each PACKAGE, which is a symbol, there are one or more
1093 elements that contain a package version PVERSION with an
1094 associated Emacs version EVERSION. These versions are strings.
1095 For example, the MH-E package updates this alist with the
1098 (add-to-list 'customize-package-emacs-version-alist
1099 '(MH-E (\"6.0\" . \"22.1\") (\"6.1\" . \"22.1\")
1100 (\"7.0\" . \"22.1\") (\"7.1\" . \"22.1\")
1101 (\"7.2\" . \"22.1\") (\"7.3\" . \"22.1\")
1102 (\"7.4\" . \"22.1\") (\"8.0\" . \"22.1\")))
1104 The value of PACKAGE needs to be unique and it needs to match the
1105 PACKAGE value appearing in the :package-version keyword. Since
1106 the user might see the value in a error message, a good choice is
1107 the official name of the package, such as MH-E or Gnus.")
1110 (defalias 'customize-changed
'customize-changed-options
)
1113 (defun customize-changed-options (since-version)
1114 "Customize all settings whose meanings have changed in Emacs itself.
1115 This includes new user option variables and faces, and new
1116 customization groups, as well as older options and faces whose meanings
1117 or default values have changed since the previous major Emacs release.
1119 With argument SINCE-VERSION (a string), customize all settings
1120 that were added or redefined since that version."
1124 (read-from-minibuffer
1125 (format "Customize options changed, since version (default %s): "
1126 customize-changed-options-previous-release
))))
1127 (if (equal since-version
"")
1128 (setq since-version nil
)
1129 (unless (condition-case nil
1130 (numberp (read since-version
))
1132 (signal 'wrong-type-argument
(list 'numberp since-version
))))
1133 (unless since-version
1134 (setq since-version customize-changed-options-previous-release
))
1136 ;; Load the information for versions since since-version. We use
1137 ;; custom-load-symbol for this.
1138 (put 'custom-versions-load-alist
'custom-loads nil
)
1139 (dolist (elt custom-versions-load-alist
)
1140 (if (customize-version-lessp since-version
(car elt
))
1141 (dolist (load (cdr elt
))
1142 (custom-add-load 'custom-versions-load-alist load
))))
1143 (custom-load-symbol 'custom-versions-load-alist
)
1144 (put 'custom-versions-load-alist
'custom-loads nil
)
1149 (let* ((package-version (get symbol
'custom-package-version
))
1151 (or (and package-version
1152 (customize-package-emacs-version symbol
1154 (get symbol
'custom-version
))))
1156 (when (customize-version-lessp since-version version
)
1157 (if (or (get symbol
'custom-group
)
1158 (get symbol
'group-documentation
))
1159 (push (list symbol
'custom-group
) found
))
1160 (if (custom-variable-p symbol
)
1161 (push (list symbol
'custom-variable
) found
))
1162 (if (custom-facep symbol
)
1163 (push (list symbol
'custom-face
) found
)))))))
1165 (custom-buffer-create (custom-sort-items found t
'first
)
1166 "*Customize Changed Options*")
1167 (error "No user option defaults have been changed since Emacs %s"
1170 (defun customize-package-emacs-version (symbol package-version
)
1171 "Return Emacs version of SYMBOL.
1172 PACKAGE-VERSION has the form (PACKAGE . VERSION). The VERSION of
1173 PACKAGE is looked up in the associated list
1174 `customize-package-emacs-version-alist' to find the version of
1175 Emacs that is associated with it."
1176 (let (package-versions emacs-version
)
1177 ;; Use message instead of error since we want user to be able to
1178 ;; see the rest of the symbols even if a package author has
1179 ;; botched things up.
1180 (cond ((not (listp package-version
))
1181 (message "Invalid package-version value for %s" symbol
))
1182 ((setq package-versions
(assq (car package-version
)
1183 customize-package-emacs-version-alist
))
1185 (cdr (assoc (cdr package-version
) package-versions
)))
1186 (unless emacs-version
1187 (message "%s version %s not found in %s" symbol
1188 (cdr package-version
)
1189 "customize-package-emacs-version-alist")))
1191 (message "Package %s neglected to update %s"
1192 (car package-version
)
1193 "customize-package-emacs-version-alist")))
1196 (defun customize-version-lessp (version1 version2
)
1197 ;; Why are the versions strings, and given that they are, why aren't
1198 ;; they converted to numbers and compared as such here? -- fx
1200 ;; In case someone made a mistake and left out the quotes
1201 ;; in the :version value.
1202 (if (numberp version2
)
1203 (setq version2
(prin1-to-string version2
)))
1204 (let (major1 major2 minor1 minor2
)
1205 (string-match "\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?" version1
)
1206 (setq major1
(read (or (match-string 1 version1
)
1208 (setq minor1
(read (or (match-string 3 version1
)
1210 (string-match "\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?" version2
)
1211 (setq major2
(read (or (match-string 1 version2
)
1213 (setq minor2
(read (or (match-string 3 version2
)
1215 (or (< major1 major2
)
1216 (and (= major1 major2
)
1217 (< minor1 minor2
)))))
1220 (defun customize-face (&optional face
)
1221 "Customize FACE, which should be a face name or nil.
1222 If FACE is nil, customize all faces. If FACE is actually a
1223 face-alias, customize the face it is aliased to.
1225 Interactively, when point is on text which has a face specified,
1226 suggest to customize that face, if it's customizable."
1228 (list (read-face-name "Customize face" "all faces" t
)))
1229 (if (member face
'(nil ""))
1230 (setq face
(face-list)))
1231 (if (and (listp face
) (null (cdr face
)))
1232 (setq face
(car face
)))
1234 (custom-buffer-create (custom-sort-items
1236 (list s
'custom-face
))
1239 "*Customize Faces*")
1240 ;; If FACE is actually an alias, customize the face it is aliased to.
1241 (if (get face
'face-alias
)
1242 (setq face
(get face
'face-alias
)))
1243 (unless (facep face
)
1244 (error "Invalid face %S" face
))
1245 (custom-buffer-create (list (list face
'custom-face
))
1246 (format "*Customize Face: %s*"
1247 (custom-unlispify-tag-name face
)))))
1250 (defun customize-face-other-window (&optional face
)
1251 "Show customization buffer for face FACE in other window.
1252 If FACE is actually a face-alias, customize the face it is aliased to.
1254 Interactively, when point is on text which has a face specified,
1255 suggest to customize that face, if it's customizable."
1257 (list (read-face-name "Customize face" "all faces" t
)))
1258 (if (member face
'(nil ""))
1259 (setq face
(face-list)))
1260 (if (and (listp face
) (null (cdr face
)))
1261 (setq face
(car face
)))
1263 (custom-buffer-create-other-window
1266 (list s
'custom-face
))
1269 "*Customize Faces*")
1270 (if (get face
'face-alias
)
1271 (setq face
(get face
'face-alias
)))
1272 (unless (facep face
)
1273 (error "Invalid face %S" face
))
1274 (custom-buffer-create-other-window
1275 (list (list face
'custom-face
))
1276 (format "*Customize Face: %s*"
1277 (custom-unlispify-tag-name face
)))))
1280 (defun customize-customized ()
1281 "Customize all user options set since the last save in this session."
1284 (mapatoms (lambda (symbol)
1285 (and (or (get symbol
'customized-face
)
1286 (get symbol
'customized-face-comment
))
1287 (custom-facep symbol
)
1288 (push (list symbol
'custom-face
) found
))
1289 (and (or (get symbol
'customized-value
)
1290 (get symbol
'customized-variable-comment
))
1292 (push (list symbol
'custom-variable
) found
))))
1294 (error "No customized user options")
1295 (custom-buffer-create (custom-sort-items found t nil
)
1296 "*Customize Customized*"))))
1299 (defun customize-rogue ()
1300 "Customize all user variables modified outside customize."
1303 (mapatoms (lambda (symbol)
1304 (let ((cval (or (get symbol
'customized-value
)
1305 (get symbol
'saved-value
)
1306 (get symbol
'standard-value
))))
1307 (when (and cval
;Declared with defcustom.
1308 (default-boundp symbol
) ;Has a value.
1309 (not (equal (eval (car cval
))
1310 ;; Which does not match customize.
1311 (default-value symbol
))))
1312 (push (list symbol
'custom-variable
) found
)))))
1314 (error "No rogue user options")
1315 (custom-buffer-create (custom-sort-items found t nil
)
1316 "*Customize Rogue*"))))
1318 (defun customize-saved ()
1319 "Customize all already saved user options."
1322 (mapatoms (lambda (symbol)
1323 (and (or (get symbol
'saved-face
)
1324 (get symbol
'saved-face-comment
))
1325 (custom-facep symbol
)
1326 (push (list symbol
'custom-face
) found
))
1327 (and (or (get symbol
'saved-value
)
1328 (get symbol
'saved-variable-comment
))
1330 (push (list symbol
'custom-variable
) found
))))
1332 (error "No saved user options")
1333 (custom-buffer-create (custom-sort-items found t nil
)
1334 "*Customize Saved*"))))
1337 (defun customize-apropos (regexp &optional all
)
1338 "Customize all loaded options, faces and groups matching REGEXP.
1339 If ALL is `options', include only options.
1340 If ALL is `faces', include only faces.
1341 If ALL is `groups', include only groups.
1342 If ALL is t (interactively, with prefix arg), include variables
1343 that are not customizable options, as well as faces and groups
1344 \(but we recommend using `apropos-variable' instead)."
1345 (interactive "sCustomize regexp: \nP")
1347 (mapatoms (lambda (symbol)
1348 (when (string-match regexp
(symbol-name symbol
))
1349 (when (and (not (memq all
'(faces options
)))
1350 (get symbol
'custom-group
))
1351 (push (list symbol
'custom-group
) found
))
1352 (when (and (not (memq all
'(options groups
)))
1353 (custom-facep symbol
))
1354 (push (list symbol
'custom-face
) found
))
1355 (when (and (not (memq all
'(groups faces
)))
1357 (eq (indirect-variable symbol
) symbol
)
1358 (or (get symbol
'saved-value
)
1359 (custom-variable-p symbol
)
1360 (and (not (memq all
'(nil options
)))
1361 (get symbol
'variable-documentation
))))
1362 (push (list symbol
'custom-variable
) found
)))))
1364 (error "No matches")
1365 (custom-buffer-create (custom-sort-items found t
1366 custom-buffer-order-groups
)
1367 "*Customize Apropos*"))))
1370 (defun customize-apropos-options (regexp &optional arg
)
1371 "Customize all loaded customizable options matching REGEXP.
1372 With prefix arg, include variables that are not customizable options
1373 \(but we recommend using `apropos-variable' instead)."
1374 (interactive "sCustomize regexp: \nP")
1375 (customize-apropos regexp
(or arg
'options
)))
1378 (defun customize-apropos-faces (regexp)
1379 "Customize all loaded faces matching REGEXP."
1380 (interactive "sCustomize regexp: \n")
1381 (customize-apropos regexp
'faces
))
1384 (defun customize-apropos-groups (regexp)
1385 "Customize all loaded groups matching REGEXP."
1386 (interactive "sCustomize regexp: \n")
1387 (customize-apropos regexp
'groups
))
1391 (defcustom custom-buffer-style
'links
1392 "Control the presentation style for customization buffers.
1393 The value should be a symbol, one of:
1395 brackets: groups nest within each other with big horizontal brackets.
1396 links: groups have links to subgroups."
1397 :type
'(radio (const brackets
)
1399 :group
'custom-buffer
)
1401 (defcustom custom-buffer-done-kill nil
1402 "*Non-nil means exiting a Custom buffer should kill it."
1405 :group
'custom-buffer
)
1407 (defcustom custom-buffer-indent
3
1408 "Number of spaces to indent nested groups."
1410 :group
'custom-buffer
)
1412 (defun custom-get-fresh-buffer (name)
1413 "Get a fresh new buffer with name NAME.
1414 If the buffer already exist, clean it up to be like new.
1415 Beware: it's not quite like new. Good enough for custom, but maybe
1417 ;; To be more complete, we should also kill all permanent-local variables,
1418 ;; but it's not needed for custom.
1419 (let ((buf (get-buffer name
)))
1420 (when (and buf
(buffer-local-value 'buffer-file-name buf
))
1421 ;; This will check if the file is not saved.
1425 (get-buffer-create name
)
1426 (with-current-buffer buf
1427 (kill-all-local-variables)
1428 (run-hooks 'kill-buffer-hook
)
1429 ;; Delete overlays before erasing the buffer so the overlay hooks
1430 ;; don't get run spuriously when we erase the buffer.
1431 (let ((ols (overlay-lists)))
1432 (dolist (ol (nconc (car ols
) (cdr ols
)))
1433 (delete-overlay ol
)))
1438 (defun custom-buffer-create (options &optional name description
)
1439 "Create a buffer containing OPTIONS.
1440 Optional NAME is the name of the buffer.
1441 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
1442 SYMBOL is a customization option, and WIDGET is a widget for editing
1444 (pop-to-buffer (custom-get-fresh-buffer (or name
"*Customization*")))
1445 (custom-buffer-create-internal options description
))
1448 (defun custom-buffer-create-other-window (options &optional name description
)
1449 "Create a buffer containing OPTIONS, and display it in another window.
1450 The result includes selecting that window.
1451 Optional NAME is the name of the buffer.
1452 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
1453 SYMBOL is a customization option, and WIDGET is a widget for editing
1455 (unless name
(setq name
"*Customization*"))
1456 (let ((pop-up-windows t
)
1457 (same-window-buffer-names nil
)
1458 (same-window-regexps nil
))
1459 (pop-to-buffer (custom-get-fresh-buffer name
))
1460 (custom-buffer-create-internal options description
)))
1462 (defcustom custom-reset-button-menu nil
1463 "If non-nil, only show a single reset button in customize buffers.
1464 This button will have a menu with all three reset operations."
1466 :group
'custom-buffer
)
1468 (defcustom custom-buffer-verbose-help t
1469 "If non-nil, include explanatory text in the customization buffer."
1471 :group
'custom-buffer
)
1473 (defun Custom-buffer-done (&rest ignore
)
1474 "Exit current Custom buffer according to `custom-buffer-done-kill'."
1476 (quit-window custom-buffer-done-kill
))
1478 (defvar custom-button nil
1479 "Face used for buttons in customization buffers.")
1481 (defvar custom-button-mouse nil
1482 "Mouse face used for buttons in customization buffers.")
1484 (defvar custom-button-pressed nil
1485 "Face used for pressed buttons in customization buffers.")
1487 (defcustom custom-raised-buttons
(not (equal (face-valid-attribute-values :box
)
1488 '(("unspecified" . unspecified
))))
1489 "If non-nil, indicate active buttons in a `raised-button' style.
1490 Otherwise use brackets."
1493 :group
'custom-buffer
1494 :set
(lambda (variable value
)
1495 (custom-set-default variable value
)
1497 (if value
'custom-button
'custom-button-unraised
))
1498 (setq custom-button-mouse
1499 (if value
'custom-button-mouse
'highlight
))
1500 (setq custom-button-pressed
1502 'custom-button-pressed
1503 'custom-button-pressed-unraised
))))
1505 (defun custom-buffer-create-internal (options &optional description
)
1507 (if custom-buffer-verbose-help
1509 (widget-insert "This is a customization buffer")
1511 (widget-insert description
))
1512 (widget-insert (format ".
1513 %s buttons; type RET or click mouse-1 to actuate one.
1514 Editing a setting changes only the text in the buffer.
1515 Use the setting's State button to set it or save changes in it.
1516 Saving a change normally works by editing your Emacs init file.
1518 (if custom-raised-buttons
1519 "`Raised' text indicates"
1520 "Square brackets indicate")))
1521 (widget-create 'custom-manual
1523 "(emacs)Saving Customizations")
1525 " for information on how to save in a different file.\n
1527 (widget-create 'custom-manual
1529 :help-echo
"Read the online help."
1530 "(emacs)Easy Customization")
1531 (widget-insert " for more information.\n\n")
1532 (widget-insert "Operate on all settings in this buffer that \
1533 are not marked HIDDEN:\n "))
1534 (widget-insert " "))
1535 (widget-create 'push-button
1536 :tag
"Set for Current Session"
1538 Make your editing in this buffer take effect for this session."
1539 :action
(lambda (widget &optional event
)
1541 (if (not custom-buffer-verbose-help
)
1544 (widget-create 'custom-manual
1546 :help-echo
"Read the online help."
1547 "(emacs)Easy Customization")))
1548 (when (or custom-file user-init-file
)
1550 (widget-create 'push-button
1551 :tag
"Save for Future Sessions"
1553 Make your editing in this buffer take effect for future Emacs sessions.
1554 This updates your Emacs initialization file or creates a new one."
1555 :action
(lambda (widget &optional event
)
1557 (if custom-reset-button-menu
1560 (widget-create 'push-button
1562 :help-echo
"Show a menu with reset operations."
1563 :mouse-down-action
(lambda (&rest junk
) t
)
1564 :action
(lambda (widget &optional event
)
1565 (custom-reset event
))))
1566 (widget-insert "\n ")
1567 (widget-create 'push-button
1570 Reset all edited text in this buffer to reflect current values."
1571 :action
'Custom-reset-current
)
1573 (widget-create 'push-button
1574 :tag
"Reset to Saved"
1576 Reset all settings in this buffer to their saved values."
1577 :action
'Custom-reset-saved
)
1579 (when (or custom-file user-init-file
)
1580 (widget-create 'push-button
1581 :tag
"Erase Customization"
1583 Un-customize all settings in this buffer and save them with standard values."
1584 :action
'Custom-reset-standard
)))
1586 (widget-create 'push-button
1589 (lambda (&rest ignore
)
1590 (if custom-buffer-done-kill
1592 "Bury this buffer"))
1593 :action
#'Custom-buffer-done
)
1594 (widget-insert "\n\n")
1595 (message "Creating customization items...")
1596 (buffer-disable-undo)
1597 (setq custom-options
1598 (if (= (length options
) 1)
1599 (mapcar (lambda (entry)
1600 (widget-create (nth 1 entry
)
1601 :documentation-shown t
1602 :custom-state
'unknown
1603 :tag
(custom-unlispify-tag-name
1605 :value
(nth 0 entry
)))
1608 (length (length options
)))
1609 (mapcar (lambda (entry)
1611 (message "Creating customization items ...%2d%%"
1612 (/ (* 100.0 count
) length
))
1613 (widget-create (nth 1 entry
)
1614 :tag
(custom-unlispify-tag-name
1616 :value
(nth 0 entry
))
1617 (setq count
(1+ count
))
1618 (unless (eq (preceding-char) ?
\n)
1619 (widget-insert "\n"))
1620 (widget-insert "\n")))
1622 (unless (eq (preceding-char) ?
\n)
1623 (widget-insert "\n"))
1624 (message "Creating customization items ...done")
1625 (message "Resetting customization items...")
1626 (unless (eq custom-buffer-style
'tree
)
1627 (mapc 'custom-magic-reset custom-options
))
1628 (message "Resetting customization items...done")
1629 (message "Creating customization setup...")
1631 (buffer-enable-undo)
1632 (goto-char (point-min))
1633 (message "Creating customization setup...done"))
1635 ;;; The Tree Browser.
1638 (defun customize-browse (&optional group
)
1639 "Create a tree browser for the customize hierarchy."
1642 (setq group
'emacs
))
1643 (let ((name "*Customize Browser*"))
1644 (pop-to-buffer (custom-get-fresh-buffer name
)))
1646 (widget-insert (format "\
1647 %s buttons; type RET or click mouse-1
1648 on a button to invoke its action.
1649 Invoke [+] to expand a group, and [-] to collapse an expanded group.\n"
1650 (if custom-raised-buttons
1651 "`Raised' text indicates"
1652 "Square brackets indicate")))
1655 (if custom-browse-only-groups
1657 Invoke the [Group] button below to edit that item in another window.\n\n")
1658 (widget-insert "Invoke the ")
1659 (widget-create 'item
1662 :tag-glyph
"folder")
1663 (widget-insert ", ")
1664 (widget-create 'item
1668 (widget-insert ", and ")
1669 (widget-create 'item
1672 :tag-glyph
"option")
1673 (widget-insert " buttons below to edit that
1674 item in another window.\n\n"))
1675 (let ((custom-buffer-style 'tree
))
1676 (widget-create 'custom-group
1678 :custom-state
'unknown
1679 :tag
(custom-unlispify-tag-name group
)
1682 (goto-char (point-min)))
1684 (define-widget 'custom-browse-visibility
'item
1685 "Control visibility of items in the customize tree browser."
1687 :action
'custom-browse-visibility-action
)
1689 (defun custom-browse-visibility-action (widget &rest ignore
)
1690 (let ((custom-buffer-style 'tree
))
1691 (custom-toggle-parent widget
)))
1693 (define-widget 'custom-browse-group-tag
'custom-group-link
1694 "Show parent in other window when activated."
1697 :action
'custom-browse-group-tag-action
)
1699 (defun custom-browse-group-tag-action (widget &rest ignore
)
1700 (let ((parent (widget-get widget
:parent
)))
1701 (customize-group-other-window (widget-value parent
))))
1703 (define-widget 'custom-browse-variable-tag
'custom-group-link
1704 "Show parent in other window when activated."
1707 :action
'custom-browse-variable-tag-action
)
1709 (defun custom-browse-variable-tag-action (widget &rest ignore
)
1710 (let ((parent (widget-get widget
:parent
)))
1711 (customize-variable-other-window (widget-value parent
))))
1713 (define-widget 'custom-browse-face-tag
'custom-group-link
1714 "Show parent in other window when activated."
1717 :action
'custom-browse-face-tag-action
)
1719 (defun custom-browse-face-tag-action (widget &rest ignore
)
1720 (let ((parent (widget-get widget
:parent
)))
1721 (customize-face-other-window (widget-value parent
))))
1723 (defconst custom-browse-alist
'((" " "space")
1729 (defun custom-browse-insert-prefix (prefix)
1730 "Insert PREFIX. On XEmacs convert it to line graphics."
1731 ;; Fixme: do graphics.
1732 (if nil
; (string-match "XEmacs" emacs-version)
1735 (while (not (string-equal prefix
""))
1736 (let ((entry (substring prefix
0 3)))
1737 (setq prefix
(substring prefix
3))
1738 (let ((overlay (make-overlay (1- (point)) (point) nil t nil
))
1739 (name (nth 1 (assoc entry custom-browse-alist
))))
1740 (overlay-put overlay
'end-glyph
(widget-glyph-find name entry
))
1741 (overlay-put overlay
'start-open t
)
1742 (overlay-put overlay
'end-open t
)))))
1745 ;;; Modification of Basic Widgets.
1747 ;; We add extra properties to the basic widgets needed here. This is
1748 ;; fine, as long as we are careful to stay within out own namespace.
1750 ;; We want simple widgets to be displayed by default, but complex
1751 ;; widgets to be hidden.
1753 (widget-put (get 'item
'widget-type
) :custom-show t
)
1754 (widget-put (get 'editable-field
'widget-type
)
1755 :custom-show
(lambda (widget value
)
1756 (let ((pp (pp-to-string value
)))
1757 (cond ((string-match "\n" pp
)
1762 (widget-put (get 'menu-choice
'widget-type
) :custom-show t
)
1764 ;;; The `custom-manual' Widget.
1766 (define-widget 'custom-manual
'info-link
1767 "Link to the manual entry for this customization option."
1768 :help-echo
"Read the manual entry for this option."
1769 :button-face
'custom-link
1770 :mouse-face
'highlight
1771 :pressed-face
'highlight
1774 ;;; The `custom-magic' Widget.
1776 (defgroup custom-magic-faces nil
1777 "Faces used by the magic button."
1778 :group
'custom-faces
1779 :group
'custom-buffer
)
1781 (defface custom-invalid
'((((class color
))
1782 (:foreground
"yellow1" :background
"red1"))
1784 (:weight bold
:slant italic
:underline t
)))
1785 "Face used when the customize item is invalid."
1786 :group
'custom-magic-faces
)
1787 ;; backward-compatibility alias
1788 (put 'custom-invalid-face
'face-alias
'custom-invalid
)
1790 (defface custom-rogue
'((((class color
))
1791 (:foreground
"pink" :background
"black"))
1794 "Face used when the customize item is not defined for customization."
1795 :group
'custom-magic-faces
)
1796 ;; backward-compatibility alias
1797 (put 'custom-rogue-face
'face-alias
'custom-rogue
)
1799 (defface custom-modified
'((((min-colors 88) (class color
))
1800 (:foreground
"white" :background
"blue1"))
1802 (:foreground
"white" :background
"blue"))
1804 (:slant italic
:bold
)))
1805 "Face used when the customize item has been modified."
1806 :group
'custom-magic-faces
)
1807 ;; backward-compatibility alias
1808 (put 'custom-modified-face
'face-alias
'custom-modified
)
1810 (defface custom-set
'((((min-colors 88) (class color
))
1811 (:foreground
"blue1" :background
"white"))
1813 (:foreground
"blue" :background
"white"))
1816 "Face used when the customize item has been set."
1817 :group
'custom-magic-faces
)
1818 ;; backward-compatibility alias
1819 (put 'custom-set-face
'face-alias
'custom-set
)
1821 (defface custom-changed
'((((min-colors 88) (class color
))
1822 (:foreground
"white" :background
"blue1"))
1824 (:foreground
"white" :background
"blue"))
1827 "Face used when the customize item has been changed."
1828 :group
'custom-magic-faces
)
1829 ;; backward-compatibility alias
1830 (put 'custom-changed-face
'face-alias
'custom-changed
)
1832 (defface custom-themed
'((((min-colors 88) (class color
))
1833 (:foreground
"white" :background
"blue1"))
1835 (:foreground
"white" :background
"blue"))
1838 "Face used when the customize item has been set by a theme."
1839 :group
'custom-magic-faces
)
1841 (defface custom-saved
'((t (:underline t
)))
1842 "Face used when the customize item has been saved."
1843 :group
'custom-magic-faces
)
1844 ;; backward-compatibility alias
1845 (put 'custom-saved-face
'face-alias
'custom-saved
)
1847 (defconst custom-magic-alist
1848 '((nil "#" underline
"\
1849 UNINITIALIZED, you should not see this.")
1850 (unknown "?" italic
"\
1851 UNKNOWN, you should not see this.")
1852 (hidden "-" default
"\
1853 HIDDEN, invoke \"Show\" in the previous line to show." "\
1854 group now hidden, invoke \"Show\", above, to show contents.")
1855 (invalid "x" custom-invalid
"\
1856 INVALID, the displayed value cannot be set.")
1857 (modified "*" custom-modified
"\
1858 EDITED, shown value does not take effect until you set or save it." "\
1859 something in this group has been edited but not set.")
1860 (set "+" custom-set
"\
1861 SET for current session only." "\
1862 something in this group has been set but not saved.")
1863 (changed ":" custom-changed
"\
1864 CHANGED outside Customize; operating on it here may be unreliable." "\
1865 something in this group has been changed outside customize.")
1866 (saved "!" custom-saved
"\
1868 something in this group has been set and saved.")
1869 (themed "o" custom-themed
"\
1871 visible group members are all at standard values.")
1872 (rogue "@" custom-rogue
"\
1873 NO CUSTOMIZATION DATA; not intended to be customized." "\
1874 something in this group is not prepared for customization.")
1875 (standard " " nil
"\
1877 visible group members are all at standard values."))
1878 "Alist of customize option states.
1879 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
1881 STATE is one of the following symbols:
1884 For internal use, should never occur.
1886 For internal use, should never occur.
1888 This item is not being displayed.
1890 This item is modified, but has an invalid form.
1892 This item is modified, and has a valid form.
1894 This item has been set but not saved.
1896 The current value of this item has been changed outside Customize.
1898 This item is marked for saving.
1900 This item has no customization information.
1902 This item is unchanged from the standard setting.
1904 MAGIC is a string used to present that state.
1906 FACE is a face used to present the state.
1908 ITEM-DESC is a string describing the state for options.
1910 GROUP-DESC is a string describing the state for groups. If this is
1911 left out, ITEM-DESC will be used.
1913 The string %c in either description will be replaced with the
1914 category of the item. These are `group'. `option', and `face'.
1916 The list should be sorted most significant first.")
1918 (defcustom custom-magic-show
'long
1919 "If non-nil, show textual description of the state.
1920 If `long', show a full-line description, not just one word."
1921 :type
'(choice (const :tag
"no" nil
)
1923 (other :tag
"short" short
))
1924 :group
'custom-buffer
)
1926 (defcustom custom-magic-show-hidden
'(option face
)
1927 "Control whether the State button is shown for hidden items.
1928 The value should be a list with the custom categories where the State
1929 button should be visible. Possible categories are `group', `option',
1931 :type
'(set (const group
) (const option
) (const face
))
1932 :group
'custom-buffer
)
1934 (defcustom custom-magic-show-button nil
1935 "Show a \"magic\" button indicating the state of each customization option."
1937 :group
'custom-buffer
)
1939 (define-widget 'custom-magic
'default
1940 "Show and manipulate state for a customization option."
1942 :action
'widget-parent-action
1945 :value-create
'custom-magic-value-create
1946 :value-delete
'widget-children-value-delete
)
1948 (defun widget-magic-mouse-down-action (widget &optional event
)
1949 ;; Non-nil unless hidden.
1950 (not (eq (widget-get (widget-get (widget-get widget
:parent
) :parent
)
1954 (defun custom-magic-value-create (widget)
1955 "Create compact status report for WIDGET."
1956 (let* ((parent (widget-get widget
:parent
))
1957 (state (widget-get parent
:custom-state
))
1958 (hidden (eq state
'hidden
))
1959 (entry (assq state custom-magic-alist
))
1960 (magic (nth 1 entry
))
1961 (face (nth 2 entry
))
1962 (category (widget-get parent
:custom-category
))
1963 (text (or (and (eq category
'group
)
1966 (form (widget-get parent
:custom-form
))
1968 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text
)
1969 (setq text
(concat (match-string 1 text
)
1970 (symbol-name category
)
1971 (match-string 2 text
))))
1972 (when (and custom-magic-show
1974 (memq category custom-magic-show-hidden
)))
1976 (when (and (eq category
'group
)
1977 (not (and (eq custom-buffer-style
'links
)
1978 (> (widget-get parent
:custom-level
) 1))))
1979 (insert-char ?\
(* custom-buffer-indent
1980 (widget-get parent
:custom-level
))))
1981 (push (widget-create-child-and-convert
1983 :help-echo
"Change the state of this item."
1984 :format
(if hidden
"%t" "%[%t%]")
1985 :button-prefix
'widget-push-button-prefix
1986 :button-suffix
'widget-push-button-suffix
1987 :mouse-down-action
'widget-magic-mouse-down-action
1991 (let ((start (point)))
1992 (if (eq custom-magic-show
'long
)
1994 (insert (symbol-name state
)))
1995 (cond ((eq form
'lisp
)
1997 ((eq form
'mismatch
)
1998 (insert " (mismatch)")))
1999 (put-text-property start
(point) 'face
'custom-state
))
2001 (when (and (eq category
'group
)
2002 (not (and (eq custom-buffer-style
'links
)
2003 (> (widget-get parent
:custom-level
) 1))))
2004 (insert-char ?\
(* custom-buffer-indent
2005 (widget-get parent
:custom-level
))))
2006 (when custom-magic-show-button
2007 (when custom-magic-show
2008 (let ((indent (widget-get parent
:indent
)))
2010 (insert-char ? indent
))))
2011 (push (widget-create-child-and-convert
2013 :mouse-down-action
'widget-magic-mouse-down-action
2017 :help-echo
"Change the state."
2018 :format
(if hidden
"%t" "%[%t%]")
2019 :tag
(if (memq form
'(lisp mismatch
))
2020 (concat "(" magic
")")
2021 (concat "[" magic
"]")))
2024 (widget-put widget
:children children
)))
2026 (defun custom-magic-reset (widget)
2027 "Redraw the :custom-magic property of WIDGET."
2028 (let ((magic (widget-get widget
:custom-magic
)))
2029 (widget-value-set magic
(widget-value magic
))))
2031 ;;; The `custom' Widget.
2033 (defface custom-button
2034 '((((type x w32 mac
) (class color
)) ; Like default modeline
2035 (:box
(:line-width
2 :style released-button
)
2036 :background
"lightgrey" :foreground
"black"))
2039 "Face for custom buffer buttons if `custom-raised-buttons' is non-nil."
2041 :group
'custom-faces
)
2042 ;; backward-compatibility alias
2043 (put 'custom-button-face
'face-alias
'custom-button
)
2045 (defface custom-button-mouse
2046 '((((type x w32 mac
) (class color
))
2047 (:box
(:line-width
2 :style released-button
)
2048 :background
"grey90" :foreground
"black"))
2051 "Mouse face for custom buffer buttons if `custom-raised-buttons' is non-nil."
2053 :group
'custom-faces
)
2055 (defface custom-button-unraised
2056 '((t :inherit underline
))
2057 "Face for custom buffer buttons if `custom-raised-buttons' is nil."
2059 :group
'custom-faces
)
2062 (if custom-raised-buttons
'custom-button
'custom-button-unraised
))
2064 (setq custom-button-mouse
2065 (if custom-raised-buttons
'custom-button-mouse
'highlight
))
2067 (defface custom-button-pressed
2068 '((((type x w32 mac
) (class color
))
2069 (:box
(:line-width
2 :style pressed-button
)
2070 :background
"lightgrey" :foreground
"black"))
2072 (:inverse-video t
)))
2073 "Face for pressed custom buttons if `custom-raised-buttons' is non-nil."
2075 :group
'custom-faces
)
2076 ;; backward-compatibility alias
2077 (put 'custom-button-pressed-face
'face-alias
'custom-button-pressed
)
2079 (defface custom-button-pressed-unraised
2080 '((default :inherit custom-button-unraised
)
2081 (((class color
) (background light
)) :foreground
"magenta4")
2082 (((class color
) (background dark
)) :foreground
"violet"))
2083 "Face for pressed custom buttons if `custom-raised-buttons' is nil."
2085 :group
'custom-faces
)
2087 (setq custom-button-pressed
2088 (if custom-raised-buttons
2089 'custom-button-pressed
2090 'custom-button-pressed-unraised
))
2092 (defface custom-documentation
'((t nil
))
2093 "Face used for documentation strings in customization buffers."
2094 :group
'custom-faces
)
2095 ;; backward-compatibility alias
2096 (put 'custom-documentation-face
'face-alias
'custom-documentation
)
2098 (defface custom-state
'((((class color
)
2100 (:foreground
"lime green"))
2103 (:foreground
"dark green"))
2105 "Face used for State descriptions in the customize buffer."
2106 :group
'custom-faces
)
2107 ;; backward-compatibility alias
2108 (put 'custom-state-face
'face-alias
'custom-state
)
2110 (defface custom-link
2111 '((t :inherit link
))
2112 "Face for links in customization buffers."
2114 :group
'custom-faces
)
2116 (define-widget 'custom
'default
2117 "Customize a user option."
2119 :convert-widget
'custom-convert-widget
2120 :notify
'custom-notify
2123 :custom-state
'hidden
2124 :documentation-property
'widget-subclass-responsibility
2125 :value-create
'widget-subclass-responsibility
2126 :value-delete
'widget-children-value-delete
2127 :value-get
'widget-value-value-get
2128 :validate
'widget-children-validate
2129 :match
(lambda (widget value
) (symbolp value
)))
2131 (defun custom-convert-widget (widget)
2132 "Initialize :value and :tag from :args in WIDGET."
2133 (let ((args (widget-get widget
:args
)))
2135 (widget-put widget
:value
(widget-apply widget
2136 :value-to-internal
(car args
)))
2137 (widget-put widget
:tag
(custom-unlispify-tag-name (car args
)))
2138 (widget-put widget
:args nil
)))
2141 (defun custom-notify (widget &rest args
)
2142 "Keep track of changes."
2143 (let ((state (widget-get widget
:custom-state
)))
2144 (unless (eq state
'modified
)
2145 (unless (memq state
'(nil unknown hidden
))
2146 (widget-put widget
:custom-state
'modified
))
2147 (custom-magic-reset widget
)
2148 (apply 'widget-default-notify widget args
))))
2150 (defun custom-redraw (widget)
2151 "Redraw WIDGET with current settings."
2152 (let ((line (count-lines (point-min) (point)))
2153 (column (current-column))
2155 (from (marker-position (widget-get widget
:from
)))
2156 (to (marker-position (widget-get widget
:to
))))
2158 (widget-value-set widget
(widget-value widget
))
2159 (custom-redraw-magic widget
))
2160 (when (and (>= pos from
) (<= pos to
))
2165 (goto-line (1+ line
)))
2166 (move-to-column column
))
2169 (defun custom-redraw-magic (widget)
2170 "Redraw WIDGET state with current settings."
2172 (let ((magic (widget-get widget
:custom-magic
)))
2174 (widget-value-set magic
(widget-value magic
))
2175 (when (setq widget
(widget-get widget
:group
))
2176 (custom-group-state-update widget
)))
2178 (setq widget nil
)))))
2181 (defun custom-show (widget value
)
2182 "Non-nil if WIDGET should be shown with VALUE by default."
2183 (let ((show (widget-get widget
:custom-show
)))
2189 (funcall show widget value
)))))
2191 (defun custom-load-widget (widget)
2192 "Load all dependencies for WIDGET."
2193 (custom-load-symbol (widget-value widget
)))
2195 (defun custom-unloaded-symbol-p (symbol)
2196 "Return non-nil if the dependencies of SYMBOL have not yet been loaded."
2198 (loads (get symbol
'custom-loads
))
2201 (setq load
(car loads
)
2203 (cond ((symbolp load
)
2204 (unless (featurep load
)
2206 ((assoc load load-history
))
2207 ((assoc (locate-library load
) load-history
)
2213 (defun custom-unloaded-widget-p (widget)
2214 "Return non-nil if the dependencies of WIDGET have not yet been loaded."
2215 (custom-unloaded-symbol-p (widget-value widget
)))
2217 (defun custom-toggle-hide (widget)
2218 "Toggle visibility of WIDGET."
2219 (custom-load-widget widget
)
2220 (let ((state (widget-get widget
:custom-state
)))
2221 (cond ((memq state
'(invalid modified
))
2222 (error "There are unset changes"))
2224 (widget-put widget
:custom-state
'unknown
))
2226 (widget-put widget
:documentation-shown nil
)
2227 (widget-put widget
:custom-state
'hidden
)))
2228 (custom-redraw widget
)
2231 (defun custom-toggle-parent (widget &rest ignore
)
2232 "Toggle visibility of parent of WIDGET."
2233 (custom-toggle-hide (widget-get widget
:parent
)))
2235 (defun custom-add-see-also (widget &optional prefix
)
2236 "Add `See also ...' to WIDGET if there are any links.
2237 Insert PREFIX first if non-nil."
2238 (let* ((symbol (widget-get widget
:value
))
2239 (links (get symbol
'custom-links
))
2240 (many (> (length links
) 2))
2241 (buttons (widget-get widget
:buttons
))
2242 (indent (widget-get widget
:indent
)))
2245 (insert-char ?\ indent
))
2248 (insert "See also ")
2250 (push (widget-create-child-and-convert
2252 :button-face
'custom-link
2253 :mouse-face
'highlight
2254 :pressed-face
'highlight
)
2256 (setq links
(cdr links
))
2265 (widget-put widget
:buttons buttons
))))
2267 (defun custom-add-parent-links (widget &optional initial-string
)
2268 "Add \"Parent groups: ...\" to WIDGET if the group has parents.
2269 The value is non-nil if any parents were found.
2270 If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
2271 (let ((name (widget-value widget
))
2272 (type (widget-type widget
))
2273 (buttons (widget-get widget
:buttons
))
2276 (insert (or initial-string
"Parent groups:"))
2277 (mapatoms (lambda (symbol)
2278 (when (member (list name type
) (get symbol
'custom-group
))
2280 (push (widget-create-child-and-convert
2281 widget
'custom-group-link
2282 :tag
(custom-unlispify-tag-name symbol
)
2285 (setq parents
(cons symbol parents
)))))
2286 (and (null (get name
'custom-links
)) ;No links of its own.
2287 (= (length parents
) 1) ;A single parent.
2288 (let* ((links (delq nil
(mapcar (lambda (w)
2289 (unless (eq (widget-type w
)
2292 (get (car parents
) 'custom-links
))))
2293 (many (> (length links
) 2)))
2295 (insert "\nParent documentation: ")
2297 (push (widget-create-child-and-convert
2299 :button-face
'custom-link
2300 :mouse-face
'highlight
2301 :pressed-face
'highlight
)
2303 (setq links
(cdr links
))
2314 (delete-region start
(point)))
2315 (widget-put widget
:buttons buttons
)
2318 ;;; The `custom-comment' Widget.
2320 ;; like the editable field
2321 (defface custom-comment
'((((type tty
))
2322 :background
"yellow3"
2323 :foreground
"black")
2324 (((class grayscale color
)
2326 :background
"gray85")
2327 (((class grayscale color
)
2329 :background
"dim gray")
2332 "Face used for comments on variables or faces"
2334 :group
'custom-faces
)
2335 ;; backward-compatibility alias
2336 (put 'custom-comment-face
'face-alias
'custom-comment
)
2338 ;; like font-lock-comment-face
2339 (defface custom-comment-tag
2340 '((((class color
) (background dark
)) (:foreground
"gray80"))
2341 (((class color
) (background light
)) (:foreground
"blue4"))
2342 (((class grayscale
) (background light
))
2343 (:foreground
"DimGray" :weight bold
:slant italic
))
2344 (((class grayscale
) (background dark
))
2345 (:foreground
"LightGray" :weight bold
:slant italic
))
2347 "Face used for variables or faces comment tags"
2348 :group
'custom-faces
)
2349 ;; backward-compatibility alias
2350 (put 'custom-comment-tag-face
'face-alias
'custom-comment-tag
)
2352 (define-widget 'custom-comment
'string
2355 :help-echo
"Edit a comment here."
2356 :sample-face
'custom-comment-tag-face
2357 :value-face
'custom-comment-face
2359 :create
'custom-comment-create
)
2361 (defun custom-comment-create (widget)
2362 (let* ((null-comment (equal "" (widget-value widget
))))
2363 (if (or (widget-get (widget-get widget
:parent
) :comment-shown
)
2365 (widget-default-create widget
)
2366 ;; `widget-default-delete' expects markers in these slots --
2367 ;; maybe it shouldn't.
2368 (widget-put widget
:from
(point-marker))
2369 (widget-put widget
:to
(point-marker)))))
2371 (defun custom-comment-hide (widget)
2372 (widget-put (widget-get widget
:parent
) :comment-shown nil
))
2374 ;; Those functions are for the menu. WIDGET is NOT the comment widget. It's
2375 ;; the global custom one
2376 (defun custom-comment-show (widget)
2377 (widget-put widget
:comment-shown t
)
2378 (custom-redraw widget
)
2381 (defun custom-comment-invisible-p (widget)
2382 (let ((val (widget-value (widget-get widget
:comment-widget
))))
2384 (not (widget-get widget
:comment-shown
)))))
2386 ;;; The `custom-variable' Widget.
2388 ;; When this was underlined blue, users confused it with a
2389 ;; Mosaic-style hyperlink...
2390 (defface custom-variable-tag
2393 (:foreground
"light blue" :weight bold
:height
1.2 :inherit variable-pitch
))
2394 (((min-colors 88) (class color
)
2396 (:foreground
"blue1" :weight bold
:height
1.2 :inherit variable-pitch
))
2399 (:foreground
"blue" :weight bold
:height
1.2 :inherit variable-pitch
))
2401 "Face used for unpushable variable tags."
2402 :group
'custom-faces
)
2403 ;; backward-compatibility alias
2404 (put 'custom-variable-tag-face
'face-alias
'custom-variable-tag
)
2406 (defface custom-variable-button
'((t (:underline t
:weight bold
)))
2407 "Face used for pushable variable tags."
2408 :group
'custom-faces
)
2409 ;; backward-compatibility alias
2410 (put 'custom-variable-button-face
'face-alias
'custom-variable-button
)
2412 (defcustom custom-variable-default-form
'edit
2413 "Default form of displaying variable values."
2414 :type
'(choice (const edit
)
2416 :group
'custom-buffer
2419 (defun custom-variable-documentation (variable)
2420 "Return documentation of VARIABLE for use in Custom buffer.
2421 Normally just return the docstring. But if VARIABLE automatically
2422 becomes buffer local when set, append a message to that effect."
2423 (if (and (local-variable-if-set-p variable
)
2424 (or (not (local-variable-p variable
))
2426 (local-variable-if-set-p variable
))))
2427 (concat (documentation-property variable
'variable-documentation
)
2429 This variable automatically becomes buffer-local when set outside Custom.
2430 However, setting it through Custom sets the default value.")
2431 (documentation-property variable
'variable-documentation
)))
2433 (define-widget 'custom-variable
'custom
2434 "Customize variable."
2436 :help-echo
"Set or reset this variable."
2437 :documentation-property
#'custom-variable-documentation
2438 :custom-category
'option
2440 :custom-menu
'custom-variable-menu-create
2441 :custom-form nil
; defaults to value of `custom-variable-default-form'
2442 :value-create
'custom-variable-value-create
2443 :action
'custom-variable-action
2444 :custom-set
'custom-variable-set
2445 :custom-save
'custom-variable-save
2446 :custom-reset-current
'custom-redraw
2447 :custom-reset-saved
'custom-variable-reset-saved
2448 :custom-reset-standard
'custom-variable-reset-standard
2449 :custom-standard-value
'custom-variable-standard-value
)
2451 (defun custom-variable-type (symbol)
2452 "Return a widget suitable for editing the value of SYMBOL.
2453 If SYMBOL has a `custom-type' property, use that.
2454 Otherwise, look up symbol in `custom-guess-type-alist'."
2455 (let* ((type (or (get symbol
'custom-type
)
2456 (and (not (get symbol
'standard-value
))
2457 (custom-guess-type symbol
))
2459 (options (get symbol
'custom-options
))
2460 (tmp (if (listp type
)
2461 (copy-sequence type
)
2464 (widget-put tmp
:options options
))
2467 (defun custom-variable-value-create (widget)
2468 "Here is where you edit the variable's value."
2469 (custom-load-widget widget
)
2470 (unless (widget-get widget
:custom-form
)
2471 (widget-put widget
:custom-form custom-variable-default-form
))
2472 (let* ((buttons (widget-get widget
:buttons
))
2473 (children (widget-get widget
:children
))
2474 (form (widget-get widget
:custom-form
))
2475 (state (widget-get widget
:custom-state
))
2476 (symbol (widget-get widget
:value
))
2477 (tag (widget-get widget
:tag
))
2478 (type (custom-variable-type symbol
))
2479 (conv (widget-convert type
))
2480 (get (or (get symbol
'custom-get
) 'default-value
))
2481 (prefix (widget-get widget
:custom-prefix
))
2482 (last (widget-get widget
:custom-last
))
2483 (value (if (default-boundp symbol
)
2484 (funcall get symbol
)
2485 (widget-get conv
:value
))))
2486 ;; If the widget is new, the child determines whether it is hidden.
2488 ((custom-show type value
)
2489 (setq state
'unknown
))
2491 (setq state
'hidden
)))
2492 ;; If we don't know the state, see if we need to edit it in lisp form.
2493 (when (eq state
'unknown
)
2494 (unless (widget-apply conv
:match value
)
2495 ;; (widget-apply (widget-convert type) :match value)
2496 (setq form
'mismatch
)))
2497 ;; Now we can create the child widget.
2498 (cond ((eq custom-buffer-style
'tree
)
2499 (insert prefix
(if last
" `--- " " |--- "))
2500 (push (widget-create-child-and-convert
2501 widget
'custom-browse-variable-tag
)
2503 (insert " " tag
"\n")
2504 (widget-put widget
:buttons buttons
))
2506 ;; Indicate hidden value.
2507 (push (widget-create-child-and-convert
2510 :sample-face
'custom-variable-tag-face
2514 (push (widget-create-child-and-convert
2516 :help-echo
"Show the value of this option."
2518 :action
'custom-toggle-parent
2521 ((memq form
'(lisp mismatch
))
2522 ;; In lisp mode edit the saved value when possible.
2523 (let* ((value (cond ((get symbol
'saved-value
)
2524 (car (get symbol
'saved-value
)))
2525 ((get symbol
'standard-value
)
2526 (car (get symbol
'standard-value
)))
2527 ((default-boundp symbol
)
2528 (custom-quote (funcall get symbol
)))
2530 (custom-quote (widget-get conv
:value
))))))
2531 (insert (symbol-name symbol
) ": ")
2532 (push (widget-create-child-and-convert
2534 :help-echo
"Hide the value of this option."
2537 :action
'custom-toggle-parent
2541 (push (widget-create-child-and-convert
2543 :button-face
'custom-variable-button-face
2545 :tag
(symbol-name symbol
)
2551 (let* ((format (widget-get type
:format
))
2552 tag-format value-format
)
2553 (unless (string-match ":" format
)
2554 (error "Bad format"))
2555 (setq tag-format
(substring format
0 (match-end 0)))
2556 (setq value-format
(substring format
(match-end 0)))
2557 (push (widget-create-child-and-convert
2560 :action
'custom-tag-action
2561 :help-echo
"Change value of this option."
2562 :mouse-down-action
'custom-tag-mouse-down-action
2563 :button-face
'custom-variable-button-face
2564 :sample-face
'custom-variable-tag-face
2568 (push (widget-create-child-and-convert
2570 :help-echo
"Hide the value of this option."
2573 :action
'custom-toggle-parent
2576 (push (widget-create-child-and-convert
2578 :format value-format
2581 (unless (eq custom-buffer-style
'tree
)
2582 (unless (eq (preceding-char) ?
\n)
2583 (widget-insert "\n"))
2584 ;; Create the magic button.
2585 (let ((magic (widget-create-child-and-convert
2586 widget
'custom-magic nil
)))
2587 (widget-put widget
:custom-magic magic
)
2588 (push magic buttons
))
2589 ;; ### NOTE: this is ugly!!!! I need to update the :buttons property
2590 ;; before the call to `widget-default-format-handler'. Otherwise, I
2591 ;; loose my current `buttons'. This function shouldn't be called like
2592 ;; this anyway. The doc string widget should be added like the others.
2594 (widget-put widget
:buttons buttons
)
2596 ;; Insert documentation.
2597 (widget-default-format-handler widget ?h
)
2599 ;; The comment field
2600 (unless (eq state
'hidden
)
2601 (let* ((comment (get symbol
'variable-comment
))
2603 (widget-create-child-and-convert
2604 widget
'custom-comment
2606 :value
(or comment
""))))
2607 (widget-put widget
:comment-widget comment-widget
)
2608 ;; Don't push it !!! Custom assumes that the first child is the
2610 (setq children
(append children
(list comment-widget
)))))
2611 ;; Update the rest of the properties properties.
2612 (widget-put widget
:custom-form form
)
2613 (widget-put widget
:children children
)
2614 ;; Now update the state.
2615 (if (eq state
'hidden
)
2616 (widget-put widget
:custom-state state
)
2617 (custom-variable-state-set widget
))
2619 (unless (eq state
'hidden
)
2620 (when (eq (widget-get widget
:custom-level
) 1)
2621 (custom-add-parent-links widget
))
2622 (custom-add-see-also widget
)))))
2624 (defun custom-tag-action (widget &rest args
)
2625 "Pass :action to first child of WIDGET's parent."
2626 (apply 'widget-apply
(car (widget-get (widget-get widget
:parent
) :children
))
2629 (defun custom-tag-mouse-down-action (widget &rest args
)
2630 "Pass :mouse-down-action to first child of WIDGET's parent."
2631 (apply 'widget-apply
(car (widget-get (widget-get widget
:parent
) :children
))
2632 :mouse-down-action args
))
2634 (defun custom-variable-state-set (widget)
2635 "Set the state of WIDGET."
2636 (let* ((symbol (widget-value widget
))
2637 (get (or (get symbol
'custom-get
) 'default-value
))
2638 (value (if (default-boundp symbol
)
2639 (funcall get symbol
)
2640 (widget-get widget
:value
)))
2641 (comment (get symbol
'variable-comment
))
2644 (state (cond ((progn (setq tmp
(get symbol
'customized-value
))
2646 (get symbol
'customized-variable-comment
))
2648 (if (condition-case nil
2649 (and (equal value
(eval (car tmp
)))
2650 (equal comment temp
))
2654 ((progn (setq tmp
(get symbol
'theme-value
))
2655 (setq temp
(get symbol
'saved-variable-comment
))
2657 (if (condition-case nil
2658 (and (equal comment temp
)
2661 (car (custom-variable-theme-value
2665 ((eq (caar tmp
) 'user
) 'saved
)
2666 ((eq (caar tmp
) 'changed
) 'changed
)
2669 ((setq tmp
(get symbol
'standard-value
))
2670 (if (condition-case nil
2671 (and (equal value
(eval (car tmp
)))
2672 (equal comment nil
))
2677 (widget-put widget
:custom-state state
)))
2679 (defun custom-variable-standard-value (widget)
2680 (get (widget-value widget
) 'standard-value
))
2682 (defvar custom-variable-menu
2683 `(("Set for Current Session" custom-variable-set
2685 (eq (widget-get widget
:custom-state
) 'modified
)))
2686 ,@(when (or custom-file user-init-file
)
2687 '(("Save for Future Sessions" custom-variable-save
2689 (memq (widget-get widget
:custom-state
)
2690 '(modified set changed rogue
))))))
2691 ("Undo Edits" custom-redraw
2693 (and (default-boundp (widget-value widget
))
2694 (memq (widget-get widget
:custom-state
) '(modified changed
)))))
2695 ("Reset to Saved" custom-variable-reset-saved
2697 (and (or (get (widget-value widget
) 'saved-value
)
2698 (get (widget-value widget
) 'saved-variable-comment
))
2699 (memq (widget-get widget
:custom-state
)
2700 '(modified set changed rogue
)))))
2701 ,@(when (or custom-file user-init-file
)
2702 '(("Erase Customization" custom-variable-reset-standard
2704 (and (get (widget-value widget
) 'standard-value
)
2705 (memq (widget-get widget
:custom-state
)
2706 '(modified set changed saved rogue
)))))))
2707 ("Set to Backup Value" custom-variable-reset-backup
2709 (get (widget-value widget
) 'backup-value
)))
2710 ("---" ignore ignore
)
2711 ("Add Comment" custom-comment-show custom-comment-invisible-p
)
2712 ("---" ignore ignore
)
2713 ("Show Current Value" custom-variable-edit
2715 (eq (widget-get widget
:custom-form
) 'lisp
)))
2716 ("Show Saved Lisp Expression" custom-variable-edit-lisp
2718 (eq (widget-get widget
:custom-form
) 'edit
))))
2719 "Alist of actions for the `custom-variable' widget.
2720 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
2721 the menu entry, ACTION is the function to call on the widget when the
2722 menu is selected, and FILTER is a predicate which takes a `custom-variable'
2723 widget as an argument, and returns non-nil if ACTION is valid on that
2724 widget. If FILTER is nil, ACTION is always valid.")
2726 (defun custom-variable-action (widget &optional event
)
2727 "Show the menu for `custom-variable' WIDGET.
2728 Optional EVENT is the location for the menu."
2729 (if (eq (widget-get widget
:custom-state
) 'hidden
)
2730 (custom-toggle-hide widget
)
2731 (unless (eq (widget-get widget
:custom-state
) 'modified
)
2732 (custom-variable-state-set widget
))
2733 (custom-redraw-magic widget
)
2734 (let* ((completion-ignore-case t
)
2735 (answer (widget-choose (concat "Operation on "
2736 (custom-unlispify-tag-name
2737 (widget-get widget
:value
)))
2738 (custom-menu-filter custom-variable-menu
2742 (funcall answer widget
)))))
2744 (defun custom-variable-edit (widget)
2745 "Edit value of WIDGET."
2746 (widget-put widget
:custom-state
'unknown
)
2747 (widget-put widget
:custom-form
'edit
)
2748 (custom-redraw widget
))
2750 (defun custom-variable-edit-lisp (widget)
2751 "Edit the Lisp representation of the value of WIDGET."
2752 (widget-put widget
:custom-state
'unknown
)
2753 (widget-put widget
:custom-form
'lisp
)
2754 (custom-redraw widget
))
2756 (defun custom-variable-set (widget)
2757 "Set the current value for the variable being edited by WIDGET."
2758 (let* ((form (widget-get widget
:custom-form
))
2759 (state (widget-get widget
:custom-state
))
2760 (child (car (widget-get widget
:children
)))
2761 (symbol (widget-value widget
))
2762 (set (or (get symbol
'custom-set
) 'set-default
))
2763 (comment-widget (widget-get widget
:comment-widget
))
2764 (comment (widget-value comment-widget
))
2766 (cond ((eq state
'hidden
)
2767 (error "Cannot set hidden variable"))
2768 ((setq val
(widget-apply child
:validate
))
2769 (goto-char (widget-get val
:from
))
2770 (error "%s" (widget-get val
:error
)))
2771 ((memq form
'(lisp mismatch
))
2772 (when (equal comment
"")
2774 ;; Make the comment invisible by hand if it's empty
2775 (custom-comment-hide comment-widget
))
2776 (custom-variable-backup-value widget
)
2777 (custom-push-theme 'theme-value symbol
'user
2778 'set
(custom-quote (widget-value child
)))
2779 (funcall set symbol
(eval (setq val
(widget-value child
))))
2780 (put symbol
'customized-value
(list val
))
2781 (put symbol
'variable-comment comment
)
2782 (put symbol
'customized-variable-comment comment
))
2784 (when (equal comment
"")
2786 ;; Make the comment invisible by hand if it's empty
2787 (custom-comment-hide comment-widget
))
2788 (custom-variable-backup-value widget
)
2789 (custom-push-theme 'theme-value symbol
'user
2790 'set
(custom-quote (widget-value child
)))
2791 (funcall set symbol
(setq val
(widget-value child
)))
2792 (put symbol
'customized-value
(list (custom-quote val
)))
2793 (put symbol
'variable-comment comment
)
2794 (put symbol
'customized-variable-comment comment
)))
2795 (custom-variable-state-set widget
)
2796 (custom-redraw-magic widget
)))
2798 (defun custom-variable-save (widget)
2799 "Set and save the value for the variable being edited by WIDGET."
2800 (let* ((form (widget-get widget
:custom-form
))
2801 (state (widget-get widget
:custom-state
))
2802 (child (car (widget-get widget
:children
)))
2803 (symbol (widget-value widget
))
2804 (set (or (get symbol
'custom-set
) 'set-default
))
2805 (comment-widget (widget-get widget
:comment-widget
))
2806 (comment (widget-value comment-widget
))
2808 (cond ((eq state
'hidden
)
2809 (error "Cannot set hidden variable"))
2810 ((setq val
(widget-apply child
:validate
))
2811 (goto-char (widget-get val
:from
))
2812 (error "Saving %s: %s" symbol
(widget-get val
:error
)))
2813 ((memq form
'(lisp mismatch
))
2814 (when (equal comment
"")
2816 ;; Make the comment invisible by hand if it's empty
2817 (custom-comment-hide comment-widget
))
2818 (put symbol
'saved-value
(list (widget-value child
)))
2819 (custom-push-theme 'theme-value symbol
'user
2820 'set
(custom-quote (widget-value child
)))
2821 (funcall set symbol
(eval (widget-value child
)))
2822 (put symbol
'variable-comment comment
)
2823 (put symbol
'saved-variable-comment comment
))
2825 (when (equal comment
"")
2827 ;; Make the comment invisible by hand if it's empty
2828 (custom-comment-hide comment-widget
))
2829 (put symbol
'saved-value
2830 (list (custom-quote (widget-value child
))))
2831 (custom-push-theme 'theme-value symbol
'user
2832 'set
(custom-quote (widget-value child
)))
2833 (funcall set symbol
(widget-value child
))
2834 (put symbol
'variable-comment comment
)
2835 (put symbol
'saved-variable-comment comment
)))
2836 (put symbol
'customized-value nil
)
2837 (put symbol
'customized-variable-comment nil
)
2839 (custom-variable-state-set widget
)
2840 (custom-redraw-magic widget
)))
2842 (defun custom-variable-reset-saved (widget)
2843 "Restore the saved value for the variable being edited by WIDGET.
2844 This also updates the buffer to show that value.
2845 The value that was current before this operation
2846 becomes the backup value, so you can get it again."
2847 (let* ((symbol (widget-value widget
))
2848 (set (or (get symbol
'custom-set
) 'set-default
))
2849 (value (get symbol
'saved-value
))
2850 (comment (get symbol
'saved-variable-comment
)))
2851 (cond ((or value comment
)
2852 (put symbol
'variable-comment comment
)
2853 (custom-variable-backup-value widget
)
2854 (custom-push-theme 'theme-value symbol
'user
'set
(car-safe value
))
2856 (funcall set symbol
(eval (car value
)))
2859 (error "No saved value for %s" symbol
)))
2860 (put symbol
'customized-value nil
)
2861 (put symbol
'customized-variable-comment nil
)
2862 (widget-put widget
:custom-state
'unknown
)
2863 ;; This call will possibly make the comment invisible
2864 (custom-redraw widget
)))
2866 (defun custom-variable-reset-standard (widget)
2867 "Restore the standard setting for the variable being edited by WIDGET.
2868 This operation eliminates any saved setting for the variable,
2869 restoring it to the state of a variable that has never been customized.
2870 The value that was current before this operation
2871 becomes the backup value, so you can get it again."
2872 (let* ((symbol (widget-value widget
)))
2873 (if (get symbol
'standard-value
)
2874 (custom-variable-backup-value widget
)
2875 (error "No standard setting known for %S" symbol
))
2876 (put symbol
'variable-comment nil
)
2877 (put symbol
'customized-value nil
)
2878 (put symbol
'customized-variable-comment nil
)
2879 (custom-push-theme 'theme-value symbol
'user
'reset
)
2880 (custom-theme-recalc-variable symbol
)
2881 (when (or (get symbol
'saved-value
) (get symbol
'saved-variable-comment
))
2882 (put symbol
'saved-value nil
)
2883 (put symbol
'saved-variable-comment nil
)
2885 (widget-put widget
:custom-state
'unknown
)
2886 ;; This call will possibly make the comment invisible
2887 (custom-redraw widget
)))
2889 (defun custom-variable-backup-value (widget)
2890 "Back up the current value for WIDGET's variable.
2891 The backup value is kept in the car of the `backup-value' property."
2892 (let* ((symbol (widget-value widget
))
2893 (get (or (get symbol
'custom-get
) 'default-value
))
2894 (type (custom-variable-type symbol
))
2895 (conv (widget-convert type
))
2896 (value (if (default-boundp symbol
)
2897 (funcall get symbol
)
2898 (widget-get conv
:value
))))
2899 (put symbol
'backup-value
(list value
))))
2901 (defun custom-variable-reset-backup (widget)
2902 "Restore the backup value for the variable being edited by WIDGET.
2903 The value that was current before this operation
2904 becomes the backup value, so you can use this operation repeatedly
2905 to switch between two values."
2906 (let* ((symbol (widget-value widget
))
2907 (set (or (get symbol
'custom-set
) 'set-default
))
2908 (value (get symbol
'backup-value
))
2909 (comment-widget (widget-get widget
:comment-widget
))
2910 (comment (widget-value comment-widget
)))
2913 (custom-variable-backup-value widget
)
2914 (custom-push-theme 'theme-value symbol
'user
'set value
)
2916 (funcall set symbol
(car value
))
2918 (error "No backup value for %s" symbol
))
2919 (put symbol
'customized-value
(list (car value
)))
2920 (put symbol
'variable-comment comment
)
2921 (put symbol
'customized-variable-comment comment
)
2922 (custom-variable-state-set widget
)
2923 ;; This call will possibly make the comment invisible
2924 (custom-redraw widget
)))
2926 ;;; The `custom-face-edit' Widget.
2928 (define-widget 'custom-face-edit
'checklist
2929 "Edit face attributes."
2933 :button-args
'(:help-echo
"Control whether this attribute has any effect.")
2934 :value-to-internal
'custom-face-edit-fix-value
2935 :match
(lambda (widget value
)
2936 (widget-checklist-match widget
2937 (custom-face-edit-fix-value widget value
)))
2938 :convert-widget
'custom-face-edit-convert-widget
2939 :args
(mapcar (lambda (att)
2942 :sibling-args
(widget-get (nth 1 att
) :sibling-args
)
2943 (list 'const
:format
"" :value
(nth 0 att
))
2945 custom-face-attributes
))
2947 (defun custom-face-edit-fix-value (widget value
)
2948 "Ignoring WIDGET, convert :bold and :italic in VALUE to new form.
2949 Also change :reverse-video to :inverse-video."
2953 (let ((key (car value
))
2954 (val (car (cdr value
))))
2955 (cond ((eq key
:italic
)
2956 (push :slant result
)
2957 (push (if val
'italic
'normal
) result
))
2959 (push :weight result
)
2960 (push (if val
'bold
'normal
) result
))
2961 ((eq key
:reverse-video
)
2962 (push :inverse-video result
)
2966 (push val result
))))
2967 (setq value
(cdr (cdr value
))))
2968 (setq result
(nreverse result
))
2972 (defun custom-face-edit-convert-widget (widget)
2973 "Convert :args as widget types in WIDGET."
2976 :args
(mapcar (lambda (arg)
2978 :deactivate
'custom-face-edit-deactivate
2979 :activate
'custom-face-edit-activate
2980 :delete
'custom-face-edit-delete
))
2981 (widget-get widget
:args
)))
2984 (defun custom-face-edit-deactivate (widget)
2985 "Make face widget WIDGET inactive for user modifications."
2986 (unless (widget-get widget
:inactive
)
2987 (let ((tag (custom-face-edit-attribute-tag widget
))
2988 (from (copy-marker (widget-get widget
:from
)))
2989 (value (widget-value widget
))
2990 (inhibit-read-only t
)
2991 (inhibit-modification-hooks t
))
2994 (widget-default-delete widget
)
2995 (insert tag
": *\n")
2996 (widget-put widget
:inactive
2997 (cons value
(cons from
(- (point) from
))))))))
2999 (defun custom-face-edit-activate (widget)
3000 "Make face widget WIDGET inactive for user modifications."
3001 (let ((inactive (widget-get widget
:inactive
))
3002 (inhibit-read-only t
)
3003 (inhibit-modification-hooks t
))
3004 (when (consp inactive
)
3006 (goto-char (car (cdr inactive
)))
3007 (delete-region (point) (+ (point) (cdr (cdr inactive
))))
3008 (widget-put widget
:inactive nil
)
3009 (widget-apply widget
:create
)
3010 (widget-value-set widget
(car inactive
))
3013 (defun custom-face-edit-delete (widget)
3014 "Remove WIDGET from the buffer."
3015 (let ((inactive (widget-get widget
:inactive
))
3016 (inhibit-read-only t
)
3017 (inhibit-modification-hooks t
))
3019 ;; Widget is alive, we don't have to do anything special
3020 (widget-default-delete widget
)
3021 ;; WIDGET is already deleted because we did so to inactivate it;
3022 ;; now just get rid of the label we put in its place.
3023 (delete-region (car (cdr inactive
))
3024 (+ (car (cdr inactive
)) (cdr (cdr inactive
))))
3025 (widget-put widget
:inactive nil
))))
3028 (defun custom-face-edit-attribute-tag (widget)
3029 "Returns the first :tag property in WIDGET or one of its children."
3030 (let ((tag (widget-get widget
:tag
)))
3031 (or (and (not (equal tag
"")) tag
)
3032 (let ((children (widget-get widget
:children
)))
3033 (while (and (null tag
) children
)
3034 (setq tag
(custom-face-edit-attribute-tag (pop children
))))
3037 ;;; The `custom-display' Widget.
3039 (define-widget 'custom-display
'menu-choice
3040 "Select a display type."
3043 :help-echo
"Specify frames where the face attributes should be used."
3044 :args
'((const :tag
"all" t
)
3045 (const :tag
"defaults" default
)
3049 :args
((group :sibling-args
(:help-echo
"\
3050 Only match the specified window systems.")
3051 (const :format
"Type: "
3053 (checklist :inline t
3056 :sibling-args
(:help-echo
"\
3057 The X11 Window System.")
3059 (const :format
"PM "
3060 :sibling-args
(:help-echo
"\
3061 OS/2 Presentation Manager.")
3063 (const :format
"W32 "
3064 :sibling-args
(:help-echo
"\
3067 (const :format
"MAC "
3068 :sibling-args
(:help-echo
"\
3071 (const :format
"DOS "
3072 :sibling-args
(:help-echo
"\
3075 (const :format
"TTY%n"
3076 :sibling-args
(:help-echo
"\
3077 Plain text terminals.")
3079 (group :sibling-args
(:help-echo
"\
3080 Only match the frames with the specified color support.")
3081 (const :format
"Class: "
3083 (checklist :inline t
3085 (const :format
"Color "
3086 :sibling-args
(:help-echo
"\
3087 Match color frames.")
3089 (const :format
"Grayscale "
3090 :sibling-args
(:help-echo
"\
3091 Match grayscale frames.")
3093 (const :format
"Monochrome%n"
3094 :sibling-args
(:help-echo
"\
3095 Match frames with no color support.")
3097 (group :sibling-args
(:help-echo
"\
3098 The minimum number of colors the frame should support.")
3099 (const :format
"" min-colors
)
3100 (integer :tag
"Minimum number of colors" ))
3101 (group :sibling-args
(:help-echo
"\
3102 Only match frames with the specified intensity.")
3104 Background brightness: "
3106 (checklist :inline t
3108 (const :format
"Light "
3109 :sibling-args
(:help-echo
"\
3110 Match frames with light backgrounds.")
3112 (const :format
"Dark\n"
3113 :sibling-args
(:help-echo
"\
3114 Match frames with dark backgrounds.")
3116 (group :sibling-args
(:help-echo
"\
3117 Only match frames that support the specified face attributes.")
3118 (const :format
"Supports attributes:" supports
)
3119 (custom-face-edit :inline t
:format
"%n%v"))))))
3121 ;;; The `custom-face' Widget.
3123 (defface custom-face-tag
3124 `((t (:weight bold
:height
1.2 :inherit variable-pitch
)))
3125 "Face used for face tags."
3126 :group
'custom-faces
)
3127 ;; backward-compatibility alias
3128 (put 'custom-face-tag-face
'face-alias
'custom-face-tag
)
3130 (defcustom custom-face-default-form
'selected
3131 "Default form of displaying face definition."
3132 :type
'(choice (const all
)
3135 :group
'custom-buffer
3138 (define-widget 'custom-face
'custom
3140 :sample-face
'custom-face-tag-face
3141 :help-echo
"Set or reset this face."
3142 :documentation-property
#'face-doc-string
3143 :value-create
'custom-face-value-create
3144 :action
'custom-face-action
3145 :custom-category
'face
3146 :custom-form nil
; defaults to value of `custom-face-default-form'
3147 :custom-set
'custom-face-set
3148 :custom-save
'custom-face-save
3149 :custom-reset-current
'custom-redraw
3150 :custom-reset-saved
'custom-face-reset-saved
3151 :custom-reset-standard
'custom-face-reset-standard
3152 :custom-standard-value
'custom-face-standard-value
3153 :custom-menu
'custom-face-menu-create
)
3155 (define-widget 'custom-face-all
'editable-list
3156 "An editable list of display specifications and attributes."
3157 :entry-format
"%i %d %v"
3158 :insert-button-args
'(:help-echo
"Insert new display specification here.")
3159 :append-button-args
'(:help-echo
"Append new display specification here.")
3160 :delete-button-args
'(:help-echo
"Delete this display specification.")
3161 :args
'((group :format
"%v" custom-display custom-face-edit
)))
3163 (defconst custom-face-all
(widget-convert 'custom-face-all
)
3164 "Converted version of the `custom-face-all' widget.")
3166 (define-widget 'custom-display-unselected
'item
3167 "A display specification that doesn't match the selected display."
3168 :match
'custom-display-unselected-match
)
3170 (defun custom-display-unselected-match (widget value
)
3171 "Non-nil if VALUE is an unselected display specification."
3172 (not (face-spec-set-match-display value
(selected-frame))))
3174 (define-widget 'custom-face-selected
'group
3175 "Edit the attributes of the selected display in a face specification."
3176 :args
'((choice :inline t
3177 (group :tag
"With Defaults" :inline t
3178 (group (const :tag
"" default
)
3179 (custom-face-edit :tag
" Default\n Attributes"))
3182 (group custom-display-unselected sexp
))
3183 (group (sexp :format
"")
3184 (custom-face-edit :tag
" Overriding\n Attributes"))
3188 (group :tag
"No Defaults" :inline t
3191 (group custom-display-unselected sexp
))
3192 (group (sexp :format
"")
3193 (custom-face-edit :tag
"\n Attributes"))
3200 (defconst custom-face-selected
(widget-convert 'custom-face-selected
)
3201 "Converted version of the `custom-face-selected' widget.")
3203 (defun custom-filter-face-spec (spec filter-index
&optional default-filter
)
3204 "Return a canonicalized version of SPEC using.
3205 FILTER-INDEX is the index in the entry for each attribute in
3206 `custom-face-attributes' at which the appropriate filter function can be
3207 found, and DEFAULT-FILTER is the filter to apply for attributes that
3209 (mapcar (lambda (entry)
3210 ;; Filter a single face-spec entry
3211 (let ((tests (car entry
))
3213 ;; Handle both old- and new-style attribute syntax
3214 (if (listp (car (cdr entry
)))
3217 (filtered-attrs nil
))
3218 ;; Filter each face attribute
3219 (while unfiltered-attrs
3220 (let* ((attr (pop unfiltered-attrs
))
3221 (pre-filtered-value (pop unfiltered-attrs
))
3223 (or (nth filter-index
(assq attr custom-face-attributes
))
3227 (funcall filter pre-filtered-value
)
3228 pre-filtered-value
)))
3229 (push filtered-value filtered-attrs
)
3230 (push attr filtered-attrs
)))
3232 (list tests filtered-attrs
)))
3235 (defun custom-pre-filter-face-spec (spec)
3236 "Return SPEC changed as necessary for editing by the face customization widget.
3237 SPEC must be a full face spec."
3238 (custom-filter-face-spec spec
2))
3240 (defun custom-post-filter-face-spec (spec)
3241 "Return the customized SPEC in a form suitable for setting the face."
3242 (custom-filter-face-spec spec
3))
3244 (defun custom-face-value-create (widget)
3245 "Create a list of the display specifications for WIDGET."
3246 (let ((buttons (widget-get widget
:buttons
))
3248 (symbol (widget-get widget
:value
))
3249 (tag (widget-get widget
:tag
))
3250 (state (widget-get widget
:custom-state
))
3252 (is-last (widget-get widget
:custom-last
))
3253 (prefix (widget-get widget
:custom-prefix
)))
3255 (setq tag
(prin1-to-string symbol
)))
3256 (cond ((eq custom-buffer-style
'tree
)
3257 (insert prefix
(if is-last
" `--- " " |--- "))
3258 (push (widget-create-child-and-convert
3259 widget
'custom-browse-face-tag
)
3261 (insert " " tag
"\n")
3262 (widget-put widget
:buttons buttons
))
3266 (widget-specify-sample widget begin
(point))
3267 (if (eq custom-buffer-style
'face
)
3269 (if (string-match "face\\'" tag
)
3271 (insert " face: ")))
3273 (push (widget-create-child-and-convert widget
'item
3280 (push (widget-create-child-and-convert
3282 :help-echo
"Hide or show this face."
3285 :action
'custom-toggle-parent
3286 (not (eq state
'hidden
)))
3290 (let ((magic (widget-create-child-and-convert
3291 widget
'custom-magic nil
)))
3292 (widget-put widget
:custom-magic magic
)
3293 (push magic buttons
))
3295 (widget-put widget
:buttons buttons
)
3296 ;; Insert documentation.
3297 (widget-default-format-handler widget ?h
)
3298 ;; The comment field
3299 (unless (eq state
'hidden
)
3300 (let* ((comment (get symbol
'face-comment
))
3302 (widget-create-child-and-convert
3303 widget
'custom-comment
3305 :value
(or comment
""))))
3306 (widget-put widget
:comment-widget comment-widget
)
3307 (push comment-widget children
)))
3309 (unless (eq state
'hidden
)
3310 (when (eq (widget-get widget
:custom-level
) 1)
3311 (custom-add-parent-links widget
))
3312 (custom-add-see-also widget
))
3314 (unless (eq (preceding-char) ?
\n)
3316 (unless (eq state
'hidden
)
3317 (message "Creating face editor...")
3318 (custom-load-widget widget
)
3319 (unless (widget-get widget
:custom-form
)
3320 (widget-put widget
:custom-form custom-face-default-form
))
3321 (let* ((symbol (widget-value widget
))
3322 (spec (or (get symbol
'customized-face
)
3323 (get symbol
'saved-face
)
3324 (get symbol
'face-defface-spec
)
3325 ;; Attempt to construct it.
3326 (list (list t
(custom-face-attributes-get
3327 symbol
(selected-frame))))))
3328 (form (widget-get widget
:custom-form
))
3329 (indent (widget-get widget
:indent
))
3331 ;; If the user has changed this face in some other way,
3332 ;; edit it as the user has specified it.
3333 (if (not (face-spec-match-p symbol spec
(selected-frame)))
3334 (setq spec
(list (list t
(face-attr-construct symbol
(selected-frame))))))
3335 (setq spec
(custom-pre-filter-face-spec spec
))
3336 (setq edit
(widget-create-child-and-convert
3338 (cond ((and (eq form
'selected
)
3339 (widget-apply custom-face-selected
3341 (when indent
(insert-char ?\ indent
))
3342 'custom-face-selected
)
3343 ((and (not (eq form
'lisp
))
3344 (widget-apply custom-face-all
3348 (when indent
(insert-char ?\ indent
))
3351 (custom-face-state-set widget
)
3352 (push edit children
)
3353 (widget-put widget
:children children
))
3354 (message "Creating face editor...done"))))))
3356 (defvar custom-face-menu
3357 `(("Set for Current Session" custom-face-set
)
3358 ,@(when (or custom-file user-init-file
)
3359 '(("Save for Future Sessions" custom-face-save
)))
3360 ("Undo Edits" custom-redraw
3362 (memq (widget-get widget
:custom-state
) '(modified changed
))))
3363 ("Reset to Saved" custom-face-reset-saved
3365 (or (get (widget-value widget
) 'saved-face
)
3366 (get (widget-value widget
) 'saved-face-comment
))))
3367 ,@(when (or custom-file user-init-file
)
3368 '(("Erase Customization" custom-face-reset-standard
3370 (get (widget-value widget
) 'face-defface-spec
)))))
3371 ("---" ignore ignore
)
3372 ("Add Comment" custom-comment-show custom-comment-invisible-p
)
3373 ("---" ignore ignore
)
3374 ("For Current Display" custom-face-edit-selected
3376 (not (eq (widget-get widget
:custom-form
) 'selected
))))
3377 ("For All Kinds of Displays" custom-face-edit-all
3379 (not (eq (widget-get widget
:custom-form
) 'all
))))
3380 ("Show Lisp Expression" custom-face-edit-lisp
3382 (not (eq (widget-get widget
:custom-form
) 'lisp
)))))
3383 "Alist of actions for the `custom-face' widget.
3384 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3385 the menu entry, ACTION is the function to call on the widget when the
3386 menu is selected, and FILTER is a predicate which takes a `custom-face'
3387 widget as an argument, and returns non-nil if ACTION is valid on that
3388 widget. If FILTER is nil, ACTION is always valid.")
3390 (defun custom-face-edit-selected (widget)
3391 "Edit selected attributes of the value of WIDGET."
3392 (widget-put widget
:custom-state
'unknown
)
3393 (widget-put widget
:custom-form
'selected
)
3394 (custom-redraw widget
))
3396 (defun custom-face-edit-all (widget)
3397 "Edit all attributes of the value of WIDGET."
3398 (widget-put widget
:custom-state
'unknown
)
3399 (widget-put widget
:custom-form
'all
)
3400 (custom-redraw widget
))
3402 (defun custom-face-edit-lisp (widget)
3403 "Edit the Lisp representation of the value of WIDGET."
3404 (widget-put widget
:custom-state
'unknown
)
3405 (widget-put widget
:custom-form
'lisp
)
3406 (custom-redraw widget
))
3408 (defun custom-face-state-set (widget)
3409 "Set the state of WIDGET."
3410 (let* ((symbol (widget-value widget
))
3411 (comment (get symbol
'face-comment
))
3415 (setq tmp
(get symbol
'customized-face
))
3416 (setq temp
(get symbol
'customized-face-comment
))
3418 (if (equal temp comment
)
3422 (setq tmp
(get symbol
'saved-face
))
3423 (setq temp
(get symbol
'saved-face-comment
))
3425 (if (equal temp comment
)
3427 ((eq 'user
(caar (get symbol
'theme-face
)))
3429 ((eq 'changed
(caar (get symbol
'theme-face
)))
3433 ((get symbol
'face-defface-spec
)
3434 (if (equal comment nil
)
3439 ;; If the user called set-face-attribute to change the default
3440 ;; for new frames, this face is "set outside of Customize".
3441 (if (and (not (eq state
'rogue
))
3442 (get symbol
'face-modified
))
3443 (setq state
'changed
))
3444 (widget-put widget
:custom-state state
)))
3446 (defun custom-face-action (widget &optional event
)
3447 "Show the menu for `custom-face' WIDGET.
3448 Optional EVENT is the location for the menu."
3449 (if (eq (widget-get widget
:custom-state
) 'hidden
)
3450 (custom-toggle-hide widget
)
3451 (let* ((completion-ignore-case t
)
3452 (symbol (widget-get widget
:value
))
3453 (answer (widget-choose (concat "Operation on "
3454 (custom-unlispify-tag-name symbol
))
3455 (custom-menu-filter custom-face-menu
3459 (funcall answer widget
)))))
3461 (defun custom-face-set (widget)
3462 "Make the face attributes in WIDGET take effect."
3463 (let* ((symbol (widget-value widget
))
3464 (child (car (widget-get widget
:children
)))
3465 (value (custom-post-filter-face-spec (widget-value child
)))
3466 (comment-widget (widget-get widget
:comment-widget
))
3467 (comment (widget-value comment-widget
)))
3468 (when (equal comment
"")
3470 ;; Make the comment invisible by hand if it's empty
3471 (custom-comment-hide comment-widget
))
3472 (put symbol
'customized-face value
)
3473 (custom-push-theme 'theme-face symbol
'user
'set value
)
3474 (if (face-spec-choose value
)
3475 (face-spec-set symbol value
)
3476 ;; face-set-spec ignores empty attribute lists, so just give it
3477 ;; something harmless instead.
3478 (face-spec-set symbol
'((t :foreground unspecified
))))
3479 (put symbol
'customized-face-comment comment
)
3480 (put symbol
'face-comment comment
)
3481 (custom-face-state-set widget
)
3482 (custom-redraw-magic widget
)))
3484 (defun custom-face-save (widget)
3485 "Save in `.emacs' the face attributes in WIDGET."
3486 (let* ((symbol (widget-value widget
))
3487 (child (car (widget-get widget
:children
)))
3488 (value (custom-post-filter-face-spec (widget-value child
)))
3489 (comment-widget (widget-get widget
:comment-widget
))
3490 (comment (widget-value comment-widget
)))
3491 (when (equal comment
"")
3493 ;; Make the comment invisible by hand if it's empty
3494 (custom-comment-hide comment-widget
))
3495 (custom-push-theme 'theme-face symbol
'user
'set value
)
3496 (if (face-spec-choose value
)
3497 (face-spec-set symbol value
)
3498 ;; face-set-spec ignores empty attribute lists, so just give it
3499 ;; something harmless instead.
3500 (face-spec-set symbol
'((t :foreground unspecified
))))
3501 (unless (eq (widget-get widget
:custom-state
) 'standard
)
3502 (put symbol
'saved-face value
))
3503 (put symbol
'customized-face nil
)
3504 (put symbol
'face-comment comment
)
3505 (put symbol
'customized-face-comment nil
)
3506 (put symbol
'saved-face-comment comment
)
3508 (custom-face-state-set widget
)
3509 (custom-redraw-magic widget
)))
3511 ;; For backward compatibility.
3512 (define-obsolete-function-alias 'custom-face-save-command
'custom-face-save
3515 (defun custom-face-reset-saved (widget)
3516 "Restore WIDGET to the face's default attributes."
3517 (let* ((symbol (widget-value widget
))
3518 (child (car (widget-get widget
:children
)))
3519 (value (get symbol
'saved-face
))
3520 (comment (get symbol
'saved-face-comment
))
3521 (comment-widget (widget-get widget
:comment-widget
)))
3522 (unless (or value comment
)
3523 (error "No saved value for this face"))
3524 (put symbol
'customized-face nil
)
3525 (put symbol
'customized-face-comment nil
)
3526 (custom-push-theme 'theme-face symbol
'user
'set value
)
3527 (face-spec-set symbol value
)
3528 (put symbol
'face-comment comment
)
3529 (widget-value-set child value
)
3530 ;; This call manages the comment visibility
3531 (widget-value-set comment-widget
(or comment
""))
3532 (custom-face-state-set widget
)
3533 (custom-redraw-magic widget
)))
3535 (defun custom-face-standard-value (widget)
3536 (get (widget-value widget
) 'face-defface-spec
))
3538 (defun custom-face-reset-standard (widget)
3539 "Restore WIDGET to the face's standard attribute values.
3540 This operation eliminates any saved attributes for the face,
3541 restoring it to the state of a face that has never been customized."
3542 (let* ((symbol (widget-value widget
))
3543 (child (car (widget-get widget
:children
)))
3544 (value (get symbol
'face-defface-spec
))
3545 (comment-widget (widget-get widget
:comment-widget
)))
3547 (error "No standard setting for this face"))
3548 (put symbol
'customized-face nil
)
3549 (put symbol
'customized-face-comment nil
)
3550 (custom-push-theme 'theme-face symbol
'user
'reset
)
3551 (face-spec-set symbol value
)
3552 (custom-theme-recalc-face symbol
)
3553 (when (or (get symbol
'saved-face
) (get symbol
'saved-face-comment
))
3554 (put symbol
'saved-face nil
)
3555 (put symbol
'saved-face-comment nil
)
3557 (put symbol
'face-comment nil
)
3558 (widget-value-set child
3559 (custom-pre-filter-face-spec
3560 (list (list t
(custom-face-attributes-get
3562 ;; This call manages the comment visibility
3563 (widget-value-set comment-widget
"")
3564 (custom-face-state-set widget
)
3565 (custom-redraw-magic widget
)))
3567 ;;; The `face' Widget.
3569 (defvar widget-face-prompt-value-history nil
3570 "History of input to `widget-face-prompt-value'.")
3572 (define-widget 'face
'symbol
3573 "A Lisp face name (with sample)."
3574 :format
"%{%t%}: (%{sample%}) %v"
3577 :sample-face-get
'widget-face-sample-face-get
3578 :notify
'widget-face-notify
3579 :match
(lambda (widget value
) (facep value
))
3580 :complete-function
(lambda ()
3582 (lisp-complete-symbol 'facep
))
3583 :prompt-match
'facep
3584 :prompt-history
'widget-face-prompt-value-history
3585 :validate
(lambda (widget)
3586 (unless (facep (widget-value widget
))
3588 :error
(format "Invalid face: %S"
3589 (widget-value widget
)))
3592 (defun widget-face-sample-face-get (widget)
3593 (let ((value (widget-value widget
)))
3598 (defun widget-face-notify (widget child
&optional event
)
3599 "Update the sample, and notify the parent."
3600 (overlay-put (widget-get widget
:sample-overlay
)
3601 'face
(widget-apply widget
:sample-face-get
))
3602 (widget-default-notify widget child event
))
3605 ;;; The `hook' Widget.
3607 (define-widget 'hook
'list
3609 :value-to-internal
(lambda (widget value
)
3610 (if (and value
(symbolp value
))
3613 :match
(lambda (widget value
)
3615 (widget-group-match widget value
)))
3616 ;; Avoid adding undefined functions to the hook, especially for
3617 ;; things like `find-file-hook' or even more basic ones, to avoid
3619 :set
(lambda (symbol value
)
3622 (add-hook symbol elt
))))
3623 :convert-widget
'custom-hook-convert-widget
3626 (defun custom-hook-convert-widget (widget)
3627 ;; Handle `:options'.
3628 (let* ((options (widget-get widget
:options
))
3629 (other `(editable-list :inline t
3630 :entry-format
"%i %d%v"
3631 (function :format
" %v")))
3633 (list `(checklist :inline t
3634 ,@(mapcar (lambda (entry)
3635 `(function-item ,entry
))
3639 (widget-put widget
:args args
)
3642 ;;; The `custom-group-link' Widget.
3644 (define-widget 'custom-group-link
'link
3645 "Show parent in other window when activated."
3646 :button-face
'custom-link
3647 :mouse-face
'highlight
3648 :pressed-face
'highlight
3649 :help-echo
"Create customization buffer for this group."
3650 :action
'custom-group-link-action
)
3652 (defun custom-group-link-action (widget &rest ignore
)
3653 (customize-group (widget-value widget
)))
3655 ;;; The `custom-group' Widget.
3657 (defcustom custom-group-tag-faces nil
3658 ;; In XEmacs, this ought to play games with font size.
3659 ;; Fixme: make it do so in Emacs.
3660 "Face used for group tags.
3661 The first member is used for level 1 groups, the second for level 2,
3662 and so forth. The remaining group tags are shown with `custom-group-tag'."
3663 :type
'(repeat face
)
3664 :group
'custom-faces
)
3666 (defface custom-group-tag-1
3669 (:foreground
"pink" :weight bold
:height
1.2 :inherit variable-pitch
))
3670 (((min-colors 88) (class color
)
3672 (:foreground
"red1" :weight bold
:height
1.2 :inherit variable-pitch
))
3675 (:foreground
"red" :weight bold
:height
1.2 :inherit variable-pitch
))
3677 "Face used for group tags."
3678 :group
'custom-faces
)
3679 ;; backward-compatibility alias
3680 (put 'custom-group-tag-face-1
'face-alias
'custom-group-tag-1
)
3682 (defface custom-group-tag
3685 (:foreground
"light blue" :weight bold
:height
1.2))
3686 (((min-colors 88) (class color
)
3688 (:foreground
"blue1" :weight bold
:height
1.2))
3691 (:foreground
"blue" :weight bold
:height
1.2))
3693 "Face used for low level group tags."
3694 :group
'custom-faces
)
3695 ;; backward-compatibility alias
3696 (put 'custom-group-tag-face
'face-alias
'custom-group-tag
)
3698 (define-widget 'custom-group
'custom
3701 :sample-face-get
'custom-group-sample-face-get
3702 :documentation-property
'group-documentation
3703 :help-echo
"Set or reset all members of this group."
3704 :value-create
'custom-group-value-create
3705 :action
'custom-group-action
3706 :custom-category
'group
3707 :custom-set
'custom-group-set
3708 :custom-save
'custom-group-save
3709 :custom-reset-current
'custom-group-reset-current
3710 :custom-reset-saved
'custom-group-reset-saved
3711 :custom-reset-standard
'custom-group-reset-standard
3712 :custom-menu
'custom-group-menu-create
)
3714 (defun custom-group-sample-face-get (widget)
3715 ;; Use :sample-face.
3716 (or (nth (1- (widget-get widget
:custom-level
)) custom-group-tag-faces
)
3719 (define-widget 'custom-group-visibility
'visibility
3720 "An indicator and manipulator for hidden group contents."
3721 :create
'custom-group-visibility-create
)
3723 (defun custom-group-visibility-create (widget)
3724 (let ((visible (widget-value widget
)))
3726 (insert "--------")))
3727 (widget-default-create widget
))
3729 (defun custom-group-members (symbol groups-only
)
3730 "Return SYMBOL's custom group members.
3731 If GROUPS-ONLY non-nil, return only those members that are groups."
3732 (if (not groups-only
)
3733 (get symbol
'custom-group
)
3735 (dolist (entry (get symbol
'custom-group
))
3736 (when (eq (nth 1 entry
) 'custom-group
)
3737 (push entry members
)))
3738 (nreverse members
))))
3740 (defun custom-group-value-create (widget)
3741 "Insert a customize group for WIDGET in the current buffer."
3742 (unless (eq (widget-get widget
:custom-state
) 'hidden
)
3743 (custom-load-widget widget
))
3744 (let* ((state (widget-get widget
:custom-state
))
3745 (level (widget-get widget
:custom-level
))
3746 ;; (indent (widget-get widget :indent))
3747 (prefix (widget-get widget
:custom-prefix
))
3748 (buttons (widget-get widget
:buttons
))
3749 (tag (widget-get widget
:tag
))
3750 (symbol (widget-value widget
))
3751 (members (custom-group-members symbol
3752 (and (eq custom-buffer-style
'tree
)
3753 custom-browse-only-groups
))))
3754 (cond ((and (eq custom-buffer-style
'tree
)
3756 (or members
(custom-unloaded-widget-p widget
)))
3757 (custom-browse-insert-prefix prefix
)
3758 (push (widget-create-child-and-convert
3759 widget
'custom-browse-visibility
3760 ;; :tag-glyph "plus"
3764 ;; (widget-glyph-insert nil "-- " "horizontal")
3765 (push (widget-create-child-and-convert
3766 widget
'custom-browse-group-tag
)
3768 (insert " " tag
"\n")
3769 (widget-put widget
:buttons buttons
))
3770 ((and (eq custom-buffer-style
'tree
)
3771 (zerop (length members
)))
3772 (custom-browse-insert-prefix prefix
)
3774 ;; (widget-glyph-insert nil "[ ]" "empty")
3775 ;; (widget-glyph-insert nil "-- " "horizontal")
3776 (push (widget-create-child-and-convert
3777 widget
'custom-browse-group-tag
)
3779 (insert " " tag
"\n")
3780 (widget-put widget
:buttons buttons
))
3781 ((eq custom-buffer-style
'tree
)
3782 (custom-browse-insert-prefix prefix
)
3783 (if (zerop (length members
))
3785 (custom-browse-insert-prefix prefix
)
3787 ;; (widget-glyph-insert nil "[ ]" "empty")
3788 ;; (widget-glyph-insert nil "-- " "horizontal")
3789 (push (widget-create-child-and-convert
3790 widget
'custom-browse-group-tag
)
3792 (insert " " tag
"\n")
3793 (widget-put widget
:buttons buttons
))
3794 (push (widget-create-child-and-convert
3795 widget
'custom-browse-visibility
3796 ;; :tag-glyph "minus"
3800 ;; (widget-glyph-insert nil "-\\ " "top")
3801 (push (widget-create-child-and-convert
3802 widget
'custom-browse-group-tag
)
3804 (insert " " tag
"\n")
3805 (widget-put widget
:buttons buttons
)
3806 (message "Creating group...")
3807 (let* ((members (custom-sort-items members
3808 custom-browse-sort-alphabetically
3809 custom-browse-order-groups
))
3810 (prefixes (widget-get widget
:custom-prefixes
))
3811 (custom-prefix-list (custom-prefix-add symbol prefixes
))
3812 (extra-prefix (if (widget-get widget
:custom-last
)
3815 (prefix (concat prefix extra-prefix
))
3818 (setq entry
(car members
)
3819 members
(cdr members
))
3820 (push (widget-create-child-and-convert
3821 widget
(nth 1 entry
)
3823 :tag
(custom-unlispify-tag-name (nth 0 entry
))
3824 :custom-prefixes custom-prefix-list
3825 :custom-level
(1+ level
)
3826 :custom-last
(null members
)
3827 :value
(nth 0 entry
)
3828 :custom-prefix prefix
)
3830 (widget-put widget
:children
(reverse children
)))
3831 (message "Creating group...done")))
3834 ;; Create level indicator.
3835 (unless (eq custom-buffer-style
'links
)
3836 (insert-char ?\
(* custom-buffer-indent
(1- level
)))
3839 (let ((begin (point)))
3841 (widget-specify-sample widget begin
(point)))
3843 ;; Create link/visibility indicator.
3844 (if (eq custom-buffer-style
'links
)
3845 (push (widget-create-child-and-convert
3846 widget
'custom-group-link
3850 (push (widget-create-child-and-convert
3851 widget
'custom-group-visibility
3852 :help-echo
"Show members of this group."
3853 :action
'custom-toggle-parent
3854 (not (eq state
'hidden
)))
3857 ;; Create magic button.
3858 (let ((magic (widget-create-child-and-convert
3859 widget
'custom-magic nil
)))
3860 (widget-put widget
:custom-magic magic
)
3861 (push magic buttons
))
3863 (widget-put widget
:buttons buttons
)
3864 ;; Insert documentation.
3865 (if (and (eq custom-buffer-style
'links
) (> level
1))
3866 (widget-put widget
:documentation-indent
0))
3867 (widget-default-format-handler widget ?h
))
3870 ;; Add parent groups references above the group.
3871 (if t
;;; This should test that the buffer
3872 ;;; was made to display a group.
3874 (if (custom-add-parent-links widget
3875 "Go to parent group:")
3877 ;; Create level indicator.
3878 (insert-char ?\
(* custom-buffer-indent
(1- level
)))
3881 (let ((start (point)))
3883 (widget-specify-sample widget start
(point)))
3885 ;; Create visibility indicator.
3886 (unless (eq custom-buffer-style
'links
)
3888 (push (widget-create-child-and-convert
3890 :help-echo
"Hide members of this group."
3891 :action
'custom-toggle-parent
3892 (not (eq state
'hidden
)))
3895 ;; Create more dashes.
3896 ;; Use 76 instead of 75 to compensate for the temporary "<"
3897 ;; added by `widget-insert'.
3898 (insert-char ?-
(- 76 (current-column)
3899 (* custom-buffer-indent level
)))
3901 ;; Create magic button.
3902 (let ((magic (widget-create-child-and-convert
3903 widget
'custom-magic
3906 (widget-put widget
:custom-magic magic
)
3907 (push magic buttons
))
3909 (widget-put widget
:buttons buttons
)
3910 ;; Insert documentation.
3911 (widget-default-format-handler widget ?h
)
3913 (if nil
;;; This should test that the buffer
3914 ;;; was not made to display a group.
3916 (insert-char ?\ custom-buffer-indent
)
3917 (custom-add-parent-links widget
)))
3918 (custom-add-see-also widget
3919 (make-string (* custom-buffer-indent level
)
3922 (message "Creating group...")
3923 (let* ((members (custom-sort-items members
3924 custom-buffer-sort-alphabetically
3925 custom-buffer-order-groups
))
3926 (prefixes (widget-get widget
:custom-prefixes
))
3927 (custom-prefix-list (custom-prefix-add symbol prefixes
))
3928 (length (length members
))
3930 (children (mapcar (lambda (entry)
3931 (widget-insert "\n")
3933 Creating group members... %2d%%"
3934 (/ (* 100.0 count
) length
))
3935 (setq count
(1+ count
))
3937 (widget-create-child-and-convert
3938 widget
(nth 1 entry
)
3940 :tag
(custom-unlispify-tag-name
3942 :custom-prefixes custom-prefix-list
3943 :custom-level
(1+ level
)
3944 :value
(nth 0 entry
))
3945 (unless (eq (preceding-char) ?
\n)
3946 (widget-insert "\n"))))
3948 (message "Creating group magic...")
3949 (mapc 'custom-magic-reset children
)
3950 (message "Creating group state...")
3951 (widget-put widget
:children children
)
3952 (custom-group-state-update widget
)
3953 (message "Creating group... done"))
3956 (insert-char ?\
(* custom-buffer-indent
(1- level
)))
3957 (insert "\\- " (widget-get widget
:tag
) " group end ")
3958 (insert-char ?-
(- 75 (current-column) (* custom-buffer-indent level
)))
3961 (defvar custom-group-menu
3962 `(("Set for Current Session" custom-group-set
3964 (eq (widget-get widget
:custom-state
) 'modified
)))
3965 ,@(when (or custom-file user-init-file
)
3966 '(("Save for Future Sessions" custom-group-save
3968 (memq (widget-get widget
:custom-state
) '(modified set
))))))
3969 ("Undo Edits" custom-group-reset-current
3971 (memq (widget-get widget
:custom-state
) '(modified))))
3972 ("Reset to Saved" custom-group-reset-saved
3974 (memq (widget-get widget
:custom-state
) '(modified set
))))
3975 ,@(when (or custom-file user-init-file
)
3976 '(("Erase Customization" custom-group-reset-standard
3978 (memq (widget-get widget
:custom-state
) '(modified set saved
)))))))
3979 "Alist of actions for the `custom-group' widget.
3980 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3981 the menu entry, ACTION is the function to call on the widget when the
3982 menu is selected, and FILTER is a predicate which takes a `custom-group'
3983 widget as an argument, and returns non-nil if ACTION is valid on that
3984 widget. If FILTER is nil, ACTION is always valid.")
3986 (defun custom-group-action (widget &optional event
)
3987 "Show the menu for `custom-group' WIDGET.
3988 Optional EVENT is the location for the menu."
3989 (if (eq (widget-get widget
:custom-state
) 'hidden
)
3990 (custom-toggle-hide widget
)
3991 (let* ((completion-ignore-case t
)
3992 (answer (widget-choose (concat "Operation on "
3993 (custom-unlispify-tag-name
3994 (widget-get widget
:value
)))
3995 (custom-menu-filter custom-group-menu
3999 (funcall answer widget
)))))
4001 (defun custom-group-set (widget)
4002 "Set changes in all modified group members."
4003 (let ((children (widget-get widget
:children
)))
4004 (mapc (lambda (child)
4005 (when (eq (widget-get child
:custom-state
) 'modified
)
4006 (widget-apply child
:custom-set
)))
4009 (defun custom-group-save (widget)
4010 "Save all modified group members."
4011 (let ((children (widget-get widget
:children
)))
4012 (mapc (lambda (child)
4013 (when (memq (widget-get child
:custom-state
) '(modified set
))
4014 (widget-apply child
:custom-save
)))
4017 (defun custom-group-reset-current (widget)
4018 "Reset all modified group members."
4019 (let ((children (widget-get widget
:children
)))
4020 (mapc (lambda (child)
4021 (when (eq (widget-get child
:custom-state
) 'modified
)
4022 (widget-apply child
:custom-reset-current
)))
4025 (defun custom-group-reset-saved (widget)
4026 "Reset all modified or set group members."
4027 (let ((children (widget-get widget
:children
)))
4028 (mapc (lambda (child)
4029 (when (memq (widget-get child
:custom-state
) '(modified set
))
4030 (widget-apply child
:custom-reset-saved
)))
4033 (defun custom-group-reset-standard (widget)
4034 "Reset all modified, set, or saved group members."
4035 (let ((children (widget-get widget
:children
)))
4036 (mapc (lambda (child)
4037 (when (memq (widget-get child
:custom-state
)
4038 '(modified set saved
))
4039 (widget-apply child
:custom-reset-standard
)))
4042 (defun custom-group-state-update (widget)
4044 (unless (eq (widget-get widget
:custom-state
) 'hidden
)
4045 (let* ((children (widget-get widget
:children
))
4046 (states (mapcar (lambda (child)
4047 (widget-get child
:custom-state
))
4049 (magics custom-magic-alist
)
4052 (let ((magic (car (car magics
))))
4053 (if (and (not (eq magic
'hidden
))
4054 (memq magic states
))
4057 (setq magics
(cdr magics
)))))
4058 (widget-put widget
:custom-state found
)))
4059 (custom-magic-reset widget
))
4061 ;;; Reading and writing the custom file.
4064 (defcustom custom-file nil
4065 "File used for storing customization information.
4066 The default is nil, which means to use your init file
4067 as specified by `user-init-file'. If the value is not nil,
4068 it should be an absolute file name.
4070 You can set this option through Custom, if you carefully read the
4071 last paragraph below. However, usually it is simpler to write
4072 something like the following in your init file:
4074 \(setq custom-file \"~/.emacs-custom.el\")
4077 Note that both lines are necessary: the first line tells Custom to
4078 save all customizations in this file, but does not load it.
4080 When you change this variable outside Custom, look in the
4081 previous custom file \(usually your init file) for the
4082 forms `(custom-set-variables ...)' and `(custom-set-faces ...)',
4083 and copy them (whichever ones you find) to the new custom file.
4084 This will preserve your existing customizations.
4086 If you save this option using Custom, Custom will write all
4087 currently saved customizations, including the new one for this
4088 option itself, into the file you specify, overwriting any
4089 `custom-set-variables' and `custom-set-faces' forms already
4090 present in that file. It will not delete any customizations from
4091 the old custom file. You should do that manually if that is what you
4092 want. You also have to put something like `\(load \"CUSTOM-FILE\")
4093 in your init file, where CUSTOM-FILE is the actual name of the
4094 file. Otherwise, Emacs will not load the file when it starts up,
4095 and hence will not set `custom-file' to that file either."
4096 :type
'(choice (const :tag
"Your Emacs init file" nil
)
4097 (file :format
"%t:%v%d"
4099 "Please read entire docstring below before setting \
4100 this through Custom.
4101 Click om \"More\" \(or position point there and press RETURN)
4102 if only the first line of the docstring is shown."))
4105 (defun custom-file ()
4106 "Return the file name for saving customizations."
4109 (let ((user-init-file user-init-file
)
4111 (if (eq system-type
'ms-dos
) "~/_emacs" "~/.emacs")))
4112 (when (null user-init-file
)
4113 (if (or (file-exists-p default-init-file
)
4114 (and (eq system-type
'windows-nt
)
4115 (file-exists-p "~/_emacs")))
4116 ;; Started with -q, i.e. the file containing
4117 ;; Custom settings hasn't been read. Saving
4118 ;; settings there would overwrite other settings.
4119 (error "Saving settings from \"emacs -q\" would overwrite existing customizations"))
4120 (setq user-init-file default-init-file
))
4124 (defun custom-save-all ()
4125 "Save all customizations in `custom-file'."
4126 (let* ((filename (custom-file))
4127 (recentf-exclude (if recentf-mode
4129 (regexp-quote (custom-file))
4132 (old-buffer (find-buffer-visiting filename
)))
4133 (with-current-buffer (or old-buffer
(find-file-noselect filename
))
4134 (let ((inhibit-read-only t
))
4135 (custom-save-variables)
4136 (custom-save-faces))
4137 (let ((file-precious-flag t
))
4140 (kill-buffer (current-buffer))))))
4143 (defun customize-save-customized ()
4144 "Save all user options which have been set in this session."
4146 (mapatoms (lambda (symbol)
4147 (let ((face (get symbol
'customized-face
))
4148 (value (get symbol
'customized-value
))
4149 (face-comment (get symbol
'customized-face-comment
))
4151 (get symbol
'customized-variable-comment
)))
4153 (put symbol
'saved-face face
)
4154 (custom-push-theme 'theme-face symbol
'user
'set value
)
4155 (put symbol
'customized-face nil
))
4157 (put symbol
'saved-value value
)
4158 (custom-push-theme 'theme-value symbol
'user
'set value
)
4159 (put symbol
'customized-value nil
))
4160 (when variable-comment
4161 (put symbol
'saved-variable-comment variable-comment
)
4162 (put symbol
'customized-variable-comment nil
))
4164 (put symbol
'saved-face-comment face-comment
)
4165 (put symbol
'customized-face-comment nil
)))))
4166 ;; We really should update all custom buffers here.
4169 ;; Editing the custom file contents in a buffer.
4171 (defun custom-save-delete (symbol)
4172 "Delete all calls to SYMBOL from the contents of the current buffer.
4173 Leave point at the old location of the first such call,
4174 or (if there were none) at the end of the buffer.
4176 This function does not save the buffer."
4177 (goto-char (point-min))
4178 ;; Skip all whitespace and comments.
4179 (while (forward-comment 1))
4181 (save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors.
4184 (while t
;; We exit this loop only via throw.
4185 ;; Skip all whitespace and comments.
4186 (while (forward-comment 1))
4187 (let ((start (point))
4188 (sexp (condition-case nil
4189 (read (current-buffer))
4190 (end-of-file (throw 'found nil
)))))
4191 (when (and (listp sexp
)
4192 (eq (car sexp
) symbol
))
4193 (delete-region start
(point))
4195 (setq first
(point)))))))
4198 ;; Move in front of local variables, otherwise long Custom
4199 ;; entries would make them ineffective.
4200 (let ((pos (point-max))
4201 (case-fold-search t
))
4203 (goto-char (point-max))
4204 (search-backward "\n\^L" (max (- (point-max) 3000) (point-min))
4206 (when (search-forward "Local Variables:" nil t
)
4207 (setq pos
(line-beginning-position))))
4210 (defun custom-save-variables ()
4211 "Save all customized variables in `custom-file'."
4213 (custom-save-delete 'custom-set-variables
)
4214 (let ((standard-output (current-buffer))
4215 (saved-list (make-list 1 0))
4217 ;; First create a sorted list of saved variables.
4220 (if (and (get symbol
'saved-value
)
4221 ;; ignore theme values
4222 (or (null (get symbol
'theme-value
))
4223 (eq 'user
(caar (get symbol
'theme-value
)))))
4224 (nconc saved-list
(list symbol
)))))
4225 (setq saved-list
(sort (cdr saved-list
) 'string
<))
4228 (princ "(custom-set-variables
4229 ;; custom-set-variables was added by Custom.
4230 ;; If you edit it by hand, you could mess it up, so be careful.
4231 ;; Your init file should contain only one such instance.
4232 ;; If there is more than one, they won't work right.\n")
4233 (dolist (symbol saved-list
)
4234 (let ((spec (car-safe (get symbol
'theme-value
)))
4235 (value (get symbol
'saved-value
))
4236 (requests (get symbol
'custom-requests
))
4237 (now (not (or (custom-variable-p symbol
)
4238 (and (not (boundp symbol
))
4239 (not (eq (get symbol
'force-value
)
4241 (comment (get symbol
'saved-variable-comment
)))
4242 ;; Check `requests'.
4243 (dolist (request requests
)
4244 (when (and (symbolp request
) (not (featurep request
)))
4245 (message "Unknown requested feature: %s" request
)
4246 (setq requests
(delq request requests
))))
4247 (when (or (and spec
(eq (car spec
) 'user
))
4249 (and (null spec
) (get symbol
'saved-value
)))
4256 (when (or now requests comment
)
4259 (when (or requests comment
)
4269 (unless (looking-at "\n")
4272 (defun custom-save-faces ()
4273 "Save all customized faces in `custom-file'."
4275 (custom-save-delete 'custom-reset-faces
)
4276 (custom-save-delete 'custom-set-faces
)
4277 (let ((standard-output (current-buffer))
4278 (saved-list (make-list 1 0))
4280 ;; First create a sorted list of saved faces.
4283 (if (and (get symbol
'saved-face
)
4284 (eq 'user
(car (car-safe (get symbol
'theme-face
)))))
4285 (nconc saved-list
(list symbol
)))))
4286 (setq saved-list
(sort (cdr saved-list
) 'string
<))
4287 ;; The default face must be first, since it affects the others.
4288 (if (memq 'default saved-list
)
4289 (setq saved-list
(cons 'default
(delq 'default saved-list
))))
4292 (princ "(custom-set-faces
4293 ;; custom-set-faces was added by Custom.
4294 ;; If you edit it by hand, you could mess it up, so be careful.
4295 ;; Your init file should contain only one such instance.
4296 ;; If there is more than one, they won't work right.\n")
4297 (dolist (symbol saved-list
)
4298 (let ((spec (car-safe (get symbol
'theme-face
)))
4299 (value (get symbol
'saved-face
))
4300 (now (not (or (get symbol
'face-defface-spec
)
4301 (and (not (custom-facep symbol
))
4302 (not (get symbol
'force-face
))))))
4303 (comment (get symbol
'saved-face-comment
)))
4304 (when (or (and spec
(eq (nth 0 spec
) 'user
))
4306 (and (null spec
) (get symbol
'saved-face
)))
4307 ;; Don't print default face here.
4314 (when (or now comment
)
4324 (unless (looking-at "\n")
4327 ;;; The Customize Menu.
4331 (defcustom custom-menu-nesting
2
4332 "Maximum nesting in custom menus."
4334 :group
'custom-menu
)
4336 (defun custom-face-menu-create (widget symbol
)
4337 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
4338 (vector (custom-unlispify-menu-entry symbol
)
4339 `(customize-face ',symbol
)
4342 (defun custom-variable-menu-create (widget symbol
)
4343 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
4344 (let ((type (get symbol
'custom-type
)))
4345 (unless (listp type
)
4346 (setq type
(list type
)))
4347 (if (and type
(widget-get type
:custom-menu
))
4348 (widget-apply type
:custom-menu symbol
)
4349 (vector (custom-unlispify-menu-entry symbol
)
4350 `(customize-variable ',symbol
)
4353 ;; Add checkboxes to boolean variable entries.
4354 (widget-put (get 'boolean
'widget-type
)
4355 :custom-menu
(lambda (widget symbol
)
4356 (vector (custom-unlispify-menu-entry symbol
)
4357 `(customize-variable ',symbol
)
4359 ':selected symbol
)))
4361 (defun custom-group-menu-create (widget symbol
)
4362 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
4363 `( ,(custom-unlispify-menu-entry symbol t
)
4364 :filter
(lambda (&rest junk
)
4365 (let ((menu (custom-menu-create ',symbol
)))
4366 (if (consp menu
) (cdr menu
) menu
)))))
4369 (defun custom-menu-create (symbol)
4370 "Create menu for customization group SYMBOL.
4371 The menu is in a format applicable to `easy-menu-define'."
4372 (let* ((item (vector (custom-unlispify-menu-entry symbol
)
4373 `(customize-group ',symbol
)
4375 (if (and (or (not (boundp 'custom-menu-nesting
))
4376 (>= custom-menu-nesting
0))
4378 (custom-load-symbol symbol
)
4379 (< (length (get symbol
'custom-group
)) widget-menu-max-size
)))
4380 (let ((custom-prefix-list (custom-prefix-add symbol
4381 custom-prefix-list
))
4382 (members (custom-sort-items (get symbol
'custom-group
)
4383 custom-menu-sort-alphabetically
4384 custom-menu-order-groups
)))
4385 `(,(custom-unlispify-menu-entry symbol t
)
4388 ,@(mapcar (lambda (entry)
4389 (widget-apply (if (listp (nth 1 entry
))
4391 (list (nth 1 entry
)))
4392 :custom-menu
(nth 0 entry
)))
4397 (defun customize-menu-create (symbol &optional name
)
4398 "Return a customize menu for customization group SYMBOL.
4399 If optional NAME is given, use that as the name of the menu.
4400 Otherwise the menu will be named `Customize'.
4401 The format is suitable for use with `easy-menu-define'."
4403 (setq name
"Customize"))
4405 :filter
(lambda (&rest junk
)
4406 (let ((menu (custom-menu-create ',symbol
)))
4407 (if (consp menu
) (cdr menu
) menu
)))))
4409 ;;; The Custom Mode.
4411 (defvar custom-mode-map
4412 ;; This keymap should be dense, but a dense keymap would prevent inheriting
4413 ;; "\r" bindings from the parent map.
4414 ;; Actually, this misfeature of dense keymaps was fixed on 2001-11-26.
4415 (let ((map (make-keymap)))
4416 (set-keymap-parent map widget-keymap
)
4417 (suppress-keymap map
)
4418 (define-key map
" " 'scroll-up
)
4419 (define-key map
"\177" 'scroll-down
)
4420 (define-key map
"\C-c\C-c" 'Custom-set
)
4421 (define-key map
"\C-x\C-s" 'Custom-save
)
4422 (define-key map
"q" 'Custom-buffer-done
)
4423 (define-key map
"u" 'Custom-goto-parent
)
4424 (define-key map
"n" 'widget-forward
)
4425 (define-key map
"p" 'widget-backward
)
4427 "Keymap for `custom-mode'.")
4429 (easy-menu-define Custom-mode-menu
4431 "Menu used in customization buffers."
4433 ,(customize-menu-create 'customize
)
4434 ["Set" Custom-set t
]
4435 ["Save" Custom-save t
]
4436 ["Undo Edits" Custom-reset-current t
]
4437 ["Reset to Saved" Custom-reset-saved t
]
4438 ["Erase Customization" Custom-reset-standard t
]
4439 ["Info" (info "(emacs)Easy Customization") t
]))
4441 (defvar custom-field-keymap
4442 (let ((map (copy-keymap widget-field-keymap
)))
4443 (define-key map
"\C-c\C-c" 'Custom-set
)
4444 (define-key map
"\C-x\C-s" 'Custom-save
)
4446 "Keymap used inside editable fields in customization buffers.")
4448 (widget-put (get 'editable-field
'widget-type
) :keymap custom-field-keymap
)
4450 (defun Custom-goto-parent ()
4451 "Go to the parent group listed at the top of this buffer.
4452 If several parents are listed, go to the first of them."
4455 (goto-char (point-min))
4456 (if (search-forward "\nGo to parent group: " nil t
)
4457 (let* ((button (get-char-property (point) 'button
))
4458 (parent (downcase (widget-get button
:tag
))))
4459 (customize-group parent
)))))
4461 (defcustom custom-mode-hook nil
4462 "Hook called when entering Custom mode."
4464 :group
'custom-buffer
)
4466 (defun custom-state-buffer-message (widget)
4467 (if (eq (widget-get (widget-get widget
:parent
) :custom-state
) 'modified
)
4468 (message "To install your edits, invoke [State] and choose the Set operation")))
4470 (defun custom-mode ()
4471 "Major mode for editing customization buffers.
4473 The following commands are available:
4476 Move to next button, link or editable field. \\[widget-forward]
4477 Move to previous button, link or editable field. \\[advertised-widget-backward]
4478 \\<custom-field-keymap>\
4479 Complete content of editable text field. \\[widget-complete]
4480 \\<custom-mode-map>\
4481 Invoke button under the mouse pointer. \\[widget-button-click]
4482 Invoke button under point. \\[widget-button-press]
4483 Set all options from current text. \\[Custom-set]
4484 Make values in current text permanent. \\[Custom-save]
4485 Make text match actual option values. \\[Custom-reset-current]
4486 Reset options to permanent settings. \\[Custom-reset-saved]
4487 Erase customizations; set options
4488 and buffer text to the standard values. \\[Custom-reset-standard]
4490 Entry to this mode calls the value of `custom-mode-hook'
4491 if that value is non-nil."
4492 (kill-all-local-variables)
4493 (setq major-mode
'custom-mode
4495 (use-local-map custom-mode-map
)
4496 (easy-menu-add Custom-mode-menu
)
4497 (make-local-variable 'custom-options
)
4498 (make-local-variable 'custom-local-buffer
)
4499 (make-local-variable 'widget-documentation-face
)
4500 (setq widget-documentation-face
'custom-documentation
)
4501 (make-local-variable 'widget-button-face
)
4502 (setq widget-button-face custom-button
)
4503 (set (make-local-variable 'widget-button-pressed-face
) custom-button-pressed
)
4504 (set (make-local-variable 'widget-mouse-face
) custom-button-mouse
)
4506 ;; When possible, use relief for buttons, not bracketing. This test
4507 ;; may not be optimal.
4508 (when custom-raised-buttons
4509 (set (make-local-variable 'widget-push-button-prefix
) "")
4510 (set (make-local-variable 'widget-push-button-suffix
) "")
4511 (set (make-local-variable 'widget-link-prefix
) "")
4512 (set (make-local-variable 'widget-link-suffix
) ""))
4513 (add-hook 'widget-edit-functions
'custom-state-buffer-message nil t
)
4514 (run-mode-hooks 'custom-mode-hook
))
4516 (put 'custom-mode
'mode-class
'special
)
4519 'debug-ignored-errors
4520 "^No user options have changed defaults in recent Emacs versions$")
4526 ;; arch-tag: 64533aa4-1b1a-48c3-8812-f9dc718e8a6f
4527 ;;; cus-edit.el ends here