1 ;;; cus-edit.el --- Tools for customization Emacs.
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: help, faces
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
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., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
29 ;; This file implements the code to create and edit customize buffers.
38 (eval-when-compile (require 'cl))
44 (defun custom-face-display-set (face spec &optional frame)
45 (face-spec-set face spec frame))
47 (defun custom-display-match-frame (display frame)
48 (face-spec-set-match-display display frame))
50 (define-widget-keywords :custom-prefixes :custom-menu :custom-show
51 :custom-magic :custom-state :custom-level :custom-form
52 :custom-set :custom-save :custom-reset-current :custom-reset-saved
53 :custom-reset-factory)
55 (put 'custom-define-hook 'custom-type 'hook)
56 (put 'custom-define-hook 'factory-value '(nil))
57 (custom-add-to-group 'customize 'custom-define-hook 'custom-variable)
59 ;;; Customization Groups.
62 "Customization of the One True Editor."
63 :link '(custom-manual "(emacs)Top"))
65 ;; Most of these groups are stolen from `finder.el',
67 "Basic text editing facilities."
71 "Abbreviation handling, typing shortcuts, macros."
75 (defgroup matching nil
76 "Various sorts of searching and matching."
79 (defgroup emulations nil
80 "Emulations of other editors."
87 (defgroup outlines nil
88 "Support for hierarchical outlining."
91 (defgroup external nil
92 "Interfacing to external utilities."
96 "Code related to the `bib' bibliography processor."
100 (defgroup processes nil
101 "Process, subshell, compilation, and job control support."
105 (defgroup programming nil
106 "Support for programming in other languages."
109 (defgroup languages nil
110 "Specialized modes for editing programming languages."
114 "Lisp support, including Emacs Lisp."
119 "Support for the C language and related languages."
127 "Support for object-oriented programming."
130 (defgroup applications nil
131 "Applications written in Emacs."
134 (defgroup calendar nil
135 "Calendar and time management support."
136 :group 'applications)
139 "Modes for electronic-mail handling."
140 :group 'applications)
143 "Support for netnews reading and posting."
144 :group 'applications)
147 "Games, jokes and amusements."
148 :group 'applications)
150 (defgroup development nil
151 "Support for further development of Emacs."
155 "Support for Emacs documentation."
158 (defgroup extensions nil
159 "Emacs Lisp language extensions."
162 (defgroup internal nil
163 "Code for Emacs internals, build process, defaults."
167 "Maintenance aids for the Emacs development group."
171 (defgroup environment nil
172 "Fitting Emacs with its environment."
176 "Communications, networking, remote access to files."
180 (defgroup hardware nil
181 "Support for interfacing with exotic hardware."
184 (defgroup terminals nil
185 "Support for terminal types."
189 "Front-ends/assistants for, or emulators of, UNIX features."
193 "Support code for vms."
197 "Internationalization and alternate character-set support."
202 "Support for Emacs frames and window systems."
206 "Support editing files of data."
214 "Code related to the TeX formatter."
218 "Support for multiple fonts."
221 (defgroup hypermedia nil
222 "Support for links between text or other media types."
226 "Support for on-line help systems."
230 "Code local to your site."
233 (defgroup customize '((widgets custom-group))
234 "Customization of the Customization support."
235 :link '(custom-manual "(custom)Top")
236 :link '(url-link :tag "Development Page"
237 "http://www.dina.kvl.dk/~abraham/custom/")
241 (defgroup custom-faces nil
242 "Faces used by customize."
246 (defgroup abbrev-mode nil
247 "Word abbreviations mode."
251 "Storage allocation and gc for GNU Emacs Lisp interpreter."
252 :tag "Storage Allocation"
256 "Undoing changes in buffers."
259 (defgroup modeline nil
260 "Content of the modeline."
264 "Indenting and filling text."
267 (defgroup editing-basics nil
268 "Most basic editing facilities."
271 (defgroup display nil
272 "How characters are displayed in buffers."
275 (defgroup execute nil
276 "Executing external commands."
279 (defgroup installation nil
280 "The Emacs installation."
288 "Internal Emacs limits."
292 "Debugging Emacs itself."
295 (defgroup minibuffer nil
296 "Controling the behaviour of the minibuffer."
299 (defgroup keyboard nil
300 "Input from the keyboard."
304 "Input from the mouse."
308 "Input from the menus."
311 (defgroup auto-save nil
312 "Preventing accidential loss of data."
315 (defgroup processes-basics nil
316 "Basic stuff dealing with processes."
319 (defgroup windows nil
320 "Windows within a frame."
325 (defun custom-quote (sexp)
326 "Quote SEXP iff it is not self quoting."
327 (if (or (memq sexp '(t nil))
329 (eq (aref (symbol-name sexp) 0) ?:))
331 (memq (car sexp) '(lambda)))
334 (and (fboundp 'characterp)
339 (defun custom-split-regexp-maybe (regexp)
340 "If REGEXP is a string, split it to a list at `\\|'.
341 You can get the original back with from the result with:
342 (mapconcat 'identity result \"\\|\")
344 IF REGEXP is not a string, return it unchanged."
348 (while (string-match "\\\\|" regexp start)
349 (setq all (cons (substring regexp start (match-beginning 0)) all)
350 start (match-end 0)))
351 (nreverse (cons (substring regexp start) all)))
354 (defun custom-variable-prompt ()
355 ;; Code stolen from `help.el'.
356 "Prompt for a variable, defaulting to the variable at point.
357 Return a list suitable for use in `interactive'."
358 (let ((v (variable-at-point))
359 (enable-recursive-minibuffers t)
361 (setq val (completing-read
363 (format "Customize variable (default %s): " v)
364 "Customize variable: ")
365 obarray (lambda (symbol)
367 (or (get symbol 'custom-type)
368 (user-variable-p symbol))))))
369 (list (if (equal val "")
372 (defun custom-menu-filter (menu widget)
373 "Convert MENU to the form used by `widget-choose'.
374 MENU should be in the same format as `custom-variable-menu'.
375 WIDGET is the widget to apply the filter entries of MENU on."
377 current name action filter)
379 (setq current (car menu)
381 action (nth 1 current)
382 filter (nth 2 current)
384 (if (or (null filter) (funcall filter widget))
385 (push (cons name action) result)
391 (defvar custom-prefix-list nil
392 "List of prefixes that should be ignored by `custom-unlispify'")
394 (defcustom custom-unlispify-menu-entries t
395 "Display menu entries as words instead of symbols if non nil."
399 (defun custom-unlispify-menu-entry (symbol &optional no-suffix)
400 "Convert symbol into a menu entry."
401 (cond ((not custom-unlispify-menu-entries)
402 (symbol-name symbol))
403 ((get symbol 'custom-tag)
405 (get symbol 'custom-tag)
406 (concat (get symbol 'custom-tag) "...")))
409 (set-buffer (get-buffer-create " *Custom-Work*"))
411 (princ symbol (current-buffer))
412 (goto-char (point-min))
413 (when (and (eq (get symbol 'custom-type) 'boolean)
414 (re-search-forward "-p\\'" nil t))
415 (replace-match "" t t)
416 (goto-char (point-min)))
417 (let ((prefixes custom-prefix-list)
420 (setq prefix (car prefixes))
421 (if (search-forward prefix (+ (point) (length prefix)) t)
424 (delete-region (point-min) (point)))
425 (setq prefixes (cdr prefixes)))))
426 (subst-char-in-region (point-min) (point-max) ?- ?\ t)
427 (capitalize-region (point-min) (point-max))
429 (goto-char (point-max))
433 (defcustom custom-unlispify-tag-names t
434 "Display tag names as words instead of symbols if non nil."
438 (defun custom-unlispify-tag-name (symbol)
439 "Convert symbol into a menu entry."
440 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names))
441 (custom-unlispify-menu-entry symbol t)))
443 (defun custom-prefix-add (symbol prefixes)
444 ;; Addd SYMBOL to list of ignored PREFIXES.
445 (cons (or (get symbol 'custom-prefix)
446 (concat (symbol-name symbol) "-"))
451 (defcustom custom-guess-name-alist
456 ("-function\\'" function)
457 ("-functions\\'" (repeat function))
458 ("-list\\'" (repeat sexp))
459 ("-alist\\'" (repeat (cons sexp sexp))))
460 "Alist of (MATCH TYPE).
462 MATCH should be a regexp matching the name of a symbol, and TYPE should
463 be a widget suitable for editing the value of that symbol. The TYPE
464 of the first entry where MATCH matches the name of the symbol will be
467 This is used for guessing the type of variables not declared with
469 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
472 (defcustom custom-guess-doc-alist
473 '(("\\`\\*?Non-nil " boolean))
474 "Alist of (MATCH TYPE).
476 MATCH should be a regexp matching a documentation string, and TYPE
477 should be a widget suitable for editing the value of a variable with
478 that documentation string. The TYPE of the first entry where MATCH
479 matches the name of the symbol will be used.
481 This is used for guessing the type of variables not declared with
483 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
486 (defun custom-guess-type (symbol)
487 "Guess a widget suitable for editing the value of SYMBOL.
488 This is done by matching SYMBOL with `custom-guess-name-alist' and
489 if that fails, the doc string with `custom-guess-doc-alist'."
490 (let ((name (symbol-name symbol))
491 (names custom-guess-name-alist)
494 (setq current (car names)
496 (when (string-match (nth 0 current) name)
497 (setq found (nth 1 current)
500 (let ((doc (documentation-property symbol 'variable-documentation))
501 (docs custom-guess-doc-alist))
504 (setq current (car docs)
506 (when (string-match (nth 0 current) doc)
507 (setq found (nth 1 current)
511 ;;; Custom Mode Commands.
513 (defvar custom-options nil
514 "Customization widgets in the current buffer.")
517 "Set changes in all modified options."
519 (let ((children custom-options))
520 (mapcar (lambda (child)
521 (when (eq (widget-get child :custom-state) 'modified)
522 (widget-apply child :custom-set)))
525 (defun custom-save ()
526 "Set all modified group members and save them."
528 (let ((children custom-options))
529 (mapcar (lambda (child)
530 (when (memq (widget-get child :custom-state) '(modified set))
531 (widget-apply child :custom-save)))
535 (defvar custom-reset-menu
536 '(("Current" . custom-reset-current)
537 ("Saved" . custom-reset-saved)
538 ("Factory Settings" . custom-reset-factory))
539 "Alist of actions for the `Reset' button.
540 The key is a string containing the name of the action, the value is a
541 lisp function taking the widget as an element which will be called
542 when the action is chosen.")
544 (defun custom-reset (event)
545 "Select item from reset menu."
546 (let* ((completion-ignore-case t)
547 (answer (widget-choose "Reset to"
553 (defun custom-reset-current ()
554 "Reset all modified group members to their current value."
556 (let ((children custom-options))
557 (mapcar (lambda (child)
558 (when (eq (widget-get child :custom-state) 'modified)
559 (widget-apply child :custom-reset-current)))
562 (defun custom-reset-saved ()
563 "Reset all modified or set group members to their saved value."
565 (let ((children custom-options))
566 (mapcar (lambda (child)
567 (when (eq (widget-get child :custom-state) 'modified)
568 (widget-apply child :custom-reset-current)))
571 (defun custom-reset-factory ()
572 "Reset all modified, set, or saved group members to their standard settings."
574 (let ((children custom-options))
575 (mapcar (lambda (child)
576 (when (eq (widget-get child :custom-state) 'modified)
577 (widget-apply child :custom-reset-current)))
580 ;;; The Customize Commands
582 (defun custom-prompt-variable (prompt-var prompt-val)
583 "Prompt for a variable and a value and return them as a list.
584 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the
585 prompt for the value. The %s escape in PROMPT-VAL is replaced with
586 the name of the variable.
588 If the variable has a `variable-interactive' property, that is used as if
589 it were the arg to `interactive' (which see) to interactively read the value.
591 If the variable has a `custom-type' property, it must be a widget and the
592 `:prompt-value' property of that widget will be used for reading the value."
593 (let* ((var (read-variable prompt-var))
594 (minibuffer-help-form '(describe-variable var)))
596 (let ((prop (get var 'variable-interactive))
597 (type (get var 'custom-type))
598 (prompt (format prompt-val var)))
600 (setq type (list type)))
602 ;; Use VAR's `variable-interactive' property
603 ;; as an interactive spec for prompting.
604 (call-interactively (list 'lambda '(arg)
605 (list 'interactive prop)
608 (widget-prompt-value type
614 (eval-minibuffer prompt)))))))
617 (defun custom-set-value (var val)
618 "Set VARIABLE to VALUE. VALUE is a Lisp object.
620 If VARIABLE has a `variable-interactive' property, that is used as if
621 it were the arg to `interactive' (which see) to interactively read the value.
623 If VARIABLE has a `custom-type' property, it must be a widget and the
624 `:prompt-value' property of that widget will be used for reading the value."
625 (interactive (custom-prompt-variable "Set variable: "
626 "Set %s to value: "))
631 (defun custom-set-variable (var val)
632 "Set the default for VARIABLE to VALUE. VALUE is a Lisp object.
634 If VARIABLE has a `custom-set' property, that is used for setting
635 VARIABLE, otherwise `set-default' is used.
637 The `customized-value' property of the VARIABLE will be set to a list
638 with a quoted VALUE as its sole list member.
640 If VARIABLE has a `variable-interactive' property, that is used as if
641 it were the arg to `interactive' (which see) to interactively read the value.
643 If VARIABLE has a `custom-type' property, it must be a widget and the
644 `:prompt-value' property of that widget will be used for reading the value. "
645 (interactive (custom-prompt-variable "Set variable: "
646 "Set customized value for %s to: "))
647 (funcall (or (get var 'custom-set) 'set-default) var val)
648 (put var 'customized-value (list (custom-quote val))))
652 "Select a customization buffer which you can use to set user options.
653 User options are structured into \"groups\".
654 Initially the top-level group `Emacs' and its immediate subgroups
655 are shown; the contents of those subgroups are initially hidden."
660 (defun customize-group (group)
661 "Customize GROUP, which must be a customization group."
662 (interactive (list (completing-read "Customize group: (default emacs) "
665 (get symbol 'custom-group))
668 (when (stringp group)
669 (if (string-equal "" group)
671 (setq group (intern group))))
672 (custom-buffer-create (list (list group 'custom-group))))
675 (defun customize-other-window (symbol)
676 "Customize SYMBOL, which must be a customization group."
677 (interactive (list (completing-read "Customize group: (default emacs) "
680 (get symbol 'custom-group))
683 (when (stringp symbol)
684 (if (string-equal "" symbol)
686 (setq symbol (intern symbol))))
687 (custom-buffer-create-other-window (list (list symbol 'custom-group))))
690 (defun customize-variable (symbol)
691 "Customize SYMBOL, which must be a variable."
692 (interactive (custom-variable-prompt))
693 (custom-buffer-create (list (list symbol 'custom-variable))))
696 (defun customize-variable-other-window (symbol)
697 "Customize SYMBOL, which must be a variable.
698 Show the buffer in another window, but don't select it."
699 (interactive (custom-variable-prompt))
700 (custom-buffer-create-other-window (list (list symbol 'custom-variable))))
703 (defun customize-face (&optional symbol)
704 "Customize SYMBOL, which should be a face name or nil.
705 If SYMBOL is nil, customize all faces."
706 (interactive (list (completing-read "Customize face: (default all) "
707 obarray 'custom-facep)))
708 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
710 (message "Looking for faces...")
711 (mapcar (lambda (symbol)
712 (setq found (cons (list symbol 'custom-face) found)))
713 (nreverse (mapcar 'intern
714 (sort (mapcar 'symbol-name (face-list))
717 (custom-buffer-create found))
719 (setq symbol (intern symbol)))
720 (unless (symbolp symbol)
721 (error "Should be a symbol %S" symbol))
722 (custom-buffer-create (list (list symbol 'custom-face)))))
725 (defun customize-face-other-window (&optional symbol)
726 "Show customization buffer for FACE in other window."
727 (interactive (list (completing-read "Customize face: "
728 obarray 'custom-facep)))
729 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
732 (setq symbol (intern symbol)))
733 (unless (symbolp symbol)
734 (error "Should be a symbol %S" symbol))
735 (custom-buffer-create-other-window (list (list symbol 'custom-face)))))
738 (defun customize-customized ()
739 "Customize all user options set since the last save in this session."
742 (mapatoms (lambda (symbol)
743 (and (get symbol 'customized-face)
744 (custom-facep symbol)
745 (setq found (cons (list symbol 'custom-face) found)))
746 (and (get symbol 'customized-value)
749 (cons (list symbol 'custom-variable) found)))))
751 (custom-buffer-create found)
752 (error "No customized user options"))))
755 (defun customize-saved ()
756 "Customize all already saved user options."
759 (mapatoms (lambda (symbol)
760 (and (get symbol 'saved-face)
761 (custom-facep symbol)
762 (setq found (cons (list symbol 'custom-face) found)))
763 (and (get symbol 'saved-value)
766 (cons (list symbol 'custom-variable) found)))))
768 (custom-buffer-create found)
769 (error "No saved user options"))))
772 (defun customize-apropos (regexp &optional all)
773 "Customize all user options matching REGEXP.
774 If ALL (e.g., started with a prefix key), include options which are not
776 (interactive "sCustomize regexp: \nP")
778 (mapatoms (lambda (symbol)
779 (when (string-match regexp (symbol-name symbol))
780 (when (get symbol 'custom-group)
781 (setq found (cons (list symbol 'custom-group) found)))
782 (when (custom-facep symbol)
783 (setq found (cons (list symbol 'custom-face) found)))
784 (when (and (boundp symbol)
785 (or (get symbol 'saved-value)
786 (get symbol 'factory-value)
788 (get symbol 'variable-documentation)
789 (user-variable-p symbol))))
791 (cons (list symbol 'custom-variable) found))))))
793 (custom-buffer-create found)
794 (error "No matches"))))
799 (defun custom-buffer-create (options)
800 "Create a buffer containing OPTIONS.
801 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
802 SYMBOL is a customization option, and WIDGET is a widget for editing
804 (kill-buffer (get-buffer-create "*Customization*"))
805 (switch-to-buffer (get-buffer-create "*Customization*"))
806 (custom-buffer-create-internal options))
809 (defun custom-buffer-create-other-window (options)
810 "Create a buffer containing OPTIONS.
811 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
812 SYMBOL is a customization option, and WIDGET is a widget for editing
814 (kill-buffer (get-buffer-create "*Customization*"))
815 (let ((window (selected-window)))
816 (switch-to-buffer-other-window (get-buffer-create "*Customization*"))
817 (custom-buffer-create-internal options)
818 (select-window window)))
821 (defun custom-buffer-create-internal (options)
822 (message "Creating customization buffer...")
824 (widget-insert "This is a customization buffer.
825 Push RET or click mouse-2 on the word ")
826 ;; (put-text-property 1 2 'start-open nil)
827 (widget-create 'info-link
829 :help-echo "Read the online help."
830 "(custom)The Customization Buffer")
831 (widget-insert " for more information.\n\n")
833 (if (= (length options) 1)
834 (mapcar (lambda (entry)
835 (widget-create (nth 1 entry)
836 :custom-state 'unknown
837 :tag (custom-unlispify-tag-name
839 :value (nth 0 entry)))
842 (length (length options)))
843 (mapcar (lambda (entry)
845 (message "Creating customization items %2d%%..."
846 (/ (* 100.0 count) length))
847 (widget-create (nth 1 entry)
848 :tag (custom-unlispify-tag-name
850 :value (nth 0 entry))
851 (setq count (1+ count))
852 (unless (eq (preceding-char) ?\n)
853 (widget-insert "\n"))
854 (widget-insert "\n")))
856 (unless (eq (preceding-char) ?\n)
857 (widget-insert "\n"))
859 (message "Creating customization magic...")
860 (mapcar 'custom-magic-reset custom-options)
861 (message "Creating customization buttons...")
862 (widget-create 'push-button
864 :help-echo "Set all modifications for this session."
865 :action (lambda (widget &optional event)
868 (widget-create 'push-button
871 Make the modifications default for future sessions."
872 :action (lambda (widget &optional event)
875 (widget-create 'push-button
877 :help-echo "Undo all modifications."
878 :action (lambda (widget &optional event)
879 (custom-reset event)))
881 (widget-create 'push-button
883 :help-echo "Bury the buffer."
884 :action (lambda (widget &optional event)
886 ;; Steal button release event.
887 (if (and (fboundp 'button-press-event-p)
888 (fboundp 'next-command-event))
891 (button-press-event-p event)
892 (next-command-event))
894 (when (memq 'down (event-modifiers event))
897 (message "Creating customization setup...")
899 (goto-char (point-min))
900 (forward-line 3) ;Kludge: bob is writable in XEmacs.
901 (message "Creating customization buffer...done"))
903 ;;; Modification of Basic Widgets.
905 ;; We add extra properties to the basic widgets needed here. This is
906 ;; fine, as long as we are careful to stay within out own namespace.
908 ;; We want simple widgets to be displayed by default, but complex
909 ;; widgets to be hidden.
911 (widget-put (get 'item 'widget-type) :custom-show t)
912 (widget-put (get 'editable-field 'widget-type)
913 :custom-show (lambda (widget value)
914 (let ((pp (pp-to-string value)))
915 (cond ((string-match "\n" pp)
920 (widget-put (get 'menu-choice 'widget-type) :custom-show t)
922 ;;; The `custom-manual' Widget.
924 (define-widget 'custom-manual 'info-link
925 "Link to the manual entry for this customization option."
926 :help-echo "Read the manual entry for this option."
929 ;;; The `custom-magic' Widget.
931 (defface custom-invalid-face '((((class color))
932 (:foreground "yellow" :background "red"))
934 (:bold t :italic t :underline t)))
935 "Face used when the customize item is invalid.")
937 (defface custom-rogue-face '((((class color))
938 (:foreground "pink" :background "black"))
941 "Face used when the customize item is not defined for customization.")
943 (defface custom-modified-face '((((class color))
944 (:foreground "white" :background "blue"))
947 "Face used when the customize item has been modified.")
949 (defface custom-set-face '((((class color))
950 (:foreground "blue" :background "white"))
953 "Face used when the customize item has been set.")
955 (defface custom-changed-face '((((class color))
956 (:foreground "white" :background "blue"))
959 "Face used when the customize item has been changed.")
961 (defface custom-saved-face '((t (:underline t)))
962 "Face used when the customize item has been saved.")
964 (defcustom custom-magic-alist '((nil "#" underline "\
965 uninitialized, you should not see this.")
966 (unknown "?" italic "\
967 unknown, you should not see this.")
968 (hidden "-" default "\
969 hidden, press the state button to show.")
970 (invalid "x" custom-invalid-face "\
971 the value displayed for this item is invalid and cannot be set.")
972 (modified "*" custom-modified-face "\
973 you have edited the item, and can now set it.")
974 (set "+" custom-set-face "\
975 you have set this item, but not saved it.")
976 (changed ":" custom-changed-face "\
977 this item has been changed outside customize.")
978 (saved "!" custom-saved-face "\
979 this item has been saved.")
980 (rogue "@" custom-rogue-face "\
981 this item is not prepared for customization.")
983 this item is unchanged from its standard setting."))
984 "Alist of customize option states.
985 Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where
987 STATE is one of the following symbols:
990 For internal use, should never occur.
992 For internal use, should never occur.
994 This item is not being displayed.
996 This item is modified, but has an invalid form.
998 This item is modified, and has a valid form.
1000 This item has been set but not saved.
1002 The current value of this item has been changed temporarily.
1004 This item is marked for saving.
1006 This item has no customization information.
1008 This item is unchanged from the standard setting.
1010 MAGIC is a string used to present that state.
1012 FACE is a face used to present the state.
1014 DESCRIPTION is a string describing the state.
1016 The list should be sorted most significant first."
1017 :type '(list (checklist :inline t
1019 (string :tag "Magic")
1021 (string :tag "Description"))
1022 (group (const unknown)
1023 (string :tag "Magic")
1025 (string :tag "Description"))
1026 (group (const hidden)
1027 (string :tag "Magic")
1029 (string :tag "Description"))
1030 (group (const invalid)
1031 (string :tag "Magic")
1033 (string :tag "Description"))
1034 (group (const modified)
1035 (string :tag "Magic")
1037 (string :tag "Description"))
1039 (string :tag "Magic")
1041 (string :tag "Description"))
1042 (group (const changed)
1043 (string :tag "Magic")
1045 (string :tag "Description"))
1046 (group (const saved)
1047 (string :tag "Magic")
1049 (string :tag "Description"))
1050 (group (const rogue)
1051 (string :tag "Magic")
1053 (string :tag "Description"))
1054 (group (const factory)
1055 (string :tag "Magic")
1057 (string :tag "Description")))
1058 (editable-list :inline t
1060 (string :tag "Magic")
1062 (string :tag "Description"))))
1064 :group 'custom-faces)
1066 (defcustom custom-group-magic-alist '((nil "#" underline "\
1067 uninitialized, you should not see this.")
1068 (unknown "?" italic "\
1069 unknown, you should not see this.")
1070 (hidden "-" default "\
1071 group now hidden; click on the asterisks above to show contents.")
1072 (invalid "x" custom-invalid-face "\
1073 the value displayed for this item is invalid and cannot be set.")
1074 (modified "*" custom-modified-face "\
1075 you have edited something in this group, and can now set it.")
1076 (set "+" custom-set-face "\
1077 something in this group has been set, but not yet saved.")
1078 (changed ":" custom-changed-face "\
1079 this item has been changed outside customize.")
1080 (saved "!" custom-saved-face "\
1081 something in this group has been set and saved.")
1082 (rogue "@" custom-rogue-face "\
1083 this item is not prepared for customization.")
1085 nothing in this group has been changed."))
1086 "Alist of customize option states.
1087 Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where
1089 STATE is one of the following symbols:
1092 For internal use, should never occur.
1094 For internal use, should never occur.
1096 This item is not being displayed.
1098 This item is modified, but has an invalid form.
1100 This item is modified, and has a valid form.
1102 This item has been set but not saved.
1104 The current value of this item has been changed temporarily.
1106 This item is marked for saving.
1108 This item has no customization information.
1110 This item is unchanged from the standard setting.
1112 MAGIC is a string used to present that state.
1114 FACE is a face used to present the state.
1116 DESCRIPTION is a string describing the state.
1118 The list should be sorted most significant first."
1119 :type '(list (checklist :inline t
1121 (string :tag "Magic")
1123 (string :tag "Description"))
1124 (group (const unknown)
1125 (string :tag "Magic")
1127 (string :tag "Description"))
1128 (group (const hidden)
1129 (string :tag "Magic")
1131 (string :tag "Description"))
1132 (group (const invalid)
1133 (string :tag "Magic")
1135 (string :tag "Description"))
1136 (group (const modified)
1137 (string :tag "Magic")
1139 (string :tag "Description"))
1141 (string :tag "Magic")
1143 (string :tag "Description"))
1144 (group (const changed)
1145 (string :tag "Magic")
1147 (string :tag "Description"))
1148 (group (const saved)
1149 (string :tag "Magic")
1151 (string :tag "Description"))
1152 (group (const rogue)
1153 (string :tag "Magic")
1155 (string :tag "Description"))
1156 (group (const factory)
1157 (string :tag "Magic")
1159 (string :tag "Description")))
1160 (editable-list :inline t
1162 (string :tag "Magic")
1164 (string :tag "Description"))))
1166 :group 'custom-faces)
1168 (defcustom custom-magic-show 'long
1169 "Show long description of the state of each customization option."
1170 :type '(choice (const :tag "no" nil)
1175 (defcustom custom-magic-show-button t
1176 "Show a magic button indicating the state of each customization option."
1180 (define-widget 'custom-magic 'default
1181 "Show and manipulate state for a customization option."
1183 :action 'widget-choice-item-action
1186 :value-create 'custom-magic-value-create
1187 :value-delete 'widget-children-value-delete)
1189 (defun custom-magic-value-create (widget)
1190 ;; Create compact status report for WIDGET.
1191 (let* ((parent (widget-get widget :parent))
1192 (state (widget-get parent :custom-state))
1193 (entry (assq state (if (eq (car parent) 'custom-group)
1194 custom-group-magic-alist
1195 custom-magic-alist)))
1196 (magic (nth 1 entry))
1197 (face (nth 2 entry))
1198 (text (nth 3 entry))
1199 (lisp (eq (widget-get parent :custom-form) 'lisp))
1201 (when custom-magic-show
1202 (push (widget-create-child-and-convert widget 'choice-item
1204 Change the state of this item."
1209 (if (eq custom-magic-show 'long)
1211 (insert (symbol-name state)))
1215 (when custom-magic-show-button
1216 (when custom-magic-show
1217 (let ((indent (widget-get parent :indent)))
1219 (insert-char ? indent))))
1220 (push (widget-create-child-and-convert widget 'choice-item
1222 :help-echo "Change the state."
1225 (concat "(" magic ")")
1226 (concat "[" magic "]")))
1229 (widget-put widget :children children)))
1231 (defun custom-magic-reset (widget)
1232 "Redraw the :custom-magic property of WIDGET."
1233 (let ((magic (widget-get widget :custom-magic)))
1234 (widget-value-set magic (widget-value magic))))
1236 ;;; The `custom-level' Widget.
1238 (define-widget 'custom-level 'item
1239 "The custom level buttons."
1241 :help-echo "Expand or collapse this item."
1242 :action 'custom-level-action)
1244 (defun custom-level-action (widget &optional event)
1245 "Toggle visibility for parent to WIDGET."
1246 (custom-toggle-hide (widget-get widget :parent)))
1248 ;;; The `custom' Widget.
1250 (define-widget 'custom 'default
1251 "Customize a user option."
1252 :convert-widget 'custom-convert-widget
1253 :format "%l%[%t%]: %v%m%h%a"
1254 :format-handler 'custom-format-handler
1255 :notify 'custom-notify
1257 :custom-state 'hidden
1258 :documentation-property 'widget-subclass-responsibility
1259 :value-create 'widget-subclass-responsibility
1260 :value-delete 'widget-children-value-delete
1261 :value-get 'widget-item-value-get
1262 :validate 'widget-editable-list-validate
1263 :match (lambda (widget value) (symbolp value)))
1265 (defun custom-convert-widget (widget)
1266 ;; Initialize :value and :tag from :args in WIDGET.
1267 (let ((args (widget-get widget :args)))
1269 (widget-put widget :value (widget-apply widget
1270 :value-to-internal (car args)))
1271 (widget-put widget :tag (custom-unlispify-tag-name (car args)))
1272 (widget-put widget :args nil)))
1275 (defun custom-format-handler (widget escape)
1276 ;; We recognize extra escape sequences.
1277 (let* ((buttons (widget-get widget :buttons))
1278 (state (widget-get widget :custom-state))
1279 (level (widget-get widget :custom-level)))
1280 (cond ((eq escape ?l)
1282 (push (widget-create-child-and-convert
1283 widget 'custom-level (make-string level ?*))
1286 (widget-put widget :buttons buttons)))
1288 (when (eq state 'hidden)
1289 (widget-insert " ...")))
1291 (and (eq (preceding-char) ?\n)
1292 (widget-get widget :indent)
1293 (insert-char ? (widget-get widget :indent)))
1294 (let ((magic (widget-create-child-and-convert
1295 widget 'custom-magic nil)))
1296 (widget-put widget :custom-magic magic)
1297 (push magic buttons)
1298 (widget-put widget :buttons buttons)))
1300 (let* ((symbol (widget-get widget :value))
1301 (links (get symbol 'custom-links))
1302 (many (> (length links) 2)))
1304 (and (eq (preceding-char) ?\n)
1305 (widget-get widget :indent)
1306 (insert-char ? (widget-get widget :indent)))
1307 (insert "See also ")
1309 (push (widget-create-child-and-convert widget (car links))
1311 (setq links (cdr links))
1320 (widget-put widget :buttons buttons))))
1322 (widget-default-format-handler widget escape)))))
1324 (defun custom-notify (widget &rest args)
1325 "Keep track of changes."
1326 (unless (memq (widget-get widget :custom-state) '(nil unknown hidden))
1327 (widget-put widget :custom-state 'modified))
1328 (let ((buffer-undo-list t))
1329 (custom-magic-reset widget))
1330 (apply 'widget-default-notify widget args))
1332 (defun custom-redraw (widget)
1333 "Redraw WIDGET with current settings."
1334 (let ((line (count-lines (point-min) (point)))
1335 (column (current-column))
1337 (from (marker-position (widget-get widget :from)))
1338 (to (marker-position (widget-get widget :to))))
1340 (widget-value-set widget (widget-value widget))
1341 (custom-redraw-magic widget))
1342 (when (and (>= pos from) (<= pos to))
1346 (move-to-column column))
1349 (defun custom-redraw-magic (widget)
1350 "Redraw WIDGET state with current settings."
1352 (let ((magic (widget-get widget :custom-magic)))
1355 (widget-value-set magic (widget-value magic))
1356 (when (setq widget (widget-get widget :group))
1357 (custom-group-state-update widget))))
1360 (defun custom-show (widget value)
1361 "Non-nil if WIDGET should be shown with VALUE by default."
1362 (let ((show (widget-get widget :custom-show)))
1368 (funcall show widget value)))))
1370 (defvar custom-load-recursion nil
1371 "Hack to avoid recursive dependencies.")
1373 (defun custom-load-symbol (symbol)
1374 "Load all dependencies for SYMBOL."
1375 (unless custom-load-recursion
1376 (let ((custom-load-recursion t)
1377 (loads (get symbol 'custom-loads))
1380 (setq load (car loads)
1382 (cond ((symbolp load)
1386 ((assoc load load-history))
1392 (defun custom-load-widget (widget)
1393 "Load all dependencies for WIDGET."
1394 (custom-load-symbol (widget-value widget)))
1396 (defun custom-toggle-hide (widget)
1397 "Toggle visibility of WIDGET."
1398 (let ((state (widget-get widget :custom-state)))
1399 (cond ((memq state '(invalid modified))
1400 (error "There are unset changes"))
1402 (widget-put widget :custom-state 'unknown))
1404 (widget-put widget :custom-state 'hidden)))
1405 (custom-redraw widget)))
1407 ;;; The `custom-variable' Widget.
1409 (defface custom-variable-sample-face '((t (:underline t)))
1410 "Face used for unpushable variable tags."
1411 :group 'custom-faces)
1413 (defface custom-variable-button-face '((t (:underline t :bold t)))
1414 "Face used for pushable variable tags."
1415 :group 'custom-faces)
1417 (define-widget 'custom-variable 'custom
1418 "Customize variable."
1419 :format "%l%v%m%h%a"
1420 :help-echo "Set or reset this variable."
1421 :documentation-property 'variable-documentation
1423 :custom-menu 'custom-variable-menu-create
1425 :value-create 'custom-variable-value-create
1426 :action 'custom-variable-action
1427 :custom-set 'custom-variable-set
1428 :custom-save 'custom-variable-save
1429 :custom-reset-current 'custom-redraw
1430 :custom-reset-saved 'custom-variable-reset-saved
1431 :custom-reset-factory 'custom-variable-reset-factory)
1433 (defun custom-variable-type (symbol)
1434 "Return a widget suitable for editing the value of SYMBOL.
1435 If SYMBOL has a `custom-type' property, use that.
1436 Otherwise, look up symbol in `custom-guess-type-alist'."
1437 (let* ((type (or (get symbol 'custom-type)
1438 (and (not (get symbol 'factory-value))
1439 (custom-guess-type symbol))
1441 (options (get symbol 'custom-options))
1442 (tmp (if (listp type)
1443 (copy-sequence type)
1446 (widget-put tmp :options options))
1449 (defun custom-variable-value-create (widget)
1450 "Here is where you edit the variables value."
1451 (custom-load-widget widget)
1452 (let* ((buttons (widget-get widget :buttons))
1453 (children (widget-get widget :children))
1454 (form (widget-get widget :custom-form))
1455 (state (widget-get widget :custom-state))
1456 (symbol (widget-get widget :value))
1457 (tag (widget-get widget :tag))
1458 (type (custom-variable-type symbol))
1459 (conv (widget-convert type))
1460 (get (or (get symbol 'custom-get) 'default-value))
1461 (set (or (get symbol 'custom-set) 'set-default))
1462 (value (if (default-boundp symbol)
1463 (funcall get symbol)
1464 (widget-get conv :value))))
1465 ;; If the widget is new, the child determine whether it is hidden.
1467 ((custom-show type value)
1468 (setq state 'unknown))
1470 (setq state 'hidden)))
1471 ;; If we don't know the state, see if we need to edit it in lisp form.
1472 (when (eq state 'unknown)
1473 (unless (widget-apply conv :match value)
1474 ;; (widget-apply (widget-convert type) :match value)
1476 ;; Now we can create the child widget.
1477 (cond ((eq state 'hidden)
1478 ;; Indicate hidden value.
1479 (push (widget-create-child-and-convert
1481 :format "%{%t%}: ..."
1482 :sample-face 'custom-variable-sample-face
1487 ;; In lisp mode edit the saved value when possible.
1488 (let* ((value (cond ((get symbol 'saved-value)
1489 (car (get symbol 'saved-value)))
1490 ((get symbol 'factory-value)
1491 (car (get symbol 'factory-value)))
1492 ((default-boundp symbol)
1493 (custom-quote (funcall get symbol)))
1495 (custom-quote (widget-get conv :value))))))
1496 (push (widget-create-child-and-convert
1498 :button-face 'custom-variable-button-face
1499 :tag (symbol-name symbol)
1505 (push (widget-create-child-and-convert
1508 :button-face 'custom-variable-button-face
1509 :sample-face 'custom-variable-sample-face
1512 ;; Now update the state.
1513 (unless (eq (preceding-char) ?\n)
1514 (widget-insert "\n"))
1515 (if (eq state 'hidden)
1516 (widget-put widget :custom-state state)
1517 (custom-variable-state-set widget))
1518 (widget-put widget :custom-form form)
1519 (widget-put widget :buttons buttons)
1520 (widget-put widget :children children)))
1522 (defun custom-variable-state-set (widget)
1523 "Set the state of WIDGET."
1524 (let* ((symbol (widget-value widget))
1525 (get (or (get symbol 'custom-get) 'default-value))
1526 (value (if (default-boundp symbol)
1527 (funcall get symbol)
1528 (widget-get widget :value)))
1530 (state (cond ((setq tmp (get symbol 'customized-value))
1531 (if (condition-case nil
1532 (equal value (eval (car tmp)))
1536 ((setq tmp (get symbol 'saved-value))
1537 (if (condition-case nil
1538 (equal value (eval (car tmp)))
1542 ((setq tmp (get symbol 'factory-value))
1543 (if (condition-case nil
1544 (equal value (eval (car tmp)))
1549 (widget-put widget :custom-state state)))
1551 (defvar custom-variable-menu
1552 '(("Hide" custom-toggle-hide
1554 (not (memq (widget-get widget :custom-state) '(modified invalid)))))
1555 ("Edit" custom-variable-edit
1557 (not (eq (widget-get widget :custom-form) 'edit))))
1558 ("Edit Lisp" custom-variable-edit-lisp
1560 (not (eq (widget-get widget :custom-form) 'lisp))))
1561 ("Set" custom-variable-set
1563 (eq (widget-get widget :custom-state) 'modified)))
1564 ("Save" custom-variable-save
1566 (memq (widget-get widget :custom-state) '(modified set changed rogue))))
1567 ("Reset to Current" custom-redraw
1569 (and (default-boundp (widget-value widget))
1570 (memq (widget-get widget :custom-state) '(modified)))))
1571 ("Reset to Saved" custom-variable-reset-saved
1573 (and (get (widget-value widget) 'saved-value)
1574 (memq (widget-get widget :custom-state)
1575 '(modified set changed rogue)))))
1576 ("Reset to Standard Settings" custom-variable-reset-factory
1578 (and (get (widget-value widget) 'factory-value)
1579 (memq (widget-get widget :custom-state)
1580 '(modified set changed saved rogue))))))
1581 "Alist of actions for the `custom-variable' widget.
1582 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
1583 the menu entry, ACTION is the function to call on the widget when the
1584 menu is selected, and FILTER is a predicate which takes a `custom-variable'
1585 widget as an argument, and returns non-nil if ACTION is valid on that
1586 widget. If FILTER is nil, ACTION is always valid.")
1588 (defun custom-variable-action (widget &optional event)
1589 "Show the menu for `custom-variable' WIDGET.
1590 Optional EVENT is the location for the menu."
1591 (if (eq (widget-get widget :custom-state) 'hidden)
1592 (custom-toggle-hide widget)
1593 (let* ((completion-ignore-case t)
1594 (answer (widget-choose (custom-unlispify-tag-name
1595 (widget-get widget :value))
1596 (custom-menu-filter custom-variable-menu
1600 (funcall answer widget)))))
1602 (defun custom-variable-edit (widget)
1603 "Edit value of WIDGET."
1604 (widget-put widget :custom-state 'unknown)
1605 (widget-put widget :custom-form 'edit)
1606 (custom-redraw widget))
1608 (defun custom-variable-edit-lisp (widget)
1609 "Edit the lisp representation of the value of WIDGET."
1610 (widget-put widget :custom-state 'unknown)
1611 (widget-put widget :custom-form 'lisp)
1612 (custom-redraw widget))
1614 (defun custom-variable-set (widget)
1615 "Set the current value for the variable being edited by WIDGET."
1616 (let* ((form (widget-get widget :custom-form))
1617 (state (widget-get widget :custom-state))
1618 (child (car (widget-get widget :children)))
1619 (symbol (widget-value widget))
1620 (set (or (get symbol 'custom-set) 'set-default))
1622 (cond ((eq state 'hidden)
1623 (error "Cannot set hidden variable."))
1624 ((setq val (widget-apply child :validate))
1625 (goto-char (widget-get val :from))
1626 (error "%s" (widget-get val :error)))
1628 (funcall set symbol (eval (setq val (widget-value child))))
1629 (put symbol 'customized-value (list val)))
1631 (funcall set symbol (setq val (widget-value child)))
1632 (put symbol 'customized-value (list (custom-quote val)))))
1633 (custom-variable-state-set widget)
1634 (custom-redraw-magic widget)))
1636 (defun custom-variable-save (widget)
1637 "Set the default value for the variable being edited by WIDGET."
1638 (let* ((form (widget-get widget :custom-form))
1639 (state (widget-get widget :custom-state))
1640 (child (car (widget-get widget :children)))
1641 (symbol (widget-value widget))
1642 (set (or (get symbol 'custom-set) 'set-default))
1644 (cond ((eq state 'hidden)
1645 (error "Cannot set hidden variable."))
1646 ((setq val (widget-apply child :validate))
1647 (goto-char (widget-get val :from))
1648 (error "%s" (widget-get val :error)))
1650 (put symbol 'saved-value (list (widget-value child)))
1651 (funcall set symbol (eval (widget-value child))))
1654 'saved-value (list (custom-quote (widget-value
1656 (funcall set symbol (widget-value child))))
1657 (put symbol 'customized-value nil)
1659 (custom-variable-state-set widget)
1660 (custom-redraw-magic widget)))
1662 (defun custom-variable-reset-saved (widget)
1663 "Restore the saved value for the variable being edited by WIDGET."
1664 (let* ((symbol (widget-value widget))
1665 (set (or (get symbol 'custom-set) 'set-default)))
1666 (if (get symbol 'saved-value)
1668 (funcall set symbol (eval (car (get symbol 'saved-value))))
1670 (error "No saved value for %s" symbol))
1671 (put symbol 'customized-value nil)
1672 (widget-put widget :custom-state 'unknown)
1673 (custom-redraw widget)))
1675 (defun custom-variable-reset-factory (widget)
1676 "Restore the standard setting for the variable being edited by WIDGET."
1677 (let* ((symbol (widget-value widget))
1678 (set (or (get symbol 'custom-set) 'set-default)))
1679 (if (get symbol 'factory-value)
1680 (funcall set symbol (eval (car (get symbol 'factory-value))))
1681 (error "No standard setting known for %S" symbol))
1682 (put symbol 'customized-value nil)
1683 (when (get symbol 'saved-value)
1684 (put symbol 'saved-value nil)
1686 (widget-put widget :custom-state 'unknown)
1687 (custom-redraw widget)))
1689 ;;; The `custom-face-edit' Widget.
1691 (define-widget 'custom-face-edit 'checklist
1692 "Edit face attributes."
1696 :button-args '(:help-echo "Control whether this attribute have any effect.")
1697 :args (mapcar (lambda (att)
1700 :sibling-args (widget-get (nth 1 att) :sibling-args)
1701 (list 'const :format "" :value (nth 0 att))
1703 custom-face-attributes))
1705 ;;; The `custom-display' Widget.
1707 (define-widget 'custom-display 'menu-choice
1708 "Select a display type."
1711 :help-echo "Specify frames where the face attributes should be used."
1712 :args '((const :tag "all" t)
1716 :args ((group :sibling-args (:help-echo "\
1717 Only match the specified window systems.")
1718 (const :format "Type: "
1720 (checklist :inline t
1723 :sibling-args (:help-echo "\
1724 The X11 Window System.")
1726 (const :format "PM "
1727 :sibling-args (:help-echo "\
1728 OS/2 Presentation Manager.")
1730 (const :format "Win32 "
1731 :sibling-args (:help-echo "\
1734 (const :format "DOS "
1735 :sibling-args (:help-echo "\
1738 (const :format "TTY%n"
1739 :sibling-args (:help-echo "\
1740 Plain text terminals.")
1742 (group :sibling-args (:help-echo "\
1743 Only match the frames with the specified color support.")
1744 (const :format "Class: "
1746 (checklist :inline t
1748 (const :format "Color "
1749 :sibling-args (:help-echo "\
1750 Match color frames.")
1752 (const :format "Grayscale "
1753 :sibling-args (:help-echo "\
1754 Match grayscale frames.")
1756 (const :format "Monochrome%n"
1757 :sibling-args (:help-echo "\
1758 Match frames with no color support.")
1760 (group :sibling-args (:help-echo "\
1761 Only match frames with the specified intensity.")
1763 Background brightness: "
1765 (checklist :inline t
1767 (const :format "Light "
1768 :sibling-args (:help-echo "\
1769 Match frames with light backgrounds.")
1771 (const :format "Dark\n"
1772 :sibling-args (:help-echo "\
1773 Match frames with dark backgrounds.")
1776 ;;; The `custom-face' Widget.
1778 (defface custom-face-tag-face '((t (:underline t)))
1779 "Face used for face tags."
1780 :group 'custom-faces)
1782 (define-widget 'custom-face 'custom
1784 :format "%l%{%t%}: %s%m%h%a%v"
1785 :format-handler 'custom-face-format-handler
1786 :sample-face 'custom-face-tag-face
1787 :help-echo "Set or reset this face."
1788 :documentation-property '(lambda (face)
1789 (face-doc-string face))
1790 :value-create 'custom-face-value-create
1791 :action 'custom-face-action
1792 :custom-form 'selected
1793 :custom-set 'custom-face-set
1794 :custom-save 'custom-face-save
1795 :custom-reset-current 'custom-redraw
1796 :custom-reset-saved 'custom-face-reset-saved
1797 :custom-reset-factory 'custom-face-reset-factory
1798 :custom-menu 'custom-face-menu-create)
1800 (defun custom-face-format-handler (widget escape)
1801 ;; We recognize extra escape sequences.
1803 (symbol (widget-get widget :value)))
1804 (cond ((eq escape ?s)
1805 (and (string-match "XEmacs" emacs-version)
1806 ;; XEmacs cannot display initialized faces.
1807 (not (custom-facep symbol))
1808 (copy-face 'custom-face-empty symbol))
1809 (setq child (widget-create-child-and-convert
1811 :format "(%{%t%})\n"
1815 (custom-format-handler widget escape)))
1818 :buttons (cons child (widget-get widget :buttons))))))
1820 (define-widget 'custom-face-all 'editable-list
1821 "An editable list of display specifications and attributes."
1822 :entry-format "%i %d %v"
1823 :insert-button-args '(:help-echo "Insert new display specification here.")
1824 :append-button-args '(:help-echo "Append new display specification here.")
1825 :delete-button-args '(:help-echo "Delete this display specification.")
1826 :args '((group :format "%v" custom-display custom-face-edit)))
1828 (defconst custom-face-all (widget-convert 'custom-face-all)
1829 "Converted version of the `custom-face-all' widget.")
1831 (define-widget 'custom-display-unselected 'item
1832 "A display specification that doesn't match the selected display."
1833 :match 'custom-display-unselected-match)
1835 (defun custom-display-unselected-match (widget value)
1836 "Non-nil if VALUE is an unselected display specification."
1837 (not (custom-display-match-frame value (selected-frame))))
1839 (define-widget 'custom-face-selected 'group
1840 "Edit the attributes of the selected display in a face specification."
1841 :args '((repeat :format ""
1843 (group custom-display-unselected sexp))
1844 (group (sexp :format "") custom-face-edit)
1849 (defconst custom-face-selected (widget-convert 'custom-face-selected)
1850 "Converted version of the `custom-face-selected' widget.")
1852 (defun custom-face-value-create (widget)
1853 ;; Create a list of the display specifications.
1854 (unless (eq (preceding-char) ?\n)
1856 (when (not (eq (widget-get widget :custom-state) 'hidden))
1857 (message "Creating face editor...")
1858 (custom-load-widget widget)
1859 (let* ((symbol (widget-value widget))
1860 (spec (or (get symbol 'saved-face)
1861 (get symbol 'factory-face)
1862 ;; Attempt to construct it.
1863 (list (list t (custom-face-attributes-get
1864 symbol (selected-frame))))))
1865 (form (widget-get widget :custom-form))
1866 (indent (widget-get widget :indent))
1867 (edit (widget-create-child-and-convert
1869 (cond ((and (eq form 'selected)
1870 (widget-apply custom-face-selected :match spec))
1871 (when indent (insert-char ?\ indent))
1872 'custom-face-selected)
1873 ((and (not (eq form 'lisp))
1874 (widget-apply custom-face-all :match spec))
1877 (when indent (insert-char ?\ indent))
1880 (custom-face-state-set widget)
1881 (widget-put widget :children (list edit)))
1882 (message "Creating face editor...done")))
1884 (defvar custom-face-menu
1885 '(("Hide" custom-toggle-hide
1887 (not (memq (widget-get widget :custom-state) '(modified invalid)))))
1888 ("Edit Selected" custom-face-edit-selected
1890 (not (eq (widget-get widget :custom-form) 'selected))))
1891 ("Edit All" custom-face-edit-all
1893 (not (eq (widget-get widget :custom-form) 'all))))
1894 ("Edit Lisp" custom-face-edit-lisp
1896 (not (eq (widget-get widget :custom-form) 'lisp))))
1897 ("Set" custom-face-set)
1898 ("Save" custom-face-save)
1899 ("Reset to Saved" custom-face-reset-saved
1901 (get (widget-value widget) 'saved-face)))
1902 ("Reset to Standard Setting" custom-face-reset-factory
1904 (get (widget-value widget) 'factory-face))))
1905 "Alist of actions for the `custom-face' widget.
1906 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
1907 the menu entry, ACTION is the function to call on the widget when the
1908 menu is selected, and FILTER is a predicate which takes a `custom-face'
1909 widget as an argument, and returns non-nil if ACTION is valid on that
1910 widget. If FILTER is nil, ACTION is always valid.")
1912 (defun custom-face-edit-selected (widget)
1913 "Edit selected attributes of the value of WIDGET."
1914 (widget-put widget :custom-state 'unknown)
1915 (widget-put widget :custom-form 'selected)
1916 (custom-redraw widget))
1918 (defun custom-face-edit-all (widget)
1919 "Edit all attributes of the value of WIDGET."
1920 (widget-put widget :custom-state 'unknown)
1921 (widget-put widget :custom-form 'all)
1922 (custom-redraw widget))
1924 (defun custom-face-edit-lisp (widget)
1925 "Edit the lisp representation of the value of WIDGET."
1926 (widget-put widget :custom-state 'unknown)
1927 (widget-put widget :custom-form 'lisp)
1928 (custom-redraw widget))
1930 (defun custom-face-state-set (widget)
1931 "Set the state of WIDGET."
1932 (let ((symbol (widget-value widget)))
1933 (widget-put widget :custom-state (cond ((get symbol 'customized-face)
1935 ((get symbol 'saved-face)
1937 ((get symbol 'factory-face)
1942 (defun custom-face-action (widget &optional event)
1943 "Show the menu for `custom-face' WIDGET.
1944 Optional EVENT is the location for the menu."
1945 (if (eq (widget-get widget :custom-state) 'hidden)
1946 (custom-toggle-hide widget)
1947 (let* ((completion-ignore-case t)
1948 (symbol (widget-get widget :value))
1949 (answer (widget-choose (custom-unlispify-tag-name symbol)
1950 (custom-menu-filter custom-face-menu
1954 (funcall answer widget)))))
1956 (defun custom-face-set (widget)
1957 "Make the face attributes in WIDGET take effect."
1958 (let* ((symbol (widget-value widget))
1959 (child (car (widget-get widget :children)))
1960 (value (widget-value child)))
1961 (put symbol 'customized-face value)
1962 (custom-face-display-set symbol value)
1963 (custom-face-state-set widget)
1964 (custom-redraw-magic widget)))
1966 (defun custom-face-save (widget)
1967 "Make the face attributes in WIDGET default."
1968 (let* ((symbol (widget-value widget))
1969 (child (car (widget-get widget :children)))
1970 (value (widget-value child)))
1971 (custom-face-display-set symbol value)
1972 (put symbol 'saved-face value)
1973 (put symbol 'customized-face nil)
1974 (custom-face-state-set widget)
1975 (custom-redraw-magic widget)))
1977 (defun custom-face-reset-saved (widget)
1978 "Restore WIDGET to the face's default attributes."
1979 (let* ((symbol (widget-value widget))
1980 (child (car (widget-get widget :children)))
1981 (value (get symbol 'saved-face)))
1983 (error "No saved value for this face"))
1984 (put symbol 'customized-face nil)
1985 (custom-face-display-set symbol value)
1986 (widget-value-set child value)
1987 (custom-face-state-set widget)
1988 (custom-redraw-magic widget)))
1990 (defun custom-face-reset-factory (widget)
1991 "Restore WIDGET to the face's standard settings."
1992 (let* ((symbol (widget-value widget))
1993 (child (car (widget-get widget :children)))
1994 (value (get symbol 'factory-face)))
1996 (error "No standard setting for this face"))
1997 (put symbol 'customized-face nil)
1998 (when (get symbol 'saved-face)
1999 (put symbol 'saved-face nil)
2001 (custom-face-display-set symbol value)
2002 (widget-value-set child value)
2003 (custom-face-state-set widget)
2004 (custom-redraw-magic widget)))
2006 ;;; The `face' Widget.
2008 (define-widget 'face 'default
2009 "Select and customize a face."
2010 :convert-widget 'widget-item-convert-widget
2011 :format "%[%t%]: %v"
2014 :value-create 'widget-face-value-create
2015 :value-delete 'widget-face-value-delete
2016 :value-get 'widget-item-value-get
2017 :validate 'widget-editable-list-validate
2018 :action 'widget-face-action
2019 :match '(lambda (widget value) (symbolp value)))
2021 (defun widget-face-value-create (widget)
2022 ;; Create a `custom-face' child.
2023 (let* ((symbol (widget-value widget))
2024 (child (widget-create-child-and-convert
2026 :format "%t %s%m%h%v"
2029 (custom-magic-reset child)
2030 (setq custom-options (cons child custom-options))
2031 (widget-put widget :children (list child))))
2033 (defun widget-face-value-delete (widget)
2034 ;; Remove the child from the options.
2035 (let ((child (car (widget-get widget :children))))
2036 (setq custom-options (delq child custom-options))
2037 (widget-children-value-delete widget)))
2039 (defvar face-history nil
2040 "History of entered face names.")
2042 (defun widget-face-action (widget &optional event)
2043 "Prompt for a face."
2044 (let ((answer (completing-read "Face: "
2045 (mapcar (lambda (face)
2046 (list (symbol-name face)))
2050 (unless (zerop (length answer))
2051 (widget-value-set widget (intern answer))
2052 (widget-apply widget :notify widget event)
2055 ;;; The `hook' Widget.
2057 (define-widget 'hook 'list
2059 :convert-widget 'custom-hook-convert-widget
2062 (defun custom-hook-convert-widget (widget)
2063 ;; Handle `:custom-options'.
2064 (let* ((options (widget-get widget :options))
2065 (other `(editable-list :inline t
2066 :entry-format "%i %d%v"
2067 (function :format " %v")))
2069 (list `(checklist :inline t
2070 ,@(mapcar (lambda (entry)
2071 `(function-item ,entry))
2075 (widget-put widget :args args)
2078 ;;; The `custom-group' Widget.
2080 (defcustom custom-group-tag-faces '(custom-group-tag-face-1)
2081 ;; In XEmacs, this ought to play games with font size.
2082 "Face used for group tags.
2083 The first member is used for level 1 groups, the second for level 2,
2084 and so forth. The remaining group tags are shown with
2085 `custom-group-tag-face'."
2086 :type '(repeat face)
2087 :group 'custom-faces)
2089 (defface custom-group-tag-face-1 '((((class color)
2091 (:foreground "pink" :underline t))
2094 (:foreground "red" :underline t))
2096 "Face used for group tags.")
2098 (defface custom-group-tag-face '((((class color)
2100 (:foreground "light blue" :underline t))
2103 (:foreground "blue" :underline t))
2105 "Face used for low level group tags."
2106 :group 'custom-faces)
2108 (define-widget 'custom-group 'custom
2110 :format "%l%{%t%}:%L\n%m%h%a%v"
2111 :sample-face-get 'custom-group-sample-face-get
2112 :documentation-property 'group-documentation
2113 :help-echo "Set or reset all members of this group."
2114 :value-create 'custom-group-value-create
2115 :action 'custom-group-action
2116 :custom-set 'custom-group-set
2117 :custom-save 'custom-group-save
2118 :custom-reset-current 'custom-group-reset-current
2119 :custom-reset-saved 'custom-group-reset-saved
2120 :custom-reset-factory 'custom-group-reset-factory
2121 :custom-menu 'custom-group-menu-create)
2123 (defun custom-group-sample-face-get (widget)
2124 ;; Use :sample-face.
2125 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
2126 'custom-group-tag-face))
2128 (defun custom-group-value-create (widget)
2129 (let ((state (widget-get widget :custom-state)))
2130 (unless (eq state 'hidden)
2131 (message "Creating group...")
2132 (custom-load-widget widget)
2133 (let* ((level (widget-get widget :custom-level))
2134 (symbol (widget-value widget))
2135 (members (get symbol 'custom-group))
2136 (prefixes (widget-get widget :custom-prefixes))
2137 (custom-prefix-list (custom-prefix-add symbol prefixes))
2138 (length (length members))
2140 (children (mapcar (lambda (entry)
2141 (widget-insert "\n")
2142 (message "Creating group members... %2d%%"
2143 (/ (* 100.0 count) length))
2144 (setq count (1+ count))
2146 (widget-create-child-and-convert
2147 widget (nth 1 entry)
2149 :tag (custom-unlispify-tag-name
2151 :custom-prefixes custom-prefix-list
2152 :custom-level (1+ level)
2153 :value (nth 0 entry))
2154 (unless (eq (preceding-char) ?\n)
2155 (widget-insert "\n"))))
2157 (message "Creating group magic...")
2158 (mapcar 'custom-magic-reset children)
2159 (message "Creating group state...")
2160 (widget-put widget :children children)
2161 (custom-group-state-update widget)
2162 (message "Creating group... done")))))
2164 (defvar custom-group-menu
2165 '(("Hide" custom-toggle-hide
2167 (not (memq (widget-get widget :custom-state) '(modified invalid)))))
2168 ("Set" custom-group-set
2170 (eq (widget-get widget :custom-state) 'modified)))
2171 ("Save" custom-group-save
2173 (memq (widget-get widget :custom-state) '(modified set))))
2174 ("Reset to Current" custom-group-reset-current
2176 (and (default-boundp (widget-value widget))
2177 (memq (widget-get widget :custom-state) '(modified)))))
2178 ("Reset to Saved" custom-group-reset-saved
2180 (and (get (widget-value widget) 'saved-value)
2181 (memq (widget-get widget :custom-state) '(modified set)))))
2182 ("Reset to Standard Settings" custom-group-reset-factory
2184 (and (get (widget-value widget) 'factory-value)
2185 (memq (widget-get widget :custom-state) '(modified set saved))))))
2186 "Alist of actions for the `custom-group' widget.
2187 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
2188 the menu entry, ACTION is the function to call on the widget when the
2189 menu is selected, and FILTER is a predicate which takes a `custom-group'
2190 widget as an argument, and returns non-nil if ACTION is valid on that
2191 widget. If FILTER is nil, ACTION is always valid.")
2193 (defun custom-group-action (widget &optional event)
2194 "Show the menu for `custom-group' WIDGET.
2195 Optional EVENT is the location for the menu."
2196 (if (eq (widget-get widget :custom-state) 'hidden)
2197 (custom-toggle-hide widget)
2198 (let* ((completion-ignore-case t)
2199 (answer (widget-choose (custom-unlispify-tag-name
2200 (widget-get widget :value))
2201 (custom-menu-filter custom-group-menu
2205 (funcall answer widget)))))
2207 (defun custom-group-set (widget)
2208 "Set changes in all modified group members."
2209 (let ((children (widget-get widget :children)))
2210 (mapcar (lambda (child)
2211 (when (eq (widget-get child :custom-state) 'modified)
2212 (widget-apply child :custom-set)))
2215 (defun custom-group-save (widget)
2216 "Save all modified group members."
2217 (let ((children (widget-get widget :children)))
2218 (mapcar (lambda (child)
2219 (when (memq (widget-get child :custom-state) '(modified set))
2220 (widget-apply child :custom-save)))
2223 (defun custom-group-reset-current (widget)
2224 "Reset all modified group members."
2225 (let ((children (widget-get widget :children)))
2226 (mapcar (lambda (child)
2227 (when (eq (widget-get child :custom-state) 'modified)
2228 (widget-apply child :custom-reset-current)))
2231 (defun custom-group-reset-saved (widget)
2232 "Reset all modified or set group members."
2233 (let ((children (widget-get widget :children)))
2234 (mapcar (lambda (child)
2235 (when (memq (widget-get child :custom-state) '(modified set))
2236 (widget-apply child :custom-reset-saved)))
2239 (defun custom-group-reset-factory (widget)
2240 "Reset all modified, set, or saved group members."
2241 (let ((children (widget-get widget :children)))
2242 (mapcar (lambda (child)
2243 (when (memq (widget-get child :custom-state)
2244 '(modified set saved))
2245 (widget-apply child :custom-reset-factory)))
2248 (defun custom-group-state-update (widget)
2250 (unless (eq (widget-get widget :custom-state) 'hidden)
2251 (let* ((children (widget-get widget :children))
2252 (states (mapcar (lambda (child)
2253 (widget-get child :custom-state))
2255 (magics custom-group-magic-alist)
2258 (let ((magic (car (car magics))))
2259 (if (and (not (eq magic 'hidden))
2260 (memq magic states))
2263 (setq magics (cdr magics)))))
2264 (widget-put widget :custom-state found)))
2265 (custom-magic-reset widget))
2267 ;;; The `custom-save-all' Function.
2269 (defcustom custom-file "~/.emacs"
2270 "File used for storing customization information.
2271 If you change this from the default \"~/.emacs\" you need to
2272 explicitly load that file for the settings to take effect."
2276 (defun custom-save-delete (symbol)
2277 "Delete the call to SYMBOL form `custom-file'.
2278 Leave point at the location of the call, or after the last expression."
2279 (set-buffer (find-file-noselect custom-file))
2280 (goto-char (point-min))
2283 (let ((sexp (condition-case nil
2284 (read (current-buffer))
2285 (end-of-file (throw 'found nil)))))
2286 (when (and (listp sexp)
2287 (eq (car sexp) symbol))
2288 (delete-region (save-excursion
2292 (throw 'found nil))))))
2294 (defun custom-save-variables ()
2295 "Save all customized variables in `custom-file'."
2297 (custom-save-delete 'custom-set-variables)
2298 (let ((standard-output (current-buffer)))
2301 (princ "(custom-set-variables")
2302 (mapatoms (lambda (symbol)
2303 (let ((value (get symbol 'saved-value))
2304 (requests (get symbol 'custom-requests))
2305 (now (not (or (get symbol 'factory-value)
2306 (and (not (boundp symbol))
2307 (not (get symbol 'force-value)))))))
2324 (unless (looking-at "\n")
2327 (defun custom-save-faces ()
2328 "Save all customized faces in `custom-file'."
2330 (custom-save-delete 'custom-set-faces)
2331 (let ((standard-output (current-buffer)))
2334 (princ "(custom-set-faces")
2335 (let ((value (get 'default 'saved-face)))
2336 ;; The default face must be first, since it affects the others.
2338 (princ "\n '(default ")
2340 (if (or (get 'default 'factory-face)
2341 (and (not (custom-facep 'default))
2342 (not (get 'default 'force-face))))
2345 (mapatoms (lambda (symbol)
2346 (let ((value (get symbol 'saved-face)))
2347 (when (and (not (eq symbol 'default))
2348 ;; Don't print default face here.
2354 (if (or (get symbol 'factory-face)
2355 (and (not (custom-facep symbol))
2356 (not (get symbol 'force-face))))
2360 (unless (looking-at "\n")
2364 (defun custom-save-customized ()
2365 "Save all user options which have been set in this session."
2367 (mapatoms (lambda (symbol)
2368 (let ((face (get symbol 'customized-face))
2369 (value (get symbol 'customized-value)))
2371 (put symbol 'saved-face face)
2372 (put symbol 'customized-face nil))
2374 (put symbol 'saved-value value)
2375 (put symbol 'customized-value nil)))))
2376 ;; We really should update all custom buffers here.
2380 (defun custom-save-all ()
2381 "Save all customizations in `custom-file'."
2382 (custom-save-variables)
2385 (set-buffer (find-file-noselect custom-file))
2388 ;;; The Customize Menu.
2392 (unless (string-match "XEmacs" emacs-version)
2393 (defconst custom-help-menu '("Customize"
2394 ["Update menu..." custom-menu-update t]
2395 ["Group..." customize t]
2396 ["Variable..." customize-variable t]
2397 ["Face..." customize-face t]
2398 ["Saved..." customize-customized t]
2399 ["Apropos..." customize-apropos t])
2400 ;; This menu should be identical to the one defined in `menu-bar.el'.
2403 (defun custom-menu-reset ()
2404 "Reset customize menu."
2405 (remove-hook 'custom-define-hook 'custom-menu-reset)
2406 (define-key global-map [menu-bar help-menu customize-menu]
2407 (cons (car custom-help-menu)
2408 (easy-menu-create-keymaps (car custom-help-menu)
2409 (cdr custom-help-menu)))))
2411 (defun custom-menu-update (event)
2412 "Update customize menu."
2414 (add-hook 'custom-define-hook 'custom-menu-reset)
2415 (let* ((emacs (widget-apply '(custom-group) :custom-menu 'emacs))
2416 (menu `(,(car custom-help-menu)
2418 ,@(cdr (cdr custom-help-menu)))))
2419 (let ((map (easy-menu-create-keymaps (car menu) (cdr menu))))
2420 (define-key global-map [menu-bar help-menu customize-menu]
2421 (cons (car menu) map)))))
2423 (defcustom custom-menu-nesting 2
2424 "Maximum nesting in custom menus."
2428 (defun custom-face-menu-create (widget symbol)
2429 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
2430 (vector (custom-unlispify-menu-entry symbol)
2431 `(custom-buffer-create '((,symbol custom-face)))
2434 (defun custom-variable-menu-create (widget symbol)
2435 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
2436 (let ((type (get symbol 'custom-type)))
2437 (unless (listp type)
2438 (setq type (list type)))
2439 (if (and type (widget-get type :custom-menu))
2440 (widget-apply type :custom-menu symbol)
2441 (vector (custom-unlispify-menu-entry symbol)
2442 `(custom-buffer-create '((,symbol custom-variable)))
2445 ;; Add checkboxes to boolean variable entries.
2446 (widget-put (get 'boolean 'widget-type)
2447 :custom-menu (lambda (widget symbol)
2448 (vector (custom-unlispify-menu-entry symbol)
2449 `(custom-buffer-create
2450 '((,symbol custom-variable)))
2452 ':selected symbol)))
2454 (if (string-match "XEmacs" emacs-version)
2455 ;; XEmacs can create menus dynamically.
2456 (defun custom-group-menu-create (widget symbol)
2457 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
2458 `( ,(custom-unlispify-menu-entry symbol t)
2459 :filter (lambda (&rest junk)
2460 (cdr (custom-menu-create ',symbol)))))
2462 (defun custom-group-menu-create (widget symbol)
2463 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
2464 ;; Limit the nesting.
2465 (let ((custom-menu-nesting (1- custom-menu-nesting)))
2466 (custom-menu-create symbol))))
2469 (defun custom-menu-create (symbol)
2470 "Create menu for customization group SYMBOL.
2471 The menu is in a format applicable to `easy-menu-define'."
2472 (let* ((item (vector (custom-unlispify-menu-entry symbol)
2473 `(custom-buffer-create '((,symbol custom-group)))
2475 (if (and (or (not (boundp 'custom-menu-nesting))
2476 (>= custom-menu-nesting 0))
2477 (< (length (get symbol 'custom-group)) widget-menu-max-size))
2478 (let ((custom-prefix-list (custom-prefix-add symbol
2479 custom-prefix-list)))
2480 (custom-load-symbol symbol)
2481 `(,(custom-unlispify-menu-entry symbol t)
2484 ,@(mapcar (lambda (entry)
2485 (widget-apply (if (listp (nth 1 entry))
2487 (list (nth 1 entry)))
2488 :custom-menu (nth 0 entry)))
2489 (get symbol 'custom-group))))
2493 (defun customize-menu-create (symbol &optional name)
2494 "Return a customize menu for customization group SYMBOL.
2495 If optional NAME is given, use that as the name of the menu.
2496 Otherwise the menu will be named `Customize'.
2497 The format is suitable for use with `easy-menu-define'."
2499 (setq name "Customize"))
2500 (if (string-match "XEmacs" emacs-version)
2501 ;; We can delay it under XEmacs.
2503 :filter (lambda (&rest junk)
2504 (cdr (custom-menu-create ',symbol))))
2505 ;; But we must create it now under Emacs.
2506 (cons name (cdr (custom-menu-create symbol)))))
2508 ;;; The Custom Mode.
2510 (defvar custom-mode-map nil
2511 "Keymap for `custom-mode'.")
2513 (unless custom-mode-map
2514 (setq custom-mode-map (make-sparse-keymap))
2515 (set-keymap-parent custom-mode-map widget-keymap)
2516 (define-key custom-mode-map "q" 'bury-buffer))
2518 (easy-menu-define custom-mode-customize-menu
2520 "Menu used to customize customization buffers."
2521 (customize-menu-create 'customize))
2523 (easy-menu-define custom-mode-menu
2525 "Menu used in customization buffers."
2527 ["Set" custom-set t]
2528 ["Save" custom-save t]
2529 ["Reset to Current" custom-reset-current t]
2530 ["Reset to Saved" custom-reset-saved t]
2531 ["Reset to Standard Settings" custom-reset-factory t]
2532 ["Info" (Info-goto-node "(custom)The Customization Buffer") t]))
2534 (defcustom custom-mode-hook nil
2535 "Hook called when entering custom-mode."
2539 (defun custom-mode ()
2540 "Major mode for editing customization buffers.
2542 The following commands are available:
2544 Move to next button or editable field. \\[widget-forward]
2545 Move to previous button or editable field. \\[widget-backward]
2546 Activate button under the mouse pointer. \\[widget-button-click]
2547 Activate button under point. \\[widget-button-press]
2548 Set all modifications. \\[custom-set]
2549 Make all modifications default. \\[custom-save]
2550 Reset all modified options. \\[custom-reset-current]
2551 Reset all modified or set options. \\[custom-reset-saved]
2552 Reset all options. \\[custom-reset-factory]
2554 Entry to this mode calls the value of `custom-mode-hook'
2555 if that value is non-nil."
2556 (kill-all-local-variables)
2557 (setq major-mode 'custom-mode
2559 (use-local-map custom-mode-map)
2560 (easy-menu-add custom-mode-customize-menu)
2561 (easy-menu-add custom-mode-menu)
2562 (make-local-variable 'custom-options)
2563 (run-hooks 'custom-mode-hook))
2569 ;; cus-edit.el ends here