comparison lisp/cus-edit.el @ 18089:bb0e09c8ada3

Synched with 1.9904
author Per Abrahamsen <abraham@dina.kvl.dk>
date Sun, 01 Jun 1997 11:58:17 +0000
parents 05c70aa62552
children 2983683a278b
comparison
equal deleted inserted replaced
18088:be8a62ae8d21 18089:bb0e09c8ada3
2 ;; 2 ;;
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 ;; 4 ;;
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6 ;; Keywords: help, faces 6 ;; Keywords: help, faces
7 ;; Version: 1.9903 7 ;; Version: 1.9904
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9 9
10 ;; This file is part of GNU Emacs. 10 ;; This file is part of GNU Emacs.
11 11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify 12 ;; GNU Emacs is free software; you can redistribute it and/or modify
31 ;; See `custom.el'. 31 ;; See `custom.el'.
32 32
33 ;;; Code: 33 ;;; Code:
34 34
35 (require 'cus-face) 35 (require 'cus-face)
36 (require 'cus-start)
37 (require 'wid-edit) 36 (require 'wid-edit)
38 (require 'easymenu) 37 (require 'easymenu)
39 (eval-when-compile (require 'cl)) 38 (eval-when-compile (require 'cl))
40 39
41 (condition-case nil 40 (condition-case nil
42 (require 'cus-load) 41 (require 'cus-load)
43 (error nil)) 42 (error nil))
44 43
45 (define-widget-keywords :custom-prefixes :custom-menu :custom-show 44 (condition-case nil
45 (require 'cus-start)
46 (error nil))
47
48 (define-widget-keywords :custom-category :custom-prefixes :custom-menu
49 :custom-show
46 :custom-magic :custom-state :custom-level :custom-form 50 :custom-magic :custom-state :custom-level :custom-form
47 :custom-set :custom-save :custom-reset-current :custom-reset-saved 51 :custom-set :custom-save :custom-reset-current :custom-reset-saved
48 :custom-reset-standard) 52 :custom-reset-standard)
49 53
50 (put 'custom-define-hook 'custom-type 'hook) 54 (put 'custom-define-hook 'custom-type 'hook)
598 custom-reset-menu 602 custom-reset-menu
599 event))) 603 event)))
600 (if answer 604 (if answer
601 (funcall answer)))) 605 (funcall answer))))
602 606
603 (defun custom-reset-current () 607 (defun custom-reset-current (&rest ignore)
604 "Reset all modified group members to their current value." 608 "Reset all modified group members to their current value."
605 (interactive) 609 (interactive)
606 (let ((children custom-options)) 610 (let ((children custom-options))
607 (mapcar (lambda (child) 611 (mapcar (lambda (child)
608 (when (eq (widget-get child :custom-state) 'modified) 612 (when (eq (widget-get child :custom-state) 'modified)
609 (widget-apply child :custom-reset-current))) 613 (widget-apply child :custom-reset-current)))
610 children))) 614 children)))
611 615
612 (defun custom-reset-saved () 616 (defun custom-reset-saved (&rest ignore)
613 "Reset all modified or set group members to their saved value." 617 "Reset all modified or set group members to their saved value."
614 (interactive) 618 (interactive)
615 (let ((children custom-options)) 619 (let ((children custom-options))
616 (mapcar (lambda (child) 620 (mapcar (lambda (child)
617 (when (eq (widget-get child :custom-state) 'modified) 621 (when (eq (widget-get child :custom-state) 'modified)
618 (widget-apply child :custom-reset-current))) 622 (widget-apply child :custom-reset-current)))
619 children))) 623 children)))
620 624
621 (defun custom-reset-standard () 625 (defun custom-reset-standard (&rest ignore)
622 "Reset all modified, set, or saved group members to their standard settings." 626 "Reset all modified, set, or saved group members to their standard settings."
623 (interactive) 627 (interactive)
624 (let ((children custom-options)) 628 (let ((children custom-options))
625 (mapcar (lambda (child) 629 (mapcar (lambda (child)
626 (when (eq (widget-get child :custom-state) 'modified) 630 (when (eq (widget-get child :custom-state) 'modified)
738 (setq symbol (intern symbol)))) 742 (setq symbol (intern symbol))))
739 (custom-buffer-create-other-window 743 (custom-buffer-create-other-window
740 (list (list symbol 'custom-group)) 744 (list (list symbol 'custom-group))
741 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol)))) 745 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol))))
742 746
743 ;;;### (defalias 'customize-variable 'customize-option) 747 ;;;###autoload
748 (defalias 'customize-variable 'customize-option)
744 749
745 ;;;###autoload 750 ;;;###autoload
746 (defun customize-option (symbol) 751 (defun customize-option (symbol)
747 "Customize SYMBOL, which must be a user option variable." 752 "Customize SYMBOL, which must be a user option variable."
748 (interactive (custom-variable-prompt)) 753 (interactive (custom-variable-prompt))
882 (kill-buffer (get-buffer-create name)) 887 (kill-buffer (get-buffer-create name))
883 (let ((window (selected-window))) 888 (let ((window (selected-window)))
884 (switch-to-buffer-other-window (get-buffer-create name)) 889 (switch-to-buffer-other-window (get-buffer-create name))
885 (custom-buffer-create-internal options) 890 (custom-buffer-create-internal options)
886 (select-window window))) 891 (select-window window)))
887 892
893 (defcustom custom-reset-button-menu nil
894 "If non-nil, only show a single reset button in customize buffers.
895 This button will have a menu with all three reset operations."
896 :type 'boolean
897 :group 'customize)
888 898
889 (defun custom-buffer-create-internal (options) 899 (defun custom-buffer-create-internal (options)
890 (message "Creating customization buffer...") 900 (message "Creating customization buffer...")
891 (custom-mode) 901 (custom-mode)
892 (widget-insert "This is a customization buffer. 902 (widget-insert "This is a customization buffer.
909 :help-echo "\ 919 :help-echo "\
910 Make the modifications default for future sessions." 920 Make the modifications default for future sessions."
911 :action (lambda (widget &optional event) 921 :action (lambda (widget &optional event)
912 (custom-save))) 922 (custom-save)))
913 (widget-insert " ") 923 (widget-insert " ")
914 (widget-create 'push-button 924 (if custom-reset-button-menu
915 :tag "Reset" 925 (widget-create 'push-button
916 :help-echo "Undo all modifications." 926 :tag "Reset"
917 :action (lambda (widget &optional event) 927 :help-echo "Undo all modifications."
918 (custom-reset event))) 928 :mouse-down-action (lambda (&rest junk) t)
929 :action (lambda (widget &optional event)
930 (custom-reset event)))
931 (widget-create 'push-button
932 :tag "Reset"
933 :help-echo "Undo all modifications."
934 :action 'custom-reset-current)
935 (widget-insert " ")
936 (widget-create 'push-button
937 :tag "Reset to Saved"
938 :help-echo "Undo all modifications."
939 :action 'custom-reset-saved)
940 (widget-insert " ")
941 (widget-create 'push-button
942 :tag "Reset to Standard"
943 :help-echo "Undo all modifications."
944 :action 'custom-reset-standard))
919 (widget-insert " ") 945 (widget-insert " ")
920 (widget-create 'push-button 946 (widget-create 'push-button
921 :tag "Done" 947 :tag "Done"
922 :help-echo "Bury the buffer." 948 :help-echo "Bury the buffer."
923 :action (lambda (widget &optional event) 949 :action (lambda (widget &optional event)
1032 unknown, you should not see this.") 1058 unknown, you should not see this.")
1033 (hidden "-" default "\ 1059 (hidden "-" default "\
1034 hidden, invoke the dots above to show." "\ 1060 hidden, invoke the dots above to show." "\
1035 group now hidden, invoke the dots above to show contents.") 1061 group now hidden, invoke the dots above to show contents.")
1036 (invalid "x" custom-invalid-face "\ 1062 (invalid "x" custom-invalid-face "\
1037 the value displayed for this item is invalid and cannot be set.") 1063 the value displayed for this %c is invalid and cannot be set.")
1038 (modified "*" custom-modified-face "\ 1064 (modified "*" custom-modified-face "\
1039 you have edited the item, and can now set it." "\ 1065 you have edited the value, and can now set the %c." "\
1040 you have edited something in this group, and can now set it.") 1066 you have edited something in this group, and can now set it.")
1041 (set "+" custom-set-face "\ 1067 (set "+" custom-set-face "\
1042 you have set this item, but not saved it." "\ 1068 you have set this %c, but not saved it." "\
1043 something in this group has been set, but not yet saved.") 1069 something in this group has been set, but not yet saved.")
1044 (changed ":" custom-changed-face "\ 1070 (changed ":" custom-changed-face "\
1045 this item has been changed outside customize." "\ 1071 this %c has been changed outside the customize buffer." "\
1046 something in this group has been changed outside customize.") 1072 something in this group has been changed outside customize.")
1047 (saved "!" custom-saved-face "\ 1073 (saved "!" custom-saved-face "\
1048 this item has been set and saved." "\ 1074 this %c has been set and saved." "\
1049 something in this group has been set and saved.") 1075 something in this group has been set and saved.")
1050 (rogue "@" custom-rogue-face "\ 1076 (rogue "@" custom-rogue-face "\
1051 this item has not been changed with customize." "\ 1077 this %c has not been changed with customize." "\
1052 something in this group is not prepared for customization.") 1078 something in this group is not prepared for customization.")
1053 (standard " " nil "\ 1079 (standard " " nil "\
1054 this item is unchanged from its standard setting." "\ 1080 this %c is unchanged from its standard setting." "\
1055 the visible members of this group are all at standard settings.")) 1081 the visible members of this group are all at standard settings."))
1056 "Alist of customize option states. 1082 "Alist of customize option states.
1057 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where 1083 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
1058 1084
1059 STATE is one of the following symbols: 1085 STATE is one of the following symbols:
1086 ITEM-DESC is a string describing the state for options. 1112 ITEM-DESC is a string describing the state for options.
1087 1113
1088 GROUP-DESC is a string describing the state for groups. If this is 1114 GROUP-DESC is a string describing the state for groups. If this is
1089 left out, ITEM-DESC will be used. 1115 left out, ITEM-DESC will be used.
1090 1116
1117 The string %c in either description will be replaced with the
1118 category of the item. These are `group'. `option', and `face'.
1119
1091 The list should be sorted most significant first.") 1120 The list should be sorted most significant first.")
1092 1121
1093 (defcustom custom-magic-show 'long 1122 (defcustom custom-magic-show 'long
1094 "If non-nil, show textual description of the state. 1123 "If non-nil, show textual description of the state.
1095 If non-nil and not the symbol `long', only show first word." 1124 If non-nil and not the symbol `long', only show first word."
1096 :type '(choice (const :tag "no" nil) 1125 :type '(choice (const :tag "no" nil)
1097 (const short) 1126 (const short)
1098 (const long)) 1127 (const long))
1099 :group 'customize) 1128 :group 'customize)
1100 1129
1101 (defcustom custom-magic-show-hidden nil 1130 (defcustom custom-magic-show-hidden '(option face)
1102 "If non-nil, also show long state description of hidden options." 1131 "Control whether the state button is shown for hidden items.
1103 :type 'boolean 1132 The value should be a list with the custom categories where the state
1133 button should be visible. Possible categories are `group', `option',
1134 and `face'."
1135 :type '(set (const group) (const option) (const face))
1104 :group 'customize) 1136 :group 'customize)
1105 1137
1106 (defcustom custom-magic-show-button nil 1138 (defcustom custom-magic-show-button nil
1107 "Show a magic button indicating the state of each customization option." 1139 "Show a magic button indicating the state of each customization option."
1108 :type 'boolean 1140 :type 'boolean
1129 (state (widget-get parent :custom-state)) 1161 (state (widget-get parent :custom-state))
1130 (hidden (eq state 'hidden)) 1162 (hidden (eq state 'hidden))
1131 (entry (assq state custom-magic-alist)) 1163 (entry (assq state custom-magic-alist))
1132 (magic (nth 1 entry)) 1164 (magic (nth 1 entry))
1133 (face (nth 2 entry)) 1165 (face (nth 2 entry))
1134 (text (or (and (eq (widget-type parent) 'custom-group) 1166 (category (widget-get parent :custom-category))
1167 (text (or (and (eq category 'group)
1135 (nth 4 entry)) 1168 (nth 4 entry))
1136 (nth 3 entry))) 1169 (nth 3 entry)))
1137 (lisp (eq (widget-get parent :custom-form) 'lisp)) 1170 (lisp (eq (widget-get parent :custom-form) 'lisp))
1138 children) 1171 children)
1172 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text)
1173 (setq text (concat (match-string 1 text)
1174 (symbol-name category)
1175 (match-string 2 text))))
1139 (when (and custom-magic-show 1176 (when (and custom-magic-show
1140 (or custom-magic-show-hidden (not hidden))) 1177 (or (not hidden)
1178 (memq category custom-magic-show-hidden)))
1141 (insert " ") 1179 (insert " ")
1142 (push (widget-create-child-and-convert 1180 (push (widget-create-child-and-convert
1143 widget 'choice-item 1181 widget 'choice-item
1144 :help-echo "Change the state of this item." 1182 :help-echo "Change the state of this item."
1145 :format (if hidden "%t" "%[%t%]") 1183 :format (if hidden "%t" "%[%t%]")
1381 (define-widget 'custom-variable 'custom 1419 (define-widget 'custom-variable 'custom
1382 "Customize variable." 1420 "Customize variable."
1383 :format "%v%m%h%a" 1421 :format "%v%m%h%a"
1384 :help-echo "Set or reset this variable." 1422 :help-echo "Set or reset this variable."
1385 :documentation-property 'variable-documentation 1423 :documentation-property 'variable-documentation
1424 :custom-category 'option
1386 :custom-state nil 1425 :custom-state nil
1387 :custom-menu 'custom-variable-menu-create 1426 :custom-menu 'custom-variable-menu-create
1388 :custom-form 'edit 1427 :custom-form 'edit
1389 :value-create 'custom-variable-value-create 1428 :value-create 'custom-variable-value-create
1390 :action 'custom-variable-action 1429 :action 'custom-variable-action
1793 :help-echo "Set or reset this face." 1832 :help-echo "Set or reset this face."
1794 :documentation-property '(lambda (face) 1833 :documentation-property '(lambda (face)
1795 (face-doc-string face)) 1834 (face-doc-string face))
1796 :value-create 'custom-face-value-create 1835 :value-create 'custom-face-value-create
1797 :action 'custom-face-action 1836 :action 'custom-face-action
1837 :custom-category 'face
1798 :custom-form 'selected 1838 :custom-form 'selected
1799 :custom-set 'custom-face-set 1839 :custom-set 'custom-face-set
1800 :custom-save 'custom-face-save 1840 :custom-save 'custom-face-save
1801 :custom-reset-current 'custom-redraw 1841 :custom-reset-current 'custom-redraw
1802 :custom-reset-saved 'custom-face-reset-saved 1842 :custom-reset-saved 'custom-face-reset-saved
2115 :sample-face-get 'custom-group-sample-face-get 2155 :sample-face-get 'custom-group-sample-face-get
2116 :documentation-property 'group-documentation 2156 :documentation-property 'group-documentation
2117 :help-echo "Set or reset all members of this group." 2157 :help-echo "Set or reset all members of this group."
2118 :value-create 'custom-group-value-create 2158 :value-create 'custom-group-value-create
2119 :action 'custom-group-action 2159 :action 'custom-group-action
2160 :custom-category 'group
2120 :custom-set 'custom-group-set 2161 :custom-set 'custom-group-set
2121 :custom-save 'custom-group-save 2162 :custom-save 'custom-group-save
2122 :custom-reset-current 'custom-group-reset-current 2163 :custom-reset-current 'custom-group-reset-current
2123 :custom-reset-saved 'custom-group-reset-saved 2164 :custom-reset-saved 'custom-group-reset-saved
2124 :custom-reset-standard 'custom-group-reset-standard 2165 :custom-reset-standard 'custom-group-reset-standard