Mercurial > hg > xemacs-beta
comparison lisp/custom/cus-edit.el @ 173:8eaf7971accc r20-3b13
Import from CVS: tag r20-3b13
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:49:09 +0200 |
parents | 929b76928fce |
children | 9ad43877534d |
comparison
equal
deleted
inserted
replaced
172:a38aed19690b | 173:8eaf7971accc |
---|---|
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.9940 | 7 ;; Version: 1.9951 |
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 |
766 "Set customized value for %s to: ")) | 766 "Set customized value for %s to: ")) |
767 (funcall (or (get var 'custom-set) 'set-default) var val) | 767 (funcall (or (get var 'custom-set) 'set-default) var val) |
768 (put var 'customized-value (list (custom-quote val)))) | 768 (put var 'customized-value (list (custom-quote val)))) |
769 | 769 |
770 ;;;###autoload | 770 ;;;###autoload |
771 (defun customize-save-variable (var val) | |
772 "Set the default for VARIABLE to VALUE, and save it for future sessions. | |
773 If VARIABLE has a `custom-set' property, that is used for setting | |
774 VARIABLE, otherwise `set-default' is used. | |
775 | |
776 The `customized-value' property of the VARIABLE will be set to a list | |
777 with a quoted VALUE as its sole list member. | |
778 | |
779 If VARIABLE has a `variable-interactive' property, that is used as if | |
780 it were the arg to `interactive' (which see) to interactively read the value. | |
781 | |
782 If VARIABLE has a `custom-type' property, it must be a widget and the | |
783 `:prompt-value' property of that widget will be used for reading the value. " | |
784 (interactive (custom-prompt-variable "Set and ave variable: " | |
785 "Set and save value for %s as: ")) | |
786 (funcall (or (get var 'custom-set) 'set-default) var val) | |
787 (put var 'saved-value (list (custom-quote val))) | |
788 (custom-save-all)) | |
789 | |
790 ;;;###autoload | |
771 (defun customize () | 791 (defun customize () |
772 "Select a customization buffer which you can use to set user options. | 792 "Select a customization buffer which you can use to set user options. |
773 User options are structured into \"groups\". | 793 User options are structured into \"groups\". |
774 Initially the top-level group `Emacs' and its immediate subgroups | 794 Initially the top-level group `Emacs' and its immediate subgroups |
775 are shown; the contents of those subgroups are initially hidden." | 795 are shown; the contents of those subgroups are initially hidden." |
793 (let ((name (format "*Customize Group: %s*" | 813 (let ((name (format "*Customize Group: %s*" |
794 (custom-unlispify-tag-name group)))) | 814 (custom-unlispify-tag-name group)))) |
795 (if (get-buffer name) | 815 (if (get-buffer name) |
796 (switch-to-buffer name) | 816 (switch-to-buffer name) |
797 (custom-buffer-create (list (list group 'custom-group)) | 817 (custom-buffer-create (list (list group 'custom-group)) |
798 name)))) | 818 name |
819 (concat " for group " | |
820 (custom-unlispify-tag-name group)))))) | |
799 | 821 |
800 ;;;###autoload | 822 ;;;###autoload |
801 (defun customize-group-other-window (symbol) | 823 (defun customize-group-other-window (symbol) |
802 "Customize SYMBOL, which must be a customization group." | 824 "Customize SYMBOL, which must be a customization group." |
803 (interactive (list (completing-read "Customize group: (default emacs) " | 825 (interactive (list (completing-read "Customize group: (default emacs) " |
877 (defun customize-customized () | 899 (defun customize-customized () |
878 "Customize all user options set since the last save in this session." | 900 "Customize all user options set since the last save in this session." |
879 (interactive) | 901 (interactive) |
880 (let ((found nil)) | 902 (let ((found nil)) |
881 (mapatoms (lambda (symbol) | 903 (mapatoms (lambda (symbol) |
882 (and (condition-case nil | 904 (and (get symbol 'customized-face) |
883 (get symbol 'customized-face) | |
884 (t (progn | |
885 (message "Bad plist in %s" | |
886 (symbol-name symbol)) | |
887 nil))) | |
888 (custom-facep symbol) | 905 (custom-facep symbol) |
889 (push (list symbol 'custom-face) found)) | 906 (push (list symbol 'custom-face) found)) |
890 (and (get symbol 'customized-value) | 907 (and (get symbol 'customized-value) |
891 (boundp symbol) | 908 (boundp symbol) |
892 (push (list symbol 'custom-variable) found)))) | 909 (push (list symbol 'custom-variable) found)))) |
899 (defun customize-saved () | 916 (defun customize-saved () |
900 "Customize all already saved user options." | 917 "Customize all already saved user options." |
901 (interactive) | 918 (interactive) |
902 (let ((found nil)) | 919 (let ((found nil)) |
903 (mapatoms (lambda (symbol) | 920 (mapatoms (lambda (symbol) |
904 (and (condition-case nil | 921 (and (get symbol 'saved-face) |
905 (get symbol 'saved-face) | |
906 (t (progn | |
907 (message "Bad plist in %s" | |
908 (symbol-name symbol)) | |
909 nil))) | |
910 (custom-facep symbol) | 922 (custom-facep symbol) |
911 (push (list symbol 'custom-face) found)) | 923 (push (list symbol 'custom-face) found)) |
912 (and (get symbol 'saved-value) | 924 (and (get symbol 'saved-value) |
913 (boundp symbol) | 925 (boundp symbol) |
914 (push (list symbol 'custom-variable) found)))) | 926 (push (list symbol 'custom-variable) found)))) |
984 "Number of spaces to indent nested groups." | 996 "Number of spaces to indent nested groups." |
985 :type 'integer | 997 :type 'integer |
986 :group 'custom-buffer) | 998 :group 'custom-buffer) |
987 | 999 |
988 ;;;###autoload | 1000 ;;;###autoload |
989 (defun custom-buffer-create (options &optional name) | 1001 (defun custom-buffer-create (options &optional name description) |
990 "Create a buffer containing OPTIONS. | 1002 "Create a buffer containing OPTIONS. |
991 Optional NAME is the name of the buffer. | 1003 Optional NAME is the name of the buffer. |
992 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where | 1004 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where |
993 SYMBOL is a customization option, and WIDGET is a widget for editing | 1005 SYMBOL is a customization option, and WIDGET is a widget for editing |
994 that option." | 1006 that option." |
995 (unless name (setq name "*Customization*")) | 1007 (unless name (setq name "*Customization*")) |
996 (kill-buffer (get-buffer-create name)) | 1008 (kill-buffer (get-buffer-create name)) |
997 (switch-to-buffer (get-buffer-create name)) | 1009 (switch-to-buffer (get-buffer-create name)) |
998 (custom-buffer-create-internal options)) | 1010 (custom-buffer-create-internal options description)) |
999 | 1011 |
1000 ;;;###autoload | 1012 ;;;###autoload |
1001 (defun custom-buffer-create-other-window (options &optional name) | 1013 (defun custom-buffer-create-other-window (options &optional name description) |
1002 "Create a buffer containing OPTIONS. | 1014 "Create a buffer containing OPTIONS. |
1003 Optional NAME is the name of the buffer. | 1015 Optional NAME is the name of the buffer. |
1004 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where | 1016 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where |
1005 SYMBOL is a customization option, and WIDGET is a widget for editing | 1017 SYMBOL is a customization option, and WIDGET is a widget for editing |
1006 that option." | 1018 that option." |
1007 (unless name (setq name "*Customization*")) | 1019 (unless name (setq name "*Customization*")) |
1008 (kill-buffer (get-buffer-create name)) | 1020 (kill-buffer (get-buffer-create name)) |
1009 (let ((window (selected-window))) | 1021 (let ((window (selected-window))) |
1010 (switch-to-buffer-other-window (get-buffer-create name)) | 1022 (switch-to-buffer-other-window (get-buffer-create name)) |
1011 (custom-buffer-create-internal options) | 1023 (custom-buffer-create-internal options description) |
1012 (select-window window))) | 1024 (select-window window))) |
1013 | 1025 |
1014 (defcustom custom-reset-button-menu nil | 1026 (defcustom custom-reset-button-menu nil |
1015 "If non-nil, only show a single reset button in customize buffers. | 1027 "If non-nil, only show a single reset button in customize buffers. |
1016 This button will have a menu with all three reset operations." | 1028 This button will have a menu with all three reset operations." |
1017 :type 'boolean | 1029 :type 'boolean |
1018 :group 'custom-buffer) | 1030 :group 'custom-buffer) |
1019 | 1031 |
1020 (defun custom-buffer-create-internal (options) | 1032 (defun custom-buffer-create-internal (options &optional description) |
1021 (message "Creating customization buffer...") | 1033 (message "Creating customization buffer...") |
1022 (custom-mode) | 1034 (custom-mode) |
1023 (widget-insert "This is a customization buffer. | 1035 (widget-insert "This is a customization buffer") |
1036 (if description | |
1037 (widget-insert description)) | |
1038 (widget-insert ". | |
1024 Square brackets show active fields; type RET or click mouse-2 | 1039 Square brackets show active fields; type RET or click mouse-2 |
1025 on an active field to invoke its action. Invoke ") | 1040 on an active field to invoke its action. Editing an option value |
1041 changes the text in the buffer; invoke the State button and | |
1042 choose the Set operation to set the option value. | |
1043 Invoke ") | |
1026 (widget-create 'info-link | 1044 (widget-create 'info-link |
1027 :tag "Help" | 1045 :tag "Help" |
1028 :help-echo "Read the online help." | 1046 :help-echo "Read the online help." |
1029 "(emacs)Easy Customization") | 1047 "(emacs)Easy Customization") |
1030 (widget-insert " for more information.\n\n") | 1048 (widget-insert " for more information.\n\n") |
1031 (message "Creating customization buttons...") | 1049 (message "Creating customization buttons...") |
1032 (widget-insert "Operate on everything in this buffer:\n ") | 1050 (widget-insert "Operate on everything in this buffer:\n ") |
1033 (widget-create 'push-button | 1051 (widget-create 'push-button |
1034 :tag "Set" | 1052 :tag "Set for Current Session" |
1035 :help-echo "\ | 1053 :help-echo "\ |
1036 Make your editing in this buffer take effect for this session." | 1054 Make your editing in this buffer take effect for this session." |
1037 :action (lambda (widget &optional event) | 1055 :action (lambda (widget &optional event) |
1038 (Custom-set))) | 1056 (Custom-set))) |
1039 (widget-insert " ") | 1057 (widget-insert " ") |
1040 (widget-create 'push-button | 1058 (widget-create 'push-button |
1041 :tag "Save" | 1059 :tag "Save for Future Sessions" |
1042 :help-echo "\ | 1060 :help-echo "\ |
1043 Make your editing in this buffer take effect for future Emacs sessions." | 1061 Make your editing in this buffer take effect for future Emacs sessions." |
1044 :action (lambda (widget &optional event) | 1062 :action (lambda (widget &optional event) |
1045 (Custom-save))) | 1063 (Custom-save))) |
1046 (widget-insert " ") | |
1047 (if custom-reset-button-menu | 1064 (if custom-reset-button-menu |
1048 (widget-create 'push-button | 1065 (progn |
1049 :tag "Reset" | 1066 (widget-insert " ") |
1050 :help-echo "Show a menu with reset operations." | 1067 (widget-create 'push-button |
1051 :mouse-down-action (lambda (&rest junk) t) | 1068 :tag "Reset" |
1052 :action (lambda (widget &optional event) | 1069 :help-echo "Show a menu with reset operations." |
1053 (custom-reset event))) | 1070 :mouse-down-action (lambda (&rest junk) t) |
1071 :action (lambda (widget &optional event) | |
1072 (custom-reset event)))) | |
1073 (widget-insert "\n ") | |
1054 (widget-create 'push-button | 1074 (widget-create 'push-button |
1055 :tag "Reset" | 1075 :tag "Reset" |
1056 :help-echo "\ | 1076 :help-echo "\ |
1057 Reset all edited text in this buffer to reflect current values." | 1077 Reset all edited text in this buffer to reflect current values." |
1058 :action 'Custom-reset-current) | 1078 :action 'Custom-reset-current) |
1101 (widget-insert "\n")) | 1121 (widget-insert "\n")) |
1102 (widget-insert "\n"))) | 1122 (widget-insert "\n"))) |
1103 options)))) | 1123 options)))) |
1104 (unless (eq (preceding-char) ?\n) | 1124 (unless (eq (preceding-char) ?\n) |
1105 (widget-insert "\n")) | 1125 (widget-insert "\n")) |
1126 (message "Creating customization items %2d%%...done" 100) | |
1106 (unless (eq custom-buffer-style 'tree) | 1127 (unless (eq custom-buffer-style 'tree) |
1107 (mapcar 'custom-magic-reset custom-options)) | 1128 (mapcar 'custom-magic-reset custom-options)) |
1108 (message "Creating customization setup...") | 1129 (message "Creating customization setup...") |
1109 (widget-setup) | 1130 (widget-setup) |
1110 (goto-char (point-min)) | 1131 (goto-char (point-min)) |
1129 (let ((name "*Customize Browser*")) | 1150 (let ((name "*Customize Browser*")) |
1130 (kill-buffer (get-buffer-create name)) | 1151 (kill-buffer (get-buffer-create name)) |
1131 (switch-to-buffer (get-buffer-create name))) | 1152 (switch-to-buffer (get-buffer-create name))) |
1132 (custom-mode) | 1153 (custom-mode) |
1133 (widget-insert "\ | 1154 (widget-insert "\ |
1134 Invoke [+] or [?] below to expand items, and [-] to collapse items. | 1155 Invoke [+] or [?] below to expand items, and [-] to collapse items.\n") |
1135 Invoke the [Group], [Face], and [Option] buttons below to edit that | 1156 (if custom-browse-only-groups |
1136 item in another window.\n\n") | 1157 (widget-insert "\ |
1158 Invoke the [Group] button below to edit that item in another window.\n\n") | |
1159 (widget-insert "Invoke the ") | |
1160 (widget-create 'item | |
1161 :format "%t" | |
1162 :tag "[Group]" | |
1163 :tag-glyph "folder") | |
1164 (widget-insert ", ") | |
1165 (widget-create 'item | |
1166 :format "%t" | |
1167 :tag "[Face]" | |
1168 :tag-glyph "face") | |
1169 (widget-insert ", and ") | |
1170 (widget-create 'item | |
1171 :format "%t" | |
1172 :tag "[Option]" | |
1173 :tag-glyph "option") | |
1174 (widget-insert " buttons below to edit that | |
1175 item in another window.\n\n")) | |
1137 (let ((custom-buffer-style 'tree)) | 1176 (let ((custom-buffer-style 'tree)) |
1138 (widget-create 'custom-group | 1177 (widget-create 'custom-group |
1139 :custom-last t | 1178 :custom-last t |
1140 :custom-state 'unknown | 1179 :custom-state 'unknown |
1141 :tag (custom-unlispify-tag-name group) | 1180 :tag (custom-unlispify-tag-name group) |
1282 hidden, invoke \"Show\" in the previous line to show." "\ | 1321 hidden, invoke \"Show\" in the previous line to show." "\ |
1283 group now hidden, invoke \"Show\", above, to show contents.") | 1322 group now hidden, invoke \"Show\", above, to show contents.") |
1284 (invalid "x" custom-invalid-face "\ | 1323 (invalid "x" custom-invalid-face "\ |
1285 the value displayed for this %c is invalid and cannot be set.") | 1324 the value displayed for this %c is invalid and cannot be set.") |
1286 (modified "*" custom-modified-face "\ | 1325 (modified "*" custom-modified-face "\ |
1287 you have edited the value, and can now set the %c." "\ | 1326 you have edited the value as text, but you have not set the %c." "\ |
1288 you have edited something in this group, and can now set it.") | 1327 you have edited something in this group, but not set it.") |
1289 (set "+" custom-set-face "\ | 1328 (set "+" custom-set-face "\ |
1290 you have set this %c, but not saved it." "\ | 1329 you have set this %c, but not saved it for future sessions." "\ |
1291 something in this group has been set, but not yet saved.") | 1330 something in this group has been set, but not saved.") |
1292 (changed ":" custom-changed-face "\ | 1331 (changed ":" custom-changed-face "\ |
1293 this %c has been changed outside the customize buffer." "\ | 1332 this %c has been changed outside the customize buffer." "\ |
1294 something in this group has been changed outside customize.") | 1333 something in this group has been changed outside customize.") |
1295 (saved "!" custom-saved-face "\ | 1334 (saved "!" custom-saved-face "\ |
1296 this %c has been set and saved." "\ | 1335 this %c has been set and saved." "\ |
1483 :documentation-property 'widget-subclass-responsibility | 1522 :documentation-property 'widget-subclass-responsibility |
1484 :value-create 'widget-subclass-responsibility | 1523 :value-create 'widget-subclass-responsibility |
1485 :value-delete 'widget-children-value-delete | 1524 :value-delete 'widget-children-value-delete |
1486 :value-get 'widget-value-value-get | 1525 :value-get 'widget-value-value-get |
1487 :validate 'widget-children-validate | 1526 :validate 'widget-children-validate |
1488 :button-face 'custom-button-face | |
1489 :match (lambda (widget value) (symbolp value))) | 1527 :match (lambda (widget value) (symbolp value))) |
1490 | 1528 |
1491 (defun custom-convert-widget (widget) | 1529 (defun custom-convert-widget (widget) |
1492 ;; Initialize :value and :tag from :args in WIDGET. | 1530 ;; Initialize :value and :tag from :args in WIDGET. |
1493 (let ((args (widget-get widget :args))) | 1531 (let ((args (widget-get widget :args))) |
1657 (buttons (widget-get widget :buttons)) | 1695 (buttons (widget-get widget :buttons)) |
1658 (start (point)) | 1696 (start (point)) |
1659 found) | 1697 found) |
1660 (insert (or initial-string "Parent groups:")) | 1698 (insert (or initial-string "Parent groups:")) |
1661 (mapatoms (lambda (symbol) | 1699 (mapatoms (lambda (symbol) |
1662 (let ((entry (assq name | 1700 (let ((entry (assq name (get symbol 'custom-group)))) |
1663 (condition-case nil | |
1664 (get symbol 'custom-group) | |
1665 (t (progn | |
1666 (message "Bad plist in %s" | |
1667 (symbol-name symbol)) | |
1668 nil)))))) | |
1669 (when (eq (nth 1 entry) type) | 1701 (when (eq (nth 1 entry) type) |
1670 (insert " ") | 1702 (insert " ") |
1671 (push (widget-create-child-and-convert | 1703 (push (widget-create-child-and-convert |
1672 widget 'custom-group-link | 1704 widget 'custom-group-link |
1673 :tag (custom-unlispify-tag-name symbol) | 1705 :tag (custom-unlispify-tag-name symbol) |
1898 'changed)) | 1930 'changed)) |
1899 (t 'rogue)))) | 1931 (t 'rogue)))) |
1900 (widget-put widget :custom-state state))) | 1932 (widget-put widget :custom-state state))) |
1901 | 1933 |
1902 (defvar custom-variable-menu | 1934 (defvar custom-variable-menu |
1903 '(("Set" custom-variable-set | 1935 '(("Set for Current Session" custom-variable-set |
1904 (lambda (widget) | 1936 (lambda (widget) |
1905 (eq (widget-get widget :custom-state) 'modified))) | 1937 (eq (widget-get widget :custom-state) 'modified))) |
1906 ("Save" custom-variable-save | 1938 ("Save for Future Sessions" custom-variable-save |
1907 (lambda (widget) | 1939 (lambda (widget) |
1908 (memq (widget-get widget :custom-state) '(modified set changed rogue)))) | 1940 (memq (widget-get widget :custom-state) '(modified set changed rogue)))) |
1909 ("Reset to Current" custom-redraw | 1941 ("Reset to Current" custom-redraw |
1910 (lambda (widget) | 1942 (lambda (widget) |
1911 (and (default-boundp (widget-value widget)) | 1943 (and (default-boundp (widget-value widget)) |
2271 (custom-face-state-set widget) | 2303 (custom-face-state-set widget) |
2272 (widget-put widget :children (list edit))) | 2304 (widget-put widget :children (list edit))) |
2273 (message "Creating face editor...done")))))) | 2305 (message "Creating face editor...done")))))) |
2274 | 2306 |
2275 (defvar custom-face-menu | 2307 (defvar custom-face-menu |
2276 '(("Set" custom-face-set) | 2308 '(("Set for Current Session" custom-face-set) |
2277 ("Save" custom-face-save) | 2309 ("Save for Future Sessions" custom-face-save) |
2278 ("Reset to Saved" custom-face-reset-saved | 2310 ("Reset to Saved" custom-face-reset-saved |
2279 (lambda (widget) | 2311 (lambda (widget) |
2280 (get (widget-value widget) 'saved-face))) | 2312 (get (widget-value widget) 'saved-face))) |
2281 ("Reset to Standard Setting" custom-face-reset-standard | 2313 ("Reset to Standard Setting" custom-face-reset-standard |
2282 (lambda (widget) | 2314 (lambda (widget) |
2536 (let ((visible (widget-value widget))) | 2568 (let ((visible (widget-value widget))) |
2537 (if visible | 2569 (if visible |
2538 (insert "--------"))) | 2570 (insert "--------"))) |
2539 (widget-default-create widget)) | 2571 (widget-default-create widget)) |
2540 | 2572 |
2573 (defun custom-group-members (symbol groups-only) | |
2574 "Return SYMBOL's custom group members. | |
2575 If GROUPS-ONLY non-nil, return only those members that are groups." | |
2576 (if (not groups-only) | |
2577 (get symbol 'custom-group) | |
2578 (let (members) | |
2579 (dolist (entry (get symbol 'custom-group)) | |
2580 (when (eq (nth 1 entry) 'custom-group) | |
2581 (push entry members))) | |
2582 (nreverse members)))) | |
2583 | |
2541 (defun custom-group-value-create (widget) | 2584 (defun custom-group-value-create (widget) |
2542 "Insert a customize group for WIDGET in the current buffer." | 2585 "Insert a customize group for WIDGET in the current buffer." |
2543 (let ((state (widget-get widget :custom-state)) | 2586 (let* ((state (widget-get widget :custom-state)) |
2544 (level (widget-get widget :custom-level)) | 2587 (level (widget-get widget :custom-level)) |
2545 (indent (widget-get widget :indent)) | 2588 (indent (widget-get widget :indent)) |
2546 (prefix (widget-get widget :custom-prefix)) | 2589 (prefix (widget-get widget :custom-prefix)) |
2547 (buttons (widget-get widget :buttons)) | 2590 (buttons (widget-get widget :buttons)) |
2548 (tag (widget-get widget :tag)) | 2591 (tag (widget-get widget :tag)) |
2549 (symbol (widget-value widget))) | 2592 (symbol (widget-value widget)) |
2593 (members (custom-group-members symbol | |
2594 (and (eq custom-buffer-style 'tree) | |
2595 custom-browse-only-groups)))) | |
2550 (cond ((and (eq custom-buffer-style 'tree) | 2596 (cond ((and (eq custom-buffer-style 'tree) |
2551 (eq state 'hidden) | 2597 (eq state 'hidden) |
2552 (or (get symbol 'custom-group) | 2598 (or members (custom-unloaded-widget-p widget))) |
2553 (custom-unloaded-widget-p widget))) | |
2554 (custom-browse-insert-prefix prefix) | 2599 (custom-browse-insert-prefix prefix) |
2555 (push (widget-create-child-and-convert | 2600 (push (widget-create-child-and-convert |
2556 widget 'custom-browse-visibility | 2601 widget 'custom-browse-visibility |
2557 ;; :tag-glyph "plus" | 2602 ;; :tag-glyph "plus" |
2558 :tag (if (custom-unloaded-widget-p widget) "?" "+")) | 2603 :tag (if (custom-unloaded-widget-p widget) "?" "+")) |
2563 widget 'custom-browse-group-tag) | 2608 widget 'custom-browse-group-tag) |
2564 buttons) | 2609 buttons) |
2565 (insert " " tag "\n") | 2610 (insert " " tag "\n") |
2566 (widget-put widget :buttons buttons)) | 2611 (widget-put widget :buttons buttons)) |
2567 ((and (eq custom-buffer-style 'tree) | 2612 ((and (eq custom-buffer-style 'tree) |
2568 (zerop (length (get symbol 'custom-group)))) | 2613 (zerop (length members))) |
2569 (custom-browse-insert-prefix prefix) | 2614 (custom-browse-insert-prefix prefix) |
2570 (insert "[ ]-- ") | 2615 (insert "[ ]-- ") |
2571 ;; (widget-glyph-insert nil "[ ]" "empty") | 2616 ;; (widget-glyph-insert nil "[ ]" "empty") |
2572 ;; (widget-glyph-insert nil "-- " "horizontal") | 2617 ;; (widget-glyph-insert nil "-- " "horizontal") |
2573 (push (widget-create-child-and-convert | 2618 (push (widget-create-child-and-convert |
2576 (insert " " tag "\n") | 2621 (insert " " tag "\n") |
2577 (widget-put widget :buttons buttons)) | 2622 (widget-put widget :buttons buttons)) |
2578 ((eq custom-buffer-style 'tree) | 2623 ((eq custom-buffer-style 'tree) |
2579 (custom-browse-insert-prefix prefix) | 2624 (custom-browse-insert-prefix prefix) |
2580 (custom-load-widget widget) | 2625 (custom-load-widget widget) |
2581 (if (zerop (length (get symbol 'custom-group))) | 2626 (if (zerop (length members)) |
2582 (progn | 2627 (progn |
2583 (custom-browse-insert-prefix prefix) | 2628 (custom-browse-insert-prefix prefix) |
2584 (insert "[ ]-- ") | 2629 (insert "[ ]-- ") |
2585 ;; (widget-glyph-insert nil "[ ]" "empty") | 2630 ;; (widget-glyph-insert nil "[ ]" "empty") |
2586 ;; (widget-glyph-insert nil "-- " "horizontal") | 2631 ;; (widget-glyph-insert nil "-- " "horizontal") |
2600 widget 'custom-browse-group-tag) | 2645 widget 'custom-browse-group-tag) |
2601 buttons) | 2646 buttons) |
2602 (insert " " tag "\n") | 2647 (insert " " tag "\n") |
2603 (widget-put widget :buttons buttons) | 2648 (widget-put widget :buttons buttons) |
2604 (message "Creating group...") | 2649 (message "Creating group...") |
2605 (let* ((members (custom-sort-items (get symbol 'custom-group) | 2650 (let* ((members (custom-sort-items members |
2606 custom-browse-sort-alphabetically | 2651 custom-browse-sort-alphabetically |
2607 custom-browse-order-groups)) | 2652 custom-browse-order-groups)) |
2608 (prefixes (widget-get widget :custom-prefixes)) | 2653 (prefixes (widget-get widget :custom-prefixes)) |
2609 (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2654 (custom-prefix-list (custom-prefix-add symbol prefixes)) |
2610 (extra-prefix (if (widget-get widget :custom-last) | 2655 (extra-prefix (if (widget-get widget :custom-last) |
2613 (prefix (concat prefix extra-prefix)) | 2658 (prefix (concat prefix extra-prefix)) |
2614 children entry) | 2659 children entry) |
2615 (while members | 2660 (while members |
2616 (setq entry (car members) | 2661 (setq entry (car members) |
2617 members (cdr members)) | 2662 members (cdr members)) |
2618 (when (or (not custom-browse-only-groups) | 2663 (push (widget-create-child-and-convert |
2619 (eq (nth 1 entry) 'custom-group)) | 2664 widget (nth 1 entry) |
2620 (push (widget-create-child-and-convert | 2665 :group widget |
2621 widget (nth 1 entry) | 2666 :tag (custom-unlispify-tag-name (nth 0 entry)) |
2622 :group widget | 2667 :custom-prefixes custom-prefix-list |
2623 :tag (custom-unlispify-tag-name (nth 0 entry)) | 2668 :custom-level (1+ level) |
2624 :custom-prefixes custom-prefix-list | 2669 :custom-last (null members) |
2625 :custom-level (1+ level) | 2670 :value (nth 0 entry) |
2626 :custom-last (null members) | 2671 :custom-prefix prefix) |
2627 :value (nth 0 entry) | 2672 children)) |
2628 :custom-prefix prefix) | |
2629 children))) | |
2630 (widget-put widget :children (reverse children))) | 2673 (widget-put widget :children (reverse children))) |
2631 (message "Creating group...done"))) | 2674 (message "Creating group...done"))) |
2632 ;; Nested style. | 2675 ;; Nested style. |
2633 ((eq state 'hidden) | 2676 ((eq state 'hidden) |
2634 ;; Create level indicator. | 2677 ;; Create level indicator. |
2719 (make-string (* custom-buffer-indent level) | 2762 (make-string (* custom-buffer-indent level) |
2720 ?\ )) | 2763 ?\ )) |
2721 ;; Members. | 2764 ;; Members. |
2722 (message "Creating group...") | 2765 (message "Creating group...") |
2723 (custom-load-widget widget) | 2766 (custom-load-widget widget) |
2724 (let* ((members (custom-sort-items (get symbol 'custom-group) | 2767 (let* ((members (custom-sort-items members |
2725 custom-buffer-sort-alphabetically | 2768 custom-buffer-sort-alphabetically |
2726 custom-buffer-order-groups)) | 2769 custom-buffer-order-groups)) |
2727 (prefixes (widget-get widget :custom-prefixes)) | 2770 (prefixes (widget-get widget :custom-prefixes)) |
2728 (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2771 (custom-prefix-list (custom-prefix-add symbol prefixes)) |
2729 (length (length members)) | 2772 (length (length members)) |
2758 (insert "\\- " (widget-get widget :tag) " group end ") | 2801 (insert "\\- " (widget-get widget :tag) " group end ") |
2759 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level))) | 2802 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level))) |
2760 (insert "/\n"))))) | 2803 (insert "/\n"))))) |
2761 | 2804 |
2762 (defvar custom-group-menu | 2805 (defvar custom-group-menu |
2763 '(("Set" custom-group-set | 2806 '(("Set for Current Session" custom-group-set |
2764 (lambda (widget) | 2807 (lambda (widget) |
2765 (eq (widget-get widget :custom-state) 'modified))) | 2808 (eq (widget-get widget :custom-state) 'modified))) |
2766 ("Save" custom-group-save | 2809 ("Save for Future Sessions" custom-group-save |
2767 (lambda (widget) | 2810 (lambda (widget) |
2768 (memq (widget-get widget :custom-state) '(modified set)))) | 2811 (memq (widget-get widget :custom-state) '(modified set)))) |
2769 ("Reset to Current" custom-group-reset-current | 2812 ("Reset to Current" custom-group-reset-current |
2770 (lambda (widget) | 2813 (lambda (widget) |
2771 (memq (widget-get widget :custom-state) '(modified)))) | 2814 (memq (widget-get widget :custom-state) '(modified)))) |
2858 (custom-magic-reset widget)) | 2901 (custom-magic-reset widget)) |
2859 | 2902 |
2860 ;;; The `custom-save-all' Function. | 2903 ;;; The `custom-save-all' Function. |
2861 ;;;###autoload | 2904 ;;;###autoload |
2862 (defcustom custom-file (if (boundp 'emacs-user-extension-dir) | 2905 (defcustom custom-file (if (boundp 'emacs-user-extension-dir) |
2863 (concat emacs-user-extension-dir "options.el") | 2906 (concat "~" |
2907 init-file-user | |
2908 emacs-user-extension-dir | |
2909 "options.el") | |
2864 "~/.emacs") | 2910 "~/.emacs") |
2865 "File used for storing customization information. | 2911 "File used for storing customization information. |
2866 If you change this from the default \"~/.emacs\" you need to | 2912 If you change this from the default \"~/.emacs\" you need to |
2867 explicitly load that file for the settings to take effect." | 2913 explicitly load that file for the settings to take effect." |
2868 :type 'file | 2914 :type 'file |
2893 (let ((standard-output (current-buffer))) | 2939 (let ((standard-output (current-buffer))) |
2894 (unless (bolp) | 2940 (unless (bolp) |
2895 (princ "\n")) | 2941 (princ "\n")) |
2896 (princ "(custom-set-variables") | 2942 (princ "(custom-set-variables") |
2897 (mapatoms (lambda (symbol) | 2943 (mapatoms (lambda (symbol) |
2898 (let ((value (condition-case nil | 2944 (let ((value (get symbol 'saved-value)) |
2899 (get symbol 'saved-value) | |
2900 (t (progn | |
2901 (message "Bad plist in %s" | |
2902 (symbol-name symbol)) | |
2903 nil)))) | |
2904 (requests (get symbol 'custom-requests)) | 2945 (requests (get symbol 'custom-requests)) |
2905 (now (not (or (get symbol 'standard-value) | 2946 (now (not (or (get symbol 'standard-value) |
2906 (and (not (boundp symbol)) | 2947 (and (not (boundp symbol)) |
2907 (not (get symbol 'force-value))))))) | 2948 (not (get symbol 'force-value))))))) |
2908 (when value | 2949 (when value |
2941 (and (not (custom-facep 'default)) | 2982 (and (not (custom-facep 'default)) |
2942 (not (get 'default 'force-face)))) | 2983 (not (get 'default 'force-face)))) |
2943 (princ ")") | 2984 (princ ")") |
2944 (princ " t)")))) | 2985 (princ " t)")))) |
2945 (mapatoms (lambda (symbol) | 2986 (mapatoms (lambda (symbol) |
2946 (let ((value (condition-case nil | 2987 (let ((value (get symbol 'saved-face))) |
2947 (get symbol 'saved-face) | |
2948 (t (progn | |
2949 (message "Bad plist in %s" | |
2950 (symbol-name symbol))) | |
2951 nil)))) | |
2952 (when (and (not (eq symbol 'default)) | 2988 (when (and (not (eq symbol 'default)) |
2953 ;; Don't print default face here. | 2989 ;; Don't print default face here. |
2954 value) | 2990 value) |
2955 (princ "\n '(") | 2991 (princ "\n '(") |
2956 (princ symbol) | 2992 (princ symbol) |
2968 ;;;###autoload | 3004 ;;;###autoload |
2969 (defun customize-save-customized () | 3005 (defun customize-save-customized () |
2970 "Save all user options which have been set in this session." | 3006 "Save all user options which have been set in this session." |
2971 (interactive) | 3007 (interactive) |
2972 (mapatoms (lambda (symbol) | 3008 (mapatoms (lambda (symbol) |
2973 (condition-case nil | 3009 (let ((face (get symbol 'customized-face)) |
2974 (let ((face (get symbol 'customized-face)) | 3010 (value (get symbol 'customized-value))) |
2975 (value (get symbol 'customized-value))) | 3011 (when face |
2976 (when face | 3012 (put symbol 'saved-face face) |
2977 (put symbol 'saved-face face) | 3013 (put symbol 'customized-face nil)) |
2978 (put symbol 'customized-face nil)) | 3014 (when value |
2979 (when value | 3015 (put symbol 'saved-value value) |
2980 (put symbol 'saved-value value) | 3016 (put symbol 'customized-value nil))))) |
2981 (put symbol 'customized-value nil))) | |
2982 (t (message "Bad plist in %s" | |
2983 (symbol-name symbol)))))) | |
2984 ;; We really should update all custom buffers here. | 3017 ;; We really should update all custom buffers here. |
2985 (custom-save-all)) | 3018 (custom-save-all)) |
2986 | 3019 |
2987 ;;;###autoload | 3020 ;;;###autoload |
2988 (defun custom-save-all () | 3021 (defun custom-save-all () |
2989 "Save all customizations in `custom-file'." | 3022 "Save all customizations in `custom-file'." |
2990 (custom-save-variables) | 3023 (let ((inhibit-read-only t)) |
2991 (custom-save-faces) | 3024 (custom-save-variables) |
2992 (save-excursion | 3025 (custom-save-faces) |
2993 (set-buffer (find-file-noselect custom-file)) | 3026 (save-excursion |
2994 (save-buffer))) | 3027 (set-buffer (find-file-noselect custom-file)) |
3028 (save-buffer)))) | |
2995 | 3029 |
2996 ;;; The Customize Menu. | 3030 ;;; The Customize Menu. |
2997 | 3031 |
2998 ;;; Menu support | 3032 ;;; Menu support |
2999 | 3033 |
3132 (set-keymap-parent custom-mode-map widget-keymap) | 3166 (set-keymap-parent custom-mode-map widget-keymap) |
3133 (suppress-keymap custom-mode-map) | 3167 (suppress-keymap custom-mode-map) |
3134 (define-key custom-mode-map " " 'scroll-up) | 3168 (define-key custom-mode-map " " 'scroll-up) |
3135 (define-key custom-mode-map "\177" 'scroll-down) | 3169 (define-key custom-mode-map "\177" 'scroll-down) |
3136 (define-key custom-mode-map "q" 'bury-buffer) | 3170 (define-key custom-mode-map "q" 'bury-buffer) |
3137 (define-key custom-mode-map "u" 'Custom-goto-parent)) | 3171 (define-key custom-mode-map "u" 'Custom-goto-parent) |
3172 ;; (define-key custom-mode-map [mouse-1] 'Custom-move-and-invoke) | |
3173 ) | |
3174 | |
3175 (defun Custom-move-and-invoke (event) | |
3176 "Move to where you click, and if it is an active field, invoke it." | |
3177 (interactive "e") | |
3178 (mouse-set-point event) | |
3179 (if (widget-event-point event) | |
3180 (let* ((pos (widget-event-point event)) | |
3181 (button (get-char-property pos 'button))) | |
3182 (if button | |
3183 (widget-button-click event))))) | |
3138 | 3184 |
3139 (easy-menu-define Custom-mode-menu | 3185 (easy-menu-define Custom-mode-menu |
3140 custom-mode-map | 3186 custom-mode-map |
3141 "Menu used in customization buffers." | 3187 "Menu used in customization buffers." |
3142 `("Custom" | 3188 `("Custom" |
3173 | 3219 |
3174 The following commands are available: | 3220 The following commands are available: |
3175 | 3221 |
3176 Move to next button or editable field. \\[widget-forward] | 3222 Move to next button or editable field. \\[widget-forward] |
3177 Move to previous button or editable field. \\[widget-backward] | 3223 Move to previous button or editable field. \\[widget-backward] |
3178 Invoke button under the mouse pointer. \\[widget-button-click] | 3224 \\<widget-field-keymap>\ |
3225 Complete content of editable text field. \\[widget-complete] | |
3226 \\<custom-mode-map>\ | |
3227 Invoke button under the mouse pointer. \\[Custom-move-and-invoke] | |
3179 Invoke button under point. \\[widget-button-press] | 3228 Invoke button under point. \\[widget-button-press] |
3180 Set all modifications. \\[Custom-set] | 3229 Set all modifications. \\[Custom-set] |
3181 Make all modifications default. \\[Custom-save] | 3230 Make all modifications default. \\[Custom-save] |
3182 Reset all modified options. \\[Custom-reset-current] | 3231 Reset all modified options. \\[Custom-reset-current] |
3183 Reset all modified or set options. \\[Custom-reset-saved] | 3232 Reset all modified or set options. \\[Custom-reset-saved] |
3191 (use-local-map custom-mode-map) | 3240 (use-local-map custom-mode-map) |
3192 (easy-menu-add Custom-mode-menu) | 3241 (easy-menu-add Custom-mode-menu) |
3193 (make-local-variable 'custom-options) | 3242 (make-local-variable 'custom-options) |
3194 (make-local-variable 'widget-documentation-face) | 3243 (make-local-variable 'widget-documentation-face) |
3195 (setq widget-documentation-face 'custom-documentation-face) | 3244 (setq widget-documentation-face 'custom-documentation-face) |
3245 (make-local-variable 'widget-button-face) | |
3246 (setq widget-button-face 'custom-button-face) | |
3196 (make-local-hook 'widget-edit-functions) | 3247 (make-local-hook 'widget-edit-functions) |
3197 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t) | 3248 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t) |
3198 (run-hooks 'custom-mode-hook)) | 3249 (run-hooks 'custom-mode-hook)) |
3199 | 3250 |
3200 ;;; The End. | 3251 ;;; The End. |