comparison lisp/cus-edit.el @ 90261:7beb78bc1f8e

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-97 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 616-696) - Add lisp/mh-e/.arch-inventory - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: lisp/smerge-mode.el: Add 'tools' to file keywords. - lisp/gnus/ChangeLog: Remove duplicate entry * gnus--rel--5.10 (patch 147-181) - Update from CVS - Merge from emacs--cvs-trunk--0 - Update from CVS: lisp/mml.el (mml-preview): Doc fix. - Update from CVS: texi/message.texi: Fix default values. - Update from CVS: texi/gnus.texi (RSS): Addition.
author Miles Bader <miles@gnu.org>
date Mon, 16 Jan 2006 08:37:27 +0000
parents 0ca0d9181b5e f4bca1157746
children d88caeac70d7
comparison
equal deleted inserted replaced
90260:0ca0d9181b5e 90261:7beb78bc1f8e
1 ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages 1 ;;; cus-edit.el --- tools for customizing Emacs and Lisp packages
2 ;; 2 ;;
3 ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 3 ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc. 4 ;; 2005, 2006 Free Software Foundation, Inc.
5 ;; 5 ;;
6 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 6 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
7 ;; Maintainer: FSF 7 ;; Maintainer: FSF
8 ;; Keywords: help, faces 8 ;; Keywords: help, faces
9 9
86 ;; when the variable is first initialized, this is only relevant for the 86 ;; when the variable is first initialized, this is only relevant for the
87 ;; saved (and standard) values, but affect others values for 87 ;; saved (and standard) values, but affect others values for
88 ;; compatibility. 88 ;; compatibility.
89 89
90 ;; You can see (and modify and save) this unevaluated value by selecting 90 ;; You can see (and modify and save) this unevaluated value by selecting
91 ;; "Show initial Lisp expression" from the Lisp interface. This will 91 ;; "Show Saved Lisp Expression" from the Lisp interface. This will
92 ;; give you the unevaluated saved value, if any, otherwise the 92 ;; give you the unevaluated saved value, if any, otherwise the
93 ;; unevaluated standard value. 93 ;; unevaluated standard value.
94 94
95 ;; The possible states for a customize widget are: 95 ;; The possible states for a customize widget are:
96 96
119 ;; The "think" value is the standard value. 119 ;; The "think" value is the standard value.
120 120
121 ;; 6. rogue 121 ;; 6. rogue
122 122
123 ;; There is no standard value. This means that the variable was 123 ;; There is no standard value. This means that the variable was
124 ;; not defined with defcustom, nor handled in cus-start.el. You 124 ;; not defined with defcustom, nor handled in cus-start.el. Most
125 ;; can not create a Custom buffer for such variables using the 125 ;; standard interactive Custom commands do not let you create a
126 ;; normal interactive Custom commands. However, such Custom 126 ;; Custom buffer containing such variables. However, such Custom
127 ;; buffers can be created in other ways, for instance, by calling 127 ;; buffers can be created, for instance, by calling
128 ;; `customize-apropos' with a prefix arg or by calling
128 ;; `customize-option' non-interactively. 129 ;; `customize-option' non-interactively.
129 130
130 ;; 7. hidden 131 ;; 7. hidden
131 132
132 ;; There is no widget value. 133 ;; There is no widget value.
210 "Specialized modes for editing programming languages." 211 "Specialized modes for editing programming languages."
211 :group 'programming) 212 :group 'programming)
212 213
213 (defgroup lisp nil 214 (defgroup lisp nil
214 "Lisp support, including Emacs Lisp." 215 "Lisp support, including Emacs Lisp."
216 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
215 :group 'languages 217 :group 'languages
216 :group 'development) 218 :group 'development)
217 219
218 (defgroup c nil 220 (defgroup c nil
219 "Support for the C language and related languages." 221 "Support for the C language and related languages."
222 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
220 :link '(custom-manual "(ccmode)") 223 :link '(custom-manual "(ccmode)")
221 :group 'languages) 224 :group 'languages)
222 225
223 (defgroup tools nil 226 (defgroup tools nil
224 "Programming tools." 227 "Programming tools."
321 "Word processing." 324 "Word processing."
322 :group 'emacs) 325 :group 'emacs)
323 326
324 (defgroup tex nil 327 (defgroup tex nil
325 "Code related to the TeX formatter." 328 "Code related to the TeX formatter."
329 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
326 :group 'wp) 330 :group 'wp)
327 331
328 (defgroup faces nil 332 (defgroup faces nil
329 "Support for multiple fonts." 333 "Support for multiple fonts."
330 :group 'emacs) 334 :group 'emacs)
452 456
453 (defgroup windows nil 457 (defgroup windows nil
454 "Windows within a frame." 458 "Windows within a frame."
455 :link '(custom-manual "(emacs)Windows") 459 :link '(custom-manual "(emacs)Windows")
456 :group 'environment) 460 :group 'environment)
461
462 (defgroup mac nil
463 "Mac specific features."
464 :link '(custom-manual "(emacs)Mac OS")
465 :group 'environment
466 :version "22.1"
467 :prefix "mac-")
457 468
458 ;;; Utilities. 469 ;;; Utilities.
459 470
460 (defun custom-quote (sexp) 471 (defun custom-quote (sexp)
461 "Quote SEXP iff it is not self quoting." 472 "Quote SEXP iff it is not self quoting."
488 regexp)) 499 regexp))
489 500
490 (defun custom-variable-prompt () 501 (defun custom-variable-prompt ()
491 "Prompt for a custom variable, defaulting to the variable at point. 502 "Prompt for a custom variable, defaulting to the variable at point.
492 Return a list suitable for use in `interactive'." 503 Return a list suitable for use in `interactive'."
493 (let ((v (variable-at-point)) 504 (let* ((v (variable-at-point))
494 (enable-recursive-minibuffers t) 505 (default (and (symbolp v) (custom-variable-p v) (symbol-name v)))
495 val) 506 (enable-recursive-minibuffers t)
507 val)
496 (setq val (completing-read 508 (setq val (completing-read
497 (if (and (symbolp v) (custom-variable-p v)) 509 (if default (format "Customize variable (default %s): " default)
498 (format "Customize option (default %s): " v) 510 "Customize variable: ")
499 "Customize option: ") 511 obarray 'custom-variable-p t nil nil default))
500 obarray 'custom-variable-p t))
501 (list (if (equal val "") 512 (list (if (equal val "")
502 (if (symbolp v) v nil) 513 (if (symbolp v) v nil)
503 (intern val))))) 514 (intern val)))))
504 515
505 (defun custom-menu-filter (menu widget) 516 (defun custom-menu-filter (menu widget)
606 used. 617 used.
607 618
608 This is used for guessing the type of variables not declared with 619 This is used for guessing the type of variables not declared with
609 customize." 620 customize."
610 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type"))) 621 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
611 :group 'customize) 622 :group 'custom-buffer)
612 623
613 (defcustom custom-guess-doc-alist 624 (defcustom custom-guess-doc-alist
614 '(("\\`\\*?Non-nil " boolean)) 625 '(("\\`\\*?Non-nil " boolean))
615 "Alist of (MATCH TYPE). 626 "Alist of (MATCH TYPE).
616 627
620 matches the name of the symbol will be used. 631 matches the name of the symbol will be used.
621 632
622 This is used for guessing the type of variables not declared with 633 This is used for guessing the type of variables not declared with
623 customize." 634 customize."
624 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type"))) 635 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
625 :group 'customize) 636 :group 'custom-buffer)
626 637
627 (defun custom-guess-type (symbol) 638 (defun custom-guess-type (symbol)
628 "Guess a widget suitable for editing the value of SYMBOL. 639 "Guess a widget suitable for editing the value of SYMBOL.
629 This is done by matching SYMBOL with `custom-guess-name-alist' and 640 This is done by matching SYMBOL with `custom-guess-name-alist' and
630 if that fails, the doc string with `custom-guess-doc-alist'." 641 if that fails, the doc string with `custom-guess-doc-alist'."
731 742
732 (defvar custom-options nil 743 (defvar custom-options nil
733 "Customization widgets in the current buffer.") 744 "Customization widgets in the current buffer.")
734 745
735 (defun Custom-set () 746 (defun Custom-set ()
736 "Set changes in all modified options." 747 "Set the current value of all edited settings in the buffer."
737 (interactive) 748 (interactive)
738 (let ((children custom-options)) 749 (let ((children custom-options))
739 (mapc (lambda (child) 750 (if (or (and (= 1 (length children))
740 (when (eq (widget-get child :custom-state) 'modified) 751 (memq (widget-type (car children))
741 (widget-apply child :custom-set))) 752 '(custom-variable custom-face)))
742 children))) 753 (y-or-n-p "Set all values according to this buffer? "))
754 (mapc (lambda (child)
755 (when (eq (widget-get child :custom-state) 'modified)
756 (widget-apply child :custom-set)))
757 children)
758 (message "Aborted"))))
743 759
744 (defun Custom-save () 760 (defun Custom-save ()
745 "Set all modified group members and save them." 761 "Set all edited settings, then save all settings that have been set.
762 If a setting was edited and set before, this saves it.
763 If a setting was merely edited before, this sets it then saves it."
746 (interactive) 764 (interactive)
747 (let ((children custom-options)) 765 (let ((children custom-options))
748 (mapc (lambda (child) 766 (if (or (and (= 1 (length children))
749 (when (memq (widget-get child :custom-state) 767 (memq (widget-type (car children))
750 '(modified set changed rogue)) 768 '(custom-variable custom-face)))
751 (widget-apply child :custom-save))) 769 (yes-or-no-p "Save all settings in this buffer? "))
752 children)) 770 (progn
753 (custom-save-all)) 771 (mapc (lambda (child)
772 (when (memq (widget-get child :custom-state)
773 '(modified set changed rogue))
774 (widget-apply child :custom-save)))
775 children)
776 (custom-save-all))
777 (message "Aborted"))))
754 778
755 (defvar custom-reset-menu 779 (defvar custom-reset-menu
756 '(("Current" . Custom-reset-current) 780 '(("Undo Edits" . Custom-reset-current)
757 ("Saved" . Custom-reset-saved) 781 ("Reset to Saved" . Custom-reset-saved)
758 ("Erase Customization (use standard settings)" . Custom-reset-standard)) 782 ("Erase Customization (use standard values)" . Custom-reset-standard))
759 "Alist of actions for the `Reset' button. 783 "Alist of actions for the `Reset' button.
760 The key is a string containing the name of the action, the value is a 784 The key is a string containing the name of the action, the value is a
761 Lisp function taking the widget as an element which will be called 785 Lisp function taking the widget as an element which will be called
762 when the action is chosen.") 786 when the action is chosen.")
763 787
764 (defun custom-reset (event) 788 (defun custom-reset (event)
765 "Select item from reset menu." 789 "Select item from reset menu."
766 (let* ((completion-ignore-case t) 790 (let* ((completion-ignore-case t)
767 (answer (widget-choose "Reset to" 791 (answer (widget-choose "Reset settings"
768 custom-reset-menu 792 custom-reset-menu
769 event))) 793 event)))
770 (if answer 794 (if answer
771 (funcall answer)))) 795 (funcall answer))))
772 796
773 (defun Custom-reset-current (&rest ignore) 797 (defun Custom-reset-current (&rest ignore)
774 "Reset all modified group members to their current value." 798 "Reset all edited settings in the buffer to show their current values."
775 (interactive) 799 (interactive)
776 (let ((children custom-options)) 800 (let ((children custom-options))
777 (mapc (lambda (widget) 801 (if (or (and (= 1 (length children))
778 (if (memq (widget-get widget :custom-state) 802 (memq (widget-type (car children))
779 '(modified changed)) 803 '(custom-variable custom-face)))
780 (widget-apply widget :custom-reset-current))) 804 (y-or-n-p "Reset all settings' buffer text to show current values? "))
781 children))) 805 (mapc (lambda (widget)
806 (if (memq (widget-get widget :custom-state)
807 '(modified changed))
808 (widget-apply widget :custom-reset-current)))
809 children)
810 (message "Aborted"))))
782 811
783 (defun Custom-reset-saved (&rest ignore) 812 (defun Custom-reset-saved (&rest ignore)
784 "Reset all modified or set group members to their saved value." 813 "Reset all edited or set settings in the buffer to their saved value.
814 This also shows the saved values in the buffer."
785 (interactive) 815 (interactive)
786 (let ((children custom-options)) 816 (let ((children custom-options))
787 (mapc (lambda (widget) 817 (if (or (and (= 1 (length children))
788 (if (memq (widget-get widget :custom-state) 818 (memq (widget-type (car children))
789 '(modified set changed rogue)) 819 '(custom-variable custom-face)))
790 (widget-apply widget :custom-reset-saved))) 820 (y-or-n-p "Reset all settings (current values and buffer text) to saved values? "))
791 children))) 821 (mapc (lambda (widget)
822 (if (memq (widget-get widget :custom-state)
823 '(modified set changed rogue))
824 (widget-apply widget :custom-reset-saved)))
825 children)
826 (message "Aborted"))))
792 827
793 (defun Custom-reset-standard (&rest ignore) 828 (defun Custom-reset-standard (&rest ignore)
794 "Erase all customization (either current or saved) for the group members. 829 "Erase all customization (either current or saved) for the group members.
795 The immediate result is to restore them to their standard settings. 830 The immediate result is to restore them to their standard values.
796 This operation eliminates any saved settings for the group members, 831 This operation eliminates any saved values for the group members,
797 making them as if they had never been customized at all." 832 making them as if they had never been customized at all."
798 (interactive) 833 (interactive)
799 (let ((children custom-options)) 834 (let ((children custom-options))
800 (mapc (lambda (widget) 835 (if (or (and (= 1 (length children))
801 (and (widget-apply widget :custom-standard-value) 836 (memq (widget-type (car children))
802 (if (memq (widget-get widget :custom-state) 837 '(custom-variable custom-face)))
838 (yes-or-no-p "Erase all customizations for settings in this buffer? "))
839 (mapc (lambda (widget)
840 (and (if (widget-get widget :custom-standard-value)
841 (widget-apply widget :custom-standard-value)
842 t)
843 (memq (widget-get widget :custom-state)
803 '(modified set changed saved rogue)) 844 '(modified set changed saved rogue))
804 (widget-apply widget :custom-reset-standard)))) 845 (widget-apply widget :custom-reset-standard)))
805 children))) 846 children)
847 (message "Aborted"))))
806 848
807 ;;; The Customize Commands 849 ;;; The Customize Commands
808 850
809 (defun custom-prompt-variable (prompt-var prompt-val &optional comment) 851 (defun custom-prompt-variable (prompt-var prompt-val &optional comment)
810 "Prompt for a variable and a value and return them as a list. 852 "Prompt for a variable and a value and return them as a list.
921 (interactive (custom-prompt-variable "Set and save variable: " 963 (interactive (custom-prompt-variable "Set and save variable: "
922 "Set and save value for %s as: " 964 "Set and save value for %s as: "
923 current-prefix-arg)) 965 current-prefix-arg))
924 (funcall (or (get variable 'custom-set) 'set-default) variable value) 966 (funcall (or (get variable 'custom-set) 'set-default) variable value)
925 (put variable 'saved-value (list (custom-quote value))) 967 (put variable 'saved-value (list (custom-quote value)))
926 (custom-push-theme 'theme-value variable 'user 'set (list (custom-quote value))) 968 (custom-push-theme 'theme-value variable 'user 'set (custom-quote value))
927 (cond ((string= comment "") 969 (cond ((string= comment "")
928 (put variable 'variable-comment nil) 970 (put variable 'variable-comment nil)
929 (put variable 'saved-variable-comment nil)) 971 (put variable 'saved-variable-comment nil))
930 (comment 972 (comment
931 (put variable 'variable-comment comment) 973 (put variable 'variable-comment comment)
964 1006
965 1007
966 ;;;###autoload 1008 ;;;###autoload
967 (defun customize-group (group) 1009 (defun customize-group (group)
968 "Customize GROUP, which must be a customization group." 1010 "Customize GROUP, which must be a customization group."
969 (interactive (list (let ((completion-ignore-case t)) 1011 (interactive
970 (completing-read "Customize group (default emacs): " 1012 (list (let ((completion-ignore-case t))
971 obarray 1013 (completing-read "Customize group (default emacs): "
972 (lambda (symbol) 1014 obarray
973 (or (get symbol 'custom-loads) 1015 (lambda (symbol)
974 (get symbol 'custom-group))) 1016 (or (and (get symbol 'custom-loads)
975 t)))) 1017 (not (get symbol 'custom-autoload)))
1018 (get symbol 'custom-group)))
1019 t))))
976 (when (stringp group) 1020 (when (stringp group)
977 (if (string-equal "" group) 1021 (if (string-equal "" group)
978 (setq group 'emacs) 1022 (setq group 'emacs)
979 (setq group (intern group)))) 1023 (setq group (intern group))))
980 (let ((name (format "*Customize Group: %s*" 1024 (let ((name (format "*Customize Group: %s*"
987 (custom-unlispify-tag-name group)))))) 1031 (custom-unlispify-tag-name group))))))
988 1032
989 ;;;###autoload 1033 ;;;###autoload
990 (defun customize-group-other-window (group) 1034 (defun customize-group-other-window (group)
991 "Customize GROUP, which must be a customization group." 1035 "Customize GROUP, which must be a customization group."
992 (interactive (list (let ((completion-ignore-case t)) 1036 (interactive
993 (completing-read "Customize group (default emacs): " 1037 (list (let ((completion-ignore-case t))
994 obarray 1038 (completing-read "Customize group (default emacs): "
995 (lambda (symbol) 1039 obarray
996 (or (get symbol 'custom-loads) 1040 (lambda (symbol)
997 (get symbol 'custom-group))) 1041 (or (and (get symbol 'custom-loads)
998 t)))) 1042 (not (get symbol 'custom-autoload)))
1043 (get symbol 'custom-group)))
1044 t))))
999 (when (stringp group) 1045 (when (stringp group)
1000 (if (string-equal "" group) 1046 (if (string-equal "" group)
1001 (setq group 'emacs) 1047 (setq group 'emacs)
1002 (setq group (intern group)))) 1048 (setq group (intern group))))
1003 (let ((name (format "*Customize Group: %s*" 1049 (let ((name (format "*Customize Group: %s*"
1042 (list (list basevar 'custom-variable)) 1088 (list (list basevar 'custom-variable))
1043 (format "*Customize Option: %s*" (custom-unlispify-tag-name basevar))) 1089 (format "*Customize Option: %s*" (custom-unlispify-tag-name basevar)))
1044 (unless (eq symbol basevar) 1090 (unless (eq symbol basevar)
1045 (message "`%s' is an alias for `%s'" symbol basevar)))) 1091 (message "`%s' is an alias for `%s'" symbol basevar))))
1046 1092
1047 (defvar customize-changed-options-previous-release "20.2" 1093 (defvar customize-changed-options-previous-release "21.1"
1048 "Version for `customize-changed-options' to refer back to by default.") 1094 "Version for `customize-changed-options' to refer back to by default.")
1095
1096 ;;;###autoload
1097 (defalias 'customize-changed 'customize-changed-options)
1049 1098
1050 ;;;###autoload 1099 ;;;###autoload
1051 (defun customize-changed-options (since-version) 1100 (defun customize-changed-options (since-version)
1052 "Customize all user option variables changed in Emacs itself. 1101 "Customize all settings whose meanings have changed in Emacs itself.
1053 This includes new user option variables and faces, and new 1102 This includes new user option variables and faces, and new
1054 customization groups, as well as older options and faces whose default 1103 customization groups, as well as older options and faces whose meanings
1055 values have changed since the previous major Emacs release. 1104 or default values have changed since the previous major Emacs release.
1056 1105
1057 With argument SINCE-VERSION (a string), customize all user option 1106 With argument SINCE-VERSION (a string), customize all settings
1058 variables that were added (or their meanings were changed) since that 1107 that were added or redefined since that version."
1059 version."
1060 1108
1061 (interactive "sCustomize options changed, since version (default all versions): ") 1109 (interactive "sCustomize options changed, since version (default all versions): ")
1062 (if (equal since-version "") 1110 (if (equal since-version "")
1063 (setq since-version nil) 1111 (setq since-version nil)
1064 (unless (condition-case nil 1112 (unless (condition-case nil
1237 (custom-buffer-create (custom-sort-items found t nil) 1285 (custom-buffer-create (custom-sort-items found t nil)
1238 "*Customize Saved*")))) 1286 "*Customize Saved*"))))
1239 1287
1240 ;;;###autoload 1288 ;;;###autoload
1241 (defun customize-apropos (regexp &optional all) 1289 (defun customize-apropos (regexp &optional all)
1242 "Customize all user options matching REGEXP. 1290 "Customize all loaded options, faces and groups matching REGEXP.
1243 If ALL is `options', include only options. 1291 If ALL is `options', include only options.
1244 If ALL is `faces', include only faces. 1292 If ALL is `faces', include only faces.
1245 If ALL is `groups', include only groups. 1293 If ALL is `groups', include only groups.
1246 If ALL is t (interactively, with prefix arg), include options which are not 1294 If ALL is t (interactively, with prefix arg), include variables
1247 user-settable, as well as faces and groups." 1295 that are not customizable options, as well as faces and groups
1296 \(but we recommend using `apropos-variable' instead)."
1248 (interactive "sCustomize regexp: \nP") 1297 (interactive "sCustomize regexp: \nP")
1249 (let ((found nil)) 1298 (let ((found nil))
1250 (mapatoms (lambda (symbol) 1299 (mapatoms (lambda (symbol)
1251 (when (string-match regexp (symbol-name symbol)) 1300 (when (string-match regexp (symbol-name symbol))
1252 (when (and (not (memq all '(faces options))) 1301 (when (and (not (memq all '(faces options)))
1255 (when (and (not (memq all '(options groups))) 1304 (when (and (not (memq all '(options groups)))
1256 (custom-facep symbol)) 1305 (custom-facep symbol))
1257 (push (list symbol 'custom-face) found)) 1306 (push (list symbol 'custom-face) found))
1258 (when (and (not (memq all '(groups faces))) 1307 (when (and (not (memq all '(groups faces)))
1259 (boundp symbol) 1308 (boundp symbol)
1309 (eq (indirect-variable symbol) symbol)
1260 (or (get symbol 'saved-value) 1310 (or (get symbol 'saved-value)
1261 (custom-variable-p symbol) 1311 (custom-variable-p symbol)
1262 (if (memq all '(nil options)) 1312 (and (not (memq all '(nil options)))
1263 (user-variable-p symbol) 1313 (get symbol 'variable-documentation))))
1264 (get symbol 'variable-documentation))))
1265 (push (list symbol 'custom-variable) found))))) 1314 (push (list symbol 'custom-variable) found)))))
1266 (if (not found) 1315 (if (not found)
1267 (error "No matches") 1316 (error "No matches")
1268 (custom-buffer-create (custom-sort-items found t 1317 (custom-buffer-create (custom-sort-items found t
1269 custom-buffer-order-groups) 1318 custom-buffer-order-groups)
1270 "*Customize Apropos*")))) 1319 "*Customize Apropos*"))))
1271 1320
1272 ;;;###autoload 1321 ;;;###autoload
1273 (defun customize-apropos-options (regexp &optional arg) 1322 (defun customize-apropos-options (regexp &optional arg)
1274 "Customize all user options matching REGEXP. 1323 "Customize all loaded customizable options matching REGEXP.
1275 With prefix arg, include options which are not user-settable." 1324 With prefix arg, include variables that are not customizable options
1325 \(but we recommend using `apropos-variable' instead)."
1276 (interactive "sCustomize regexp: \nP") 1326 (interactive "sCustomize regexp: \nP")
1277 (customize-apropos regexp (or arg 'options))) 1327 (customize-apropos regexp (or arg 'options)))
1278 1328
1279 ;;;###autoload 1329 ;;;###autoload
1280 (defun customize-apropos-faces (regexp) 1330 (defun customize-apropos-faces (regexp)
1281 "Customize all user faces matching REGEXP." 1331 "Customize all loaded faces matching REGEXP."
1282 (interactive "sCustomize regexp: \n") 1332 (interactive "sCustomize regexp: \n")
1283 (customize-apropos regexp 'faces)) 1333 (customize-apropos regexp 'faces))
1284 1334
1285 ;;;###autoload 1335 ;;;###autoload
1286 (defun customize-apropos-groups (regexp) 1336 (defun customize-apropos-groups (regexp)
1287 "Customize all user groups matching REGEXP." 1337 "Customize all loaded groups matching REGEXP."
1288 (interactive "sCustomize regexp: \n") 1338 (interactive "sCustomize regexp: \n")
1289 (customize-apropos regexp 'groups)) 1339 (customize-apropos regexp 'groups))
1290 1340
1291 ;;; Buffer. 1341 ;;; Buffer.
1292 1342
1375 (defun Custom-buffer-done (&rest ignore) 1425 (defun Custom-buffer-done (&rest ignore)
1376 "Exit current Custom buffer according to `custom-buffer-done-kill'." 1426 "Exit current Custom buffer according to `custom-buffer-done-kill'."
1377 (interactive) 1427 (interactive)
1378 (quit-window custom-buffer-done-kill)) 1428 (quit-window custom-buffer-done-kill))
1379 1429
1430 (defvar custom-button nil
1431 "Face used for buttons in customization buffers.")
1432
1433 (defvar custom-button-mouse nil
1434 "Mouse face used for buttons in customization buffers.")
1435
1436 (defvar custom-button-pressed nil
1437 "Face used for pressed buttons in customization buffers.")
1438
1380 (defcustom custom-raised-buttons (not (equal (face-valid-attribute-values :box) 1439 (defcustom custom-raised-buttons (not (equal (face-valid-attribute-values :box)
1381 '(("unspecified" . unspecified)))) 1440 '(("unspecified" . unspecified))))
1382 "If non-nil, indicate active buttons in a `raised-button' style. 1441 "If non-nil, indicate active buttons in a `raised-button' style.
1383 Otherwise use brackets." 1442 Otherwise use brackets."
1384 :type 'boolean 1443 :type 'boolean
1385 :version "21.1" 1444 :version "21.1"
1386 :group 'custom-buffer) 1445 :group 'custom-buffer
1446 :set (lambda (variable value)
1447 (custom-set-default variable value)
1448 (setq custom-button
1449 (if value 'custom-button 'custom-button-unraised))
1450 (setq custom-button-mouse
1451 (if value 'custom-button-mouse 'highlight))
1452 (setq custom-button-pressed
1453 (if value
1454 'custom-button-pressed
1455 'custom-button-pressed-unraised))))
1387 1456
1388 (defun custom-buffer-create-internal (options &optional description) 1457 (defun custom-buffer-create-internal (options &optional description)
1389 (custom-mode) 1458 (custom-mode)
1390 (if custom-buffer-verbose-help 1459 (if custom-buffer-verbose-help
1391 (progn 1460 (progn
1392 (widget-insert "This is a customization buffer") 1461 (widget-insert "This is a customization buffer")
1393 (if description 1462 (if description
1394 (widget-insert description)) 1463 (widget-insert description))
1395 (widget-insert (format ". 1464 (widget-insert (format ".
1396 %s show active fields; type RET or click mouse-1 1465 %s buttons; type RET or click mouse-1 to actuate one.
1397 on an active field to invoke its action. Editing an option value 1466 Editing a setting changes only the text in the buffer.
1398 changes only the text in the buffer. Invoke the State button to set or 1467 Use the setting's State button to set it or save changes in it.
1399 save the option value. Saving an option normally edits your init file. 1468 Saving a change normally works by editing your Emacs init file.
1400 Invoke " 1469 See "
1401 (if custom-raised-buttons 1470 (if custom-raised-buttons
1402 "`Raised' buttons" 1471 "`Raised' text indicates"
1403 "Square brackets"))) 1472 "Square brackets indicate")))
1404 (widget-create 'info-link 1473 (widget-create 'info-link
1405 :tag "Custom file" 1474 :tag "Custom file"
1475 :button-face 'custom-link
1476 :mouse-face 'highlight
1406 "(emacs)Saving Customizations") 1477 "(emacs)Saving Customizations")
1407 (widget-insert 1478 (widget-insert
1408 " for information on how to save in a different file. 1479 " for information on how to save in a different file.\n
1409 Invoke ") 1480 See ")
1410 (widget-create 'info-link 1481 (widget-create 'info-link
1411 :tag "Help" 1482 :tag "Help"
1483 :button-face 'custom-link
1484 :mouse-face 'highlight
1412 :help-echo "Read the online help." 1485 :help-echo "Read the online help."
1413 "(emacs)Easy Customization") 1486 "(emacs)Easy Customization")
1414 (widget-insert " for general information.\n\n") 1487 (widget-insert " for more information.\n\n")
1415 (widget-insert "Operate on everything in this buffer:\n ")) 1488 (widget-insert "Operate on everything in this buffer:\n "))
1416 (widget-insert " ")) 1489 (widget-insert " "))
1417 (widget-create 'push-button 1490 (widget-create 'push-button
1418 :tag "Set for Current Session" 1491 :tag "Set for Current Session"
1419 :help-echo "\ 1492 :help-echo "\
1420 Make your editing in this buffer take effect for this session." 1493 Make your editing in this buffer take effect for this session."
1421 :action (lambda (widget &optional event) 1494 :action (lambda (widget &optional event)
1422 (Custom-set))) 1495 (Custom-set)))
1423 (widget-insert " ") 1496 (if (not custom-buffer-verbose-help)
1424 (widget-create 'push-button 1497 (progn
1425 :tag "Save for Future Sessions" 1498 (widget-insert " ")
1426 :help-echo "\ 1499 (widget-create 'info-link
1500 :tag "Help"
1501 :button-face 'custom-link
1502 :mouse-face 'highlight
1503 :help-echo "Read the online help."
1504 "(emacs)Easy Customization")))
1505 (when (or custom-file user-init-file)
1506 (widget-insert " ")
1507 (widget-create 'push-button
1508 :tag "Save for Future Sessions"
1509 :help-echo "\
1427 Make your editing in this buffer take effect for future Emacs sessions. 1510 Make your editing in this buffer take effect for future Emacs sessions.
1428 This updates your Emacs initialization file or creates a new one." 1511 This updates your Emacs initialization file or creates a new one."
1429 :action (lambda (widget &optional event) 1512 :action (lambda (widget &optional event)
1430 (Custom-save))) 1513 (Custom-save))))
1431 (if custom-reset-button-menu 1514 (if custom-reset-button-menu
1432 (progn 1515 (progn
1433 (widget-insert " ") 1516 (widget-insert " ")
1434 (widget-create 'push-button 1517 (widget-create 'push-button
1435 :tag "Reset" 1518 :tag "Reset buffer"
1436 :help-echo "Show a menu with reset operations." 1519 :help-echo "Show a menu with reset operations."
1437 :mouse-down-action (lambda (&rest junk) t) 1520 :mouse-down-action (lambda (&rest junk) t)
1438 :action (lambda (widget &optional event) 1521 :action (lambda (widget &optional event)
1439 (custom-reset event)))) 1522 (custom-reset event))))
1440 (widget-insert "\n ") 1523 (widget-insert "\n ")
1441 (widget-create 'push-button 1524 (widget-create 'push-button
1442 :tag "Reset" 1525 :tag "Undo Edits"
1443 :help-echo "\ 1526 :help-echo "\
1444 Reset all edited text in this buffer to reflect current values." 1527 Reset all edited text in this buffer to reflect current values."
1445 :action 'Custom-reset-current) 1528 :action 'Custom-reset-current)
1446 (widget-insert " ") 1529 (widget-insert " ")
1447 (widget-create 'push-button 1530 (widget-create 'push-button
1448 :tag "Reset to Saved" 1531 :tag "Reset to Saved"
1449 :help-echo "\ 1532 :help-echo "\
1450 Reset all values in this buffer to their saved settings." 1533 Reset all settings in this buffer to their saved values."
1451 :action 'Custom-reset-saved) 1534 :action 'Custom-reset-saved)
1452 (widget-insert " ") 1535 (widget-insert " ")
1453 (widget-create 'push-button 1536 (when (or custom-file user-init-file)
1454 :tag "Erase Customization" 1537 (widget-create 'push-button
1455 :help-echo "\ 1538 :tag "Erase Customization"
1456 Un-customize all values in this buffer. They get their standard settings." 1539 :help-echo "\
1457 :action 'Custom-reset-standard)) 1540 Un-customize all settings in this buffer and save them with standard values."
1458 (if (not custom-buffer-verbose-help) 1541 :action 'Custom-reset-standard)))
1459 (progn
1460 (widget-insert " ")
1461 (widget-create 'info-link
1462 :tag "Help"
1463 :help-echo "Read the online help."
1464 "(emacs)Easy Customization")))
1465 (widget-insert " ") 1542 (widget-insert " ")
1466 (widget-create 'push-button 1543 (widget-create 'push-button
1467 :tag "Finish" 1544 :tag "Finish"
1468 :help-echo 1545 :help-echo
1469 (lambda (&rest ignore) 1546 (lambda (&rest ignore)
1521 (unless group 1598 (unless group
1522 (setq group 'emacs)) 1599 (setq group 'emacs))
1523 (let ((name "*Customize Browser*")) 1600 (let ((name "*Customize Browser*"))
1524 (pop-to-buffer (custom-get-fresh-buffer name))) 1601 (pop-to-buffer (custom-get-fresh-buffer name)))
1525 (custom-mode) 1602 (custom-mode)
1526 (widget-insert "\ 1603 (widget-insert (format "\
1527 Square brackets show active fields; type RET or click mouse-1 1604 %s buttons; type RET or click mouse-1
1528 on an active field to invoke its action. 1605 on a button to invoke its action.
1529 Invoke [+] below to expand a group, and [-] to collapse an expanded group.\n") 1606 Invoke [+] to expand a group, and [-] to collapse an expanded group.\n"
1607 (if custom-raised-buttons
1608 "`Raised' text indicates"
1609 "Square brackets indicate")))
1610
1611
1530 (if custom-browse-only-groups 1612 (if custom-browse-only-groups
1531 (widget-insert "\ 1613 (widget-insert "\
1532 Invoke the [Group] button below to edit that item in another window.\n\n") 1614 Invoke the [Group] button below to edit that item in another window.\n\n")
1533 (widget-insert "Invoke the ") 1615 (widget-insert "Invoke the ")
1534 (widget-create 'item 1616 (widget-create 'item
1639 ;;; The `custom-manual' Widget. 1721 ;;; The `custom-manual' Widget.
1640 1722
1641 (define-widget 'custom-manual 'info-link 1723 (define-widget 'custom-manual 'info-link
1642 "Link to the manual entry for this customization option." 1724 "Link to the manual entry for this customization option."
1643 :help-echo "Read the manual entry for this option." 1725 :help-echo "Read the manual entry for this option."
1726 :button-face 'custom-link
1727 :mouse-face 'highlight
1644 :tag "Manual") 1728 :tag "Manual")
1645 1729
1646 ;;; The `custom-magic' Widget. 1730 ;;; The `custom-magic' Widget.
1647 1731
1648 (defgroup custom-magic-faces nil 1732 (defgroup custom-magic-faces nil
1698 (:slant italic))) 1782 (:slant italic)))
1699 "Face used when the customize item has been changed." 1783 "Face used when the customize item has been changed."
1700 :group 'custom-magic-faces) 1784 :group 'custom-magic-faces)
1701 ;; backward-compatibility alias 1785 ;; backward-compatibility alias
1702 (put 'custom-changed-face 'face-alias 'custom-changed) 1786 (put 'custom-changed-face 'face-alias 'custom-changed)
1787
1788 (defface custom-themed '((((min-colors 88) (class color))
1789 (:foreground "white" :background "blue1"))
1790 (((class color))
1791 (:foreground "white" :background "blue"))
1792 (t
1793 (:slant italic)))
1794 "Face used when the customize item has been set by a theme."
1795 :group 'custom-magic-faces)
1703 1796
1704 (defface custom-saved '((t (:underline t))) 1797 (defface custom-saved '((t (:underline t)))
1705 "Face used when the customize item has been saved." 1798 "Face used when the customize item has been saved."
1706 :group 'custom-magic-faces) 1799 :group 'custom-magic-faces)
1707 ;; backward-compatibility alias 1800 ;; backward-compatibility alias
1727 CHANGED outside Customize; operating on it here may be unreliable." "\ 1820 CHANGED outside Customize; operating on it here may be unreliable." "\
1728 something in this group has been changed outside customize.") 1821 something in this group has been changed outside customize.")
1729 (saved "!" custom-saved "\ 1822 (saved "!" custom-saved "\
1730 SAVED and set." "\ 1823 SAVED and set." "\
1731 something in this group has been set and saved.") 1824 something in this group has been set and saved.")
1825 (themed "o" custom-themed "\
1826 THEMED." "\
1827 visible group members are all at standard values.")
1732 (rogue "@" custom-rogue "\ 1828 (rogue "@" custom-rogue "\
1733 NO CUSTOMIZATION DATA; you should not see this." "\ 1829 NO CUSTOMIZATION DATA; not intended to be customized." "\
1734 something in this group is not prepared for customization.") 1830 something in this group is not prepared for customization.")
1735 (standard " " nil "\ 1831 (standard " " nil "\
1736 STANDARD." "\ 1832 STANDARD." "\
1737 visible group members are all at standard settings.")) 1833 visible group members are all at standard values."))
1738 "Alist of customize option states. 1834 "Alist of customize option states.
1739 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where 1835 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
1740 1836
1741 STATE is one of the following symbols: 1837 STATE is one of the following symbols:
1742 1838
1894 '((((type x w32 mac) (class color)) ; Like default modeline 1990 '((((type x w32 mac) (class color)) ; Like default modeline
1895 (:box (:line-width 2 :style released-button) 1991 (:box (:line-width 2 :style released-button)
1896 :background "lightgrey" :foreground "black")) 1992 :background "lightgrey" :foreground "black"))
1897 (t 1993 (t
1898 nil)) 1994 nil))
1899 "Face used for buttons in customization buffers." 1995 "Face for custom buffer buttons if `custom-raised-buttons' is non-nil."
1900 :version "21.1" 1996 :version "21.1"
1901 :group 'custom-faces) 1997 :group 'custom-faces)
1902 ;; backward-compatibility alias 1998 ;; backward-compatibility alias
1903 (put 'custom-button-face 'face-alias 'custom-button) 1999 (put 'custom-button-face 'face-alias 'custom-button)
2000
2001 (defface custom-button-mouse
2002 '((((type x w32 mac) (class color))
2003 (:box (:line-width 2 :style released-button)
2004 :background "grey90" :foreground "black"))
2005 (t
2006 nil))
2007 "Mouse face for custom buffer buttons if `custom-raised-buttons' is non-nil."
2008 :version "22.1"
2009 :group 'custom-faces)
2010
2011 (defface custom-button-unraised
2012 '((((min-colors 88)
2013 (class color) (background light)) :foreground "blue1" :underline t)
2014 (((class color) (background light)) :foreground "blue" :underline t)
2015 (((min-colors 88)
2016 (class color) (background dark)) :foreground "cyan1" :underline t)
2017 (((class color) (background dark)) :foreground "cyan" :underline t)
2018 (t :underline t))
2019 "Face for custom buffer buttons if `custom-raised-buttons' is nil."
2020 :version "22.1"
2021 :group 'custom-faces)
2022
2023 (setq custom-button
2024 (if custom-raised-buttons 'custom-button 'custom-button-unraised))
2025
2026 (setq custom-button-mouse
2027 (if custom-raised-buttons 'custom-button-mouse 'highlight))
1904 2028
1905 (defface custom-button-pressed 2029 (defface custom-button-pressed
1906 '((((type x w32 mac) (class color)) 2030 '((((type x w32 mac) (class color))
1907 (:box (:line-width 2 :style pressed-button) 2031 (:box (:line-width 2 :style pressed-button)
1908 :background "lightgrey" :foreground "black")) 2032 :background "lightgrey" :foreground "black"))
1909 (t 2033 (t
1910 (:inverse-video t))) 2034 (:inverse-video t)))
1911 "Face used for buttons in customization buffers." 2035 "Face for pressed custom buttons if `custom-raised-buttons' is non-nil."
1912 :version "21.1" 2036 :version "21.1"
1913 :group 'custom-faces) 2037 :group 'custom-faces)
1914 ;; backward-compatibility alias 2038 ;; backward-compatibility alias
1915 (put 'custom-button-pressed-face 'face-alias 'custom-button-pressed) 2039 (put 'custom-button-pressed-face 'face-alias 'custom-button-pressed)
2040
2041 (defface custom-button-pressed-unraised
2042 '((default :inherit custom-button-unraised)
2043 (((class color) (background light)) :foreground "magenta4")
2044 (((class color) (background dark)) :foreground "violet"))
2045 "Face for pressed custom buttons if `custom-raised-buttons' is nil."
2046 :version "22.1"
2047 :group 'custom-faces)
2048
2049 (setq custom-button-pressed
2050 (if custom-raised-buttons
2051 'custom-button-pressed
2052 'custom-button-pressed-unraised))
1916 2053
1917 (defface custom-documentation nil 2054 (defface custom-documentation nil
1918 "Face used for documentation strings in customization buffers." 2055 "Face used for documentation strings in customization buffers."
1919 :group 'custom-faces) 2056 :group 'custom-faces)
1920 ;; backward-compatibility alias 2057 ;; backward-compatibility alias
1929 (t nil)) 2066 (t nil))
1930 "Face used for State descriptions in the customize buffer." 2067 "Face used for State descriptions in the customize buffer."
1931 :group 'custom-faces) 2068 :group 'custom-faces)
1932 ;; backward-compatibility alias 2069 ;; backward-compatibility alias
1933 (put 'custom-state-face 'face-alias 'custom-state) 2070 (put 'custom-state-face 'face-alias 'custom-state)
2071
2072 (defface custom-link
2073 '((((min-colors 88)
2074 (class color) (background light)) :foreground "blue1" :underline t)
2075 (((class color) (background light)) :foreground "blue" :underline t)
2076 (((min-colors 88)
2077 (class color) (background dark)) :foreground "cyan1" :underline t)
2078 (((class color) (background dark)) :foreground "cyan" :underline t)
2079 (t :underline t))
2080 "Face for Info links in customization buffers."
2081 :group 'info)
1934 2082
1935 (define-widget 'custom 'default 2083 (define-widget 'custom 'default
1936 "Customize a user option." 2084 "Customize a user option."
1937 :format "%v" 2085 :format "%v"
1938 :convert-widget 'custom-convert-widget 2086 :convert-widget 'custom-convert-widget
2064 (insert-char ?\ indent)) 2212 (insert-char ?\ indent))
2065 (when prefix 2213 (when prefix
2066 (insert prefix)) 2214 (insert prefix))
2067 (insert "See also ") 2215 (insert "See also ")
2068 (while links 2216 (while links
2069 (push (widget-create-child-and-convert widget (car links)) 2217 (push (widget-create-child-and-convert
2218 widget (car links)
2219 :button-face 'custom-link
2220 :mouse-face 'highlight)
2070 buttons) 2221 buttons)
2071 (setq links (cdr links)) 2222 (setq links (cdr links))
2072 (cond ((null links) 2223 (cond ((null links)
2073 (insert ".\n")) 2224 (insert ".\n"))
2074 ((null (cdr links)) 2225 ((null (cdr links))
2079 (insert ", ")))) 2230 (insert ", "))))
2080 (widget-put widget :buttons buttons)))) 2231 (widget-put widget :buttons buttons))))
2081 2232
2082 (defun custom-add-parent-links (widget &optional initial-string) 2233 (defun custom-add-parent-links (widget &optional initial-string)
2083 "Add \"Parent groups: ...\" to WIDGET if the group has parents. 2234 "Add \"Parent groups: ...\" to WIDGET if the group has parents.
2084 The value if non-nil if any parents were found. 2235 The value is non-nil if any parents were found.
2085 If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"." 2236 If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
2086 (let ((name (widget-value widget)) 2237 (let ((name (widget-value widget))
2087 (type (widget-type widget)) 2238 (type (widget-type widget))
2088 (buttons (widget-get widget :buttons)) 2239 (buttons (widget-get widget :buttons))
2089 (start (point)) 2240 (start (point))
2090 (parents nil)) 2241 (parents nil))
2091 (insert (or initial-string "Parent groups:")) 2242 (insert (or initial-string "Parent groups:"))
2092 (mapatoms (lambda (symbol) 2243 (mapatoms (lambda (symbol)
2093 (let ((entry (assq name (get symbol 'custom-group)))) 2244 (when (member (list name type) (get symbol 'custom-group))
2094 (when (eq (nth 1 entry) type) 2245 (insert " ")
2095 (insert " ") 2246 (push (widget-create-child-and-convert
2096 (push (widget-create-child-and-convert 2247 widget 'custom-group-link
2097 widget 'custom-group-link 2248 :button-face 'custom-link
2098 :tag (custom-unlispify-tag-name symbol) 2249 :mouse-face 'highlight
2099 symbol) 2250 :tag (custom-unlispify-tag-name symbol)
2100 buttons) 2251 symbol)
2101 (setq parents (cons symbol parents)))))) 2252 buttons)
2253 (setq parents (cons symbol parents)))))
2102 (and (null (get name 'custom-links)) ;No links of its own. 2254 (and (null (get name 'custom-links)) ;No links of its own.
2103 (= (length parents) 1) ;A single parent. 2255 (= (length parents) 1) ;A single parent.
2104 (let* ((links (get (car parents) 'custom-links)) 2256 (let* ((links (delq nil (mapcar (lambda (w)
2257 (unless (eq (widget-type w)
2258 'custom-group-link)
2259 w))
2260 (get (car parents) 'custom-links))))
2105 (many (> (length links) 2))) 2261 (many (> (length links) 2)))
2106 (when links 2262 (when links
2107 (insert "\nParent documentation: ") 2263 (insert "\nParent documentation: ")
2108 (while links 2264 (while links
2109 (push (widget-create-child-and-convert widget (car links)) 2265 (push (widget-create-child-and-convert
2266 widget (car links)
2267 :button-face 'custom-link
2268 :mouse-face 'highlight)
2110 buttons) 2269 buttons)
2111 (setq links (cdr links)) 2270 (setq links (cdr links))
2112 (cond ((null links) 2271 (cond ((null links)
2113 (insert ".\n")) 2272 (insert ".\n"))
2114 ((null (cdr links)) 2273 ((null (cdr links))
2124 parents)) 2283 parents))
2125 2284
2126 ;;; The `custom-comment' Widget. 2285 ;;; The `custom-comment' Widget.
2127 2286
2128 ;; like the editable field 2287 ;; like the editable field
2129 (defface custom-comment '((((class grayscale color) 2288 (defface custom-comment '((((type tty))
2289 :background "yellow3"
2290 :foreground "black")
2291 (((class grayscale color)
2130 (background light)) 2292 (background light))
2131 (:background "gray85")) 2293 :background "gray85")
2132 (((class grayscale color) 2294 (((class grayscale color)
2133 (background dark)) 2295 (background dark))
2134 (:background "dim gray")) 2296 :background "dim gray")
2135 (t 2297 (t
2136 (:slant italic))) 2298 :slant italic))
2137 "Face used for comments on variables or faces" 2299 "Face used for comments on variables or faces"
2138 :version "21.1" 2300 :version "21.1"
2139 :group 'custom-faces) 2301 :group 'custom-faces)
2140 ;; backward-compatibility alias 2302 ;; backward-compatibility alias
2141 (put 'custom-comment-face 'face-alias 'custom-comment) 2303 (put 'custom-comment-face 'face-alias 'custom-comment)
2454 (and (equal value (eval (car tmp))) 2616 (and (equal value (eval (car tmp)))
2455 (equal comment temp)) 2617 (equal comment temp))
2456 (error nil)) 2618 (error nil))
2457 'set 2619 'set
2458 'changed)) 2620 'changed))
2459 ((progn (setq tmp (get symbol 'saved-value)) 2621 ((progn (setq tmp (get symbol 'theme-value))
2460 (setq temp (get symbol 'saved-variable-comment)) 2622 (setq temp (get symbol 'saved-variable-comment))
2461 (or tmp temp)) 2623 (or tmp temp))
2462 (if (condition-case nil 2624 (if (condition-case nil
2463 (and (equal value (eval (car tmp))) 2625 (and (equal comment temp)
2464 (equal comment temp)) 2626 (equal value
2627 (eval
2628 (car (custom-variable-theme-value
2629 symbol)))))
2465 (error nil)) 2630 (error nil))
2466 'saved 2631 (cond
2632 ((eq (caar tmp) 'user) 'saved)
2633 ((eq (caar tmp) 'changed) 'changed)
2634 (t 'themed))
2467 'changed)) 2635 'changed))
2468 ((setq tmp (get symbol 'standard-value)) 2636 ((setq tmp (get symbol 'standard-value))
2469 (if (condition-case nil 2637 (if (condition-case nil
2470 (and (equal value (eval (car tmp))) 2638 (and (equal value (eval (car tmp)))
2471 (equal comment nil)) 2639 (equal comment nil))
2477 2645
2478 (defun custom-variable-standard-value (widget) 2646 (defun custom-variable-standard-value (widget)
2479 (get (widget-value widget) 'standard-value)) 2647 (get (widget-value widget) 'standard-value))
2480 2648
2481 (defvar custom-variable-menu 2649 (defvar custom-variable-menu
2482 '(("Set for Current Session" custom-variable-set 2650 `(("Set for Current Session" custom-variable-set
2483 (lambda (widget) 2651 (lambda (widget)
2484 (eq (widget-get widget :custom-state) 'modified))) 2652 (eq (widget-get widget :custom-state) 'modified)))
2485 ("Save for Future Sessions" custom-variable-save 2653 ,@(when (or custom-file user-init-file)
2486 (lambda (widget) 2654 '(("Save for Future Sessions" custom-variable-save
2487 (memq (widget-get widget :custom-state) '(modified set changed rogue)))) 2655 (lambda (widget)
2488 ("Reset to Current" custom-redraw 2656 (memq (widget-get widget :custom-state)
2657 '(modified set changed rogue))))))
2658 ("Undo Edits" custom-redraw
2489 (lambda (widget) 2659 (lambda (widget)
2490 (and (default-boundp (widget-value widget)) 2660 (and (default-boundp (widget-value widget))
2491 (memq (widget-get widget :custom-state) '(modified changed))))) 2661 (memq (widget-get widget :custom-state) '(modified changed)))))
2492 ("Reset to Saved" custom-variable-reset-saved 2662 ("Reset to Saved" custom-variable-reset-saved
2493 (lambda (widget) 2663 (lambda (widget)
2494 (and (or (get (widget-value widget) 'saved-value) 2664 (and (or (get (widget-value widget) 'saved-value)
2495 (get (widget-value widget) 'saved-variable-comment)) 2665 (get (widget-value widget) 'saved-variable-comment))
2496 (memq (widget-get widget :custom-state) 2666 (memq (widget-get widget :custom-state)
2497 '(modified set changed rogue))))) 2667 '(modified set changed rogue)))))
2498 ("Erase Customization" custom-variable-reset-standard 2668 ,@(when (or custom-file user-init-file)
2499 (lambda (widget) 2669 '(("Erase Customization" custom-variable-reset-standard
2500 (and (get (widget-value widget) 'standard-value) 2670 (lambda (widget)
2501 (memq (widget-get widget :custom-state) 2671 (and (get (widget-value widget) 'standard-value)
2502 '(modified set changed saved rogue))))) 2672 (memq (widget-get widget :custom-state)
2503 ("Use Backup Value" custom-variable-reset-backup 2673 '(modified set changed saved rogue)))))))
2674 ("Set to Backup Value" custom-variable-reset-backup
2504 (lambda (widget) 2675 (lambda (widget)
2505 (get (widget-value widget) 'backup-value))) 2676 (get (widget-value widget) 'backup-value)))
2506 ("---" ignore ignore) 2677 ("---" ignore ignore)
2507 ("Add Comment" custom-comment-show custom-comment-invisible-p) 2678 ("Add Comment" custom-comment-show custom-comment-invisible-p)
2508 ("---" ignore ignore) 2679 ("---" ignore ignore)
2509 ("Don't show as Lisp expression" custom-variable-edit 2680 ("Show Current Value" custom-variable-edit
2510 (lambda (widget) 2681 (lambda (widget)
2511 (eq (widget-get widget :custom-form) 'lisp))) 2682 (eq (widget-get widget :custom-form) 'lisp)))
2512 ("Show initial Lisp expression" custom-variable-edit-lisp 2683 ("Show Saved Lisp Expression" custom-variable-edit-lisp
2513 (lambda (widget) 2684 (lambda (widget)
2514 (eq (widget-get widget :custom-form) 'edit)))) 2685 (eq (widget-get widget :custom-form) 'edit))))
2515 "Alist of actions for the `custom-variable' widget. 2686 "Alist of actions for the `custom-variable' widget.
2516 Each entry has the form (NAME ACTION FILTER) where NAME is the name of 2687 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
2517 the menu entry, ACTION is the function to call on the widget when the 2688 the menu entry, ACTION is the function to call on the widget when the
2568 (when (equal comment "") 2739 (when (equal comment "")
2569 (setq comment nil) 2740 (setq comment nil)
2570 ;; Make the comment invisible by hand if it's empty 2741 ;; Make the comment invisible by hand if it's empty
2571 (custom-comment-hide comment-widget)) 2742 (custom-comment-hide comment-widget))
2572 (custom-variable-backup-value widget) 2743 (custom-variable-backup-value widget)
2744 (custom-push-theme 'theme-value symbol 'user
2745 'set (custom-quote (widget-value child)))
2573 (funcall set symbol (eval (setq val (widget-value child)))) 2746 (funcall set symbol (eval (setq val (widget-value child))))
2574 (put symbol 'customized-value (list val)) 2747 (put symbol 'customized-value (list val))
2575 (put symbol 'variable-comment comment) 2748 (put symbol 'variable-comment comment)
2576 (put symbol 'customized-variable-comment comment)) 2749 (put symbol 'customized-variable-comment comment))
2577 (t 2750 (t
2578 (when (equal comment "") 2751 (when (equal comment "")
2579 (setq comment nil) 2752 (setq comment nil)
2580 ;; Make the comment invisible by hand if it's empty 2753 ;; Make the comment invisible by hand if it's empty
2581 (custom-comment-hide comment-widget)) 2754 (custom-comment-hide comment-widget))
2582 (custom-variable-backup-value widget) 2755 (custom-variable-backup-value widget)
2756 (custom-push-theme 'theme-value symbol 'user
2757 'set (custom-quote (widget-value child)))
2583 (funcall set symbol (setq val (widget-value child))) 2758 (funcall set symbol (setq val (widget-value child)))
2584 (put symbol 'customized-value (list (custom-quote val))) 2759 (put symbol 'customized-value (list (custom-quote val)))
2585 (put symbol 'variable-comment comment) 2760 (put symbol 'variable-comment comment)
2586 (put symbol 'customized-variable-comment comment))) 2761 (put symbol 'customized-variable-comment comment)))
2587 (custom-variable-state-set widget) 2762 (custom-variable-state-set widget)
2607 (setq comment nil) 2782 (setq comment nil)
2608 ;; Make the comment invisible by hand if it's empty 2783 ;; Make the comment invisible by hand if it's empty
2609 (custom-comment-hide comment-widget)) 2784 (custom-comment-hide comment-widget))
2610 (put symbol 'saved-value (list (widget-value child))) 2785 (put symbol 'saved-value (list (widget-value child)))
2611 (custom-push-theme 'theme-value symbol 'user 2786 (custom-push-theme 'theme-value symbol 'user
2612 'set (list (widget-value child))) 2787 'set (custom-quote (widget-value child)))
2613 (funcall set symbol (eval (widget-value child))) 2788 (funcall set symbol (eval (widget-value child)))
2614 (put symbol 'variable-comment comment) 2789 (put symbol 'variable-comment comment)
2615 (put symbol 'saved-variable-comment comment)) 2790 (put symbol 'saved-variable-comment comment))
2616 (t 2791 (t
2617 (when (equal comment "") 2792 (when (equal comment "")
2619 ;; Make the comment invisible by hand if it's empty 2794 ;; Make the comment invisible by hand if it's empty
2620 (custom-comment-hide comment-widget)) 2795 (custom-comment-hide comment-widget))
2621 (put symbol 'saved-value 2796 (put symbol 'saved-value
2622 (list (custom-quote (widget-value child)))) 2797 (list (custom-quote (widget-value child))))
2623 (custom-push-theme 'theme-value symbol 'user 2798 (custom-push-theme 'theme-value symbol 'user
2624 'set (list (custom-quote (widget-value 2799 'set (custom-quote (widget-value child)))
2625 child))))
2626 (funcall set symbol (widget-value child)) 2800 (funcall set symbol (widget-value child))
2627 (put symbol 'variable-comment comment) 2801 (put symbol 'variable-comment comment)
2628 (put symbol 'saved-variable-comment comment))) 2802 (put symbol 'saved-variable-comment comment)))
2629 (put symbol 'customized-value nil) 2803 (put symbol 'customized-value nil)
2630 (put symbol 'customized-variable-comment nil) 2804 (put symbol 'customized-variable-comment nil)
2632 (custom-variable-state-set widget) 2806 (custom-variable-state-set widget)
2633 (custom-redraw-magic widget))) 2807 (custom-redraw-magic widget)))
2634 2808
2635 (defun custom-variable-reset-saved (widget) 2809 (defun custom-variable-reset-saved (widget)
2636 "Restore the saved value for the variable being edited by WIDGET. 2810 "Restore the saved value for the variable being edited by WIDGET.
2811 This also updates the buffer to show that value.
2637 The value that was current before this operation 2812 The value that was current before this operation
2638 becomes the backup value, so you can get it again." 2813 becomes the backup value, so you can get it again."
2639 (let* ((symbol (widget-value widget)) 2814 (let* ((symbol (widget-value widget))
2640 (set (or (get symbol 'custom-set) 'set-default)) 2815 (set (or (get symbol 'custom-set) 'set-default))
2641 (value (get symbol 'saved-value)) 2816 (value (get symbol 'saved-value))
2642 (comment (get symbol 'saved-variable-comment))) 2817 (comment (get symbol 'saved-variable-comment)))
2643 (cond ((or value comment) 2818 (cond ((or value comment)
2644 (put symbol 'variable-comment comment) 2819 (put symbol 'variable-comment comment)
2645 (custom-variable-backup-value widget) 2820 (custom-variable-backup-value widget)
2821 (custom-push-theme 'theme-value symbol 'user 'set (car-safe value))
2646 (condition-case nil 2822 (condition-case nil
2647 (funcall set symbol (eval (car value))) 2823 (funcall set symbol (eval (car value)))
2648 (error nil))) 2824 (error nil)))
2649 (t 2825 (t
2650 (error "No saved value for %s" symbol))) 2826 (error "No saved value for %s" symbol)))
2658 "Restore the standard setting for the variable being edited by WIDGET. 2834 "Restore the standard setting for the variable being edited by WIDGET.
2659 This operation eliminates any saved setting for the variable, 2835 This operation eliminates any saved setting for the variable,
2660 restoring it to the state of a variable that has never been customized. 2836 restoring it to the state of a variable that has never been customized.
2661 The value that was current before this operation 2837 The value that was current before this operation
2662 becomes the backup value, so you can get it again." 2838 becomes the backup value, so you can get it again."
2663 (let* ((symbol (widget-value widget)) 2839 (let* ((symbol (widget-value widget)))
2664 (set (or (get symbol 'custom-set) 'set-default)))
2665 (if (get symbol 'standard-value) 2840 (if (get symbol 'standard-value)
2666 (progn 2841 (custom-variable-backup-value widget)
2667 (custom-variable-backup-value widget)
2668 (funcall set symbol (eval (car (get symbol 'standard-value)))))
2669 (error "No standard setting known for %S" symbol)) 2842 (error "No standard setting known for %S" symbol))
2670 (put symbol 'variable-comment nil) 2843 (put symbol 'variable-comment nil)
2671 (put symbol 'customized-value nil) 2844 (put symbol 'customized-value nil)
2672 (put symbol 'customized-variable-comment nil) 2845 (put symbol 'customized-variable-comment nil)
2846 (custom-push-theme 'theme-value symbol 'user 'reset)
2847 (custom-theme-recalc-variable symbol)
2673 (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment)) 2848 (when (or (get symbol 'saved-value) (get symbol 'saved-variable-comment))
2674 (put symbol 'saved-value nil) 2849 (put symbol 'saved-value nil)
2675 (custom-push-theme 'theme-value symbol 'user 'reset 'standard)
2676 ;; As a special optimizations we do not (explictly)
2677 ;; save resets to standard when no theme set the value.
2678 (if (null (cdr (get symbol 'theme-value)))
2679 (put symbol 'theme-value nil))
2680 (put symbol 'saved-variable-comment nil) 2850 (put symbol 'saved-variable-comment nil)
2681 (custom-save-all)) 2851 (custom-save-all))
2682 (widget-put widget :custom-state 'unknown) 2852 (widget-put widget :custom-state 'unknown)
2683 ;; This call will possibly make the comment invisible 2853 ;; This call will possibly make the comment invisible
2684 (custom-redraw widget))) 2854 (custom-redraw widget)))
2706 (comment-widget (widget-get widget :comment-widget)) 2876 (comment-widget (widget-get widget :comment-widget))
2707 (comment (widget-value comment-widget))) 2877 (comment (widget-value comment-widget)))
2708 (if value 2878 (if value
2709 (progn 2879 (progn
2710 (custom-variable-backup-value widget) 2880 (custom-variable-backup-value widget)
2881 (custom-push-theme 'theme-value symbol 'user 'set value)
2711 (condition-case nil 2882 (condition-case nil
2712 (funcall set symbol (car value)) 2883 (funcall set symbol (car value))
2713 (error nil))) 2884 (error nil)))
2714 (error "No backup value for %s" symbol)) 2885 (error "No backup value for %s" symbol))
2715 (put symbol 'customized-value (list (car value))) 2886 (put symbol 'customized-value (list (car value)))
3148 (push edit children) 3319 (push edit children)
3149 (widget-put widget :children children)) 3320 (widget-put widget :children children))
3150 (message "Creating face editor...done")))))) 3321 (message "Creating face editor...done"))))))
3151 3322
3152 (defvar custom-face-menu 3323 (defvar custom-face-menu
3153 '(("Set for Current Session" custom-face-set) 3324 `(("Set for Current Session" custom-face-set)
3154 ("Save for Future Sessions" custom-face-save-command) 3325 ,@(when (or custom-file user-init-file)
3326 '(("Save for Future Sessions" custom-face-save-command)))
3327 ("Undo Edits" custom-redraw
3328 (lambda (widget)
3329 (memq (widget-get widget :custom-state) '(modified changed))))
3155 ("Reset to Saved" custom-face-reset-saved 3330 ("Reset to Saved" custom-face-reset-saved
3156 (lambda (widget) 3331 (lambda (widget)
3157 (or (get (widget-value widget) 'saved-face) 3332 (or (get (widget-value widget) 'saved-face)
3158 (get (widget-value widget) 'saved-face-comment)))) 3333 (get (widget-value widget) 'saved-face-comment))))
3159 ("Erase Customization" custom-face-reset-standard 3334 ,@(when (or custom-file user-init-file)
3160 (lambda (widget) 3335 '(("Erase Customization" custom-face-reset-standard
3161 (get (widget-value widget) 'face-defface-spec))) 3336 (lambda (widget)
3337 (get (widget-value widget) 'face-defface-spec)))))
3162 ("---" ignore ignore) 3338 ("---" ignore ignore)
3163 ("Add Comment" custom-comment-show custom-comment-invisible-p) 3339 ("Add Comment" custom-comment-show custom-comment-invisible-p)
3164 ("---" ignore ignore) 3340 ("---" ignore ignore)
3165 ("Show all display specs" custom-face-edit-all 3341 ("For Current Display" custom-face-edit-selected
3342 (lambda (widget)
3343 (not (eq (widget-get widget :custom-form) 'selected))))
3344 ("For All Kinds of Displays" custom-face-edit-all
3166 (lambda (widget) 3345 (lambda (widget)
3167 (not (eq (widget-get widget :custom-form) 'all)))) 3346 (not (eq (widget-get widget :custom-form) 'all))))
3168 ("Just current attributes" custom-face-edit-selected 3347 ("Show Lisp Expression" custom-face-edit-lisp
3169 (lambda (widget)
3170 (not (eq (widget-get widget :custom-form) 'selected))))
3171 ("Show as Lisp expression" custom-face-edit-lisp
3172 (lambda (widget) 3348 (lambda (widget)
3173 (not (eq (widget-get widget :custom-form) 'lisp))))) 3349 (not (eq (widget-get widget :custom-form) 'lisp)))))
3174 "Alist of actions for the `custom-face' widget. 3350 "Alist of actions for the `custom-face' widget.
3175 Each entry has the form (NAME ACTION FILTER) where NAME is the name of 3351 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3176 the menu entry, ACTION is the function to call on the widget when the 3352 the menu entry, ACTION is the function to call on the widget when the
3212 ((progn 3388 ((progn
3213 (setq tmp (get symbol 'saved-face)) 3389 (setq tmp (get symbol 'saved-face))
3214 (setq temp (get symbol 'saved-face-comment)) 3390 (setq temp (get symbol 'saved-face-comment))
3215 (or tmp temp)) 3391 (or tmp temp))
3216 (if (equal temp comment) 3392 (if (equal temp comment)
3217 'saved 3393 (cond
3394 ((eq 'user (caar (get symbol 'theme-face)))
3395 'saved)
3396 ((eq 'changed (caar (get symbol 'theme-face)))
3397 'changed)
3398 (t 'themed))
3218 'changed)) 3399 'changed))
3219 ((get symbol 'face-defface-spec) 3400 ((get symbol 'face-defface-spec)
3220 (if (equal comment nil) 3401 (if (equal comment nil)
3221 'standard 3402 'standard
3222 'changed)) 3403 'changed))
3259 (if (face-spec-choose value) 3440 (if (face-spec-choose value)
3260 (face-spec-set symbol value) 3441 (face-spec-set symbol value)
3261 ;; face-set-spec ignores empty attribute lists, so just give it 3442 ;; face-set-spec ignores empty attribute lists, so just give it
3262 ;; something harmless instead. 3443 ;; something harmless instead.
3263 (face-spec-set symbol '((t :foreground unspecified)))) 3444 (face-spec-set symbol '((t :foreground unspecified))))
3445 (custom-push-theme 'theme-face symbol 'user 'set value)
3264 (put symbol 'customized-face-comment comment) 3446 (put symbol 'customized-face-comment comment)
3265 (put symbol 'face-comment comment) 3447 (put symbol 'face-comment comment)
3266 (custom-face-state-set widget) 3448 (custom-face-state-set widget)
3267 (custom-redraw-magic widget))) 3449 (custom-redraw-magic widget)))
3268 3450
3280 (comment (widget-value comment-widget))) 3462 (comment (widget-value comment-widget)))
3281 (when (equal comment "") 3463 (when (equal comment "")
3282 (setq comment nil) 3464 (setq comment nil)
3283 ;; Make the comment invisible by hand if it's empty 3465 ;; Make the comment invisible by hand if it's empty
3284 (custom-comment-hide comment-widget)) 3466 (custom-comment-hide comment-widget))
3467 (custom-push-theme 'theme-face symbol 'user 'set value)
3285 (if (face-spec-choose value) 3468 (if (face-spec-choose value)
3286 (face-spec-set symbol value) 3469 (face-spec-set symbol value)
3287 ;; face-set-spec ignores empty attribute lists, so just give it 3470 ;; face-set-spec ignores empty attribute lists, so just give it
3288 ;; something harmless instead. 3471 ;; something harmless instead.
3289 (face-spec-set symbol '((t :foreground unspecified)))) 3472 (face-spec-set symbol '((t :foreground unspecified))))
3290 (unless (eq (widget-get widget :custom-state) 'standard) 3473 (unless (eq (widget-get widget :custom-state) 'standard)
3291 (put symbol 'saved-face value)) 3474 (put symbol 'saved-face value))
3292 (custom-push-theme 'theme-face symbol 'user 'set value)
3293 (put symbol 'customized-face nil) 3475 (put symbol 'customized-face nil)
3294 (put symbol 'face-comment comment) 3476 (put symbol 'face-comment comment)
3295 (put symbol 'customized-face-comment nil) 3477 (put symbol 'customized-face-comment nil)
3296 (put symbol 'saved-face-comment comment) 3478 (put symbol 'saved-face-comment comment)
3297 (custom-save-all) 3479 (custom-save-all)
3307 (comment-widget (widget-get widget :comment-widget))) 3489 (comment-widget (widget-get widget :comment-widget)))
3308 (unless (or value comment) 3490 (unless (or value comment)
3309 (error "No saved value for this face")) 3491 (error "No saved value for this face"))
3310 (put symbol 'customized-face nil) 3492 (put symbol 'customized-face nil)
3311 (put symbol 'customized-face-comment nil) 3493 (put symbol 'customized-face-comment nil)
3494 (custom-push-theme 'theme-face symbol 'user 'set value)
3312 (face-spec-set symbol value) 3495 (face-spec-set symbol value)
3313 (put symbol 'face-comment comment) 3496 (put symbol 'face-comment comment)
3314 (widget-value-set child value) 3497 (widget-value-set child value)
3315 ;; This call manages the comment visibility 3498 ;; This call manages the comment visibility
3316 (widget-value-set comment-widget (or comment "")) 3499 (widget-value-set comment-widget (or comment ""))
3319 3502
3320 (defun custom-face-standard-value (widget) 3503 (defun custom-face-standard-value (widget)
3321 (get (widget-value widget) 'face-defface-spec)) 3504 (get (widget-value widget) 'face-defface-spec))
3322 3505
3323 (defun custom-face-reset-standard (widget) 3506 (defun custom-face-reset-standard (widget)
3324 "Restore WIDGET to the face's standard settings. 3507 "Restore WIDGET to the face's standard attribute values.
3325 This operation eliminates any saved setting for the face, 3508 This operation eliminates any saved attributes for the face,
3326 restoring it to the state of a face that has never been customized." 3509 restoring it to the state of a face that has never been customized."
3327 (let* ((symbol (widget-value widget)) 3510 (let* ((symbol (widget-value widget))
3328 (child (car (widget-get widget :children))) 3511 (child (car (widget-get widget :children)))
3329 (value (get symbol 'face-defface-spec)) 3512 (value (get symbol 'face-defface-spec))
3330 (comment-widget (widget-get widget :comment-widget))) 3513 (comment-widget (widget-get widget :comment-widget)))
3331 (unless value 3514 (unless value
3332 (error "No standard setting for this face")) 3515 (error "No standard setting for this face"))
3333 (put symbol 'customized-face nil) 3516 (put symbol 'customized-face nil)
3334 (put symbol 'customized-face-comment nil) 3517 (put symbol 'customized-face-comment nil)
3518 (custom-push-theme 'theme-face symbol 'user 'reset)
3519 (custom-theme-recalc-face symbol)
3335 (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment)) 3520 (when (or (get symbol 'saved-face) (get symbol 'saved-face-comment))
3336 (put symbol 'saved-face nil) 3521 (put symbol 'saved-face nil)
3337 (custom-push-theme 'theme-face symbol 'user 'reset 'standard)
3338 ;; Do not explictly save resets to standards without themes.
3339 (if (null (cdr (get symbol 'theme-face)))
3340 (put symbol 'theme-face nil))
3341 (put symbol 'saved-face-comment nil) 3522 (put symbol 'saved-face-comment nil)
3342 (custom-save-all)) 3523 (custom-save-all))
3343 (face-spec-set symbol value)
3344 (put symbol 'face-comment nil) 3524 (put symbol 'face-comment nil)
3345 (widget-value-set child value) 3525 (widget-value-set child value)
3346 ;; This call manages the comment visibility 3526 ;; This call manages the comment visibility
3347 (widget-value-set comment-widget "") 3527 (widget-value-set comment-widget "")
3348 (custom-face-state-set widget) 3528 (custom-face-state-set widget)
3353 (defvar widget-face-prompt-value-history nil 3533 (defvar widget-face-prompt-value-history nil
3354 "History of input to `widget-face-prompt-value'.") 3534 "History of input to `widget-face-prompt-value'.")
3355 3535
3356 (define-widget 'face 'symbol 3536 (define-widget 'face 'symbol
3357 "A Lisp face name (with sample)." 3537 "A Lisp face name (with sample)."
3358 :format "%t: (%{sample%}) %v" 3538 :format "%{%t%}: (%{sample%}) %v"
3359 :tag "Face" 3539 :tag "Face"
3360 :value 'default 3540 :value 'default
3361 :sample-face-get 'widget-face-sample-face-get 3541 :sample-face-get 'widget-face-sample-face-get
3362 :notify 'widget-face-notify 3542 :notify 'widget-face-notify
3363 :match (lambda (widget value) (facep value)) 3543 :match (lambda (widget value) (facep value))
3623 (insert " group: ") 3803 (insert " group: ")
3624 ;; Create link/visibility indicator. 3804 ;; Create link/visibility indicator.
3625 (if (eq custom-buffer-style 'links) 3805 (if (eq custom-buffer-style 'links)
3626 (push (widget-create-child-and-convert 3806 (push (widget-create-child-and-convert
3627 widget 'custom-group-link 3807 widget 'custom-group-link
3808 :button-face 'custom-link
3809 :mouse-face 'highlight
3628 :tag "Go to Group" 3810 :tag "Go to Group"
3629 symbol) 3811 symbol)
3630 buttons) 3812 buttons)
3631 (push (widget-create-child-and-convert 3813 (push (widget-create-child-and-convert
3632 widget 'custom-group-visibility 3814 widget 'custom-group-visibility
3738 (insert "\\- " (widget-get widget :tag) " group end ") 3920 (insert "\\- " (widget-get widget :tag) " group end ")
3739 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level))) 3921 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level)))
3740 (insert "/\n"))))) 3922 (insert "/\n")))))
3741 3923
3742 (defvar custom-group-menu 3924 (defvar custom-group-menu
3743 '(("Set for Current Session" custom-group-set 3925 `(("Set for Current Session" custom-group-set
3744 (lambda (widget) 3926 (lambda (widget)
3745 (eq (widget-get widget :custom-state) 'modified))) 3927 (eq (widget-get widget :custom-state) 'modified)))
3746 ("Save for Future Sessions" custom-group-save 3928 ,@(when (or custom-file user-init-file)
3747 (lambda (widget) 3929 '(("Save for Future Sessions" custom-group-save
3748 (memq (widget-get widget :custom-state) '(modified set)))) 3930 (lambda (widget)
3749 ("Reset to Current" custom-group-reset-current 3931 (memq (widget-get widget :custom-state) '(modified set))))))
3932 ("Undo Edits" custom-group-reset-current
3750 (lambda (widget) 3933 (lambda (widget)
3751 (memq (widget-get widget :custom-state) '(modified)))) 3934 (memq (widget-get widget :custom-state) '(modified))))
3752 ("Reset to Saved" custom-group-reset-saved 3935 ("Reset to Saved" custom-group-reset-saved
3753 (lambda (widget) 3936 (lambda (widget)
3754 (memq (widget-get widget :custom-state) '(modified set)))) 3937 (memq (widget-get widget :custom-state) '(modified set))))
3755 ("Reset to standard setting" custom-group-reset-standard 3938 ,@(when (or custom-file user-init-file)
3756 (lambda (widget) 3939 '(("Erase Customization" custom-group-reset-standard
3757 (memq (widget-get widget :custom-state) '(modified set saved))))) 3940 (lambda (widget)
3941 (memq (widget-get widget :custom-state) '(modified set saved)))))))
3758 "Alist of actions for the `custom-group' widget. 3942 "Alist of actions for the `custom-group' widget.
3759 Each entry has the form (NAME ACTION FILTER) where NAME is the name of 3943 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
3760 the menu entry, ACTION is the function to call on the widget when the 3944 the menu entry, ACTION is the function to call on the widget when the
3761 menu is selected, and FILTER is a predicate which takes a `custom-group' 3945 menu is selected, and FILTER is a predicate which takes a `custom-group'
3762 widget as an argument, and returns non-nil if ACTION is valid on that 3946 widget as an argument, and returns non-nil if ACTION is valid on that
3915 (custom-save-faces)) 4099 (custom-save-faces))
3916 (let ((file-precious-flag t)) 4100 (let ((file-precious-flag t))
3917 (save-buffer)) 4101 (save-buffer))
3918 (unless old-buffer 4102 (unless old-buffer
3919 (kill-buffer (current-buffer)))))) 4103 (kill-buffer (current-buffer))))))
4104
4105 ;;;###autoload
4106 (defun customize-save-customized ()
4107 "Save all user options which have been set in this session."
4108 (interactive)
4109 (mapatoms (lambda (symbol)
4110 (let ((face (get symbol 'customized-face))
4111 (value (get symbol 'customized-value))
4112 (face-comment (get symbol 'customized-face-comment))
4113 (variable-comment
4114 (get symbol 'customized-variable-comment)))
4115 (when face
4116 (put symbol 'saved-face face)
4117 (custom-push-theme 'theme-face symbol 'user 'set value)
4118 (put symbol 'customized-face nil))
4119 (when value
4120 (put symbol 'saved-value value)
4121 (custom-push-theme 'theme-value symbol 'user 'set value)
4122 (put symbol 'customized-value nil))
4123 (when variable-comment
4124 (put symbol 'saved-variable-comment variable-comment)
4125 (put symbol 'customized-variable-comment nil))
4126 (when face-comment
4127 (put symbol 'saved-face-comment face-comment)
4128 (put symbol 'customized-face-comment nil)))))
4129 ;; We really should update all custom buffers here.
4130 (custom-save-all))
3920 4131
3921 ;; Editing the custom file contents in a buffer. 4132 ;; Editing the custom file contents in a buffer.
3922 4133
3923 (defun custom-save-delete (symbol) 4134 (defun custom-save-delete (symbol)
3924 "Delete all calls to SYMBOL from the contents of the current buffer. 4135 "Delete all calls to SYMBOL from the contents of the current buffer.
3960 (goto-char pos))))) 4171 (goto-char pos)))))
3961 4172
3962 (defun custom-save-variables () 4173 (defun custom-save-variables ()
3963 "Save all customized variables in `custom-file'." 4174 "Save all customized variables in `custom-file'."
3964 (save-excursion 4175 (save-excursion
3965 (custom-save-delete 'custom-load-themes)
3966 (custom-save-delete 'custom-reset-variables)
3967 (custom-save-delete 'custom-set-variables) 4176 (custom-save-delete 'custom-set-variables)
3968 (custom-save-loaded-themes)
3969 (custom-save-resets 'theme-value 'custom-reset-variables nil)
3970 (let ((standard-output (current-buffer)) 4177 (let ((standard-output (current-buffer))
3971 (saved-list (make-list 1 0)) 4178 (saved-list (make-list 1 0))
3972 sort-fold-case) 4179 sort-fold-case)
3973 ;; First create a sorted list of saved variables. 4180 ;; First create a sorted list of saved variables.
3974 (mapatoms 4181 (mapatoms
3975 (lambda (symbol) 4182 (lambda (symbol)
3976 (if (get symbol 'saved-value) 4183 (if (and (get symbol 'saved-value)
4184 (eq 'user (car (car-safe (get symbol 'theme-value)))))
3977 (nconc saved-list (list symbol))))) 4185 (nconc saved-list (list symbol)))))
3978 (setq saved-list (sort (cdr saved-list) 'string<)) 4186 (setq saved-list (sort (cdr saved-list) 'string<))
3979 (unless (bolp) 4187 (unless (bolp)
3980 (princ "\n")) 4188 (princ "\n"))
3981 (princ "(custom-set-variables 4189 (princ "(custom-set-variables
3995 ;; Check `requests'. 4203 ;; Check `requests'.
3996 (dolist (request requests) 4204 (dolist (request requests)
3997 (when (and (symbolp request) (not (featurep request))) 4205 (when (and (symbolp request) (not (featurep request)))
3998 (message "Unknown requested feature: %s" request) 4206 (message "Unknown requested feature: %s" request)
3999 (setq requests (delq request requests)))) 4207 (setq requests (delq request requests))))
4000 (when (or (and spec 4208 (when (or (and spec (eq (car spec) 'user))
4001 (eq (nth 0 spec) 'user)
4002 (eq (nth 1 spec) 'set))
4003 comment 4209 comment
4004 (and (null spec) (get symbol 'saved-value))) 4210 (and (null spec) (get symbol 'saved-value)))
4005 (unless (bolp) 4211 (unless (bolp)
4006 (princ "\n")) 4212 (princ "\n"))
4007 (princ " '(") 4213 (princ " '(")
4027 (defun custom-save-faces () 4233 (defun custom-save-faces ()
4028 "Save all customized faces in `custom-file'." 4234 "Save all customized faces in `custom-file'."
4029 (save-excursion 4235 (save-excursion
4030 (custom-save-delete 'custom-reset-faces) 4236 (custom-save-delete 'custom-reset-faces)
4031 (custom-save-delete 'custom-set-faces) 4237 (custom-save-delete 'custom-set-faces)
4032 (custom-save-resets 'theme-face 'custom-reset-faces '(default))
4033 (let ((standard-output (current-buffer)) 4238 (let ((standard-output (current-buffer))
4034 (saved-list (make-list 1 0)) 4239 (saved-list (make-list 1 0))
4035 sort-fold-case) 4240 sort-fold-case)
4036 ;; First create a sorted list of saved faces. 4241 ;; First create a sorted list of saved faces.
4037 (mapatoms 4242 (mapatoms
4038 (lambda (symbol) 4243 (lambda (symbol)
4039 (if (get symbol 'saved-face) 4244 (if (and (get symbol 'saved-face)
4245 (eq 'user (car (car-safe (get symbol 'theme-face)))))
4040 (nconc saved-list (list symbol))))) 4246 (nconc saved-list (list symbol)))))
4041 (setq saved-list (sort (cdr saved-list) 'string<)) 4247 (setq saved-list (sort (cdr saved-list) 'string<))
4042 ;; The default face must be first, since it affects the others. 4248 ;; The default face must be first, since it affects the others.
4043 (if (memq 'default saved-list) 4249 (if (memq 'default saved-list)
4044 (setq saved-list (cons 'default (delq 'default saved-list)))) 4250 (setq saved-list (cons 'default (delq 'default saved-list))))
4054 (value (get symbol 'saved-face)) 4260 (value (get symbol 'saved-face))
4055 (now (not (or (get symbol 'face-defface-spec) 4261 (now (not (or (get symbol 'face-defface-spec)
4056 (and (not (custom-facep symbol)) 4262 (and (not (custom-facep symbol))
4057 (not (get symbol 'force-face)))))) 4263 (not (get symbol 'force-face))))))
4058 (comment (get symbol 'saved-face-comment))) 4264 (comment (get symbol 'saved-face-comment)))
4059 (when (or (and spec 4265 (when (or (and spec (eq (nth 0 spec) 'user))
4060 (eq (nth 0 spec) 'user)
4061 (eq (nth 1 spec) 'set))
4062 comment 4266 comment
4063 (and (null spec) (get symbol 'saved-face))) 4267 (and (null spec) (get symbol 'saved-face)))
4064 ;; Don't print default face here. 4268 ;; Don't print default face here.
4065 (unless (bolp) 4269 (unless (bolp)
4066 (princ "\n")) 4270 (princ "\n"))
4078 (if (bolp) 4282 (if (bolp)
4079 (princ " ")) 4283 (princ " "))
4080 (princ ")") 4284 (princ ")")
4081 (unless (looking-at "\n") 4285 (unless (looking-at "\n")
4082 (princ "\n"))))) 4286 (princ "\n")))))
4083
4084 (defun custom-save-resets (property setter special)
4085 (let (started-writing ignored-special)
4086 ;; (custom-save-delete setter) Done by caller
4087 (let ((standard-output (current-buffer))
4088 (mapper `(lambda (object)
4089 (let ((spec (car-safe (get object (quote ,property)))))
4090 (when (and (not (memq object ignored-special))
4091 (eq (nth 0 spec) 'user)
4092 (eq (nth 1 spec) 'reset))
4093 ;; Do not write reset statements unless necessary.
4094 (unless started-writing
4095 (setq started-writing t)
4096 (unless (bolp)
4097 (princ "\n"))
4098 (princ "(")
4099 (princ (quote ,setter))
4100 (princ "\n '(")
4101 (prin1 object)
4102 (princ " ")
4103 (prin1 (nth 3 spec))
4104 (princ ")")))))))
4105 (mapc mapper special)
4106 (setq ignored-special special)
4107 (mapatoms mapper)
4108 (when started-writing
4109 (princ ")\n")))))
4110
4111 (defun custom-save-loaded-themes ()
4112 (let ((themes (reverse (get 'user 'theme-loads-themes)))
4113 (standard-output (current-buffer)))
4114 (when themes
4115 (unless (bolp) (princ "\n"))
4116 (princ "(custom-load-themes")
4117 (mapc (lambda (theme)
4118 (princ "\n '")
4119 (prin1 theme)) themes)
4120 (princ " )\n"))))
4121
4122 ;;;###autoload
4123 (defun customize-save-customized ()
4124 "Save all user options which have been set in this session."
4125 (interactive)
4126 (mapatoms (lambda (symbol)
4127 (let ((face (get symbol 'customized-face))
4128 (value (get symbol 'customized-value))
4129 (face-comment (get symbol 'customized-face-comment))
4130 (variable-comment
4131 (get symbol 'customized-variable-comment)))
4132 (when face
4133 (put symbol 'saved-face face)
4134 (custom-push-theme 'theme-face symbol 'user 'set value)
4135 (put symbol 'customized-face nil))
4136 (when value
4137 (put symbol 'saved-value value)
4138 (custom-push-theme 'theme-value symbol 'user 'set value)
4139 (put symbol 'customized-value nil))
4140 (when variable-comment
4141 (put symbol 'saved-variable-comment variable-comment)
4142 (put symbol 'customized-variable-comment nil))
4143 (when face-comment
4144 (put symbol 'saved-face-comment face-comment)
4145 (put symbol 'customized-face-comment nil)))))
4146 ;; We really should update all custom buffers here.
4147 (custom-save-all))
4148 4287
4149 ;;; The Customize Menu. 4288 ;;; The Customize Menu.
4150 4289
4151 ;;; Menu support 4290 ;;; Menu support
4152 4291
4254 "Menu used in customization buffers." 4393 "Menu used in customization buffers."
4255 `("Custom" 4394 `("Custom"
4256 ,(customize-menu-create 'customize) 4395 ,(customize-menu-create 'customize)
4257 ["Set" Custom-set t] 4396 ["Set" Custom-set t]
4258 ["Save" Custom-save t] 4397 ["Save" Custom-save t]
4259 ["Reset to Current" Custom-reset-current t] 4398 ["Undo Edits" Custom-reset-current t]
4260 ["Reset to Saved" Custom-reset-saved t] 4399 ["Reset to Saved" Custom-reset-saved t]
4261 ["Reset to Standard Settings" Custom-reset-standard t] 4400 ["Erase Customization" Custom-reset-standard t]
4262 ["Info" (info "(emacs)Easy Customization") t])) 4401 ["Info" (info "(emacs)Easy Customization") t]))
4263 4402
4264 (defun Custom-goto-parent () 4403 (defun Custom-goto-parent ()
4265 "Go to the parent group listed at the top of this buffer. 4404 "Go to the parent group listed at the top of this buffer.
4266 If several parents are listed, go to the first of them." 4405 If several parents are listed, go to the first of them."
4291 \\<widget-field-keymap>\ 4430 \\<widget-field-keymap>\
4292 Complete content of editable text field. \\[widget-complete] 4431 Complete content of editable text field. \\[widget-complete]
4293 \\<custom-mode-map>\ 4432 \\<custom-mode-map>\
4294 Invoke button under the mouse pointer. \\[Custom-move-and-invoke] 4433 Invoke button under the mouse pointer. \\[Custom-move-and-invoke]
4295 Invoke button under point. \\[widget-button-press] 4434 Invoke button under point. \\[widget-button-press]
4296 Set all modifications. \\[Custom-set] 4435 Set all options from current text. \\[Custom-set]
4297 Make all modifications default. \\[Custom-save] 4436 Make values in current text permanent. \\[Custom-save]
4298 Reset all modified options. \\[Custom-reset-current] 4437 Make text match actual option values. \\[Custom-reset-current]
4299 Reset all modified or set options. \\[Custom-reset-saved] 4438 Reset options to permanent settings. \\[Custom-reset-saved]
4300 Reset all options. \\[Custom-reset-standard] 4439 Erase customizations; set options
4440 and buffer text to the standard values. \\[Custom-reset-standard]
4301 4441
4302 Entry to this mode calls the value of `custom-mode-hook' 4442 Entry to this mode calls the value of `custom-mode-hook'
4303 if that value is non-nil." 4443 if that value is non-nil."
4304 (kill-all-local-variables) 4444 (kill-all-local-variables)
4305 (setq major-mode 'custom-mode 4445 (setq major-mode 'custom-mode
4309 (make-local-variable 'custom-options) 4449 (make-local-variable 'custom-options)
4310 (make-local-variable 'custom-local-buffer) 4450 (make-local-variable 'custom-local-buffer)
4311 (make-local-variable 'widget-documentation-face) 4451 (make-local-variable 'widget-documentation-face)
4312 (setq widget-documentation-face 'custom-documentation) 4452 (setq widget-documentation-face 'custom-documentation)
4313 (make-local-variable 'widget-button-face) 4453 (make-local-variable 'widget-button-face)
4314 (setq widget-button-face 'custom-button) 4454 (setq widget-button-face custom-button)
4315 (set (make-local-variable 'widget-button-pressed-face) 'custom-button-pressed) 4455 (set (make-local-variable 'widget-button-pressed-face) custom-button-pressed)
4316 (set (make-local-variable 'widget-mouse-face) 4456 (set (make-local-variable 'widget-mouse-face) custom-button-mouse)
4317 'custom-button-pressed) ; buttons `depress' when moused 4457
4318 ;; When possible, use relief for buttons, not bracketing. This test 4458 ;; When possible, use relief for buttons, not bracketing. This test
4319 ;; may not be optimal. 4459 ;; may not be optimal.
4320 (when custom-raised-buttons 4460 (when custom-raised-buttons
4321 (set (make-local-variable 'widget-push-button-prefix) "") 4461 (set (make-local-variable 'widget-push-button-prefix) "")
4322 (set (make-local-variable 'widget-push-button-suffix) "") 4462 (set (make-local-variable 'widget-push-button-suffix) "")