Mercurial > hg > xemacs-beta
comparison lisp/custom/cus-edit.el @ 155:43dd3413c7c7 r20-3b4
Import from CVS: tag r20-3b4
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:39:39 +0200 |
parents | 25f70ba0133c |
children | 6b37e6ddd302 |
comparison
equal
deleted
inserted
replaced
154:94141801dd7e | 155:43dd3413c7c7 |
---|---|
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.98 | 7 ;; Version: 1.9907 |
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 |
39 | 39 |
40 (condition-case nil | 40 (condition-case nil |
41 (require 'cus-load) | 41 (require 'cus-load) |
42 (error nil)) | 42 (error nil)) |
43 | 43 |
44 (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 | |
45 :custom-magic :custom-state :custom-level :custom-form | 50 :custom-magic :custom-state :custom-level :custom-form |
46 :custom-set :custom-save :custom-reset-current :custom-reset-saved | 51 :custom-set :custom-save :custom-reset-current :custom-reset-saved |
47 :custom-reset-standard) | 52 :custom-reset-standard) |
48 | 53 |
49 (put 'custom-define-hook 'custom-type 'hook) | 54 (put 'custom-define-hook 'custom-type 'hook) |
305 (defgroup menu nil | 310 (defgroup menu nil |
306 "Input from the menus." | 311 "Input from the menus." |
307 :group 'environment) | 312 :group 'environment) |
308 | 313 |
309 (defgroup auto-save nil | 314 (defgroup auto-save nil |
310 "Preventing accidental loss of data." | 315 "Preventing accidential loss of data." |
311 :group 'data) | 316 :group 'data) |
312 | 317 |
313 (defgroup processes-basics nil | 318 (defgroup processes-basics nil |
314 "Basic stuff dealing with processes." | 319 "Basic stuff dealing with processes." |
315 :group 'processes) | 320 :group 'processes) |
316 | 321 |
317 (defgroup mule nil | 322 (defgroup mule nil |
318 "MULE Emacs internationalization." | 323 "MULE Emacs internationalization." |
319 :group 'emacs) | 324 :group 'i18n) |
320 | 325 |
321 (defgroup windows nil | 326 (defgroup windows nil |
322 "Windows within a frame." | 327 "Windows within a frame." |
323 :group 'environment) | 328 :group 'environment) |
324 | 329 |
359 Return a list suitable for use in `interactive'." | 364 Return a list suitable for use in `interactive'." |
360 (let ((v (variable-at-point)) | 365 (let ((v (variable-at-point)) |
361 (enable-recursive-minibuffers t) | 366 (enable-recursive-minibuffers t) |
362 val) | 367 val) |
363 (setq val (completing-read | 368 (setq val (completing-read |
364 (if v | 369 (if (symbolp v) |
365 (format "Customize variable: (default %s) " v) | 370 (format "Customize variable: (default %s) " v) |
366 "Customize variable: ") | 371 "Customize variable: ") |
367 obarray (lambda (symbol) | 372 obarray (lambda (symbol) |
368 (and (boundp symbol) | 373 (and (boundp symbol) |
369 (or (get symbol 'custom-type) | 374 (or (get symbol 'custom-type) |
370 (user-variable-p symbol)))))) | 375 (user-variable-p symbol)))))) |
371 (list (if (equal val "") | 376 (list (if (equal val "") |
372 v (intern val))))) | 377 (if (symbolp v) v nil) |
378 (intern val))))) | |
373 | 379 |
374 (defun custom-menu-filter (menu widget) | 380 (defun custom-menu-filter (menu widget) |
375 "Convert MENU to the form used by `widget-choose'. | 381 "Convert MENU to the form used by `widget-choose'. |
376 MENU should be in the same format as `custom-variable-menu'. | 382 MENU should be in the same format as `custom-variable-menu'. |
377 WIDGET is the widget to apply the filter entries of MENU on." | 383 WIDGET is the widget to apply the filter entries of MENU on." |
508 (when (string-match (nth 0 current) doc) | 514 (when (string-match (nth 0 current) doc) |
509 (setq found (nth 1 current) | 515 (setq found (nth 1 current) |
510 docs nil)))))) | 516 docs nil)))))) |
511 found)) | 517 found)) |
512 | 518 |
519 ;;; Sorting. | |
520 | |
521 (defcustom custom-buffer-sort-predicate 'custom-buffer-sort-alphabetically | |
522 "Function used for sorting group members in buffers. | |
523 The value should be useful as a predicate for `sort'. | |
524 The list to be sorted is the value of the groups `custom-group' property." | |
525 :type '(radio (function-item custom-buffer-sort-alphabetically) | |
526 (function :tag "Other")) | |
527 :group 'customize) | |
528 | |
529 (defun custom-buffer-sort-alphabetically (a b) | |
530 "Return t iff is A should be before B. | |
531 A and B should be members of a `custom-group' property. | |
532 The members are sorted alphabetically, except that all groups are | |
533 sorted after all non-groups." | |
534 (cond ((and (eq (nth 1 a) 'custom-group) | |
535 (not (eq (nth 1 b) 'custom-group))) | |
536 nil) | |
537 ((and (eq (nth 1 b) 'custom-group) | |
538 (not (eq (nth 1 a) 'custom-group))) | |
539 t) | |
540 (t | |
541 (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b)))))) | |
542 | |
543 (defcustom custom-menu-sort-predicate 'custom-menu-sort-alphabetically | |
544 "Function used for sorting group members in menus. | |
545 The value should be useful as a predicate for `sort'. | |
546 The list to be sorted is the value of the groups `custom-group' property." | |
547 :type '(radio (function-item custom-menu-sort-alphabetically) | |
548 (function :tag "Other")) | |
549 :group 'customize) | |
550 | |
551 (defun custom-menu-sort-alphabetically (a b) | |
552 "Return t iff is A should be before B. | |
553 A and B should be members of a `custom-group' property. | |
554 The members are sorted alphabetically, except that all groups are | |
555 sorted before all non-groups." | |
556 (cond ((and (eq (nth 1 a) 'custom-group) | |
557 (not (eq (nth 1 b) 'custom-group))) | |
558 t) | |
559 ((and (eq (nth 1 b) 'custom-group) | |
560 (not (eq (nth 1 a) 'custom-group))) | |
561 nil) | |
562 (t | |
563 (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b)))))) | |
564 | |
513 ;;; Custom Mode Commands. | 565 ;;; Custom Mode Commands. |
514 | 566 |
515 (defvar custom-options nil | 567 (defvar custom-options nil |
516 "Customization widgets in the current buffer.") | 568 "Customization widgets in the current buffer.") |
517 | 569 |
550 custom-reset-menu | 602 custom-reset-menu |
551 event))) | 603 event))) |
552 (if answer | 604 (if answer |
553 (funcall answer)))) | 605 (funcall answer)))) |
554 | 606 |
555 (defun custom-reset-current () | 607 (defun custom-reset-current (&rest ignore) |
556 "Reset all modified group members to their current value." | 608 "Reset all modified group members to their current value." |
557 (interactive) | 609 (interactive) |
558 (let ((children custom-options)) | 610 (let ((children custom-options)) |
559 (mapcar (lambda (child) | 611 (mapcar (lambda (child) |
560 (when (eq (widget-get child :custom-state) 'modified) | 612 (when (eq (widget-get child :custom-state) 'modified) |
561 (widget-apply child :custom-reset-current))) | 613 (widget-apply child :custom-reset-current))) |
562 children))) | 614 children))) |
563 | 615 |
564 (defun custom-reset-saved () | 616 (defun custom-reset-saved (&rest ignore) |
565 "Reset all modified or set group members to their saved value." | 617 "Reset all modified or set group members to their saved value." |
566 (interactive) | 618 (interactive) |
567 (let ((children custom-options)) | 619 (let ((children custom-options)) |
568 (mapcar (lambda (child) | 620 (mapcar (lambda (child) |
569 (when (eq (widget-get child :custom-state) 'modified) | 621 (when (eq (widget-get child :custom-state) 'modified) |
570 (widget-apply child :custom-reset-current))) | 622 (widget-apply child :custom-reset-current))) |
571 children))) | 623 children))) |
572 | 624 |
573 (defun custom-reset-standard () | 625 (defun custom-reset-standard (&rest ignore) |
574 "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." |
575 (interactive) | 627 (interactive) |
576 (let ((children custom-options)) | 628 (let ((children custom-options)) |
577 (mapcar (lambda (child) | 629 (mapcar (lambda (child) |
578 (when (eq (widget-get child :custom-state) 'modified) | 630 (when (eq (widget-get child :custom-state) 'modified) |
691 (custom-buffer-create-other-window | 743 (custom-buffer-create-other-window |
692 (list (list symbol 'custom-group)) | 744 (list (list symbol 'custom-group)) |
693 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol)))) | 745 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol)))) |
694 | 746 |
695 ;;;###autoload | 747 ;;;###autoload |
696 (defun customize-variable (symbol) | 748 (defalias 'customize-variable 'customize-option) |
697 "Customize SYMBOL, which must be a variable." | 749 |
750 ;;;###autoload | |
751 (defun customize-option (symbol) | |
752 "Customize SYMBOL, which must be a user option variable." | |
698 (interactive (custom-variable-prompt)) | 753 (interactive (custom-variable-prompt)) |
699 (custom-buffer-create (list (list symbol 'custom-variable)) | 754 (custom-buffer-create (list (list symbol 'custom-variable)) |
700 (format "*Customize Variable: %s*" | 755 (format "*Customize Option: %s*" |
701 (custom-unlispify-tag-name symbol)))) | 756 (custom-unlispify-tag-name symbol)))) |
702 | 757 |
703 ;;;###autoload | 758 ;;;###autoload |
704 (defun customize-variable-other-window (symbol) | 759 (defalias 'customize-variable-other-window 'customize-option-other-window) |
705 "Customize SYMBOL, which must be a variable. | 760 |
761 ;;;###autoload | |
762 (defun customize-option-other-window (symbol) | |
763 "Customize SYMBOL, which must be a user option variable. | |
706 Show the buffer in another window, but don't select it." | 764 Show the buffer in another window, but don't select it." |
707 (interactive (custom-variable-prompt)) | 765 (interactive (custom-variable-prompt)) |
708 (custom-buffer-create-other-window | 766 (custom-buffer-create-other-window |
709 (list (list symbol 'custom-variable)) | 767 (list (list symbol 'custom-variable)) |
710 (format "*Customize Variable: %s*" (custom-unlispify-tag-name symbol)))) | 768 (format "*Customize Option: %s*" (custom-unlispify-tag-name symbol)))) |
711 | 769 |
712 ;;;###autoload | 770 ;;;###autoload |
713 (defun customize-face (&optional symbol) | 771 (defun customize-face (&optional symbol) |
714 "Customize SYMBOL, which should be a face name or nil. | 772 "Customize SYMBOL, which should be a face name or nil. |
715 If SYMBOL is nil, customize all faces." | 773 If SYMBOL is nil, customize all faces." |
832 (kill-buffer (get-buffer-create name)) | 890 (kill-buffer (get-buffer-create name)) |
833 (let ((window (selected-window))) | 891 (let ((window (selected-window))) |
834 (switch-to-buffer-other-window (get-buffer-create name)) | 892 (switch-to-buffer-other-window (get-buffer-create name)) |
835 (custom-buffer-create-internal options) | 893 (custom-buffer-create-internal options) |
836 (select-window window))) | 894 (select-window window))) |
837 | 895 |
896 (defcustom custom-reset-button-menu nil | |
897 "If non-nil, only show a single reset button in customize buffers. | |
898 This button will have a menu with all three reset operations." | |
899 :type 'boolean | |
900 :group 'customize) | |
838 | 901 |
839 (defun custom-buffer-create-internal (options) | 902 (defun custom-buffer-create-internal (options) |
840 (message "Creating customization buffer...") | 903 (message "Creating customization buffer...") |
841 (custom-mode) | 904 (custom-mode) |
842 (widget-insert "This is a customization buffer. | 905 (widget-insert "This is a customization buffer. |
843 Push RET or click mouse-2 on the word ") | 906 Push RET or click mouse-2 on the word ") |
844 ;; (put-text-property 1 2 'start-open nil) | |
845 (widget-create 'info-link | 907 (widget-create 'info-link |
846 :tag "help" | 908 :tag "help" |
847 :help-echo "Read the online help." | 909 :help-echo "Read the online help." |
848 "(custom)The Customization Buffer") | 910 "(emacs)Easy Customization") |
849 (widget-insert " for more information.\n\n") | 911 (widget-insert " for more information.\n\n") |
850 (message "Creating customization buttons...") | 912 (message "Creating customization buttons...") |
851 (widget-create 'push-button | 913 (widget-create 'push-button |
852 :tag "Set" | 914 :tag "Set" |
853 :help-echo "Set all modifications for this session." | 915 :help-echo "Set all modifications for this session." |
859 :help-echo "\ | 921 :help-echo "\ |
860 Make the modifications default for future sessions." | 922 Make the modifications default for future sessions." |
861 :action (lambda (widget &optional event) | 923 :action (lambda (widget &optional event) |
862 (custom-save))) | 924 (custom-save))) |
863 (widget-insert " ") | 925 (widget-insert " ") |
864 (widget-create 'push-button | 926 (if custom-reset-button-menu |
865 :tag "Reset" | 927 (widget-create 'push-button |
866 :help-echo "Undo all modifications." | 928 :tag "Reset" |
867 :action (lambda (widget &optional event) | 929 :help-echo "Show a menu with reset operations." |
868 (custom-reset event))) | 930 :mouse-down-action (lambda (&rest junk) t) |
931 :action (lambda (widget &optional event) | |
932 (custom-reset event))) | |
933 (widget-create 'push-button | |
934 :tag "Reset" | |
935 :help-echo "\ | |
936 Reset all visible items in this buffer to their current settings." | |
937 :action 'custom-reset-current) | |
938 (widget-insert " ") | |
939 (widget-create 'push-button | |
940 :tag "Reset to Saved" | |
941 :help-echo "\ | |
942 Reset all visible items in this buffer to their saved settings." | |
943 :action 'custom-reset-saved) | |
944 (widget-insert " ") | |
945 (widget-create 'push-button | |
946 :tag "Reset to Standard" | |
947 :help-echo "\ | |
948 Reset all visible items in this buffer to their standard settings." | |
949 :action 'custom-reset-standard)) | |
869 (widget-insert " ") | 950 (widget-insert " ") |
870 (widget-create 'push-button | 951 (widget-create 'push-button |
871 :tag "Done" | 952 :tag "Done" |
872 :help-echo "Bury the buffer." | 953 :help-echo "Bury the buffer." |
873 :action (lambda (widget &optional event) | 954 :action (lambda (widget &optional event) |
903 (message "Creating customization magic...") | 984 (message "Creating customization magic...") |
904 (mapcar 'custom-magic-reset custom-options) | 985 (mapcar 'custom-magic-reset custom-options) |
905 (message "Creating customization setup...") | 986 (message "Creating customization setup...") |
906 (widget-setup) | 987 (widget-setup) |
907 (goto-char (point-min)) | 988 (goto-char (point-min)) |
908 (when (fboundp 'map-extents) | |
909 ;; This horrible kludge should make bob and eob read-only in XEmacs. | |
910 (map-extents (lambda (extent &rest junk) | |
911 (set-extent-property extent 'start-closed t)) | |
912 nil (point-min) (1+ (point-min))) | |
913 (map-extents (lambda (extent &rest junk) | |
914 (set-extent-property extent 'end-closed t)) | |
915 nil (1- (point-max)) (point-max))) | |
916 (message "Creating customization buffer...done")) | 989 (message "Creating customization buffer...done")) |
917 | 990 |
918 ;;; Modification of Basic Widgets. | 991 ;;; Modification of Basic Widgets. |
919 ;; | 992 ;; |
920 ;; We add extra properties to the basic widgets needed here. This is | 993 ;; We add extra properties to the basic widgets needed here. This is |
979 (defconst custom-magic-alist '((nil "#" underline "\ | 1052 (defconst custom-magic-alist '((nil "#" underline "\ |
980 uninitialized, you should not see this.") | 1053 uninitialized, you should not see this.") |
981 (unknown "?" italic "\ | 1054 (unknown "?" italic "\ |
982 unknown, you should not see this.") | 1055 unknown, you should not see this.") |
983 (hidden "-" default "\ | 1056 (hidden "-" default "\ |
984 hidden, activate the state button to show." "\ | 1057 hidden, invoke the dots above to show." "\ |
985 the group members are hidden, activate the state button to show them.") | 1058 group now hidden, invoke the dots above to show contents.") |
986 (invalid "x" custom-invalid-face "\ | 1059 (invalid "x" custom-invalid-face "\ |
987 the value displayed for this item is invalid and cannot be set.") | 1060 the value displayed for this %c is invalid and cannot be set.") |
988 (modified "*" custom-modified-face "\ | 1061 (modified "*" custom-modified-face "\ |
989 you have edited the item, and can now set it." "\ | 1062 you have edited the value, and can now set the %c." "\ |
990 you have edited something in this group, and can now set it.") | 1063 you have edited something in this group, and can now set it.") |
991 (set "+" custom-set-face "\ | 1064 (set "+" custom-set-face "\ |
992 you have set this item, but not saved it." "\ | 1065 you have set this %c, but not saved it." "\ |
993 something in this group has been set, but not yet saved.") | 1066 something in this group has been set, but not yet saved.") |
994 (changed ":" custom-changed-face "\ | 1067 (changed ":" custom-changed-face "\ |
995 this item has been changed outside customize." "\ | 1068 this %c has been changed outside the customize buffer." "\ |
996 something in this group has been changed outside customize.") | 1069 something in this group has been changed outside customize.") |
997 (saved "!" custom-saved-face "\ | 1070 (saved "!" custom-saved-face "\ |
998 this item has been set and saved." "\ | 1071 this %c has been set and saved." "\ |
999 something in this group has been set and saved.") | 1072 something in this group has been set and saved.") |
1000 (rogue "@" custom-rogue-face "\ | 1073 (rogue "@" custom-rogue-face "\ |
1001 this item has not been changed with customize." "\ | 1074 this %c has not been changed with customize." "\ |
1002 something in this group is not prepared for customization.") | 1075 something in this group is not prepared for customization.") |
1003 (standard " " nil "\ | 1076 (standard " " nil "\ |
1004 this item is unchanged from its standard setting." "\ | 1077 this %c is unchanged from its standard setting." "\ |
1005 the visible members of this group are all at their standard settings.")) | 1078 visible group members are all at standard settings.")) |
1006 "Alist of customize option states. | 1079 "Alist of customize option states. |
1007 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where | 1080 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where |
1008 | 1081 |
1009 STATE is one of the following symbols: | 1082 STATE is one of the following symbols: |
1010 | 1083 |
1036 ITEM-DESC is a string describing the state for options. | 1109 ITEM-DESC is a string describing the state for options. |
1037 | 1110 |
1038 GROUP-DESC is a string describing the state for groups. If this is | 1111 GROUP-DESC is a string describing the state for groups. If this is |
1039 left out, ITEM-DESC will be used. | 1112 left out, ITEM-DESC will be used. |
1040 | 1113 |
1114 The string %c in either description will be replaced with the | |
1115 category of the item. These are `group'. `option', and `face'. | |
1116 | |
1041 The list should be sorted most significant first.") | 1117 The list should be sorted most significant first.") |
1042 | 1118 |
1043 (defcustom custom-magic-show 'long | 1119 (defcustom custom-magic-show 'long |
1044 "Show long description of the state of each customization option." | 1120 "If non-nil, show textual description of the state. |
1121 If non-nil and not the symbol `long', only show first word." | |
1045 :type '(choice (const :tag "no" nil) | 1122 :type '(choice (const :tag "no" nil) |
1046 (const short) | 1123 (const short) |
1047 (const long)) | 1124 (const long)) |
1125 :group 'customize) | |
1126 | |
1127 (defcustom custom-magic-show-hidden '(option face) | |
1128 "Control whether the state button is shown for hidden items. | |
1129 The value should be a list with the custom categories where the state | |
1130 button should be visible. Possible categories are `group', `option', | |
1131 and `face'." | |
1132 :type '(set (const group) (const option) (const face)) | |
1048 :group 'customize) | 1133 :group 'customize) |
1049 | 1134 |
1050 (defcustom custom-magic-show-button nil | 1135 (defcustom custom-magic-show-button nil |
1051 "Show a magic button indicating the state of each customization option." | 1136 "Show a magic button indicating the state of each customization option." |
1052 :type 'boolean | 1137 :type 'boolean |
1069 | 1154 |
1070 (defun custom-magic-value-create (widget) | 1155 (defun custom-magic-value-create (widget) |
1071 ;; Create compact status report for WIDGET. | 1156 ;; Create compact status report for WIDGET. |
1072 (let* ((parent (widget-get widget :parent)) | 1157 (let* ((parent (widget-get widget :parent)) |
1073 (state (widget-get parent :custom-state)) | 1158 (state (widget-get parent :custom-state)) |
1159 (hidden (eq state 'hidden)) | |
1074 (entry (assq state custom-magic-alist)) | 1160 (entry (assq state custom-magic-alist)) |
1075 (magic (nth 1 entry)) | 1161 (magic (nth 1 entry)) |
1076 (face (nth 2 entry)) | 1162 (face (nth 2 entry)) |
1077 (text (or (and (eq (widget-type parent) 'custom-group) | 1163 (category (widget-get parent :custom-category)) |
1164 (text (or (and (eq category 'group) | |
1078 (nth 4 entry)) | 1165 (nth 4 entry)) |
1079 (nth 3 entry))) | 1166 (nth 3 entry))) |
1080 (lisp (eq (widget-get parent :custom-form) 'lisp)) | 1167 (lisp (eq (widget-get parent :custom-form) 'lisp)) |
1081 children) | 1168 children) |
1082 (when custom-magic-show | 1169 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text) |
1170 (setq text (concat (match-string 1 text) | |
1171 (symbol-name category) | |
1172 (match-string 2 text)))) | |
1173 (when (and custom-magic-show | |
1174 (or (not hidden) | |
1175 (memq category custom-magic-show-hidden))) | |
1176 (insert " ") | |
1083 (push (widget-create-child-and-convert | 1177 (push (widget-create-child-and-convert |
1084 widget 'choice-item | 1178 widget 'choice-item |
1085 :help-echo "\ | 1179 :help-echo "Change the state of this item." |
1086 Change the state of this item." | 1180 :format (if hidden "%t" "%[%t%]") |
1087 :format "%[%t%]" | 1181 :button-prefix 'widget-push-button-prefix |
1182 :button-suffix 'widget-push-button-suffix | |
1088 :mouse-down-action 'widget-magic-mouse-down-action | 1183 :mouse-down-action 'widget-magic-mouse-down-action |
1089 :tag "State") | 1184 :tag "State") |
1090 children) | 1185 children) |
1091 (insert ": ") | 1186 (insert ": ") |
1092 (if (eq custom-magic-show 'long) | 1187 (if (eq custom-magic-show 'long) |
1102 (insert-char ? indent)))) | 1197 (insert-char ? indent)))) |
1103 (push (widget-create-child-and-convert | 1198 (push (widget-create-child-and-convert |
1104 widget 'choice-item | 1199 widget 'choice-item |
1105 :mouse-down-action 'widget-magic-mouse-down-action | 1200 :mouse-down-action 'widget-magic-mouse-down-action |
1106 :button-face face | 1201 :button-face face |
1202 :button-prefix "" | |
1203 :button-suffix "" | |
1107 :help-echo "Change the state." | 1204 :help-echo "Change the state." |
1108 :format "%[%t%]" | 1205 :format (if hidden "%t" "%[%t%]") |
1109 :tag (if lisp | 1206 :tag (if lisp |
1110 (concat "(" magic ")") | 1207 (concat "(" magic ")") |
1111 (concat "[" magic "]"))) | 1208 (concat "[" magic "]"))) |
1112 children) | 1209 children) |
1113 (insert " ")) | 1210 (insert " ")) |
1149 (let* ((buttons (widget-get widget :buttons)) | 1246 (let* ((buttons (widget-get widget :buttons)) |
1150 (state (widget-get widget :custom-state)) | 1247 (state (widget-get widget :custom-state)) |
1151 (level (widget-get widget :custom-level))) | 1248 (level (widget-get widget :custom-level))) |
1152 (cond ((eq escape ?l) | 1249 (cond ((eq escape ?l) |
1153 (when level | 1250 (when level |
1154 (push (widget-create-child-and-convert | 1251 (insert-char ?\ (1- level)) |
1155 widget 'item :format "%v " (make-string level ?*)) | 1252 (if (eq state 'hidden) |
1156 buttons) | 1253 (insert-char ?- (1+ level)) |
1157 (widget-put widget :buttons buttons))) | 1254 (insert "/") |
1255 (insert-char ?- level)))) | |
1256 ((eq escape ?e) | |
1257 (when (and level (not (eq state 'hidden))) | |
1258 (insert "\n") | |
1259 (insert-char ?\ (1- level)) | |
1260 (insert "\\") | |
1261 (insert-char ?- level) | |
1262 (insert " " (widget-get widget :tag) " group end ") | |
1263 (insert-char ?- (- 75 (current-column) level)) | |
1264 (insert "/\n"))) | |
1265 ((eq escape ?-) | |
1266 (when (and level (not (eq state 'hidden))) | |
1267 (insert-char ?- (- 76 (current-column) level)) | |
1268 (insert "\\"))) | |
1158 ((eq escape ?L) | 1269 ((eq escape ?L) |
1159 (when (eq state 'hidden) | 1270 (push (widget-create-child-and-convert |
1160 (widget-insert " ..."))) | 1271 widget 'visibility |
1272 :action 'custom-toggle-parent | |
1273 (not (eq state 'hidden))) | |
1274 buttons)) | |
1161 ((eq escape ?m) | 1275 ((eq escape ?m) |
1162 (and (eq (preceding-char) ?\n) | 1276 (and (eq (preceding-char) ?\n) |
1163 (widget-get widget :indent) | 1277 (widget-get widget :indent) |
1164 (insert-char ? (widget-get widget :indent))) | 1278 (insert-char ? (widget-get widget :indent))) |
1165 (let ((magic (widget-create-child-and-convert | 1279 (let ((magic (widget-create-child-and-convert |
1166 widget 'custom-magic nil))) | 1280 widget 'custom-magic nil))) |
1167 (widget-put widget :custom-magic magic) | 1281 (widget-put widget :custom-magic magic) |
1168 (push magic buttons) | 1282 (push magic buttons) |
1169 (widget-put widget :buttons buttons))) | 1283 (widget-put widget :buttons buttons))) |
1170 ((eq escape ?a) | 1284 ((eq escape ?a) |
1171 (let* ((symbol (widget-get widget :value)) | 1285 (unless (eq state 'hidden) |
1172 (links (get symbol 'custom-links)) | 1286 (let* ((symbol (widget-get widget :value)) |
1173 (many (> (length links) 2))) | 1287 (links (get symbol 'custom-links)) |
1174 (when links | 1288 (many (> (length links) 2))) |
1175 (and (eq (preceding-char) ?\n) | 1289 (when links |
1176 (widget-get widget :indent) | 1290 (and (eq (preceding-char) ?\n) |
1177 (insert-char ? (widget-get widget :indent))) | 1291 (widget-get widget :indent) |
1178 (insert "See also ") | 1292 (insert-char ? (widget-get widget :indent))) |
1179 (while links | 1293 (insert "See also ") |
1180 (push (widget-create-child-and-convert widget (car links)) | 1294 (while links |
1181 buttons) | 1295 (push (widget-create-child-and-convert widget (car links)) |
1182 (setq links (cdr links)) | 1296 buttons) |
1183 (cond ((null links) | 1297 (setq links (cdr links)) |
1184 (insert ".\n")) | 1298 (cond ((null links) |
1185 ((null (cdr links)) | 1299 (insert ".\n")) |
1186 (if many | 1300 ((null (cdr links)) |
1187 (insert ", and ") | 1301 (if many |
1188 (insert " and "))) | 1302 (insert ", and ") |
1189 (t | 1303 (insert " and "))) |
1190 (insert ", ")))) | 1304 (t |
1191 (widget-put widget :buttons buttons)))) | 1305 (insert ", ")))) |
1306 (widget-put widget :buttons buttons))))) | |
1192 (t | 1307 (t |
1193 (widget-default-format-handler widget escape))))) | 1308 (widget-default-format-handler widget escape))))) |
1194 | 1309 |
1195 (defun custom-notify (widget &rest args) | 1310 (defun custom-notify (widget &rest args) |
1196 "Keep track of changes." | 1311 "Keep track of changes." |
1197 (unless (memq (widget-get widget :custom-state) '(nil unknown hidden)) | 1312 (let ((state (widget-get widget :custom-state))) |
1198 (widget-put widget :custom-state 'modified)) | 1313 (unless (eq state 'modified) |
1199 (let ((buffer-undo-list t)) | 1314 (unless (memq state '(nil unknown hidden)) |
1200 (custom-magic-reset widget)) | 1315 (widget-put widget :custom-state 'modified)) |
1201 (apply 'widget-default-notify widget args)) | 1316 (custom-magic-reset widget) |
1317 (apply 'widget-default-notify widget args)))) | |
1202 | 1318 |
1203 (defun custom-redraw (widget) | 1319 (defun custom-redraw (widget) |
1204 "Redraw WIDGET with current settings." | 1320 "Redraw WIDGET with current settings." |
1205 (let ((line (count-lines (point-min) (point))) | 1321 (let ((line (count-lines (point-min) (point))) |
1206 (column (current-column)) | 1322 (column (current-column)) |
1254 loads (cdr loads)) | 1370 loads (cdr loads)) |
1255 (cond ((symbolp load) | 1371 (cond ((symbolp load) |
1256 (condition-case nil | 1372 (condition-case nil |
1257 (require load) | 1373 (require load) |
1258 (error nil))) | 1374 (error nil))) |
1375 ;; Don't reload a file already loaded. | |
1259 ((assoc load load-history)) | 1376 ((assoc load load-history)) |
1377 ((assoc (locate-library load) load-history)) | |
1260 (t | 1378 (t |
1261 (condition-case nil | 1379 (condition-case nil |
1262 (load-library load) | 1380 ;; Without this, we would load cus-edit recursively. |
1381 ;; We are still loading it when we call this, | |
1382 ;; and it is not in load-history yet. | |
1383 (or (equal load "cus-edit") | |
1384 (load-library load)) | |
1263 (error nil)))))))) | 1385 (error nil)))))))) |
1264 | 1386 |
1265 (defun custom-load-widget (widget) | 1387 (defun custom-load-widget (widget) |
1266 "Load all dependencies for WIDGET." | 1388 "Load all dependencies for WIDGET." |
1267 (custom-load-symbol (widget-value widget))) | 1389 (custom-load-symbol (widget-value widget))) |
1272 (cond ((memq state '(invalid modified)) | 1394 (cond ((memq state '(invalid modified)) |
1273 (error "There are unset changes")) | 1395 (error "There are unset changes")) |
1274 ((eq state 'hidden) | 1396 ((eq state 'hidden) |
1275 (widget-put widget :custom-state 'unknown)) | 1397 (widget-put widget :custom-state 'unknown)) |
1276 (t | 1398 (t |
1399 (widget-put widget :documentation-shown nil) | |
1277 (widget-put widget :custom-state 'hidden))) | 1400 (widget-put widget :custom-state 'hidden))) |
1278 (custom-redraw widget))) | 1401 (custom-redraw widget))) |
1402 | |
1403 (defun custom-toggle-parent (widget &rest ignore) | |
1404 "Toggle visibility of parent to WIDGET." | |
1405 (custom-toggle-hide (widget-get widget :parent))) | |
1279 | 1406 |
1280 ;;; The `custom-variable' Widget. | 1407 ;;; The `custom-variable' Widget. |
1281 | 1408 |
1282 (defface custom-variable-sample-face '((t (:underline t))) | 1409 (defface custom-variable-sample-face '((t (:underline t))) |
1283 "Face used for unpushable variable tags." | 1410 "Face used for unpushable variable tags." |
1290 (define-widget 'custom-variable 'custom | 1417 (define-widget 'custom-variable 'custom |
1291 "Customize variable." | 1418 "Customize variable." |
1292 :format "%v%m%h%a" | 1419 :format "%v%m%h%a" |
1293 :help-echo "Set or reset this variable." | 1420 :help-echo "Set or reset this variable." |
1294 :documentation-property 'variable-documentation | 1421 :documentation-property 'variable-documentation |
1422 :custom-category 'option | |
1295 :custom-state nil | 1423 :custom-state nil |
1296 :custom-menu 'custom-variable-menu-create | 1424 :custom-menu 'custom-variable-menu-create |
1297 :custom-form 'edit | 1425 :custom-form 'edit |
1298 :value-create 'custom-variable-value-create | 1426 :value-create 'custom-variable-value-create |
1299 :action 'custom-variable-action | 1427 :action 'custom-variable-action |
1348 ;; Now we can create the child widget. | 1476 ;; Now we can create the child widget. |
1349 (cond ((eq state 'hidden) | 1477 (cond ((eq state 'hidden) |
1350 ;; Indicate hidden value. | 1478 ;; Indicate hidden value. |
1351 (push (widget-create-child-and-convert | 1479 (push (widget-create-child-and-convert |
1352 widget 'item | 1480 widget 'item |
1353 :format "%{%t%}: ..." | 1481 :format "%{%t%}: " |
1354 :sample-face 'custom-variable-sample-face | 1482 :sample-face 'custom-variable-sample-face |
1355 :tag tag | 1483 :tag tag |
1356 :parent widget) | 1484 :parent widget) |
1357 children)) | 1485 buttons) |
1486 (push (widget-create-child-and-convert | |
1487 widget 'visibility | |
1488 :action 'custom-toggle-parent | |
1489 nil) | |
1490 buttons)) | |
1358 ((eq form 'lisp) | 1491 ((eq form 'lisp) |
1359 ;; In lisp mode edit the saved value when possible. | 1492 ;; In lisp mode edit the saved value when possible. |
1360 (let* ((value (cond ((get symbol 'saved-value) | 1493 (let* ((value (cond ((get symbol 'saved-value) |
1361 (car (get symbol 'saved-value))) | 1494 (car (get symbol 'saved-value))) |
1362 ((get symbol 'standard-value) | 1495 ((get symbol 'standard-value) |
1363 (car (get symbol 'standard-value))) | 1496 (car (get symbol 'standard-value))) |
1364 ((default-boundp symbol) | 1497 ((default-boundp symbol) |
1365 (custom-quote (funcall get symbol))) | 1498 (custom-quote (funcall get symbol))) |
1366 (t | 1499 (t |
1367 (custom-quote (widget-get conv :value)))))) | 1500 (custom-quote (widget-get conv :value)))))) |
1501 (insert (symbol-name symbol) ": ") | |
1502 (push (widget-create-child-and-convert | |
1503 widget 'visibility | |
1504 :action 'custom-toggle-parent | |
1505 t) | |
1506 buttons) | |
1507 (insert " ") | |
1368 (push (widget-create-child-and-convert | 1508 (push (widget-create-child-and-convert |
1369 widget 'sexp | 1509 widget 'sexp |
1370 :button-face 'custom-variable-button-face | 1510 :button-face 'custom-variable-button-face |
1511 :format "%v" | |
1371 :tag (symbol-name symbol) | 1512 :tag (symbol-name symbol) |
1372 :parent widget | 1513 :parent widget |
1373 :value value) | 1514 :value value) |
1374 children))) | 1515 children))) |
1375 (t | 1516 (t |
1376 ;; Edit mode. | 1517 ;; Edit mode. |
1377 (push (widget-create-child-and-convert | 1518 (let* ((format (widget-get type :format)) |
1378 widget type | 1519 tag-format value-format) |
1379 :tag tag | 1520 (unless (string-match ":" format) |
1380 :button-face 'custom-variable-button-face | 1521 (error "Bad format.")) |
1381 :sample-face 'custom-variable-sample-face | 1522 (setq tag-format (substring format 0 (match-end 0))) |
1382 :value value) | 1523 (setq value-format (substring format (match-end 0))) |
1383 children))) | 1524 (push (widget-create-child-and-convert |
1525 widget 'item | |
1526 :format tag-format | |
1527 :action 'custom-tag-action | |
1528 :mouse-down-action 'custom-tag-mouse-down-action | |
1529 :button-face 'custom-variable-button-face | |
1530 :sample-face 'custom-variable-sample-face | |
1531 tag) | |
1532 buttons) | |
1533 (insert " ") | |
1534 (push (widget-create-child-and-convert | |
1535 widget 'visibility | |
1536 :action 'custom-toggle-parent | |
1537 t) | |
1538 buttons) | |
1539 (push (widget-create-child-and-convert | |
1540 widget type | |
1541 :format value-format | |
1542 :value value) | |
1543 children)))) | |
1384 ;; Now update the state. | 1544 ;; Now update the state. |
1385 (unless (eq (preceding-char) ?\n) | 1545 (unless (eq (preceding-char) ?\n) |
1386 (widget-insert "\n")) | 1546 (widget-insert "\n")) |
1387 (if (eq state 'hidden) | 1547 (if (eq state 'hidden) |
1388 (widget-put widget :custom-state state) | 1548 (widget-put widget :custom-state state) |
1389 (custom-variable-state-set widget)) | 1549 (custom-variable-state-set widget)) |
1390 (widget-put widget :custom-form form) | 1550 (widget-put widget :custom-form form) |
1391 (widget-put widget :buttons buttons) | 1551 (widget-put widget :buttons buttons) |
1392 (widget-put widget :children children))) | 1552 (widget-put widget :children children))) |
1553 | |
1554 (defun custom-tag-action (widget &rest args) | |
1555 "Pass :action to first child of WIDGET's parent." | |
1556 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children)) | |
1557 :action args)) | |
1558 | |
1559 (defun custom-tag-mouse-down-action (widget &rest args) | |
1560 "Pass :mouse-down-action to first child of WIDGET's parent." | |
1561 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children)) | |
1562 :mouse-down-action args)) | |
1393 | 1563 |
1394 (defun custom-variable-state-set (widget) | 1564 (defun custom-variable-state-set (widget) |
1395 "Set the state of WIDGET." | 1565 "Set the state of WIDGET." |
1396 (let* ((symbol (widget-value widget)) | 1566 (let* ((symbol (widget-value widget)) |
1397 (get (or (get symbol 'custom-get) 'default-value)) | 1567 (get (or (get symbol 'custom-get) 'default-value)) |
1419 'changed)) | 1589 'changed)) |
1420 (t 'rogue)))) | 1590 (t 'rogue)))) |
1421 (widget-put widget :custom-state state))) | 1591 (widget-put widget :custom-state state))) |
1422 | 1592 |
1423 (defvar custom-variable-menu | 1593 (defvar custom-variable-menu |
1424 '(("Hide" custom-toggle-hide | 1594 '(("Edit" custom-variable-edit |
1425 (lambda (widget) | |
1426 (not (memq (widget-get widget :custom-state) '(modified invalid))))) | |
1427 ("Edit" custom-variable-edit | |
1428 (lambda (widget) | 1595 (lambda (widget) |
1429 (not (eq (widget-get widget :custom-form) 'edit)))) | 1596 (not (eq (widget-get widget :custom-form) 'edit)))) |
1430 ("Edit Lisp" custom-variable-edit-lisp | 1597 ("Edit Lisp" custom-variable-edit-lisp |
1431 (lambda (widget) | 1598 (lambda (widget) |
1432 (not (eq (widget-get widget :custom-form) 'lisp)))) | 1599 (not (eq (widget-get widget :custom-form) 'lisp)))) |
1464 (custom-toggle-hide widget) | 1631 (custom-toggle-hide widget) |
1465 (unless (eq (widget-get widget :custom-state) 'modified) | 1632 (unless (eq (widget-get widget :custom-state) 'modified) |
1466 (custom-variable-state-set widget)) | 1633 (custom-variable-state-set widget)) |
1467 (custom-redraw-magic widget) | 1634 (custom-redraw-magic widget) |
1468 (let* ((completion-ignore-case t) | 1635 (let* ((completion-ignore-case t) |
1469 (answer (widget-choose (custom-unlispify-tag-name | 1636 (answer (widget-choose (concat "Operation on " |
1470 (widget-get widget :value)) | 1637 (custom-unlispify-tag-name |
1638 (widget-get widget :value))) | |
1471 (custom-menu-filter custom-variable-menu | 1639 (custom-menu-filter custom-variable-menu |
1472 widget) | 1640 widget) |
1473 event))) | 1641 event))) |
1474 (if answer | 1642 (if answer |
1475 (funcall answer widget))))) | 1643 (funcall answer widget))))) |
1654 "Face used for face tags." | 1822 "Face used for face tags." |
1655 :group 'custom-faces) | 1823 :group 'custom-faces) |
1656 | 1824 |
1657 (define-widget 'custom-face 'custom | 1825 (define-widget 'custom-face 'custom |
1658 "Customize face." | 1826 "Customize face." |
1659 :format "%{%t%}: %s%m%h%a%v" | 1827 :format "%{%t%}: %s %L\n%m%h%a%v" |
1660 :format-handler 'custom-face-format-handler | 1828 :format-handler 'custom-face-format-handler |
1661 :sample-face 'custom-face-tag-face | 1829 :sample-face 'custom-face-tag-face |
1662 :help-echo "Set or reset this face." | 1830 :help-echo "Set or reset this face." |
1663 :documentation-property '(lambda (face) | 1831 :documentation-property '(lambda (face) |
1664 (face-doc-string face)) | 1832 (face-doc-string face)) |
1665 :value-create 'custom-face-value-create | 1833 :value-create 'custom-face-value-create |
1666 :action 'custom-face-action | 1834 :action 'custom-face-action |
1835 :custom-category 'face | |
1667 :custom-form 'selected | 1836 :custom-form 'selected |
1668 :custom-set 'custom-face-set | 1837 :custom-set 'custom-face-set |
1669 :custom-save 'custom-face-save | 1838 :custom-save 'custom-face-save |
1670 :custom-reset-current 'custom-redraw | 1839 :custom-reset-current 'custom-redraw |
1671 :custom-reset-saved 'custom-face-reset-saved | 1840 :custom-reset-saved 'custom-face-reset-saved |
1681 ;; XEmacs cannot display initialized faces. | 1850 ;; XEmacs cannot display initialized faces. |
1682 (not (custom-facep symbol)) | 1851 (not (custom-facep symbol)) |
1683 (copy-face 'custom-face-empty symbol)) | 1852 (copy-face 'custom-face-empty symbol)) |
1684 (setq child (widget-create-child-and-convert | 1853 (setq child (widget-create-child-and-convert |
1685 widget 'item | 1854 widget 'item |
1686 :format "(%{%t%})\n" | 1855 :format "(%{%t%})" |
1687 :sample-face symbol | 1856 :sample-face symbol |
1688 :tag "sample"))) | 1857 :tag "sample"))) |
1689 (t | 1858 (t |
1690 (custom-format-handler widget escape))) | 1859 (custom-format-handler widget escape))) |
1691 (when child | 1860 (when child |
1755 (custom-face-state-set widget) | 1924 (custom-face-state-set widget) |
1756 (widget-put widget :children (list edit))) | 1925 (widget-put widget :children (list edit))) |
1757 (message "Creating face editor...done"))) | 1926 (message "Creating face editor...done"))) |
1758 | 1927 |
1759 (defvar custom-face-menu | 1928 (defvar custom-face-menu |
1760 '(("Hide" custom-toggle-hide | 1929 '(("Edit Selected" custom-face-edit-selected |
1761 (lambda (widget) | |
1762 (not (memq (widget-get widget :custom-state) '(modified invalid))))) | |
1763 ("Edit Selected" custom-face-edit-selected | |
1764 (lambda (widget) | 1930 (lambda (widget) |
1765 (not (eq (widget-get widget :custom-form) 'selected)))) | 1931 (not (eq (widget-get widget :custom-form) 'selected)))) |
1766 ("Edit All" custom-face-edit-all | 1932 ("Edit All" custom-face-edit-all |
1767 (lambda (widget) | 1933 (lambda (widget) |
1768 (not (eq (widget-get widget :custom-form) 'all)))) | 1934 (not (eq (widget-get widget :custom-form) 'all)))) |
1819 Optional EVENT is the location for the menu." | 1985 Optional EVENT is the location for the menu." |
1820 (if (eq (widget-get widget :custom-state) 'hidden) | 1986 (if (eq (widget-get widget :custom-state) 'hidden) |
1821 (custom-toggle-hide widget) | 1987 (custom-toggle-hide widget) |
1822 (let* ((completion-ignore-case t) | 1988 (let* ((completion-ignore-case t) |
1823 (symbol (widget-get widget :value)) | 1989 (symbol (widget-get widget :value)) |
1824 (answer (widget-choose (custom-unlispify-tag-name symbol) | 1990 (answer (widget-choose (concat "Operation on " |
1991 (custom-unlispify-tag-name symbol)) | |
1825 (custom-menu-filter custom-face-menu | 1992 (custom-menu-filter custom-face-menu |
1826 widget) | 1993 widget) |
1827 event))) | 1994 event))) |
1828 (if answer | 1995 (if answer |
1829 (funcall answer widget))))) | 1996 (funcall answer widget))))) |
1832 "Make the face attributes in WIDGET take effect." | 1999 "Make the face attributes in WIDGET take effect." |
1833 (let* ((symbol (widget-value widget)) | 2000 (let* ((symbol (widget-value widget)) |
1834 (child (car (widget-get widget :children))) | 2001 (child (car (widget-get widget :children))) |
1835 (value (widget-value child))) | 2002 (value (widget-value child))) |
1836 (put symbol 'customized-face value) | 2003 (put symbol 'customized-face value) |
1837 (custom-face-display-set symbol value) | 2004 (face-spec-set symbol value) |
1838 (custom-face-state-set widget) | 2005 (custom-face-state-set widget) |
1839 (custom-redraw-magic widget))) | 2006 (custom-redraw-magic widget))) |
1840 | 2007 |
1841 (defun custom-face-save (widget) | 2008 (defun custom-face-save (widget) |
1842 "Make the face attributes in WIDGET default." | 2009 "Make the face attributes in WIDGET default." |
1843 (let* ((symbol (widget-value widget)) | 2010 (let* ((symbol (widget-value widget)) |
1844 (child (car (widget-get widget :children))) | 2011 (child (car (widget-get widget :children))) |
1845 (value (widget-value child))) | 2012 (value (widget-value child))) |
1846 (custom-face-display-set symbol value) | 2013 (face-spec-set symbol value) |
1847 (put symbol 'saved-face value) | 2014 (put symbol 'saved-face value) |
1848 (put symbol 'customized-face nil) | 2015 (put symbol 'customized-face nil) |
1849 (custom-face-state-set widget) | 2016 (custom-face-state-set widget) |
1850 (custom-redraw-magic widget))) | 2017 (custom-redraw-magic widget))) |
1851 | 2018 |
1855 (child (car (widget-get widget :children))) | 2022 (child (car (widget-get widget :children))) |
1856 (value (get symbol 'saved-face))) | 2023 (value (get symbol 'saved-face))) |
1857 (unless value | 2024 (unless value |
1858 (error "No saved value for this face")) | 2025 (error "No saved value for this face")) |
1859 (put symbol 'customized-face nil) | 2026 (put symbol 'customized-face nil) |
1860 (custom-face-display-set symbol value) | 2027 (face-spec-set symbol value) |
1861 (widget-value-set child value) | 2028 (widget-value-set child value) |
1862 (custom-face-state-set widget) | 2029 (custom-face-state-set widget) |
1863 (custom-redraw-magic widget))) | 2030 (custom-redraw-magic widget))) |
1864 | 2031 |
1865 (defun custom-face-reset-standard (widget) | 2032 (defun custom-face-reset-standard (widget) |
1871 (error "No standard setting for this face")) | 2038 (error "No standard setting for this face")) |
1872 (put symbol 'customized-face nil) | 2039 (put symbol 'customized-face nil) |
1873 (when (get symbol 'saved-face) | 2040 (when (get symbol 'saved-face) |
1874 (put symbol 'saved-face nil) | 2041 (put symbol 'saved-face nil) |
1875 (custom-save-all)) | 2042 (custom-save-all)) |
1876 (custom-face-display-set symbol value) | 2043 (face-spec-set symbol value) |
1877 (widget-value-set child value) | 2044 (widget-value-set child value) |
1878 (custom-face-state-set widget) | 2045 (custom-face-state-set widget) |
1879 (custom-redraw-magic widget))) | 2046 (custom-redraw-magic widget))) |
1880 | 2047 |
1881 ;;; The `face' Widget. | 2048 ;;; The `face' Widget. |
1896 (defun widget-face-value-create (widget) | 2063 (defun widget-face-value-create (widget) |
1897 ;; Create a `custom-face' child. | 2064 ;; Create a `custom-face' child. |
1898 (let* ((symbol (widget-value widget)) | 2065 (let* ((symbol (widget-value widget)) |
1899 (child (widget-create-child-and-convert | 2066 (child (widget-create-child-and-convert |
1900 widget 'custom-face | 2067 widget 'custom-face |
1901 :format "%t %s%m%h%v" | 2068 :format "%t %s %L\n%m%h%v" |
1902 :custom-level nil | 2069 :custom-level nil |
1903 :value symbol))) | 2070 :value symbol))) |
1904 (custom-magic-reset child) | 2071 (custom-magic-reset child) |
1905 (setq custom-options (cons child custom-options)) | 2072 (setq custom-options (cons child custom-options)) |
1906 (widget-put widget :children (list child)))) | 2073 (widget-put widget :children (list child)))) |
1980 "Face used for low level group tags." | 2147 "Face used for low level group tags." |
1981 :group 'custom-faces) | 2148 :group 'custom-faces) |
1982 | 2149 |
1983 (define-widget 'custom-group 'custom | 2150 (define-widget 'custom-group 'custom |
1984 "Customize group." | 2151 "Customize group." |
1985 :format "%l%{%t%}:%L\n%m%h%a%v" | 2152 :format "%l %{%t%} group: %L %-\n%m%h%a%v%e" |
1986 :sample-face-get 'custom-group-sample-face-get | 2153 :sample-face-get 'custom-group-sample-face-get |
1987 :documentation-property 'group-documentation | 2154 :documentation-property 'group-documentation |
1988 :help-echo "Set or reset all members of this group." | 2155 :help-echo "Set or reset all members of this group." |
1989 :value-create 'custom-group-value-create | 2156 :value-create 'custom-group-value-create |
1990 :action 'custom-group-action | 2157 :action 'custom-group-action |
2158 :custom-category 'group | |
1991 :custom-set 'custom-group-set | 2159 :custom-set 'custom-group-set |
1992 :custom-save 'custom-group-save | 2160 :custom-save 'custom-group-save |
1993 :custom-reset-current 'custom-group-reset-current | 2161 :custom-reset-current 'custom-group-reset-current |
1994 :custom-reset-saved 'custom-group-reset-saved | 2162 :custom-reset-saved 'custom-group-reset-saved |
1995 :custom-reset-standard 'custom-group-reset-standard | 2163 :custom-reset-standard 'custom-group-reset-standard |
2005 (unless (eq state 'hidden) | 2173 (unless (eq state 'hidden) |
2006 (message "Creating group...") | 2174 (message "Creating group...") |
2007 (custom-load-widget widget) | 2175 (custom-load-widget widget) |
2008 (let* ((level (widget-get widget :custom-level)) | 2176 (let* ((level (widget-get widget :custom-level)) |
2009 (symbol (widget-value widget)) | 2177 (symbol (widget-value widget)) |
2010 (members (get symbol 'custom-group)) | 2178 (members (sort (get symbol 'custom-group) |
2179 custom-buffer-sort-predicate)) | |
2011 (prefixes (widget-get widget :custom-prefixes)) | 2180 (prefixes (widget-get widget :custom-prefixes)) |
2012 (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2181 (custom-prefix-list (custom-prefix-add symbol prefixes)) |
2013 (length (length members)) | 2182 (length (length members)) |
2014 (count 0) | 2183 (count 0) |
2015 (children (mapcar (lambda (entry) | 2184 (children (mapcar (lambda (entry) |
2027 :custom-level (1+ level) | 2196 :custom-level (1+ level) |
2028 :value (nth 0 entry)) | 2197 :value (nth 0 entry)) |
2029 (unless (eq (preceding-char) ?\n) | 2198 (unless (eq (preceding-char) ?\n) |
2030 (widget-insert "\n")))) | 2199 (widget-insert "\n")))) |
2031 members))) | 2200 members))) |
2201 (put symbol 'custom-group members) | |
2032 (message "Creating group magic...") | 2202 (message "Creating group magic...") |
2033 (mapcar 'custom-magic-reset children) | 2203 (mapcar 'custom-magic-reset children) |
2034 (message "Creating group state...") | 2204 (message "Creating group state...") |
2035 (widget-put widget :children children) | 2205 (widget-put widget :children children) |
2036 (custom-group-state-update widget) | 2206 (custom-group-state-update widget) |
2037 (message "Creating group... done"))))) | 2207 (message "Creating group... done"))))) |
2038 | 2208 |
2039 (defvar custom-group-menu | 2209 (defvar custom-group-menu |
2040 '(("Hide" custom-toggle-hide | 2210 '(("Set" custom-group-set |
2041 (lambda (widget) | |
2042 (not (memq (widget-get widget :custom-state) '(modified invalid))))) | |
2043 ("Set" custom-group-set | |
2044 (lambda (widget) | 2211 (lambda (widget) |
2045 (eq (widget-get widget :custom-state) 'modified))) | 2212 (eq (widget-get widget :custom-state) 'modified))) |
2046 ("Save" custom-group-save | 2213 ("Save" custom-group-save |
2047 (lambda (widget) | 2214 (lambda (widget) |
2048 (memq (widget-get widget :custom-state) '(modified set)))) | 2215 (memq (widget-get widget :custom-state) '(modified set)))) |
2066 "Show the menu for `custom-group' WIDGET. | 2233 "Show the menu for `custom-group' WIDGET. |
2067 Optional EVENT is the location for the menu." | 2234 Optional EVENT is the location for the menu." |
2068 (if (eq (widget-get widget :custom-state) 'hidden) | 2235 (if (eq (widget-get widget :custom-state) 'hidden) |
2069 (custom-toggle-hide widget) | 2236 (custom-toggle-hide widget) |
2070 (let* ((completion-ignore-case t) | 2237 (let* ((completion-ignore-case t) |
2071 (answer (widget-choose (custom-unlispify-tag-name | 2238 (answer (widget-choose (concat "Operation on " |
2072 (widget-get widget :value)) | 2239 (custom-unlispify-tag-name |
2240 (widget-get widget :value))) | |
2073 (custom-menu-filter custom-group-menu | 2241 (custom-menu-filter custom-group-menu |
2074 widget) | 2242 widget) |
2075 event))) | 2243 event))) |
2076 (if answer | 2244 (if answer |
2077 (funcall answer widget))))) | 2245 (funcall answer widget))))) |
2262 ;;; Menu support | 2430 ;;; Menu support |
2263 | 2431 |
2264 (unless (string-match "XEmacs" emacs-version) | 2432 (unless (string-match "XEmacs" emacs-version) |
2265 (defconst custom-help-menu '("Customize" | 2433 (defconst custom-help-menu '("Customize" |
2266 ["Update menu..." custom-menu-update t] | 2434 ["Update menu..." custom-menu-update t] |
2267 ["Group..." customize t] | 2435 ["Group..." customize-group t] |
2268 ["Variable..." customize-variable t] | 2436 ["Variable..." customize-variable t] |
2269 ["Face..." customize-face t] | 2437 ["Face..." customize-face t] |
2270 ["Saved..." customize-customized t] | 2438 ["Saved..." customize-saved t] |
2439 ["Set..." customize-customized t] | |
2271 ["Apropos..." customize-apropos t]) | 2440 ["Apropos..." customize-apropos t]) |
2272 ;; This menu should be identical to the one defined in `menu-bar.el'. | 2441 ;; This menu should be identical to the one defined in `menu-bar.el'. |
2273 "Customize menu") | 2442 "Customize menu") |
2274 | 2443 |
2275 (defun custom-menu-reset () | 2444 (defun custom-menu-reset () |
2345 t))) | 2514 t))) |
2346 (if (and (or (not (boundp 'custom-menu-nesting)) | 2515 (if (and (or (not (boundp 'custom-menu-nesting)) |
2347 (>= custom-menu-nesting 0)) | 2516 (>= custom-menu-nesting 0)) |
2348 (< (length (get symbol 'custom-group)) widget-menu-max-size)) | 2517 (< (length (get symbol 'custom-group)) widget-menu-max-size)) |
2349 (let ((custom-prefix-list (custom-prefix-add symbol | 2518 (let ((custom-prefix-list (custom-prefix-add symbol |
2350 custom-prefix-list))) | 2519 custom-prefix-list)) |
2520 (members (sort (get symbol 'custom-group) | |
2521 custom-menu-sort-predicate))) | |
2522 (put symbol 'custom-group members) | |
2351 (custom-load-symbol symbol) | 2523 (custom-load-symbol symbol) |
2352 `(,(custom-unlispify-menu-entry symbol t) | 2524 `(,(custom-unlispify-menu-entry symbol t) |
2353 ,item | 2525 ,item |
2354 "--" | 2526 "--" |
2355 ,@(mapcar (lambda (entry) | 2527 ,@(mapcar (lambda (entry) |
2356 (widget-apply (if (listp (nth 1 entry)) | 2528 (widget-apply (if (listp (nth 1 entry)) |
2357 (nth 1 entry) | 2529 (nth 1 entry) |
2358 (list (nth 1 entry))) | 2530 (list (nth 1 entry))) |
2359 :custom-menu (nth 0 entry))) | 2531 :custom-menu (nth 0 entry))) |
2360 (get symbol 'custom-group)))) | 2532 members))) |
2361 item))) | 2533 item))) |
2362 | 2534 |
2363 ;;;###autoload | 2535 ;;;###autoload |
2364 (defun customize-menu-create (symbol &optional name) | 2536 (defun customize-menu-create (symbol &optional name) |
2365 "Return a customize menu for customization group SYMBOL. | 2537 "Return a customize menu for customization group SYMBOL. |
2412 | 2584 |
2413 The following commands are available: | 2585 The following commands are available: |
2414 | 2586 |
2415 Move to next button or editable field. \\[widget-forward] | 2587 Move to next button or editable field. \\[widget-forward] |
2416 Move to previous button or editable field. \\[widget-backward] | 2588 Move to previous button or editable field. \\[widget-backward] |
2417 Activate button under the mouse pointer. \\[widget-button-click] | 2589 Invoke button under the mouse pointer. \\[widget-button-click] |
2418 Activate button under point. \\[widget-button-press] | 2590 Invoke button under point. \\[widget-button-press] |
2419 Set all modifications. \\[custom-set] | 2591 Set all modifications. \\[custom-set] |
2420 Make all modifications default. \\[custom-save] | 2592 Make all modifications default. \\[custom-save] |
2421 Reset all modified options. \\[custom-reset-current] | 2593 Reset all modified options. \\[custom-reset-current] |
2422 Reset all modified or set options. \\[custom-reset-saved] | 2594 Reset all modified or set options. \\[custom-reset-saved] |
2423 Reset all options. \\[custom-reset-standard] | 2595 Reset all options. \\[custom-reset-standard] |