1 ;;; cus-edit.el --- Tools for customizating Emacs and Lisp packages.
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Maintainer: Hrvoje Niksic <hniksic@srce.hr>
7 ;; Keywords: help, faces
9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
11 ;; This file is part of XEmacs.
13 ;; XEmacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; XEmacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with XEmacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
30 ;; This file implements the code to create and edit customize buffers.
34 ;; No commands should have names starting with `custom-' because
35 ;; that interferes with completion. Use `customize-' for commands
36 ;; that the user will run with M-x, and `Custom-' for interactive commands.
38 ;; NOTE: In many places within this file we use `mapatoms', which is
39 ;; very slow in an average XEmacs because of the large number of
40 ;; symbols requiring a large number of funcalls -- XEmacs with Gnus
41 ;; can grow to some 17000 symbols without ever doing anything fancy.
42 ;; It would probably pay off to make a hash table of symbols known to
43 ;; Custom, similar to custom-group-hash-table.
45 ;; This is not top priority, because none of the functions that do
46 ;; mapatoms are speed-critical (the one that was now uses
47 ;; custom-group-hash-table), but it would be nice to have.
59 ;; Huh? This looks dirty!
60 (put 'custom-define-hook 'custom-type 'hook)
61 (put 'custom-define-hook 'standard-value '(nil))
62 (custom-add-to-group 'customize 'custom-define-hook 'custom-variable)
64 ;;; Customization Groups.
67 "Customization of the One True Editor."
68 :link '(custom-manual "(XEmacs)Top"))
70 ;; Most of these groups are stolen from `finder.el',
72 "Basic text editing facilities."
75 (defgroup matching nil
76 "Various sorts of searching and matching."
79 (defgroup emulations nil
80 "Emulations of other editors."
83 (defgroup outlines nil
84 "Support for hierarchical outlining."
87 (defgroup external nil
88 "Interfacing to external utilities."
92 "Code related to the `bib' bibliography processor."
96 (defgroup programming nil
97 "Support for programming in other languages."
100 (defgroup languages nil
101 "Specialized modes for editing programming languages."
104 ;; #### This should be in cc-vars.el
106 "Support for the C language and related languages."
114 "Support for object-oriented programming."
117 (defgroup applications nil
118 "Applications written in Emacs."
121 ;; #### This should be in calendar.el
122 (defgroup calendar nil
123 "Calendar and time management support."
124 :group 'applications)
127 "Modes for electronic-mail handling."
128 :group 'applications)
131 "Support for netnews reading and posting."
132 :group 'applications)
135 "Games, jokes and amusements."
136 :group 'applications)
138 (defgroup development nil
139 "Support for further development of Emacs."
143 "Support for Emacs documentation."
146 (defgroup extensions nil
147 "Emacs Lisp language extensions."
150 (defgroup internal nil
151 "Code for Emacs internals, build process, defaults."
155 "Maintenance aids for the Emacs development group."
159 (defgroup environment nil
160 "Fitting Emacs with its environment."
164 "Communications, networking, remote access to files."
168 (defgroup hardware nil
169 "Support for interfacing with exotic hardware."
172 (defgroup terminals nil
173 "Support for terminal types."
177 "Front-ends/assistants for, or emulators of, UNIX features."
181 "Internationalization and alternate character-set support."
186 "Support editing files of data."
194 "Code related to the TeX formatter."
197 (defgroup hypermedia nil
198 "Support for links between text or other media types."
202 "Code local to your site."
205 (defgroup customize '((widgets custom-group))
206 "Customization of the Customization support."
207 :link '(custom-manual "(custom)Top")
208 :link '(url-link :tag "Development Page"
209 "http://www.dina.kvl.dk/~abraham/custom/")
213 (defgroup custom-faces nil
214 "Faces used by customize."
218 (defgroup custom-browse nil
219 "Control customize browser."
223 (defgroup custom-buffer nil
224 "Control customize buffers."
228 (defgroup custom-menu nil
229 "Control customize menus."
234 "Storage allocation and gc for GNU Emacs Lisp interpreter."
235 :tag "Storage Allocation"
239 "Undoing changes in buffers."
242 (defgroup editing-basics nil
243 "Most basic editing facilities."
246 (defgroup display nil
247 "How characters are displayed in buffers."
250 (defgroup installation nil
251 "The Emacs installation."
255 "Internal Emacs limits."
259 "Debugging Emacs itself."
263 "Mule XEmacs internationalization."
269 (defun custom-quote (sexp)
270 "Quote SEXP iff it is not self quoting."
271 (if (or (memq sexp '(t nil))
273 (eq (car-safe sexp) 'lambda)
282 (defun custom-split-regexp-maybe (regexp)
283 "If REGEXP is a string, split it to a list at `\\|'.
284 You can get the original back with from the result with:
285 (mapconcat #'identity result \"\\|\")
287 IF REGEXP is not a string, return it unchanged."
289 (split-string regexp "\\\\|")
292 (defun custom-variable-prompt ()
293 ;; Code stolen from `help.el'.
294 "Prompt for a variable, defaulting to the variable at point.
295 Return a list suitable for use in `interactive'."
296 (let ((v (variable-at-point))
297 (enable-recursive-minibuffers t)
299 (setq val (completing-read
301 (format "Customize variable: (default %s) " v)
302 "Customize variable: ")
303 obarray (lambda (symbol)
305 (or (get symbol 'custom-type)
306 (user-variable-p symbol)))) t))
307 (list (if (equal val "")
308 (if (symbolp v) v nil)
311 ;; Here we take not only the actual groups, but the loads, too.
312 (defun custom-group-prompt (prompt)
313 "Read group from minibuffer."
314 (let ((completion-ignore-case t))
315 (list (completing-read
318 (or (get symbol 'custom-group)
319 (get symbol 'custom-loads)))
322 (defun custom-menu-filter (menu widget)
323 "Convert MENU to the form used by `widget-choose'.
324 MENU should be in the same format as `custom-variable-menu'.
325 WIDGET is the widget to apply the filter entries of MENU on."
327 current name action filter)
329 (setq current (car menu)
331 action (nth 1 current)
332 filter (nth 2 current)
334 (if (or (null filter) (funcall filter widget))
335 (push (cons name action) result)
342 (defvar custom-prefix-list nil
343 "List of prefixes that should be ignored by `custom-unlispify'")
345 (defcustom custom-unlispify-menu-entries t
346 "Display menu entries as words instead of symbols if non nil."
350 (defcustom custom-unlispify-remove-prefixes t
351 "Non-nil means remove group prefixes from option names in buffers and menus.
352 This only has an effect when `custom-unlispify-tag-names' or
353 `custom-unlispify-menu-entries' is on."
357 (defun custom-unlispify-menu-entry (symbol &optional no-suffix)
358 "Convert symbol into a menu entry."
359 (cond ((not custom-unlispify-menu-entries)
360 (symbol-name symbol))
361 ((get symbol 'custom-tag)
363 (get symbol 'custom-tag)
364 (concat (get symbol 'custom-tag) "...")))
366 (with-current-buffer (get-buffer-create " *Custom-Work*")
368 (princ symbol (current-buffer))
369 (goto-char (point-min))
370 (when (and (eq (get symbol 'custom-type) 'boolean)
371 (re-search-forward "-p\\'" nil t))
372 (replace-match "" t t)
373 (goto-char (point-min)))
374 (when custom-unlispify-remove-prefixes
375 (let ((prefixes custom-prefix-list)
378 (setq prefix (car prefixes))
379 (if (search-forward prefix (+ (point) (length prefix)) t)
382 (delete-region (point-min) (point)))
383 (setq prefixes (cdr prefixes))))))
384 (subst-char-in-region (point-min) (point-max) ?- ?\ t)
385 (capitalize-region (point-min) (point-max))
387 (goto-char (point-max))
391 (defcustom custom-unlispify-tag-names t
392 "Display tag names as words instead of symbols if non nil."
393 :group 'custom-buffer
396 (defun custom-unlispify-tag-name (symbol)
397 "Convert symbol into a menu entry."
398 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names))
399 (custom-unlispify-menu-entry symbol t)))
401 (defun custom-prefix-add (symbol prefixes)
402 ;; Addd SYMBOL to list of ignored PREFIXES.
403 (cons (or (get symbol 'custom-prefix)
404 (concat (symbol-name symbol) "-"))
410 (defcustom custom-guess-name-alist
415 ("-function\\'" function)
416 ("-functions\\'" (repeat function))
417 ("-list\\'" (repeat sexp))
418 ("-alist\\'" (repeat (cons sexp sexp))))
419 "Alist of (MATCH TYPE).
421 MATCH should be a regexp matching the name of a symbol, and TYPE should
422 be a widget suitable for editing the value of that symbol. The TYPE
423 of the first entry where MATCH matches the name of the symbol will be
426 This is used for guessing the type of variables not declared with
428 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
431 (defcustom custom-guess-doc-alist
432 '(("\\`\\*?Non-nil " boolean))
433 "Alist of (MATCH TYPE).
435 MATCH should be a regexp matching a documentation string, and TYPE
436 should be a widget suitable for editing the value of a variable with
437 that documentation string. The TYPE of the first entry where MATCH
438 matches the name of the symbol will be used.
440 This is used for guessing the type of variables not declared with
442 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
445 (defun custom-guess-type (symbol)
446 "Guess a widget suitable for editing the value of SYMBOL.
447 This is done by matching SYMBOL with `custom-guess-name-alist' and
448 if that fails, the doc string with `custom-guess-doc-alist'."
449 (let ((name (symbol-name symbol))
450 (names custom-guess-name-alist)
453 (setq current (car names)
455 (when (string-match (nth 0 current) name)
456 (setq found (nth 1 current)
459 (let ((doc (documentation-property symbol 'variable-documentation))
460 (docs custom-guess-doc-alist))
463 (setq current (car docs)
465 (when (string-match (nth 0 current) doc)
466 (setq found (nth 1 current)
473 (defcustom custom-browse-sort-alphabetically nil
474 "If non-nil, sort members of each customization group alphabetically."
476 :group 'custom-browse)
478 (defcustom custom-browse-order-groups nil
479 "If non-nil, order group members within each customization group.
480 If `first', order groups before non-groups.
481 If `last', order groups after non-groups."
482 :type '(choice (const first)
484 (const :tag "none" nil))
485 :group 'custom-browse)
487 (defcustom custom-browse-only-groups nil
488 "If non-nil, show group members only within each customization group."
490 :group 'custom-browse)
492 (defcustom custom-buffer-sort-alphabetically nil
493 "If non-nil, sort members of each customization group alphabetically."
495 :group 'custom-buffer)
497 (defcustom custom-buffer-order-groups 'last
498 "If non-nil, order group members within each customization group.
499 If `first', order groups before non-groups.
500 If `last', order groups after non-groups."
501 :type '(choice (const first)
503 (const :tag "none" nil))
504 :group 'custom-buffer)
506 (defcustom custom-menu-sort-alphabetically nil
507 "If non-nil, sort members of each customization group alphabetically."
511 (defcustom custom-menu-order-groups 'first
512 "If non-nil, order group members within each customization group.
513 If `first', order groups before non-groups.
514 If `last', order groups after non-groups."
515 :type '(choice (const first)
517 (const :tag "none" nil))
520 (defun custom-sort-items (items sort-alphabetically order-groups)
521 "Return a sorted copy of ITEMS.
522 ITEMS should be a `custom-group' property.
523 If SORT-ALPHABETICALLY non-nil, sort alphabetically.
524 If ORDER-GROUPS is `first' order groups before non-groups, if `last' order
525 groups after non-groups, if nil do not order groups at all."
526 (sort (copy-sequence items)
528 (let ((typea (nth 1 a)) (typeb (nth 1 b))
529 (namea (symbol-name (nth 0 a))) (nameb (symbol-name (nth 0 b))))
530 (cond ((not order-groups)
531 ;; Since we don't care about A and B order, maybe sort.
532 (when sort-alphabetically
533 (string-lessp namea nameb)))
534 ((eq typea 'custom-group)
535 ;; If B is also a group, maybe sort. Otherwise, order A and B.
536 (if (eq typeb 'custom-group)
537 (when sort-alphabetically
538 (string-lessp namea nameb))
539 (eq order-groups 'first)))
540 ((eq typeb 'custom-group)
541 ;; Since A cannot be a group, order A and B.
542 (eq order-groups 'last))
544 ;; Since A and B cannot be groups, sort.
545 (string-lessp namea nameb)))))))
548 ;;; Custom Mode Commands.
550 (defvar custom-options nil
551 "Customization widgets in the current buffer.")
554 "Set changes in all modified options."
556 (let ((children custom-options))
557 (mapc (lambda (child)
558 (when (eq (widget-get child :custom-state) 'modified)
559 (widget-apply child :custom-set)))
562 (defun Custom-save ()
563 "Set all modified group members and save them."
565 (let ((children custom-options))
566 (mapc (lambda (child)
567 (when (memq (widget-get child :custom-state) '(modified set))
568 (widget-apply child :custom-save)))
572 (defvar custom-reset-menu
573 '(("Current" . Custom-reset-current)
574 ("Saved" . Custom-reset-saved)
575 ("Standard Settings" . Custom-reset-standard))
576 "Alist of actions for the `Reset' button.
577 The key is a string containing the name of the action, the value is a
578 lisp function taking the widget as an element which will be called
579 when the action is chosen.")
581 (defun custom-reset (event)
582 "Select item from reset menu."
583 (let* ((completion-ignore-case t)
584 (answer (widget-choose "Reset to"
590 (defun Custom-reset-current (&rest ignore)
591 "Reset all modified group members to their current value."
593 (let ((children custom-options))
594 (mapc (lambda (child)
595 (when (eq (widget-get child :custom-state) 'modified)
596 (widget-apply child :custom-reset-current)))
599 (defun Custom-reset-saved (&rest ignore)
600 "Reset all modified or set group members to their saved value."
602 (let ((children custom-options))
603 (mapc (lambda (child)
604 (when (eq (widget-get child :custom-state) 'modified)
605 (widget-apply child :custom-reset-saved)))
608 (defun Custom-reset-standard (&rest ignore)
609 "Reset all modified, set, or saved group members to their standard settings."
611 (let ((children custom-options))
612 (mapc (lambda (child)
613 (when (eq (widget-get child :custom-state) 'modified)
614 (widget-apply child :custom-reset-standard)))
618 ;;; The Customize Commands
620 (defun custom-prompt-variable (prompt-var prompt-val)
621 "Prompt for a variable and a value and return them as a list.
622 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the
623 prompt for the value. The %s escape in PROMPT-VAL is replaced with
624 the name of the variable.
626 If the variable has a `variable-interactive' property, that is used as if
627 it were the arg to `interactive' (which see) to interactively read the value.
629 If the variable has a `custom-type' property, it must be a widget and the
630 `:prompt-value' property of that widget will be used for reading the value."
631 (let* ((var (read-variable prompt-var))
632 (minibuffer-help-form '(describe-variable var)))
634 (let ((prop (get var 'variable-interactive))
635 (type (get var 'custom-type))
636 (prompt (format prompt-val var)))
638 (setq type (list type)))
640 ;; Use VAR's `variable-interactive' property
641 ;; as an interactive spec for prompting.
642 (call-interactively (list 'lambda '(arg)
643 (list 'interactive prop)
646 (widget-prompt-value type
652 (eval-minibuffer prompt)))))))
655 (defun customize-set-value (var val)
656 "Set VARIABLE to VALUE. VALUE is a Lisp object.
658 If VARIABLE has a `variable-interactive' property, that is used as if
659 it were the arg to `interactive' (which see) to interactively read the value.
661 If VARIABLE has a `custom-type' property, it must be a widget and the
662 `:prompt-value' property of that widget will be used for reading the value."
663 (interactive (custom-prompt-variable "Set variable: "
664 "Set %s to value: "))
669 (defun customize-set-variable (var val)
670 "Set the default for VARIABLE to VALUE. VALUE is a Lisp object.
672 If VARIABLE has a `custom-set' property, that is used for setting
673 VARIABLE, otherwise `set-default' is used.
675 The `customized-value' property of the VARIABLE will be set to a list
676 with a quoted VALUE as its sole list member.
678 If VARIABLE has a `variable-interactive' property, that is used as if
679 it were the arg to `interactive' (which see) to interactively read the value.
681 If VARIABLE has a `custom-type' property, it must be a widget and the
682 `:prompt-value' property of that widget will be used for reading the value. "
683 (interactive (custom-prompt-variable "Set variable: "
684 "Set customized value for %s to: "))
685 (funcall (or (get var 'custom-set) 'set-default) var val)
686 (put var 'customized-value (list (custom-quote val))))
689 (defun customize-save-variable (var val)
690 "Set the default for VARIABLE to VALUE, and save it for future sessions.
691 If VARIABLE has a `custom-set' property, that is used for setting
692 VARIABLE, otherwise `set-default' is used.
694 The `customized-value' property of the VARIABLE will be set to a list
695 with a quoted VALUE as its sole list member.
697 If VARIABLE has a `variable-interactive' property, that is used as if
698 it were the arg to `interactive' (which see) to interactively read the value.
700 If VARIABLE has a `custom-type' property, it must be a widget and the
701 `:prompt-value' property of that widget will be used for reading the value. "
702 (interactive (custom-prompt-variable "Set and ave variable: "
703 "Set and save value for %s as: "))
704 (funcall (or (get var 'custom-set) 'set-default) var val)
705 (put var 'saved-value (list (custom-quote val)))
709 (defun customize (group)
710 "Select a customization buffer which you can use to set user options.
711 User options are structured into \"groups\".
712 The default group is `Emacs'."
713 (interactive (custom-group-prompt
714 "Customize group: (default emacs) "))
715 (when (stringp group)
716 (if (string-equal "" group)
718 (setq group (intern group))))
719 (let ((name (format "*Customize Group: %s*"
720 (custom-unlispify-tag-name group))))
721 (if (get-buffer name)
722 (switch-to-buffer name)
723 (custom-buffer-create (list (list group 'custom-group))
725 (concat " for group "
726 (custom-unlispify-tag-name group))))))
729 (defalias 'customize-group 'customize)
732 (defun customize-other-window (symbol)
733 "Customize SYMBOL, which must be a customization group."
734 (interactive (custom-group-prompt
735 "Customize group: (default emacs) "))
736 (when (stringp symbol)
737 (if (string-equal "" symbol)
739 (setq symbol (intern symbol))))
740 (custom-buffer-create-other-window
741 (list (list symbol 'custom-group))
742 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol))))
745 (defalias 'customize-group-other-window 'customize-other-window)
748 (defalias 'customize-option 'customize-variable)
751 (defun customize-variable (symbol)
752 "Customize SYMBOL, which must be a user option variable."
753 (interactive (custom-variable-prompt))
754 (custom-buffer-create (list (list symbol 'custom-variable))
755 (format "*Customize Variable: %s*"
756 (custom-unlispify-tag-name symbol))))
759 (defun customize-changed-options (since-version)
760 "Customize all user option variables whose default values changed recently.
761 This means, in other words, variables defined with a `:version' keyword."
762 (interactive "sCustomize options changed, since version (default all versions): ")
763 (if (equal since-version "")
764 (setq since-version nil))
766 (mapatoms (lambda (symbol)
768 (let ((version (get symbol 'custom-version)))
770 (or (null since-version)
771 (customize-version-lessp since-version version))))
772 (push (list symbol 'custom-variable) found))))
774 (error "No user options have changed defaults %s"
776 (format "since XEmacs %s" since-version)
777 "in recent Emacs versions")))
778 (custom-buffer-create (custom-sort-items found t nil)
779 "*Customize Changed Options*")))
781 (defun customize-version-lessp (version1 version2)
782 (let (major1 major2 minor1 minor2)
783 (string-match "\\([0-9]+\\)[.]\\([0-9]+\\)" version1)
784 (setq major1 (read (match-string 1 version1)))
785 (setq minor1 (read (match-string 2 version1)))
786 (string-match "\\([0-9]+\\)[.]\\([0-9]+\\)" version2)
787 (setq major2 (read (match-string 1 version2)))
788 (setq minor2 (read (match-string 2 version2)))
789 (or (< major1 major2)
790 (and (= major1 major2)
791 (< minor1 minor2)))))
794 (defalias 'customize-variable-other-window 'customize-option-other-window)
797 (defun customize-option-other-window (symbol)
798 "Customize SYMBOL, which must be a user option variable.
799 Show the buffer in another window, but don't select it."
800 (interactive (custom-variable-prompt))
801 (custom-buffer-create-other-window
802 (list (list symbol 'custom-variable))
803 (format "*Customize Option: %s*" (custom-unlispify-tag-name symbol))))
806 (defun customize-face (&optional symbol)
807 "Customize SYMBOL, which should be a face name or nil.
808 If SYMBOL is nil, customize all faces."
809 (interactive (list (completing-read "Customize face: (default all) "
810 obarray 'find-face)))
811 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
812 (custom-buffer-create (custom-sort-items
813 (mapcar (lambda (symbol)
814 (list symbol 'custom-face))
818 (when (stringp symbol)
819 (setq symbol (intern symbol)))
820 (check-argument-type 'symbolp symbol)
821 (custom-buffer-create (list (list symbol 'custom-face))
822 (format "*Customize Face: %s*"
823 (custom-unlispify-tag-name symbol)))))
826 (defun customize-face-other-window (&optional symbol)
827 "Show customization buffer for FACE in other window."
828 (interactive (list (completing-read "Customize face: "
829 obarray 'find-face)))
830 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
833 (setq symbol (intern symbol)))
834 (check-argument-type 'symbolp symbol)
835 (custom-buffer-create-other-window
836 (list (list symbol 'custom-face))
837 (format "*Customize Face: %s*" (custom-unlispify-tag-name symbol)))))
840 (defun customize-customized ()
841 "Customize all user options set since the last save in this session."
844 (mapatoms (lambda (symbol)
845 (and (get symbol 'customized-face)
847 (push (list symbol 'custom-face) found))
848 (and (get symbol 'customized-value)
850 (push (list symbol 'custom-variable) found))))
852 (error "No customized user options")
853 (custom-buffer-create (custom-sort-items found t nil)
854 "*Customize Customized*"))))
857 (defun customize-saved ()
858 "Customize all already saved user options."
861 (mapatoms (lambda (symbol)
862 (and (get symbol 'saved-face)
864 (push (list symbol 'custom-face) found))
865 (and (get symbol 'saved-value)
867 (push (list symbol 'custom-variable) found))))
869 (error "No saved user options")
870 (custom-buffer-create (custom-sort-items found t nil)
871 "*Customize Saved*"))))
874 (defun customize-apropos (regexp &optional all)
875 "Customize all user options matching REGEXP.
876 If ALL is `options', include only options.
877 If ALL is `faces', include only faces.
878 If ALL is `groups', include only groups.
879 If ALL is t (interactively, with prefix arg), include options which are not
880 user-settable, as well as faces and groups."
881 (interactive "sCustomize regexp: \nP")
883 (mapatoms (lambda (symbol)
884 (when (string-match regexp (symbol-name symbol))
885 (when (and (not (memq all '(faces options)))
886 (get symbol 'custom-group))
887 (push (list symbol 'custom-group) found))
888 (when (and (not (memq all '(options groups)))
890 (push (list symbol 'custom-face) found))
891 (when (and (not (memq all '(groups faces)))
893 (or (get symbol 'saved-value)
894 (get symbol 'standard-value)
895 (if (memq all '(nil options))
896 (user-variable-p symbol)
897 (get symbol 'variable-documentation))))
898 (push (list symbol 'custom-variable) found)))))
901 (custom-buffer-create (custom-sort-items found t
902 custom-buffer-order-groups)
903 "*Customize Apropos*"))))
906 (defun customize-apropos-options (regexp &optional arg)
907 "Customize all user options matching REGEXP.
908 With prefix arg, include options which are not user-settable."
909 (interactive "sCustomize regexp: \nP")
910 (customize-apropos regexp (or arg 'options)))
913 (defun customize-apropos-faces (regexp)
914 "Customize all user faces matching REGEXP."
915 (interactive "sCustomize regexp: \n")
916 (customize-apropos regexp 'faces))
919 (defun customize-apropos-groups (regexp)
920 "Customize all user groups matching REGEXP."
921 (interactive "sCustomize regexp: \n")
922 (customize-apropos regexp 'groups))
927 (defcustom custom-buffer-style 'links
928 "*Control the presentation style for customization buffers.
929 The value should be a symbol, one of:
931 brackets: groups nest within each other with big horizontal brackets.
932 links: groups have links to subgroups."
933 :type '(radio (const :tag "brackets: Groups nest within each others" brackets)
934 (const :tag "links: Group have links to subgroups" links))
935 :group 'custom-buffer)
937 (defcustom custom-buffer-done-function 'kill-buffer
938 "*Function to be used to remove the buffer when the user is done with it.
939 Choices include `kill-buffer' (the default) and `bury-buffer'.
940 The function will be called with one argument, the buffer to remove."
941 :type '(radio (function-item kill-buffer)
942 (function-item bury-buffer)
943 (function :tag "Other" nil))
944 :group 'custom-buffer)
946 (defcustom custom-buffer-indent 3
947 "Number of spaces to indent nested groups."
949 :group 'custom-buffer)
952 (defun custom-buffer-create (options &optional name description)
953 "Create a buffer containing OPTIONS.
954 Optional NAME is the name of the buffer.
955 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
956 SYMBOL is a customization option, and WIDGET is a widget for editing
958 (unless name (setq name "*Customization*"))
959 (kill-buffer (get-buffer-create name))
960 (switch-to-buffer (get-buffer-create name))
961 (custom-buffer-create-internal options description))
964 (defun custom-buffer-create-other-window (options &optional name description)
965 "Create a buffer containing OPTIONS.
966 Optional NAME is the name of the buffer.
967 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
968 SYMBOL is a customization option, and WIDGET is a widget for editing
970 (unless name (setq name "*Customization*"))
971 (kill-buffer (get-buffer-create name))
972 (let ((window (selected-window)))
973 (switch-to-buffer-other-window (get-buffer-create name))
974 (custom-buffer-create-internal options description)
975 (select-window window)))
977 (defcustom custom-reset-button-menu t
978 "If non-nil, only show a single reset button in customize buffers.
979 This button will have a menu with all three reset operations."
981 :group 'custom-buffer)
983 (defconst custom-skip-messages 5)
985 (defun Custom-buffer-done ()
986 "Remove current buffer.
987 This works by calling the function specified by
988 `custom-buffer-done-function'."
990 (funcall custom-buffer-done-function (current-buffer)))
992 (defun custom-buffer-create-buttons ()
993 (message "Creating customization buttons...")
994 (widget-insert "\nOperate on everything in this buffer:\n ")
995 (widget-create 'push-button
997 :tag-glyph '("set-up" "set-down")
999 Make your editing in this buffer take effect for this session"
1000 :action (lambda (widget &optional event)
1003 (widget-create 'push-button
1005 :tag-glyph '("save-up" "save-down")
1007 Make your editing in this buffer take effect for future Emacs sessions"
1008 :action (lambda (widget &optional event)
1010 (if custom-reset-button-menu
1013 (widget-create 'push-button
1015 :tag-glyph '("reset-up" "reset-down")
1016 :help-echo "Show a menu with reset operations"
1017 :mouse-down-action (lambda (&rest junk) t)
1018 :action (lambda (widget &optional event)
1019 (custom-reset event))))
1021 (widget-create 'push-button
1024 Reset all edited text in this buffer to reflect current values"
1025 :action 'Custom-reset-current)
1027 (widget-create 'push-button
1028 :tag "Reset to Saved"
1030 Reset all values in this buffer to their saved settings"
1031 :action 'Custom-reset-saved)
1033 (widget-create 'push-button
1034 :tag "Reset to Standard"
1036 Reset all values in this buffer to their standard settings"
1037 :action 'Custom-reset-standard))
1039 (widget-create 'push-button
1041 :tag-glyph '("done-up" "done-down")
1042 :help-echo "Remove the buffer"
1043 :action (lambda (widget &optional event)
1044 (Custom-buffer-done)))
1045 (widget-insert "\n"))
1047 (defcustom custom-novice t
1048 "If non-nil, show help message at top of customize buffers."
1050 :group 'custom-buffer)
1052 (defcustom custom-display-global-buttons 'top
1053 "If `nil' don't display the global buttons. If `top' display at the
1054 beginning of custom buffers. If `bottom', display at the end."
1055 :type '(choice (const top)
1057 (const :tag "don't" nil))
1058 :group 'custom-buffer)
1060 (defun custom-buffer-create-internal (options &optional description)
1061 (message "Creating customization buffer...")
1063 (widget-insert "This is a customization buffer")
1065 (widget-insert description))
1067 (widget-insert ".\n\
1068 Type RET or click button2 on an active field to invoke its action.
1070 (widget-create 'info-link
1072 :help-echo "Read the online help"
1073 "(XEmacs)Easy Customization")
1074 (widget-insert " for more information."))
1075 (widget-insert "\n")
1076 (if (equal custom-display-global-buttons 'top)
1077 (custom-buffer-create-buttons))
1078 (widget-insert "\n")
1079 (message "Creating customization items...")
1080 (setq custom-options
1081 (if (= (length options) 1)
1082 (mapcar (lambda (entry)
1083 (widget-create (nth 1 entry)
1084 :documentation-shown t
1085 :custom-state 'unknown
1086 :tag (custom-unlispify-tag-name
1088 :value (nth 0 entry)))
1091 (length (length options)))
1092 (mapcar (lambda (entry)
1096 (format "Creating customization items %2d%%..."
1097 (/ (* 100.0 count) length)))
1098 (widget-create (nth 1 entry)
1099 :tag (custom-unlispify-tag-name
1101 :value (nth 0 entry))
1103 (unless (eq (preceding-char) ?\n)
1104 (widget-insert "\n"))
1105 (widget-insert "\n")))
1107 (unless (eq (preceding-char) ?\n)
1108 (widget-insert "\n"))
1109 (if (equal custom-display-global-buttons 'bottom)
1110 (custom-buffer-create-buttons))
1111 (display-message 'progress
1113 "Creating customization items %2d%%...done" 100))
1114 (unless (eq custom-buffer-style 'tree)
1115 (mapc 'custom-magic-reset custom-options))
1116 (message "Creating customization setup...")
1118 (goto-char (point-min))
1119 (message "Creating customization buffer...done"))
1122 ;;; The Tree Browser.
1125 (defun customize-browse (&optional group)
1126 "Create a tree browser for the customize hierarchy."
1129 (setq group 'emacs))
1130 (let ((name "*Customize Browser*"))
1131 (kill-buffer (get-buffer-create name))
1132 (switch-to-buffer (get-buffer-create name)))
1135 Square brackets show active fields; type RET or click button2
1136 on an active field to invoke its action.
1137 Invoke [+] below to expand a group, and [-] to collapse an expanded group.\n")
1138 (if custom-browse-only-groups
1140 Invoke the [Group] button below to edit that item in another window.\n\n")
1141 (widget-insert "Invoke the ")
1142 (widget-create 'item
1145 :tag-glyph "folder")
1146 (widget-insert ", ")
1147 (widget-create 'item
1151 (widget-insert ", and ")
1152 (widget-create 'item
1155 :tag-glyph "option")
1156 (widget-insert " buttons below to edit that
1157 item in another window.\n\n"))
1158 (let ((custom-buffer-style 'tree))
1159 (widget-create 'custom-group
1161 :custom-state 'unknown
1162 :tag (custom-unlispify-tag-name group)
1165 (goto-char (point-min)))
1167 (define-widget 'custom-browse-visibility 'item
1168 "Control visibility of of items in the customize tree browser."
1170 :action 'custom-browse-visibility-action)
1172 (defun custom-browse-visibility-action (widget &rest ignore)
1173 (let ((custom-buffer-style 'tree))
1174 (custom-toggle-parent widget)))
1176 (define-widget 'custom-browse-group-tag 'push-button
1177 "Show parent in other window when activated."
1180 :action 'custom-browse-group-tag-action)
1182 (defun custom-browse-group-tag-action (widget &rest ignore)
1183 (let ((parent (widget-get widget :parent)))
1184 (customize-group-other-window (widget-value parent))))
1186 (define-widget 'custom-browse-variable-tag 'push-button
1187 "Show parent in other window when activated."
1190 :action 'custom-browse-variable-tag-action)
1192 (defun custom-browse-variable-tag-action (widget &rest ignore)
1193 (let ((parent (widget-get widget :parent)))
1194 (customize-variable-other-window (widget-value parent))))
1196 (define-widget 'custom-browse-face-tag 'push-button
1197 "Show parent in other window when activated."
1200 :action 'custom-browse-face-tag-action)
1202 (defun custom-browse-face-tag-action (widget &rest ignore)
1203 (let ((parent (widget-get widget :parent)))
1204 (customize-face-other-window (widget-value parent))))
1206 (defconst custom-browse-alist '((" " "space")
1212 (defun custom-browse-insert-prefix (prefix)
1213 "Insert PREFIX. On XEmacs convert it to line graphics."
1215 (if nil ; (string-match "XEmacs" emacs-version)
1218 (while (not (string-equal prefix ""))
1219 (let ((entry (substring prefix 0 3)))
1220 (setq prefix (substring prefix 3))
1221 (let ((overlay (make-overlay (1- (point)) (point) nil t nil))
1222 (name (nth 1 (assoc entry custom-browse-alist))))
1223 (overlay-put overlay 'end-glyph (widget-glyph-find name entry))
1224 (overlay-put overlay 'start-open t)
1225 (overlay-put overlay 'end-open t)))))
1229 ;;; Modification of Basic Widgets.
1231 ;; We add extra properties to the basic widgets needed here. This is
1232 ;; fine, as long as we are careful to stay within out own namespace.
1234 ;; We want simple widgets to be displayed by default, but complex
1235 ;; widgets to be hidden.
1237 (widget-put (get 'item 'widget-type) :custom-show t)
1238 (widget-put (get 'editable-field 'widget-type)
1239 :custom-show (lambda (widget value)
1240 ;; This used to call pp-to-string
1241 (let ((pp (widget-prettyprint-to-string value)))
1242 (cond ((string-match "\n" pp)
1247 (widget-put (get 'menu-choice 'widget-type) :custom-show t)
1249 ;;; The `custom-manual' Widget.
1251 (define-widget 'custom-manual 'info-link
1252 "Link to the manual entry for this customization option."
1255 ;;; The `custom-magic' Widget.
1257 (defgroup custom-magic-faces nil
1258 "Faces used by the magic button."
1259 :group 'custom-faces
1260 :group 'custom-buffer)
1262 (defface custom-invalid-face '((((class color))
1263 (:foreground "yellow" :background "red"))
1265 (:bold t :italic t :underline t)))
1266 "Face used when the customize item is invalid."
1267 :group 'custom-magic-faces)
1269 (defface custom-rogue-face '((((class color))
1270 (:foreground "pink" :background "black"))
1273 "Face used when the customize item is not defined for customization."
1274 :group 'custom-magic-faces)
1276 (defface custom-modified-face '((((class color))
1277 (:foreground "white" :background "blue"))
1280 "Face used when the customize item has been modified."
1281 :group 'custom-magic-faces)
1283 (defface custom-set-face '((((class color))
1284 (:foreground "blue" :background "white"))
1287 "Face used when the customize item has been set."
1288 :group 'custom-magic-faces)
1290 (defface custom-changed-face '((((class color))
1291 (:foreground "white" :background "blue"))
1294 "Face used when the customize item has been changed."
1295 :group 'custom-magic-faces)
1297 (defface custom-saved-face '((t (:underline t)))
1298 "Face used when the customize item has been saved."
1299 :group 'custom-magic-faces)
1301 (defconst custom-magic-alist '((nil "#" underline "\
1302 uninitialized, you should not see this.")
1303 (unknown "?" italic "\
1304 unknown, you should not see this.")
1305 (hidden "-" default "\
1306 hidden, invoke \"Show\" button in the previous line to show." "\
1307 group now hidden, invoke the above \"Show\" button to show contents.")
1308 (invalid "x" custom-invalid-face "\
1309 the value displayed for this %c is invalid and cannot be set.")
1310 (modified "*" custom-modified-face "\
1311 you have edited the value as text, but you have not set the %c." "\
1312 you have edited something in this group, but not set it.")
1313 (set "+" custom-set-face "\
1314 you have set this %c, but not saved it for future sessions." "\
1315 something in this group has been set, but not saved.")
1316 (changed ":" custom-changed-face "\
1317 this %c has been changed outside the customize buffer." "\
1318 something in this group has been changed outside customize.")
1319 (saved "!" custom-saved-face "\
1320 this %c has been set and saved." "\
1321 something in this group has been set and saved.")
1322 (rogue "@" custom-rogue-face "\
1323 this %c has not been changed with customize." "\
1324 something in this group is not prepared for customization.")
1325 (standard " " nil "\
1326 this %c is unchanged from its standard setting." "\
1327 visible group members are all at standard settings."))
1328 "Alist of customize option states.
1329 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
1331 STATE is one of the following symbols:
1334 For internal use, should never occur.
1336 For internal use, should never occur.
1338 This item is not being displayed.
1340 This item is modified, but has an invalid form.
1342 This item is modified, and has a valid form.
1344 This item has been set but not saved.
1346 The current value of this item has been changed temporarily.
1348 This item is marked for saving.
1350 This item has no customization information.
1352 This item is unchanged from the standard setting.
1354 MAGIC is a string used to present that state.
1356 FACE is a face used to present the state.
1358 ITEM-DESC is a string describing the state for options.
1360 GROUP-DESC is a string describing the state for groups. If this is
1361 left out, ITEM-DESC will be used.
1363 The string %c in either description will be replaced with the
1364 category of the item. These are `group'. `option', and `face'.
1366 The list should be sorted most significant first.")
1368 (defcustom custom-magic-show 'long
1369 "If non-nil, show textual description of the state.
1370 If `long', show a full-line description, not just one word."
1371 :type '(choice (const :tag "no" nil)
1374 :group 'custom-buffer)
1376 (defcustom custom-magic-show-hidden '(option face)
1377 "Control whether the State button is shown for hidden items.
1378 The value should be a list with the custom categories where the State
1379 button should be visible. Possible categories are `group', `option',
1381 :type '(set (const group) (const option) (const face))
1382 :group 'custom-buffer)
1384 (defcustom custom-magic-show-button nil
1385 "Show a \"magic\" button indicating the state of each customization option."
1387 :group 'custom-buffer)
1389 (define-widget 'custom-magic 'default
1390 "Show and manipulate state for a customization option."
1392 :action 'widget-parent-action
1395 :value-create 'custom-magic-value-create
1396 :value-delete 'widget-children-value-delete)
1398 (defun widget-magic-mouse-down-action (widget &optional event)
1399 ;; Non-nil unless hidden.
1400 (not (eq (widget-get (widget-get (widget-get widget :parent) :parent)
1404 (defun custom-magic-value-create (widget)
1405 ;; Create compact status report for WIDGET.
1406 (let* ((parent (widget-get widget :parent))
1407 (state (widget-get parent :custom-state))
1408 (hidden (eq state 'hidden))
1409 (entry (assq state custom-magic-alist))
1410 (magic (nth 1 entry))
1411 (face (nth 2 entry))
1412 (category (widget-get parent :custom-category))
1413 (text (or (and (eq category 'group)
1416 (form (widget-get parent :custom-form))
1418 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text)
1419 (setq text (concat (match-string 1 text)
1420 (symbol-name category)
1421 (match-string 2 text))))
1422 (when (and custom-magic-show
1424 (memq category custom-magic-show-hidden)))
1426 (when (and (eq category 'group)
1427 (not (and (eq custom-buffer-style 'links)
1428 (> (widget-get parent :custom-level) 1))))
1429 (insert-char ?\ (* custom-buffer-indent
1430 (widget-get parent :custom-level))))
1431 (push (widget-create-child-and-convert
1433 :help-echo "Change the state of this item"
1434 :format (if hidden "%t" "%[%t%]")
1435 :button-prefix 'widget-push-button-prefix
1436 :button-suffix 'widget-push-button-suffix
1437 :mouse-down-action 'widget-magic-mouse-down-action
1439 ;;:tag-glyph (or hidden '("state-up" "state-down"))
1443 (let ((start (point)))
1444 (if (eq custom-magic-show 'long)
1446 (insert (symbol-name state)))
1447 (cond ((eq form 'lisp)
1449 ((eq form 'mismatch)
1450 (insert " (mismatch)")))
1451 (put-text-property start (point) 'face 'custom-state-face))
1453 (when (and (eq category 'group)
1454 (not (and (eq custom-buffer-style 'links)
1455 (> (widget-get parent :custom-level) 1))))
1456 (insert-char ?\ (* custom-buffer-indent
1457 (widget-get parent :custom-level))))
1458 (when custom-magic-show-button
1459 (when custom-magic-show
1460 (let ((indent (widget-get parent :indent)))
1462 (insert-char ?\ indent))))
1463 (push (widget-create-child-and-convert
1465 :mouse-down-action 'widget-magic-mouse-down-action
1469 :help-echo "Change the state"
1470 :format (if hidden "%t" "%[%t%]")
1471 :tag (if (memq form '(lisp mismatch))
1472 (concat "(" magic ")")
1473 (concat "[" magic "]")))
1476 (widget-put widget :children children)))
1478 (defun custom-magic-reset (widget)
1479 "Redraw the :custom-magic property of WIDGET."
1480 (let ((magic (widget-get widget :custom-magic)))
1481 (widget-value-set magic (widget-value magic))))
1483 ;;; The `custom' Widget.
1485 (defface custom-button-face '((t (:bold t)))
1486 "Face used for buttons in customization buffers."
1487 :group 'custom-faces)
1489 (defface custom-documentation-face nil
1490 "Face used for documentation strings in customization buffers."
1491 :group 'custom-faces)
1493 (defface custom-state-face '((((class color)
1495 (:foreground "lime green"))
1498 (:foreground "dark green"))
1500 "Face used for State descriptions in the customize buffer."
1501 :group 'custom-faces)
1503 (define-widget 'custom 'default
1504 "Customize a user option."
1506 :convert-widget 'custom-convert-widget
1507 :notify 'custom-notify
1510 :custom-state 'hidden
1511 :documentation-property 'widget-subclass-responsibility
1512 :value-create 'widget-subclass-responsibility
1513 :value-delete 'widget-children-value-delete
1514 :value-get 'widget-value-value-get
1515 :validate 'widget-children-validate
1516 :match (lambda (widget value) (symbolp value)))
1518 (defun custom-convert-widget (widget)
1519 ;; Initialize :value and :tag from :args in WIDGET.
1520 (let ((args (widget-get widget :args)))
1522 (widget-put widget :value (widget-apply widget
1523 :value-to-internal (car args)))
1524 (widget-put widget :tag (custom-unlispify-tag-name (car args)))
1525 (widget-put widget :args nil)))
1528 (defun custom-notify (widget &rest args)
1529 "Keep track of changes."
1530 (let ((state (widget-get widget :custom-state)))
1531 (unless (eq state 'modified)
1532 (unless (memq state '(nil unknown hidden))
1533 (widget-put widget :custom-state 'modified))
1534 (custom-magic-reset widget)
1535 (apply 'widget-default-notify widget args))))
1537 (defun custom-redraw (widget)
1538 "Redraw WIDGET with current settings."
1539 (let ((line (count-lines (point-min) (point)))
1540 (column (current-column))
1542 (from (marker-position (widget-get widget :from)))
1543 (to (marker-position (widget-get widget :to))))
1545 (widget-value-set widget (widget-value widget))
1546 (custom-redraw-magic widget))
1547 (when (and (>= pos from) (<= pos to))
1552 (goto-line (1+ line)))
1553 (move-to-column column))
1556 (defun custom-redraw-magic (widget)
1557 "Redraw WIDGET state with current settings."
1559 (let ((magic (widget-get widget :custom-magic)))
1561 (widget-value-set magic (widget-value magic))
1562 (when (setq widget (widget-get widget :group))
1563 (custom-group-state-update widget)))
1565 (setq widget nil)))))
1568 (defun custom-show (widget value)
1569 "Non-nil if WIDGET should be shown with VALUE by default."
1570 (let ((show (widget-get widget :custom-show)))
1576 (funcall show widget value)))))
1578 (defvar custom-load-recursion nil
1579 "Hack to avoid recursive dependencies.")
1581 (defun custom-load-symbol (symbol)
1582 "Load all dependencies for SYMBOL."
1583 (unless custom-load-recursion
1584 (let ((custom-load-recursion t)
1585 (loads (get symbol 'custom-loads))
1588 (setq load (car loads)
1590 (cond ((symbolp load)
1594 ;; Don't reload a file already loaded.
1595 ((and (boundp 'preloaded-file-list)
1596 (member load preloaded-file-list)))
1597 ((assoc load load-history))
1598 ((assoc (locate-library load) load-history))
1601 ;; Without this, we would load cus-edit recursively.
1602 ;; We are still loading it when we call this,
1603 ;; and it is not in load-history yet.
1604 (or (equal load "cus-edit")
1605 (load-library load))
1608 (defun custom-load-widget (widget)
1609 "Load all dependencies for WIDGET."
1610 (custom-load-symbol (widget-value widget)))
1612 (defun custom-unloaded-symbol-p (symbol)
1613 "Return non-nil if the dependencies of SYMBOL has not yet been loaded."
1615 (loads (get symbol 'custom-loads))
1618 (setq load (car loads)
1620 (cond ((symbolp load)
1621 (unless (featurep load)
1623 ((assoc load load-history))
1624 ((assoc (locate-library load) load-history)
1631 (defun custom-unloaded-widget-p (widget)
1632 "Return non-nil if the dependencies of WIDGET has not yet been loaded."
1633 (custom-unloaded-symbol-p (widget-value widget)))
1635 (defun custom-toggle-hide (widget)
1636 "Toggle visibility of WIDGET."
1637 (custom-load-widget widget)
1638 (let ((state (widget-get widget :custom-state)))
1639 (cond ((memq state '(invalid modified))
1640 (error "There are unset changes"))
1642 (widget-put widget :custom-state 'unknown))
1644 (widget-put widget :documentation-shown nil)
1645 (widget-put widget :custom-state 'hidden)))
1646 (custom-redraw widget)
1649 (defun custom-toggle-parent (widget &rest ignore)
1650 "Toggle visibility of parent of WIDGET."
1651 (custom-toggle-hide (widget-get widget :parent)))
1653 (defun custom-add-see-also (widget &optional prefix)
1654 "Add `See also ...' to WIDGET if there are any links.
1655 Insert PREFIX first if non-nil."
1656 (let* ((symbol (widget-get widget :value))
1657 (links (get symbol 'custom-links))
1658 (many (> (length links) 2))
1659 (buttons (widget-get widget :buttons))
1660 (indent (widget-get widget :indent)))
1663 (insert-char ?\ indent))
1666 (insert "See also ")
1668 (push (widget-create-child-and-convert widget (car links))
1670 (setq links (cdr links))
1679 (widget-put widget :buttons buttons))))
1681 (defun custom-add-parent-links (widget &optional initial-string)
1682 "Add \"Parent groups: ...\" to WIDGET if the group has parents.
1683 The value if non-nil if any parents were found.
1684 If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
1685 (let ((name (widget-value widget))
1686 (type (widget-type widget))
1687 (buttons (widget-get widget :buttons))
1690 (insert (or initial-string "Parent groups:"))
1691 (maphash (lambda (group ignore)
1692 (let ((entry (assq name (get group 'custom-group))))
1693 (when (eq (nth 1 entry) type)
1695 (push (widget-create-child-and-convert
1696 widget 'custom-group-link
1697 :tag (custom-unlispify-tag-name group)
1701 custom-group-hash-table)
1702 (widget-put widget :buttons buttons)
1705 (delete-region start (point)))
1708 ;;; The `custom-variable' Widget.
1710 (defface custom-variable-tag-face '((((class color)
1712 (:foreground "light blue" :underline t))
1715 (:foreground "blue" :underline t))
1717 "Face used for unpushable variable tags."
1718 :group 'custom-faces)
1720 (defface custom-variable-button-face '((t (:underline t :bold t)))
1721 "Face used for pushable variable tags."
1722 :group 'custom-faces)
1724 (defcustom custom-variable-default-form 'edit
1725 "Default form of displaying variable values."
1726 :type '(choice (const edit)
1728 :group 'custom-buffer)
1730 (define-widget 'custom-variable 'custom
1731 "Customize variable."
1733 :help-echo "Set or reset this variable"
1734 :documentation-property 'variable-documentation
1735 :custom-category 'option
1737 :custom-menu 'custom-variable-menu-create
1738 :custom-form nil ; defaults to value of `custom-variable-default-form'
1739 :value-create 'custom-variable-value-create
1740 :action 'custom-variable-action
1741 :custom-set 'custom-variable-set
1742 :custom-save 'custom-variable-save
1743 :custom-reset-current 'custom-redraw
1744 :custom-reset-saved 'custom-variable-reset-saved
1745 :custom-reset-standard 'custom-variable-reset-standard)
1747 (defun custom-variable-type (symbol)
1748 "Return a widget suitable for editing the value of SYMBOL.
1749 If SYMBOL has a `custom-type' property, use that.
1750 Otherwise, look up symbol in `custom-guess-type-alist'."
1751 (let* ((type (or (get symbol 'custom-type)
1752 (and (not (get symbol 'standard-value))
1753 (custom-guess-type symbol))
1755 (options (get symbol 'custom-options))
1756 (tmp (if (listp type)
1757 (copy-sequence type)
1760 (widget-put tmp :options options))
1763 (defun custom-variable-value-create (widget)
1764 "Here is where you edit the variables value."
1765 (custom-load-widget widget)
1766 (unless (widget-get widget :custom-form)
1767 (widget-put widget :custom-form custom-variable-default-form))
1768 (let* ((buttons (widget-get widget :buttons))
1769 (children (widget-get widget :children))
1770 (form (widget-get widget :custom-form))
1771 (state (widget-get widget :custom-state))
1772 (symbol (widget-get widget :value))
1773 (tag (widget-get widget :tag))
1774 (type (custom-variable-type symbol))
1775 (conv (widget-convert type))
1776 (get (or (get symbol 'custom-get) 'default-value))
1777 (prefix (widget-get widget :custom-prefix))
1778 (last (widget-get widget :custom-last))
1779 (value (if (default-boundp symbol)
1780 (funcall get symbol)
1781 (widget-get conv :value))))
1782 ;; If the widget is new, the child determine whether it is hidden.
1784 ((custom-show type value)
1785 (setq state 'unknown))
1787 (setq state 'hidden)))
1788 ;; If we don't know the state, see if we need to edit it in lisp form.
1789 (when (eq state 'unknown)
1790 (unless (widget-apply conv :match value)
1791 ;; (widget-apply (widget-convert type) :match value)
1792 (setq form 'mismatch)))
1793 ;; Now we can create the child widget.
1794 (cond ((eq custom-buffer-style 'tree)
1795 (insert prefix (if last " `--- " " |--- "))
1796 (push (widget-create-child-and-convert
1797 widget 'custom-browse-variable-tag)
1799 (insert " " tag "\n")
1800 (widget-put widget :buttons buttons))
1802 ;; Indicate hidden value.
1803 (push (widget-create-child-and-convert
1806 :sample-face 'custom-variable-tag-face
1810 (push (widget-create-child-and-convert
1812 :help-echo "Show the value of this option"
1813 :action 'custom-toggle-parent
1816 ((memq form '(lisp mismatch))
1817 ;; In lisp mode edit the saved value when possible.
1818 (let* ((value (cond ((get symbol 'saved-value)
1819 (car (get symbol 'saved-value)))
1820 ((get symbol 'standard-value)
1821 (car (get symbol 'standard-value)))
1822 ((default-boundp symbol)
1823 (custom-quote (funcall get symbol)))
1825 (custom-quote (widget-get conv :value))))))
1826 (insert (symbol-name symbol) ": ")
1827 (push (widget-create-child-and-convert
1829 :help-echo "Hide the value of this option"
1830 :action 'custom-toggle-parent
1834 (push (widget-create-child-and-convert
1836 :button-face 'custom-variable-button-face
1838 :tag (symbol-name symbol)
1844 (let* ((format (widget-get type :format))
1845 tag-format value-format)
1846 (while (not (string-match ":" format))
1847 (setq format (signal 'error (list "Bad format" format))))
1848 (setq tag-format (substring format 0 (match-end 0)))
1849 (setq value-format (substring format (match-end 0)))
1850 (push (widget-create-child-and-convert
1853 :action 'custom-tag-action
1854 :help-echo "Change value of this option"
1855 :mouse-down-action 'custom-tag-mouse-down-action
1856 :button-face 'custom-variable-button-face
1857 :sample-face 'custom-variable-tag-face
1861 (push (widget-create-child-and-convert
1863 :help-echo "Hide the value of this option"
1864 :action 'custom-toggle-parent
1867 (push (widget-create-child-and-convert
1869 :format value-format
1872 (unless (eq custom-buffer-style 'tree)
1873 ;; Now update the state.
1874 (unless (eq (preceding-char) ?\n)
1875 (widget-insert "\n"))
1876 (if (eq state 'hidden)
1877 (widget-put widget :custom-state state)
1878 (custom-variable-state-set widget))
1879 ;; Create the magic button.
1880 (let ((magic (widget-create-child-and-convert
1881 widget 'custom-magic nil)))
1882 (widget-put widget :custom-magic magic)
1883 (push magic buttons))
1884 ;; Update properties.
1885 (widget-put widget :custom-form form)
1886 (widget-put widget :buttons buttons)
1887 (widget-put widget :children children)
1888 ;; Insert documentation.
1889 (widget-default-format-handler widget ?h)
1891 (unless (eq state 'hidden)
1892 (when (eq (widget-get widget :custom-level) 1)
1893 (custom-add-parent-links widget))
1894 (custom-add-see-also widget)))))
1896 (defun custom-tag-action (widget &rest args)
1897 "Pass :action to first child of WIDGET's parent."
1898 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
1901 (defun custom-tag-mouse-down-action (widget &rest args)
1902 "Pass :mouse-down-action to first child of WIDGET's parent."
1903 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
1904 :mouse-down-action args))
1906 (defun custom-variable-state-set (widget)
1907 "Set the state of WIDGET."
1908 (let* ((symbol (widget-value widget))
1909 (get (or (get symbol 'custom-get) 'default-value))
1910 (value (if (default-boundp symbol)
1911 (funcall get symbol)
1912 (widget-get widget :value)))
1914 (state (cond ((setq tmp (get symbol 'customized-value))
1915 (if (condition-case nil
1916 (equal value (eval (car tmp)))
1920 ((setq tmp (get symbol 'saved-value))
1921 (if (condition-case nil
1922 (equal value (eval (car tmp)))
1926 ((setq tmp (get symbol 'standard-value))
1927 (if (condition-case nil
1928 (equal value (eval (car tmp)))
1933 (widget-put widget :custom-state state)))
1935 (defvar custom-variable-menu
1936 '(("Set for Current Session" custom-variable-set
1938 (eq (widget-get widget :custom-state) 'modified)))
1939 ("Save for Future Sessions" custom-variable-save
1941 (memq (widget-get widget :custom-state) '(modified set changed rogue))))
1942 ("Reset to Current" custom-redraw
1944 (and (default-boundp (widget-value widget))
1945 (memq (widget-get widget :custom-state) '(modified changed)))))
1946 ("Reset to Saved" custom-variable-reset-saved
1948 (and (get (widget-value widget) 'saved-value)
1949 (memq (widget-get widget :custom-state)
1950 '(modified set changed rogue)))))
1951 ("Reset to Standard Settings" custom-variable-reset-standard
1953 (and (get (widget-value widget) 'standard-value)
1954 (memq (widget-get widget :custom-state)
1955 '(modified set changed saved rogue)))))
1956 ("---" ignore ignore)
1957 ("Don't show as Lisp expression" custom-variable-edit
1959 (eq (widget-get widget :custom-form) 'lisp)))
1960 ("Show as Lisp expression" custom-variable-edit-lisp
1962 (eq (widget-get widget :custom-form) 'edit))))
1963 "Alist of actions for the `custom-variable' widget.
1964 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
1965 the menu entry, ACTION is the function to call on the widget when the
1966 menu is selected, and FILTER is a predicate which takes a `custom-variable'
1967 widget as an argument, and returns non-nil if ACTION is valid on that
1968 widget. If FILTER is nil, ACTION is always valid.")
1970 (defun custom-variable-action (widget &optional event)
1971 "Show the menu for `custom-variable' WIDGET.
1972 Optional EVENT is the location for the menu."
1973 (if (eq (widget-get widget :custom-state) 'hidden)
1974 (custom-toggle-hide widget)
1975 (unless (eq (widget-get widget :custom-state) 'modified)
1976 (custom-variable-state-set widget))
1977 ;; Redrawing magic also depresses the state glyph.
1978 ;(custom-redraw-magic widget)
1979 (let* ((completion-ignore-case t)
1980 (answer (widget-choose (concat "Operation on "
1981 (custom-unlispify-tag-name
1982 (widget-get widget :value)))
1983 (custom-menu-filter custom-variable-menu
1987 (funcall answer widget)))))
1989 (defun custom-variable-edit (widget)
1990 "Edit value of WIDGET."
1991 (widget-put widget :custom-state 'unknown)
1992 (widget-put widget :custom-form 'edit)
1993 (custom-redraw widget))
1995 (defun custom-variable-edit-lisp (widget)
1996 "Edit the lisp representation of the value of WIDGET."
1997 (widget-put widget :custom-state 'unknown)
1998 (widget-put widget :custom-form 'lisp)
1999 (custom-redraw widget))
2001 (defun custom-variable-set (widget)
2002 "Set the current value for the variable being edited by WIDGET."
2003 (let* ((form (widget-get widget :custom-form))
2004 (state (widget-get widget :custom-state))
2005 (child (car (widget-get widget :children)))
2006 (symbol (widget-value widget))
2007 (set (or (get symbol 'custom-set) 'set-default))
2009 (cond ((eq state 'hidden)
2010 (error "Cannot set hidden variable"))
2011 ((setq val (widget-apply child :validate))
2012 (goto-char (widget-get val :from))
2013 (error "%s" (widget-get val :error)))
2014 ((memq form '(lisp mismatch))
2015 (funcall set symbol (eval (setq val (widget-value child))))
2016 (put symbol 'customized-value (list val)))
2018 (funcall set symbol (setq val (widget-value child)))
2019 (put symbol 'customized-value (list (custom-quote val)))))
2020 (custom-variable-state-set widget)
2021 (custom-redraw-magic widget)))
2023 (defun custom-variable-save (widget)
2024 "Set and save the value for the variable being edited by WIDGET."
2025 (let* ((form (widget-get widget :custom-form))
2026 (state (widget-get widget :custom-state))
2027 (child (car (widget-get widget :children)))
2028 (symbol (widget-value widget))
2029 (set (or (get symbol 'custom-set) 'set-default))
2031 (cond ((eq state 'hidden)
2032 (error "Cannot set hidden variable"))
2033 ((setq val (widget-apply child :validate))
2034 (goto-char (widget-get val :from))
2035 (error "%s" (widget-get val :error)))
2036 ((memq form '(lisp mismatch))
2037 (put symbol 'saved-value (list (widget-value child)))
2038 (funcall set symbol (eval (widget-value child))))
2041 'saved-value (list (custom-quote (widget-value
2043 (funcall set symbol (widget-value child))))
2044 (put symbol 'customized-value nil)
2046 (custom-variable-state-set widget)
2047 (custom-redraw-magic widget)))
2049 (defun custom-variable-reset-saved (widget)
2050 "Restore the saved value for the variable being edited by WIDGET."
2051 (let* ((symbol (widget-value widget))
2052 (set (or (get symbol 'custom-set) 'set-default)))
2053 (if (get symbol 'saved-value)
2055 (funcall set symbol (eval (car (get symbol 'saved-value))))
2057 (signal 'error (list "No saved value for variable" symbol)))
2058 (put symbol 'customized-value nil)
2059 (widget-put widget :custom-state 'unknown)
2060 (custom-redraw widget)))
2062 (defun custom-variable-reset-standard (widget)
2063 "Restore the standard setting for the variable being edited by WIDGET."
2064 (let* ((symbol (widget-value widget))
2065 (set (or (get symbol 'custom-set) 'set-default)))
2066 (if (get symbol 'standard-value)
2067 (funcall set symbol (eval (car (get symbol 'standard-value))))
2068 (signal 'error (list "No standard setting known for variable" symbol)))
2069 (put symbol 'customized-value nil)
2070 (when (get symbol 'saved-value)
2071 (put symbol 'saved-value nil)
2073 (widget-put widget :custom-state 'unknown)
2074 (custom-redraw widget)))
2076 ;;; The `custom-face-edit' Widget.
2078 (define-widget 'custom-face-edit 'checklist
2079 "Edit face attributes."
2083 :button-args '(:help-echo "Control whether this attribute have any effect")
2084 :args (mapcar (lambda (att)
2087 :sibling-args (widget-get (nth 1 att) :sibling-args)
2088 (list 'const :format "" :value (nth 0 att))
2090 custom-face-attributes))
2092 ;;; The `custom-display' Widget.
2094 (define-widget 'custom-display 'menu-choice
2095 "Select a display type."
2098 :help-echo "Specify frames where the face attributes should be used"
2099 :args '((const :tag "all" t)
2103 :args ((group :sibling-args (:help-echo "\
2104 Only match the specified window systems")
2105 (const :format "Type: "
2107 (checklist :inline t
2110 :sibling-args (:help-echo "\
2111 The X11 Window System")
2113 (const :format "PM "
2114 :sibling-args (:help-echo "\
2115 OS/2 Presentation Manager")
2117 (const :format "MSWindows "
2118 :sibling-args (:help-echo "\
2121 (const :format "DOS "
2122 :sibling-args (:help-echo "\
2125 (const :format "TTY%n"
2126 :sibling-args (:help-echo "\
2127 Plain text terminals")
2129 (group :sibling-args (:help-echo "\
2130 Only match the frames with the specified color support")
2131 (const :format "Class: "
2133 (checklist :inline t
2135 (const :format "Color "
2136 :sibling-args (:help-echo "\
2137 Match color frames")
2139 (const :format "Grayscale "
2140 :sibling-args (:help-echo "\
2141 Match grayscale frames")
2143 (const :format "Monochrome%n"
2144 :sibling-args (:help-echo "\
2145 Match frames with no color support")
2147 (group :sibling-args (:help-echo "\
2148 Only match frames with the specified intensity")
2150 Background brightness: "
2152 (checklist :inline t
2154 (const :format "Light "
2155 :sibling-args (:help-echo "\
2156 Match frames with light backgrounds")
2158 (const :format "Dark\n"
2159 :sibling-args (:help-echo "\
2160 Match frames with dark backgrounds")
2163 ;;; The `custom-face' Widget.
2165 (defface custom-face-tag-face '((t (:underline t)))
2166 "Face used for face tags."
2167 :group 'custom-faces)
2169 (defcustom custom-face-default-form 'selected
2170 "Default form of displaying face definition."
2171 :type '(choice (const all)
2174 :group 'custom-buffer)
2176 (define-widget 'custom-face 'custom
2178 :sample-face 'custom-face-tag-face
2179 :help-echo "Set or reset this face"
2180 :documentation-property '(lambda (face)
2181 (face-doc-string face))
2182 :value-create 'custom-face-value-create
2183 :action 'custom-face-action
2184 :custom-category 'face
2185 :custom-form nil ; defaults to value of `custom-face-default-form'
2186 :custom-set 'custom-face-set
2187 :custom-save 'custom-face-save
2188 :custom-reset-current 'custom-redraw
2189 :custom-reset-saved 'custom-face-reset-saved
2190 :custom-reset-standard 'custom-face-reset-standard
2191 :custom-menu 'custom-face-menu-create)
2193 (define-widget 'custom-face-all 'editable-list
2194 "An editable list of display specifications and attributes."
2195 :entry-format "%i %d %v"
2196 :insert-button-args '(:help-echo "Insert new display specification here")
2197 :append-button-args '(:help-echo "Append new display specification here")
2198 :delete-button-args '(:help-echo "Delete this display specification")
2199 :args '((group :format "%v" custom-display custom-face-edit)))
2201 (defconst custom-face-all (widget-convert 'custom-face-all)
2202 "Converted version of the `custom-face-all' widget.")
2204 (define-widget 'custom-display-unselected 'item
2205 "A display specification that doesn't match the selected display."
2206 :match 'custom-display-unselected-match)
2208 (defun custom-display-unselected-match (widget value)
2209 "Non-nil if VALUE is an unselected display specification."
2210 (not (face-spec-set-match-display value (selected-frame))))
2212 (define-widget 'custom-face-selected 'group
2213 "Edit the attributes of the selected display in a face specification."
2214 :args '((repeat :format ""
2216 (group custom-display-unselected sexp))
2217 (group (sexp :format "") custom-face-edit)
2222 (defconst custom-face-selected (widget-convert 'custom-face-selected)
2223 "Converted version of the `custom-face-selected' widget.")
2225 (defun custom-face-value-create (widget)
2226 "Create a list of the display specifications for WIDGET."
2227 (let ((buttons (widget-get widget :buttons))
2228 (symbol (widget-get widget :value))
2229 (tag (widget-get widget :tag))
2230 (state (widget-get widget :custom-state))
2232 (is-last (widget-get widget :custom-last))
2233 (prefix (widget-get widget :custom-prefix)))
2235 (setq tag (prin1-to-string symbol)))
2236 (cond ((eq custom-buffer-style 'tree)
2237 (insert prefix (if is-last " `--- " " |--- "))
2238 (push (widget-create-child-and-convert
2239 widget 'custom-browse-face-tag)
2241 (insert " " tag "\n")
2242 (widget-put widget :buttons buttons))
2246 (if (eq custom-buffer-style 'face)
2248 (widget-specify-sample widget begin (point))
2251 (and (not (find-face symbol))
2252 ;; XEmacs cannot display uninitialized faces.
2254 (push (widget-create-child-and-convert widget 'item
2261 (push (widget-create-child-and-convert
2263 :help-echo "Hide or show this face"
2264 :action 'custom-toggle-parent
2265 (not (eq state 'hidden)))
2269 (let ((magic (widget-create-child-and-convert
2270 widget 'custom-magic nil)))
2271 (widget-put widget :custom-magic magic)
2272 (push magic buttons))
2274 (widget-put widget :buttons buttons)
2275 ;; Insert documentation.
2276 (widget-default-format-handler widget ?h)
2278 (unless (eq state 'hidden)
2279 (when (eq (widget-get widget :custom-level) 1)
2280 (custom-add-parent-links widget))
2281 (custom-add-see-also widget))
2283 (unless (eq (preceding-char) ?\n)
2285 (unless (eq state 'hidden)
2286 (message "Creating face editor...")
2287 (custom-load-widget widget)
2288 (unless (widget-get widget :custom-form)
2289 (widget-put widget :custom-form custom-face-default-form))
2290 (let* ((symbol (widget-value widget))
2291 (spec (or (get symbol 'customized-face)
2292 (get symbol 'saved-face)
2293 (get symbol 'face-defface-spec)
2294 ;; Attempt to construct it.
2295 (list (list t (face-custom-attributes-get
2296 symbol (selected-frame))))))
2297 (form (widget-get widget :custom-form))
2298 (indent (widget-get widget :indent))
2299 (edit (widget-create-child-and-convert
2301 (cond ((and (eq form 'selected)
2302 (widget-apply custom-face-selected
2304 (when indent (insert-char ?\ indent))
2305 'custom-face-selected)
2306 ((and (not (eq form 'lisp))
2307 (widget-apply custom-face-all
2311 (when indent (insert-char ?\ indent))
2314 (custom-face-state-set widget)
2315 (widget-put widget :children (list edit)))
2316 (message "Creating face editor...done"))))))
2318 (defvar custom-face-menu
2319 '(("Set for Current Session" custom-face-set)
2320 ("Save for Future Sessions" custom-face-save)
2321 ("Reset to Saved" custom-face-reset-saved
2323 (get (widget-value widget) 'saved-face)))
2324 ("Reset to Standard Setting" custom-face-reset-standard
2326 (get (widget-value widget) 'face-defface-spec)))
2327 ("---" ignore ignore)
2328 ("Show all display specs" custom-face-edit-all
2330 (not (eq (widget-get widget :custom-form) 'all))))
2331 ("Just current attributes" custom-face-edit-selected
2333 (not (eq (widget-get widget :custom-form) 'selected))))
2334 ("Show as Lisp expression" custom-face-edit-lisp
2336 (not (eq (widget-get widget :custom-form) 'lisp)))))
2337 "Alist of actions for the `custom-face' widget.
2338 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
2339 the menu entry, ACTION is the function to call on the widget when the
2340 menu is selected, and FILTER is a predicate which takes a `custom-face'
2341 widget as an argument, and returns non-nil if ACTION is valid on that
2342 widget. If FILTER is nil, ACTION is always valid.")
2344 (defun custom-face-edit-selected (widget)
2345 "Edit selected attributes of the value of WIDGET."
2346 (widget-put widget :custom-state 'unknown)
2347 (widget-put widget :custom-form 'selected)
2348 (custom-redraw widget))
2350 (defun custom-face-edit-all (widget)
2351 "Edit all attributes of the value of WIDGET."
2352 (widget-put widget :custom-state 'unknown)
2353 (widget-put widget :custom-form 'all)
2354 (custom-redraw widget))
2356 (defun custom-face-edit-lisp (widget)
2357 "Edit the lisp representation of the value of WIDGET."
2358 (widget-put widget :custom-state 'unknown)
2359 (widget-put widget :custom-form 'lisp)
2360 (custom-redraw widget))
2362 (defun custom-face-state-set (widget)
2363 "Set the state of WIDGET."
2364 (let ((symbol (widget-value widget)))
2365 (widget-put widget :custom-state (cond ((get symbol 'customized-face)
2367 ((get symbol 'saved-face)
2369 ((get symbol 'face-defface-spec)
2374 (defun custom-face-action (widget &optional event)
2375 "Show the menu for `custom-face' WIDGET.
2376 Optional EVENT is the location for the menu."
2377 (if (eq (widget-get widget :custom-state) 'hidden)
2378 (custom-toggle-hide widget)
2379 (let* ((completion-ignore-case t)
2380 (symbol (widget-get widget :value))
2381 (answer (widget-choose (concat "Operation on "
2382 (custom-unlispify-tag-name symbol))
2383 (custom-menu-filter custom-face-menu
2387 (funcall answer widget)))))
2389 (defun custom-face-set (widget)
2390 "Make the face attributes in WIDGET take effect."
2391 (let* ((symbol (widget-value widget))
2392 (child (car (widget-get widget :children)))
2393 (value (widget-value child)))
2394 (put symbol 'customized-face value)
2395 (face-spec-set symbol value)
2396 (custom-face-state-set widget)
2397 (custom-redraw-magic widget)))
2399 (defun custom-face-save (widget)
2400 "Make the face attributes in WIDGET default."
2401 (let* ((symbol (widget-value widget))
2402 (child (car (widget-get widget :children)))
2403 (value (widget-value child)))
2404 (face-spec-set symbol value)
2405 (put symbol 'saved-face value)
2406 (put symbol 'customized-face nil)
2408 (custom-face-state-set widget)
2409 (custom-redraw-magic widget)))
2411 (defun custom-face-reset-saved (widget)
2412 "Restore WIDGET to the face's default attributes."
2413 (let* ((symbol (widget-value widget))
2414 (child (car (widget-get widget :children)))
2415 (value (get symbol 'saved-face)))
2417 (signal 'error (list "No saved value for this face" symbol)))
2418 (put symbol 'customized-face nil)
2419 (face-spec-set symbol value)
2420 (widget-value-set child value)
2421 (custom-face-state-set widget)
2422 (custom-redraw-magic widget)))
2424 (defun custom-face-reset-standard (widget)
2425 "Restore WIDGET to the face's standard settings."
2426 (let* ((symbol (widget-value widget))
2427 (child (car (widget-get widget :children)))
2428 (value (get symbol 'face-defface-spec)))
2430 (signal 'error (list "No standard setting for this face" symbol)))
2431 (put symbol 'customized-face nil)
2432 (when (get symbol 'saved-face)
2433 (put symbol 'saved-face nil)
2435 (face-spec-set symbol value)
2436 (widget-value-set child value)
2437 (custom-face-state-set widget)
2438 (custom-redraw-magic widget)))
2440 ;;; The `face' Widget.
2442 (define-widget 'face 'default
2443 "Select and customize a face."
2444 :convert-widget 'widget-value-convert-widget
2445 :button-prefix 'widget-push-button-prefix
2446 :button-suffix 'widget-push-button-suffix
2447 :format "%t: %[select face%] %v"
2450 :value-create 'widget-face-value-create
2451 :value-delete 'widget-face-value-delete
2452 :value-get 'widget-value-value-get
2453 :validate 'widget-children-validate
2454 :action 'widget-face-action
2455 :match (lambda (widget value) (symbolp value)))
2457 (defun widget-face-value-create (widget)
2458 ;; Create a `custom-face' child.
2459 (let* ((symbol (widget-value widget))
2460 (custom-buffer-style 'face)
2461 (child (widget-create-child-and-convert
2465 (custom-magic-reset child)
2466 (setq custom-options (cons child custom-options))
2467 (widget-put widget :children (list child))))
2469 (defun widget-face-value-delete (widget)
2470 ;; Remove the child from the options.
2471 (let ((child (car (widget-get widget :children))))
2472 (setq custom-options (delq child custom-options))
2473 (widget-children-value-delete widget)))
2475 (defvar face-history nil
2476 "History of entered face names.")
2478 (defun widget-face-action (widget &optional event)
2479 "Prompt for a face."
2480 (let ((answer (completing-read "Face: "
2481 (mapcar (lambda (face)
2482 (list (symbol-name face)))
2486 (unless (zerop (length answer))
2487 (widget-value-set widget (intern answer))
2488 (widget-apply widget :notify widget event)
2491 ;;; The `hook' Widget.
2493 (define-widget 'hook 'list
2495 :value-to-internal (lambda (widget value)
2499 :match (lambda (widget value)
2501 (widget-group-match widget value)))
2502 :convert-widget 'custom-hook-convert-widget
2505 (defun custom-hook-convert-widget (widget)
2506 ;; Handle `:custom-options'.
2507 (let* ((options (widget-get widget :options))
2508 (other `(editable-list :inline t
2509 :entry-format "%i %d%v"
2510 (function :format " %v")))
2512 (list `(checklist :inline t
2513 ,@(mapcar (lambda (entry)
2514 `(function-item ,entry))
2518 (widget-put widget :args args)
2521 ;;; The `plist' Widget.
2523 (define-widget 'plist 'list
2525 :match (lambda (widget value)
2526 (valid-plist-p value))
2527 :convert-widget 'custom-plist-convert-widget
2528 :tag "Property List")
2530 ;; #### Should handle options better.
2531 (defun custom-plist-convert-widget (widget)
2532 (let* ((options (widget-get widget :options))
2533 (other `(editable-list :inline t
2535 (symbol :format "%t: %v "
2538 (sexp :tag "Value"))))
2541 `((checklist :inline t
2542 ,@(mapcar 'custom-plist-process-option options))
2545 (widget-put widget :args args)
2548 (defun custom-plist-process-option (entry)
2550 (const :tag "Property"
2554 (sexp :tag "Value")))
2556 ;;; The `custom-group-link' Widget.
2558 (define-widget 'custom-group-link 'link
2559 "Show parent in other window when activated."
2560 :help-echo 'custom-group-link-help-echo
2561 :action 'custom-group-link-action)
2563 (defun custom-group-link-help-echo (widget)
2564 (concat "Create customization buffer for the `"
2565 (custom-unlispify-tag-name (widget-value widget))
2568 (defun custom-group-link-action (widget &rest ignore)
2569 (customize-group (widget-value widget)))
2571 ;;; The `custom-group' Widget.
2573 (defcustom custom-group-tag-faces nil
2574 ;; In XEmacs, this ought to play games with font size.
2575 "Face used for group tags.
2576 The first member is used for level 1 groups, the second for level 2,
2577 and so forth. The remaining group tags are shown with
2578 `custom-group-tag-face'."
2579 :type '(repeat face)
2580 :group 'custom-faces)
2582 (defface custom-group-tag-face-1 '((((class color)
2584 (:foreground "pink" :underline t))
2587 (:foreground "red" :underline t))
2589 "Face used for group tags.")
2591 (defface custom-group-tag-face '((((class color)
2593 (:foreground "light blue" :underline t))
2596 (:foreground "blue" :underline t))
2598 "Face used for low level group tags."
2599 :group 'custom-faces)
2601 (define-widget 'custom-group 'custom
2604 :sample-face-get 'custom-group-sample-face-get
2605 :documentation-property 'group-documentation
2606 :help-echo "Set or reset all members of this group"
2607 :value-create 'custom-group-value-create
2608 :action 'custom-group-action
2609 :custom-category 'group
2610 :custom-set 'custom-group-set
2611 :custom-save 'custom-group-save
2612 :custom-reset-current 'custom-group-reset-current
2613 :custom-reset-saved 'custom-group-reset-saved
2614 :custom-reset-standard 'custom-group-reset-standard
2615 :custom-menu 'custom-group-menu-create)
2617 (defun custom-group-sample-face-get (widget)
2618 ;; Use :sample-face.
2619 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
2620 'custom-group-tag-face))
2622 (define-widget 'custom-group-visibility 'visibility
2623 "An indicator and manipulator for hidden group contents."
2624 :create 'custom-group-visibility-create)
2626 (defun custom-group-visibility-create (widget)
2627 (let ((visible (widget-value widget)))
2629 (insert "--------")))
2630 (widget-default-create widget))
2632 (defun custom-group-members (symbol groups-only)
2633 "Return SYMBOL's custom group members.
2634 If GROUPS-ONLY non-nil, return only those members that are groups."
2635 (if (not groups-only)
2636 (get symbol 'custom-group)
2638 (dolist (entry (get symbol 'custom-group) (nreverse members))
2639 (when (eq (nth 1 entry) 'custom-group)
2640 (push entry members))))))
2642 (defun custom-group-value-create (widget)
2643 "Insert a customize group for WIDGET in the current buffer."
2644 (let* ((state (widget-get widget :custom-state))
2645 (level (widget-get widget :custom-level))
2646 ;; (indent (widget-get widget :indent))
2647 (prefix (widget-get widget :custom-prefix))
2648 (buttons (widget-get widget :buttons))
2649 (tag (widget-get widget :tag))
2650 (symbol (widget-value widget))
2651 (members (custom-group-members symbol
2652 (and (eq custom-buffer-style 'tree)
2653 custom-browse-only-groups))))
2654 (cond ((and (eq custom-buffer-style 'tree)
2656 (or members (custom-unloaded-widget-p widget)))
2657 (custom-browse-insert-prefix prefix)
2658 (push (widget-create-child-and-convert
2659 widget 'custom-browse-visibility
2660 ;; :tag-glyph "plus"
2664 ;; (widget-glyph-insert nil "-- " "horizontal")
2665 (push (widget-create-child-and-convert
2666 widget 'custom-browse-group-tag)
2668 (insert " " tag "\n")
2669 (widget-put widget :buttons buttons))
2670 ((and (eq custom-buffer-style 'tree)
2671 (zerop (length members)))
2672 (custom-browse-insert-prefix prefix)
2674 ;; (widget-glyph-insert nil "[ ]" "empty")
2675 ;; (widget-glyph-insert nil "-- " "horizontal")
2676 (push (widget-create-child-and-convert
2677 widget 'custom-browse-group-tag)
2679 (insert " " tag "\n")
2680 (widget-put widget :buttons buttons))
2681 ((eq custom-buffer-style 'tree)
2682 (custom-browse-insert-prefix prefix)
2683 (custom-load-widget widget)
2684 (if (zerop (length members))
2686 (custom-browse-insert-prefix prefix)
2688 ;; (widget-glyph-insert nil "[ ]" "empty")
2689 ;; (widget-glyph-insert nil "-- " "horizontal")
2690 (push (widget-create-child-and-convert
2691 widget 'custom-browse-group-tag)
2693 (insert " " tag "\n")
2694 (widget-put widget :buttons buttons))
2695 (push (widget-create-child-and-convert
2696 widget 'custom-browse-visibility
2697 ;; :tag-glyph "minus"
2701 ;; (widget-glyph-insert nil "-\\ " "top")
2702 (push (widget-create-child-and-convert
2703 widget 'custom-browse-group-tag)
2705 (insert " " tag "\n")
2706 (widget-put widget :buttons buttons)
2707 (message "Creating group...")
2708 (let* ((members (custom-sort-items members
2709 custom-browse-sort-alphabetically
2710 custom-browse-order-groups))
2711 (prefixes (widget-get widget :custom-prefixes))
2712 (custom-prefix-list (custom-prefix-add symbol prefixes))
2713 (extra-prefix (if (widget-get widget :custom-last)
2716 (prefix (concat prefix extra-prefix))
2719 (setq entry (car members)
2720 members (cdr members))
2721 (push (widget-create-child-and-convert
2722 widget (nth 1 entry)
2724 :tag (custom-unlispify-tag-name (nth 0 entry))
2725 :custom-prefixes custom-prefix-list
2726 :custom-level (1+ level)
2727 :custom-last (null members)
2728 :value (nth 0 entry)
2729 :custom-prefix prefix)
2731 (widget-put widget :children (reverse children)))
2732 (message "Creating group...done")))
2735 ;; Create level indicator.
2736 (unless (eq custom-buffer-style 'links)
2737 (insert-char ?\ (* custom-buffer-indent (1- level)))
2739 ;; Create link indicator.
2740 (when (eq custom-buffer-style 'links)
2742 (push (widget-create-child-and-convert
2743 widget 'custom-group-link
2745 :tag-glyph '("open-up" "open-down")
2750 (let ((begin (point)))
2752 (widget-specify-sample widget begin (point)))
2754 ;; Create visibility indicator.
2755 (unless (eq custom-buffer-style 'links)
2757 (push (widget-create-child-and-convert
2758 widget 'custom-group-visibility
2759 :help-echo "Show members of this group"
2760 :action 'custom-toggle-parent
2761 (not (eq state 'hidden)))
2764 ;; Create magic button.
2765 (let ((magic (widget-create-child-and-convert
2766 widget 'custom-magic nil)))
2767 (widget-put widget :custom-magic magic)
2768 (push magic buttons))
2770 (widget-put widget :buttons buttons)
2771 ;; Insert documentation.
2772 (if (and (eq custom-buffer-style 'links) (> level 1))
2773 (widget-put widget :documentation-indent 0))
2774 (widget-default-format-handler widget ?h))
2777 (custom-load-widget widget)
2779 (setq members (custom-group-members
2780 symbol (and (eq custom-buffer-style 'tree)
2781 custom-browse-only-groups)))
2782 ;; Add parent groups references above the group.
2783 (if t ;;; This should test that the buffer
2784 ;;; was made to display a group.
2786 (if (custom-add-parent-links widget
2787 "Go to parent group:")
2789 ;; Create level indicator.
2790 (insert-char ?\ (* custom-buffer-indent (1- level)))
2793 (let ((start (point)))
2795 (widget-specify-sample widget start (point)))
2797 ;; Create visibility indicator.
2798 (unless (eq custom-buffer-style 'links)
2800 (push (widget-create-child-and-convert
2802 :help-echo "Hide members of this group"
2803 :action 'custom-toggle-parent
2804 (not (eq state 'hidden)))
2807 ;; Create more dashes.
2808 ;; Use 76 instead of 75 to compensate for the temporary "<"
2809 ;; added by `widget-insert'.
2810 (insert-char ?- (- 76 (current-column)
2811 (* custom-buffer-indent level)))
2813 ;; Create magic button.
2814 (let ((magic (widget-create-child-and-convert
2815 widget 'custom-magic
2818 (widget-put widget :custom-magic magic)
2819 (push magic buttons))
2821 (widget-put widget :buttons buttons)
2822 ;; Insert documentation.
2823 (widget-default-format-handler widget ?h)
2825 (if nil ;;; This should test that the buffer
2826 ;;; was not made to display a group.
2828 (insert-char ?\ custom-buffer-indent)
2829 (custom-add-parent-links widget)))
2830 (custom-add-see-also widget
2831 (make-string (* custom-buffer-indent level)
2834 (message "Creating group...")
2835 (let* ((members (custom-sort-items members
2836 custom-buffer-sort-alphabetically
2837 custom-buffer-order-groups))
2838 (prefixes (widget-get widget :custom-prefixes))
2839 (custom-prefix-list (custom-prefix-add symbol prefixes))
2840 (length (length members))
2844 (widget-insert "\n")
2845 (when (zerop (% count custom-skip-messages))
2849 Creating group members... %2d%%"
2850 (/ (* 100.0 count) length))))
2853 (widget-create-child-and-convert
2854 widget (nth 1 entry)
2856 :tag (custom-unlispify-tag-name
2858 :custom-prefixes custom-prefix-list
2859 :custom-level (1+ level)
2860 :value (nth 0 entry))
2861 (unless (eq (preceding-char) ?\n)
2862 (widget-insert "\n"))))
2864 (message "Creating group magic...")
2865 (mapc 'custom-magic-reset children)
2866 (message "Creating group state...")
2867 (widget-put widget :children children)
2868 (custom-group-state-update widget)
2869 (message "Creating group... done"))
2872 (insert-char ?\ (* custom-buffer-indent (1- level)))
2873 (insert "\\- " (widget-get widget :tag) " group end ")
2874 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level)))
2877 (defvar custom-group-menu
2878 '(("Set for Current Session" custom-group-set
2880 (eq (widget-get widget :custom-state) 'modified)))
2881 ("Save for Future Sessions" custom-group-save
2883 (memq (widget-get widget :custom-state) '(modified set))))
2884 ("Reset to Current" custom-group-reset-current
2886 (memq (widget-get widget :custom-state) '(modified))))
2887 ("Reset to Saved" custom-group-reset-saved
2889 (memq (widget-get widget :custom-state) '(modified set))))
2890 ("Reset to standard setting" custom-group-reset-standard
2892 (memq (widget-get widget :custom-state) '(modified set saved)))))
2893 "Alist of actions for the `custom-group' widget.
2894 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
2895 the menu entry, ACTION is the function to call on the widget when the
2896 menu is selected, and FILTER is a predicate which takes a `custom-group'
2897 widget as an argument, and returns non-nil if ACTION is valid on that
2898 widget. If FILTER is nil, ACTION is always valid.")
2900 (defun custom-group-action (widget &optional event)
2901 "Show the menu for `custom-group' WIDGET.
2902 Optional EVENT is the location for the menu."
2903 (if (eq (widget-get widget :custom-state) 'hidden)
2904 (custom-toggle-hide widget)
2905 (let* ((completion-ignore-case t)
2906 (answer (widget-choose (concat "Operation on "
2907 (custom-unlispify-tag-name
2908 (widget-get widget :value)))
2909 (custom-menu-filter custom-group-menu
2913 (funcall answer widget)))))
2915 (defun custom-group-set (widget)
2916 "Set changes in all modified group members."
2917 (let ((children (widget-get widget :children)))
2918 (mapc (lambda (child)
2919 (when (eq (widget-get child :custom-state) 'modified)
2920 (widget-apply child :custom-set)))
2923 (defun custom-group-save (widget)
2924 "Save all modified group members."
2925 (let ((children (widget-get widget :children)))
2926 (mapc (lambda (child)
2927 (when (memq (widget-get child :custom-state) '(modified set))
2928 (widget-apply child :custom-save)))
2931 (defun custom-group-reset-current (widget)
2932 "Reset all modified group members."
2933 (let ((children (widget-get widget :children)))
2934 (mapc (lambda (child)
2935 (when (eq (widget-get child :custom-state) 'modified)
2936 (widget-apply child :custom-reset-current)))
2939 (defun custom-group-reset-saved (widget)
2940 "Reset all modified or set group members."
2941 (let ((children (widget-get widget :children)))
2942 (mapc (lambda (child)
2943 (when (memq (widget-get child :custom-state) '(modified set))
2944 (widget-apply child :custom-reset-saved)))
2947 (defun custom-group-reset-standard (widget)
2948 "Reset all modified, set, or saved group members."
2949 (let ((children (widget-get widget :children)))
2950 (mapc (lambda (child)
2951 (when (memq (widget-get child :custom-state)
2952 '(modified set saved))
2953 (widget-apply child :custom-reset-standard)))
2956 (defun custom-group-state-update (widget)
2958 (unless (eq (widget-get widget :custom-state) 'hidden)
2959 (let* ((children (widget-get widget :children))
2960 (states (mapcar (lambda (child)
2961 (widget-get child :custom-state))
2963 (magics custom-magic-alist)
2966 (let ((magic (car (car magics))))
2967 (if (and (not (eq magic 'hidden))
2968 (memq magic states))
2971 (setq magics (cdr magics)))))
2972 (widget-put widget :custom-state found)))
2973 (custom-magic-reset widget))
2975 ;;; The `custom-save-all' Function.
2977 (defcustom custom-file "~/.emacs"
2978 "File used for storing customization information.
2979 If you change this from the default \"~/.emacs\" you need to
2980 explicitly load that file for the settings to take effect."
2984 (defun custom-save-delete (symbol)
2985 "Delete the call to SYMBOL form `custom-file'.
2986 Leave point at the location of the call, or after the last expression."
2987 (let ((find-file-hooks nil)
2988 (auto-mode-alist nil))
2989 (set-buffer (find-file-noselect custom-file)))
2990 (goto-char (point-min))
2993 (let ((sexp (condition-case nil
2994 (read (current-buffer))
2995 (end-of-file (throw 'found nil)))))
2996 (when (and (listp sexp)
2997 (eq (car sexp) symbol))
2998 (delete-region (save-excursion
3002 (throw 'found nil))))))
3004 (defun custom-save-variables ()
3005 "Save all customized variables in `custom-file'."
3007 (custom-save-delete 'custom-set-variables)
3008 (let ((standard-output (current-buffer)))
3011 (princ "(custom-set-variables")
3012 (mapatoms (lambda (symbol)
3013 (let ((value (get symbol 'saved-value))
3014 (requests (get symbol 'custom-requests))
3015 (now (not (or (get symbol 'standard-value)
3016 (and (not (boundp symbol))
3017 (not (get symbol 'force-value)))))))
3034 (unless (looking-at "\n")
3037 (defun custom-save-faces ()
3038 "Save all customized faces in `custom-file'."
3040 (custom-save-delete 'custom-set-faces)
3041 (let ((standard-output (current-buffer)))
3044 (princ "(custom-set-faces")
3045 (let ((value (get 'default 'saved-face)))
3046 ;; The default face must be first, since it affects the others.
3048 (princ "\n '(default ")
3050 (if (or (get 'default 'face-defface-spec)
3051 (and (not (find-face 'default))
3052 (not (get 'default 'force-face))))
3055 (mapatoms (lambda (symbol)
3056 (let ((value (get symbol 'saved-face)))
3057 (when (and (not (eq symbol 'default))
3058 ;; Don't print default face here.
3064 (if (or (get symbol 'face-defface-spec)
3065 (and (not (find-face symbol))
3066 (not (get symbol 'force-face))))
3070 (unless (looking-at "\n")
3074 (defun customize-save-customized ()
3075 "Save all user options which have been set in this session."
3077 (mapatoms (lambda (symbol)
3078 (let ((face (get symbol 'customized-face))
3079 (value (get symbol 'customized-value)))
3081 (put symbol 'saved-face face)
3082 (put symbol 'customized-face nil))
3084 (put symbol 'saved-value value)
3085 (put symbol 'customized-value nil)))))
3086 ;; We really should update all custom buffers here.
3090 (defun custom-save-all ()
3091 "Save all customizations in `custom-file'."
3092 (let ((inhibit-read-only t))
3093 (custom-save-variables)
3095 (let ((find-file-hooks nil)
3097 (with-current-buffer (find-file-noselect custom-file)
3101 ;;; The Customize Menu.
3105 (defun custom-face-menu-create (widget symbol)
3106 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
3107 (vector (custom-unlispify-menu-entry symbol)
3108 `(customize-face ',symbol)
3111 (defun custom-variable-menu-create (widget symbol)
3112 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
3113 (let ((type (get symbol 'custom-type)))
3114 (unless (listp type)
3115 (setq type (list type)))
3116 (if (and type (widget-get type :custom-menu))
3117 (widget-apply type :custom-menu symbol)
3118 (vector (custom-unlispify-menu-entry symbol)
3119 `(customize-variable ',symbol)
3122 ;; Add checkboxes to boolean variable entries.
3123 (widget-put (get 'boolean 'widget-type)
3124 :custom-menu (lambda (widget symbol)
3125 `[,(custom-unlispify-menu-entry symbol)
3126 (customize-variable ',symbol)
3128 :selected ,symbol]))
3130 ;; XEmacs can create menus dynamically.
3131 (defun custom-group-menu-create (widget symbol)
3132 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
3133 `( ,(custom-unlispify-menu-entry symbol t)
3134 :filter (lambda (&rest junk)
3135 (let ((item (custom-menu-create ',symbol)))
3141 (defun custom-menu-create (symbol)
3142 "Create menu for customization group SYMBOL.
3143 The menu is in a format applicable to `easy-menu-define'."
3144 (let* ((item (vector (custom-unlispify-menu-entry symbol)
3145 `(customize-group ',symbol)
3147 ;; Item is the entry for creating a menu buffer for SYMBOL.
3148 ;; We may nest, if the menu is not too big.
3149 (custom-load-symbol symbol)
3150 (if (< (length (get symbol 'custom-group)) widget-menu-max-size)
3151 ;; The menu is not too big.
3152 (let ((custom-prefix-list (custom-prefix-add symbol
3153 custom-prefix-list))
3154 (members (custom-sort-items (get symbol 'custom-group)
3155 custom-menu-sort-alphabetically
3156 custom-menu-order-groups)))
3158 `(,(custom-unlispify-menu-entry symbol t)
3161 ,@(mapcar (lambda (entry)
3162 (widget-apply (if (listp (nth 1 entry))
3164 (list (nth 1 entry)))
3165 :custom-menu (nth 0 entry)))
3167 ;; The menu was too big.
3171 (defun customize-menu-create (symbol &optional name)
3172 "Return a customize menu for customization group SYMBOL.
3173 If optional NAME is given, use that as the name of the menu.
3174 Otherwise the menu will be named `Customize'.
3175 The format is suitable for use with `easy-menu-define'."
3177 (setq name "Customize"))
3179 :filter (lambda (&rest junk)
3180 (cdr (custom-menu-create ',symbol)))))
3182 ;;; The Custom Mode.
3184 (defvar custom-mode-map nil
3185 "Keymap for `custom-mode'.")
3187 (unless custom-mode-map
3188 (setq custom-mode-map (make-sparse-keymap))
3189 (set-keymap-parents custom-mode-map widget-keymap)
3190 (suppress-keymap custom-mode-map)
3191 (define-key custom-mode-map " " 'scroll-up)
3192 (define-key custom-mode-map [delete] 'scroll-down)
3193 (define-key custom-mode-map "q" 'Custom-buffer-done)
3194 (define-key custom-mode-map "u" 'Custom-goto-parent)
3195 (define-key custom-mode-map "n" 'widget-forward)
3196 (define-key custom-mode-map "p" 'widget-backward))
3198 (easy-menu-define Custom-mode-menu
3200 "Menu used in customization buffers."
3202 ,(customize-menu-create 'customize)
3203 ["Set" Custom-set t]
3204 ["Save" Custom-save t]
3205 ["Reset to Current" Custom-reset-current t]
3206 ["Reset to Saved" Custom-reset-saved t]
3207 ["Reset to Standard Settings" Custom-reset-standard t]
3208 ["Info" (Info-goto-node "(xemacs)Easy Customization") t]))
3210 (defun Custom-goto-parent ()
3211 "Go to the parent group listed at the top of this buffer.
3212 If several parents are listed, go to the first of them."
3215 (goto-char (point-min))
3216 (if (search-forward "\nGo to parent group: " nil t)
3217 (let* ((button (get-char-property (point) 'button))
3218 (parent (downcase (widget-get button :tag))))
3219 (customize-group parent)))))
3221 (defcustom custom-mode-hook nil
3222 "Hook called when entering custom-mode."
3224 :group 'custom-buffer )
3226 (defun custom-state-buffer-message (widget)
3227 (if (eq (widget-get (widget-get widget :parent) :custom-state) 'modified)
3229 "To install your edits, invoke [State] and choose the Set operation")))
3231 (defun custom-mode ()
3232 "Major mode for editing customization buffers.
3234 The following commands are available:
3236 Move to next button or editable field. \\[widget-forward]
3237 Move to previous button or editable field. \\[widget-backward]
3238 \\<widget-field-keymap>\
3239 Complete content of editable text field. \\[widget-complete]
3240 \\<custom-mode-map>\
3241 Invoke button under point. \\[widget-button-press]
3242 Set all modifications. \\[Custom-set]
3243 Make all modifications default. \\[Custom-save]
3244 Reset all modified options. \\[Custom-reset-current]
3245 Reset all modified or set options. \\[Custom-reset-saved]
3246 Reset all options. \\[Custom-reset-standard]
3248 Entry to this mode calls the value of `custom-mode-hook'
3249 if that value is non-nil."
3250 (kill-all-local-variables)
3251 (setq major-mode 'custom-mode
3253 (use-local-map custom-mode-map)
3254 (easy-menu-add Custom-mode-menu)
3255 (make-local-variable 'custom-options)
3256 (make-local-variable 'widget-documentation-face)
3257 (setq widget-documentation-face 'custom-documentation-face)
3258 (make-local-variable 'widget-button-face)
3259 (setq widget-button-face 'custom-button-face)
3260 (make-local-hook 'widget-edit-functions)
3261 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t)
3262 (run-hooks 'custom-mode-hook))
3269 ;; cus-edit.el ends here