Mercurial > hg > xemacs-beta
comparison lisp/custom/cus-edit.el @ 163:0132846995bd r20-3b8
Import from CVS: tag r20-3b8
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:43:35 +0200 |
parents | 28f395d8dc7a |
children | 5a88923fcbfe |
comparison
equal
deleted
inserted
replaced
162:4de2936b4e77 | 163:0132846995bd |
---|---|
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.9916 | 7 ;; Version: 1.9931 |
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 |
43 | 43 |
44 (condition-case nil | 44 (condition-case nil |
45 (require 'cus-start) | 45 (require 'cus-start) |
46 (error nil)) | 46 (error nil)) |
47 | 47 |
48 (define-widget-keywords :custom-category :custom-prefixes :custom-menu | 48 (define-widget-keywords :custom-last :custom-prefix :custom-category |
49 :custom-prefixes :custom-menu | |
49 :custom-show | 50 :custom-show |
50 :custom-magic :custom-state :custom-level :custom-form | 51 :custom-magic :custom-state :custom-level :custom-form |
51 :custom-set :custom-save :custom-reset-current :custom-reset-saved | 52 :custom-set :custom-save :custom-reset-current :custom-reset-saved |
52 :custom-reset-standard) | 53 :custom-reset-standard) |
53 | 54 |
205 "Support for Emacs frames and window systems." | 206 "Support for Emacs frames and window systems." |
206 :group 'environment) | 207 :group 'environment) |
207 | 208 |
208 (defgroup data nil | 209 (defgroup data nil |
209 "Support editing files of data." | 210 "Support editing files of data." |
211 :group 'emacs) | |
212 | |
213 (defgroup files nil | |
214 "Support editing files." | |
210 :group 'emacs) | 215 :group 'emacs) |
211 | 216 |
212 (defgroup wp nil | 217 (defgroup wp nil |
213 "Word processing." | 218 "Word processing." |
214 :group 'emacs) | 219 :group 'emacs) |
321 "Input from the menus." | 326 "Input from the menus." |
322 :group 'environment) | 327 :group 'environment) |
323 | 328 |
324 (defgroup auto-save nil | 329 (defgroup auto-save nil |
325 "Preventing accidential loss of data." | 330 "Preventing accidential loss of data." |
326 :group 'data) | 331 :group 'files) |
327 | 332 |
328 (defgroup processes-basics nil | 333 (defgroup processes-basics nil |
329 "Basic stuff dealing with processes." | 334 "Basic stuff dealing with processes." |
330 :group 'processes) | 335 :group 'processes) |
331 | 336 |
336 (defgroup windows nil | 341 (defgroup windows nil |
337 "Windows within a frame." | 342 "Windows within a frame." |
338 :group 'environment) | 343 :group 'environment) |
339 | 344 |
340 ;;; Utilities. | 345 ;;; Utilities. |
346 | |
347 (defun custom-last (x &optional n) | |
348 ;; Stolen from `cl.el'. | |
349 "Returns the last link in the list LIST. | |
350 With optional argument N, returns Nth-to-last link (default 1)." | |
351 (if n | |
352 (let ((m 0) (p x)) | |
353 (while (consp p) (incf m) (pop p)) | |
354 (if (<= n 0) p | |
355 (if (< n m) (nthcdr (- m n) x) x))) | |
356 (while (consp (cdr x)) (pop x)) | |
357 x)) | |
341 | 358 |
342 (defun custom-quote (sexp) | 359 (defun custom-quote (sexp) |
343 "Quote SEXP iff it is not self quoting." | 360 "Quote SEXP iff it is not self quoting." |
344 (if (or (memq sexp '(t nil)) | 361 (if (or (memq sexp '(t nil)) |
345 (and (symbolp sexp) | 362 (and (symbolp sexp) |
526 docs nil)))))) | 543 docs nil)))))) |
527 found)) | 544 found)) |
528 | 545 |
529 ;;; Sorting. | 546 ;;; Sorting. |
530 | 547 |
531 (defcustom custom-buffer-sort-predicate 'ignore | 548 (defcustom custom-buffer-sort-alphabetically nil |
532 "Function used for sorting group members in buffers. | 549 "If non-nil, sort the members of each customization group alphabetically." |
533 The value should be useful as a predicate for `sort'. | 550 :type 'boolean |
534 The list to be sorted is the value of the groups `custom-group' property." | |
535 :type '(radio (const :tag "Unsorted" ignore) | |
536 (const :tag "Alphabetic" custom-sort-items-alphabetically) | |
537 (function :tag "Other")) | |
538 :group 'custom-buffer) | 551 :group 'custom-buffer) |
539 | 552 |
540 (defcustom custom-buffer-order-predicate 'custom-sort-groups-last | 553 (defcustom custom-buffer-groups-last nil |
541 "Function used for sorting group members in buffers. | 554 "If non-nil, put subgroups after all ordinary options within a group." |
542 The value should be useful as a predicate for `sort'. | 555 :type 'boolean |
543 The list to be sorted is the value of the groups `custom-group' property." | |
544 :type '(radio (const :tag "Groups first" custom-sort-groups-first) | |
545 (const :tag "Groups last" custom-sort-groups-last) | |
546 (function :tag "Other")) | |
547 :group 'custom-buffer) | 556 :group 'custom-buffer) |
548 | 557 |
549 (defcustom custom-menu-sort-predicate 'ignore | 558 (defcustom custom-menu-sort-alphabetically nil |
550 "Function used for sorting group members in menus. | 559 "If non-nil, sort the members of each customization group alphabetically." |
551 The value should be useful as a predicate for `sort'. | 560 :type 'boolean |
552 The list to be sorted is the value of the groups `custom-group' property." | |
553 :type '(radio (const :tag "Unsorted" ignore) | |
554 (const :tag "Alphabetic" custom-sort-items-alphabetically) | |
555 (function :tag "Other")) | |
556 :group 'custom-menu) | 561 :group 'custom-menu) |
557 | 562 |
558 (defcustom custom-menu-order-predicate 'custom-sort-groups-first | 563 (defcustom custom-menu-groups-first t |
559 "Function used for sorting group members in menus. | 564 "If non-nil, put subgroups before all ordinary options within a group." |
560 The value should be useful as a predicate for `sort'. | 565 :type 'boolean |
561 The list to be sorted is the value of the groups `custom-group' property." | |
562 :type '(radio (const :tag "Groups first" custom-sort-groups-first) | |
563 (const :tag "Groups last" custom-sort-groups-last) | |
564 (function :tag "Other")) | |
565 :group 'custom-menu) | 566 :group 'custom-menu) |
566 | 567 |
567 (defun custom-sort-items-alphabetically (a b) | 568 (defun custom-buffer-sort-predicate (a b) |
568 "Return t iff A is alphabetically before B and the same custom type. | 569 "Return t iff A should come before B in a customization buffer. |
569 A and B should be members of a `custom-group' property." | 570 A and B should be members of a `custom-group' property." |
570 (and (eq (nth 1 a) (nth 1 b)) | 571 (cond ((and (not custom-buffer-groups-last) |
571 (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))))) | 572 (not custom-buffer-sort-alphabetically)) |
572 | 573 nil) |
573 (defun custom-sort-groups-first (a b) | 574 ((or (eq (eq (nth 1 a) 'custom-group) (eq (nth 1 b) 'custom-group)) |
574 "Return t iff A a custom group and B is a not. | 575 (not custom-buffer-groups-last)) |
576 (if custom-buffer-sort-alphabetically | |
577 (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))) | |
578 nil)) | |
579 (t | |
580 (not (eq (nth 1 a) 'custom-group) )))) | |
581 | |
582 (defalias 'custom-browse-sort-predicate 'ignore) | |
583 | |
584 (defun custom-menu-sort-predicate (a b) | |
585 "Return t iff A should come before B in a customization menu. | |
575 A and B should be members of a `custom-group' property." | 586 A and B should be members of a `custom-group' property." |
576 (and (eq (nth 1 a) 'custom-group) | 587 (cond ((and (not custom-menu-groups-first) |
577 (not (eq (nth 1 b) 'custom-group)))) | 588 (not custom-menu-sort-alphabetically)) |
578 | 589 nil) |
579 (defun custom-sort-groups-last (a b) | 590 ((or (eq (eq (nth 1 a) 'custom-group) (eq (nth 1 b) 'custom-group)) |
580 "Return t iff B a custom group and A is a not. | 591 (not custom-menu-groups-first)) |
581 A and B should be members of a `custom-group' property." | 592 (if custom-menu-sort-alphabetically |
582 (and (eq (nth 1 b) 'custom-group) | 593 (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))) |
583 (not (eq (nth 1 a) 'custom-group)))) | 594 nil)) |
595 (t | |
596 (eq (nth 1 a) 'custom-group) ))) | |
584 | 597 |
585 ;;; Custom Mode Commands. | 598 ;;; Custom Mode Commands. |
586 | 599 |
587 (defvar custom-options nil | 600 (defvar custom-options nil |
588 "Customization widgets in the current buffer.") | 601 "Customization widgets in the current buffer.") |
637 "Reset all modified or set group members to their saved value." | 650 "Reset all modified or set group members to their saved value." |
638 (interactive) | 651 (interactive) |
639 (let ((children custom-options)) | 652 (let ((children custom-options)) |
640 (mapcar (lambda (child) | 653 (mapcar (lambda (child) |
641 (when (eq (widget-get child :custom-state) 'modified) | 654 (when (eq (widget-get child :custom-state) 'modified) |
642 (widget-apply child :custom-reset-current))) | 655 (widget-apply child :custom-reset-saved))) |
643 children))) | 656 children))) |
644 | 657 |
645 (defun custom-reset-standard (&rest ignore) | 658 (defun custom-reset-standard (&rest ignore) |
646 "Reset all modified, set, or saved group members to their standard settings." | 659 "Reset all modified, set, or saved group members to their standard settings." |
647 (interactive) | 660 (interactive) |
648 (let ((children custom-options)) | 661 (let ((children custom-options)) |
649 (mapcar (lambda (child) | 662 (mapcar (lambda (child) |
650 (when (eq (widget-get child :custom-state) 'modified) | 663 (when (eq (widget-get child :custom-state) 'modified) |
651 (widget-apply child :custom-reset-current))) | 664 (widget-apply child :custom-reset-standard))) |
652 children))) | 665 children))) |
653 | 666 |
654 ;;; The Customize Commands | 667 ;;; The Customize Commands |
655 | 668 |
656 (defun custom-prompt-variable (prompt-var prompt-val) | 669 (defun custom-prompt-variable (prompt-var prompt-val) |
731 (customize-group 'emacs)) | 744 (customize-group 'emacs)) |
732 | 745 |
733 ;;;###autoload | 746 ;;;###autoload |
734 (defun customize-group (group) | 747 (defun customize-group (group) |
735 "Customize GROUP, which must be a customization group." | 748 "Customize GROUP, which must be a customization group." |
736 (interactive (list (completing-read "Customize group: (default emacs) " | 749 (interactive (list (let ((completion-ignore-case t)) |
737 obarray | 750 (completing-read "Customize group: (default emacs) " |
738 (lambda (symbol) | 751 obarray |
739 (get symbol 'custom-group)) | 752 (lambda (symbol) |
740 t))) | 753 (get symbol 'custom-group)) |
754 t)))) | |
741 | 755 |
742 (when (stringp group) | 756 (when (stringp group) |
743 (if (string-equal "" group) | 757 (if (string-equal "" group) |
744 (setq group 'emacs) | 758 (setq group 'emacs) |
745 (setq group (intern group)))) | 759 (setq group (intern group)))) |
746 (custom-buffer-create (list (list group 'custom-group)) | 760 (let ((name (format "*Customize Group: %s*" |
747 (format "*Customize Group: %s*" | 761 (custom-unlispify-tag-name group)))) |
748 (custom-unlispify-tag-name group)))) | 762 (if (get-buffer name) |
763 (switch-to-buffer name) | |
764 (custom-buffer-create (list (list group 'custom-group)) | |
765 name)))) | |
749 | 766 |
750 ;;;###autoload | 767 ;;;###autoload |
751 (defun customize-group-other-window (symbol) | 768 (defun customize-group-other-window (symbol) |
752 "Customize SYMBOL, which must be a customization group." | 769 "Customize SYMBOL, which must be a customization group." |
753 (interactive (list (completing-read "Customize group: (default emacs) " | 770 (interactive (list (completing-read "Customize group: (default emacs) " |
795 obarray 'custom-facep))) | 812 obarray 'custom-facep))) |
796 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol)))) | 813 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol)))) |
797 (let ((found nil)) | 814 (let ((found nil)) |
798 (message "Looking for faces...") | 815 (message "Looking for faces...") |
799 (mapcar (lambda (symbol) | 816 (mapcar (lambda (symbol) |
800 (setq found (cons (list symbol 'custom-face) found))) | 817 (push (list symbol 'custom-face) found)) |
801 (nreverse (mapcar 'intern | 818 (nreverse (mapcar 'intern |
802 (sort (mapcar 'symbol-name (face-list)) | 819 (sort (mapcar 'symbol-name (face-list)) |
803 'string<)))) | 820 'string-lessp)))) |
804 | 821 |
805 (custom-buffer-create found "*Customize Faces*")) | 822 (custom-buffer-create found "*Customize Faces*")) |
806 (if (stringp symbol) | 823 (if (stringp symbol) |
807 (setq symbol (intern symbol))) | 824 (setq symbol (intern symbol))) |
808 (unless (symbolp symbol) | 825 (unless (symbolp symbol) |
832 (interactive) | 849 (interactive) |
833 (let ((found nil)) | 850 (let ((found nil)) |
834 (mapatoms (lambda (symbol) | 851 (mapatoms (lambda (symbol) |
835 (and (get symbol 'customized-face) | 852 (and (get symbol 'customized-face) |
836 (custom-facep symbol) | 853 (custom-facep symbol) |
837 (setq found (cons (list symbol 'custom-face) found))) | 854 (push (list symbol 'custom-face) found)) |
838 (and (get symbol 'customized-value) | 855 (and (get symbol 'customized-value) |
839 (boundp symbol) | 856 (boundp symbol) |
840 (setq found | 857 (push (list symbol 'custom-variable) found)))) |
841 (cons (list symbol 'custom-variable) found))))) | |
842 (if found | 858 (if found |
843 (custom-buffer-create found "*Customize Customized*") | 859 (custom-buffer-create found "*Customize Customized*") |
844 (error "No customized user options")))) | 860 (error "No customized user options")))) |
845 | 861 |
846 ;;;###autoload | 862 ;;;###autoload |
849 (interactive) | 865 (interactive) |
850 (let ((found nil)) | 866 (let ((found nil)) |
851 (mapatoms (lambda (symbol) | 867 (mapatoms (lambda (symbol) |
852 (and (get symbol 'saved-face) | 868 (and (get symbol 'saved-face) |
853 (custom-facep symbol) | 869 (custom-facep symbol) |
854 (setq found (cons (list symbol 'custom-face) found))) | 870 (push (list symbol 'custom-face) found)) |
855 (and (get symbol 'saved-value) | 871 (and (get symbol 'saved-value) |
856 (boundp symbol) | 872 (boundp symbol) |
857 (setq found | 873 (push (list symbol 'custom-variable) found)))) |
858 (cons (list symbol 'custom-variable) found))))) | |
859 (if found | 874 (if found |
860 (custom-buffer-create found "*Customize Saved*") | 875 (custom-buffer-create found "*Customize Saved*") |
861 (error "No saved user options")))) | 876 (error "No saved user options")))) |
862 | 877 |
863 ;;;###autoload | 878 ;;;###autoload |
864 (defun customize-apropos (regexp &optional all) | 879 (defun customize-apropos (regexp &optional all) |
865 "Customize all user options matching REGEXP. | 880 "Customize all user options matching REGEXP. |
866 If ALL (e.g., started with a prefix key), include options which are not | 881 If ALL is `options', include only options. |
867 user-settable." | 882 If ALL is `faces', include only faces. |
883 If ALL is `groups', include only groups. | |
884 If ALL is t (interactively, with prefix arg), include options which are not | |
885 user-settable, as well as faces and groups." | |
868 (interactive "sCustomize regexp: \nP") | 886 (interactive "sCustomize regexp: \nP") |
869 (let ((found nil)) | 887 (let ((found nil)) |
870 (mapatoms (lambda (symbol) | 888 (mapatoms (lambda (symbol) |
871 (when (string-match regexp (symbol-name symbol)) | 889 (when (string-match regexp (symbol-name symbol)) |
872 (when (get symbol 'custom-group) | 890 (when (and (not (memq all '(faces options))) |
873 (setq found (cons (list symbol 'custom-group) found))) | 891 (get symbol 'custom-group)) |
874 (when (custom-facep symbol) | 892 (push (list symbol 'custom-group) found)) |
875 (setq found (cons (list symbol 'custom-face) found))) | 893 (when (and (not (memq all '(options groups))) |
876 (when (and (boundp symbol) | 894 (custom-facep symbol)) |
895 (push (list symbol 'custom-face) found)) | |
896 (when (and (not (memq all '(groups faces))) | |
897 (boundp symbol) | |
877 (or (get symbol 'saved-value) | 898 (or (get symbol 'saved-value) |
878 (get symbol 'standard-value) | 899 (get symbol 'standard-value) |
879 (if all | 900 (if (memq all '(nil options)) |
880 (get symbol 'variable-documentation) | 901 (user-variable-p symbol) |
881 (user-variable-p symbol)))) | 902 (get symbol 'variable-documentation)))) |
882 (setq found | 903 (push (list symbol 'custom-variable) found))))) |
883 (cons (list symbol 'custom-variable) found)))))) | 904 (if (not found) |
884 (if found | 905 (error "No matches") |
885 (custom-buffer-create found "*Customize Apropos*") | 906 (let ((custom-buffer-sort-alphabetically t)) |
886 (error "No matches")))) | 907 (custom-buffer-create (sort found 'custom-buffer-sort-predicate) |
908 "*Customize Apropos*"))))) | |
909 | |
910 ;;;###autoload | |
911 (defun customize-apropos-options (regexp &optional arg) | |
912 "Customize all user options matching REGEXP. | |
913 With prefix arg, include options which are not user-settable." | |
914 (interactive "sCustomize regexp: \nP") | |
915 (customize-apropos regexp (or arg 'options))) | |
916 | |
917 ;;;###autoload | |
918 (defun customize-apropos-faces (regexp) | |
919 "Customize all user faces matching REGEXP." | |
920 (interactive "sCustomize regexp: \n") | |
921 (customize-apropos regexp 'faces)) | |
922 | |
923 ;;;###autoload | |
924 (defun customize-apropos-groups (regexp) | |
925 "Customize all user groups matching REGEXP." | |
926 (interactive "sCustomize regexp: \n") | |
927 (customize-apropos regexp 'groups)) | |
887 | 928 |
888 ;;; Buffer. | 929 ;;; Buffer. |
930 | |
931 (defcustom custom-buffer-style 'links | |
932 "Control the presentation style for customization buffers. | |
933 The value should be a symbol, one of: | |
934 | |
935 brackets: groups nest within each other with big horizontal brackets. | |
936 links: groups have links to subgroups." | |
937 :type '(radio (const brackets) | |
938 (const links)) | |
939 :group 'custom-buffer) | |
940 | |
941 (defcustom custom-buffer-indent 3 | |
942 "Number of spaces to indent nested groups." | |
943 :type 'integer | |
944 :group 'custom-buffer) | |
889 | 945 |
890 ;;;###autoload | 946 ;;;###autoload |
891 (defun custom-buffer-create (options &optional name) | 947 (defun custom-buffer-create (options &optional name) |
892 "Create a buffer containing OPTIONS. | 948 "Create a buffer containing OPTIONS. |
893 Optional NAME is the name of the buffer. | 949 Optional NAME is the name of the buffer. |
1000 (widget-insert "\n")) | 1056 (widget-insert "\n")) |
1001 (widget-insert "\n"))) | 1057 (widget-insert "\n"))) |
1002 options)))) | 1058 options)))) |
1003 (unless (eq (preceding-char) ?\n) | 1059 (unless (eq (preceding-char) ?\n) |
1004 (widget-insert "\n")) | 1060 (widget-insert "\n")) |
1005 (message "Creating customization magic...") | 1061 (unless (eq custom-buffer-style 'tree) |
1006 (mapcar 'custom-magic-reset custom-options) | 1062 (mapcar 'custom-magic-reset custom-options)) |
1007 (message "Creating customization setup...") | 1063 (message "Creating customization setup...") |
1008 (widget-setup) | 1064 (widget-setup) |
1009 (goto-char (point-min)) | 1065 (goto-char (point-min)) |
1010 (message "Creating customization buffer...done")) | 1066 (message "Creating customization buffer...done")) |
1067 | |
1068 ;;; The Tree Browser. | |
1069 | |
1070 ;;;###autoload | |
1071 (defun customize-browse () | |
1072 "Create a tree browser for the customize hierarchy." | |
1073 (interactive) | |
1074 (let ((name "*Customize Browser*")) | |
1075 (kill-buffer (get-buffer-create name)) | |
1076 (switch-to-buffer (get-buffer-create name))) | |
1077 (custom-mode) | |
1078 (widget-insert "\ | |
1079 Invoke [+] below to expand items, and [-] to collapse items. | |
1080 Invoke the [group], [face], and [option] buttons below to edit that | |
1081 item in another window.\n\n") | |
1082 (let ((custom-buffer-style 'tree)) | |
1083 (widget-create 'custom-group | |
1084 :custom-last t | |
1085 :custom-state 'unknown | |
1086 :tag (custom-unlispify-tag-name 'emacs) | |
1087 :value 'emacs)) | |
1088 (goto-char (point-min))) | |
1089 | |
1090 (define-widget 'custom-tree-visibility 'item | |
1091 "Control visibility of of items in the customize tree browser." | |
1092 :format "%[[%t]%]" | |
1093 :action 'custom-tree-visibility-action) | |
1094 | |
1095 (defun custom-tree-visibility-action (widget &rest ignore) | |
1096 (let ((custom-buffer-style 'tree)) | |
1097 (custom-toggle-parent widget))) | |
1098 | |
1099 (define-widget 'custom-tree-group-tag 'push-button | |
1100 "Show parent in other window when activated." | |
1101 :tag "group" | |
1102 :tag-glyph "folder" | |
1103 :action 'custom-tree-group-tag-action) | |
1104 | |
1105 (defun custom-tree-group-tag-action (widget &rest ignore) | |
1106 (let ((parent (widget-get widget :parent))) | |
1107 (customize-group-other-window (widget-value parent)))) | |
1108 | |
1109 (define-widget 'custom-tree-variable-tag 'push-button | |
1110 "Show parent in other window when activated." | |
1111 :tag "option" | |
1112 :tag-glyph "option" | |
1113 :action 'custom-tree-variable-tag-action) | |
1114 | |
1115 (defun custom-tree-variable-tag-action (widget &rest ignore) | |
1116 (let ((parent (widget-get widget :parent))) | |
1117 (customize-variable-other-window (widget-value parent)))) | |
1118 | |
1119 (define-widget 'custom-tree-face-tag 'push-button | |
1120 "Show parent in other window when activated." | |
1121 :tag "face" | |
1122 :tag-glyph "face" | |
1123 :action 'custom-tree-face-tag-action) | |
1124 | |
1125 (defun custom-tree-face-tag-action (widget &rest ignore) | |
1126 (let ((parent (widget-get widget :parent))) | |
1127 (customize-face-other-window (widget-value parent)))) | |
1128 | |
1129 (defconst custom-tree-alist '((" " "space") | |
1130 (" | " "vertical") | |
1131 (" |-" "middle") | |
1132 (" `-" "bottom"))) | |
1133 | |
1134 (defun custom-tree-insert (prefix) | |
1135 "Insert PREFIX. On XEmacs convert it to line graphics." | |
1136 (if nil ;(string-match "XEmacs" emacs-version) | |
1137 (while (not (string-equal prefix "")) | |
1138 (let ((entry (substring prefix 0 3))) | |
1139 (setq prefix (substring prefix 3)) | |
1140 (widget-specify-insert | |
1141 (widget-glyph-insert nil entry | |
1142 (nth 1 (assoc entry custom-tree-alist)))))) | |
1143 (insert prefix))) | |
1011 | 1144 |
1012 ;;; Modification of Basic Widgets. | 1145 ;;; Modification of Basic Widgets. |
1013 ;; | 1146 ;; |
1014 ;; We add extra properties to the basic widgets needed here. This is | 1147 ;; We add extra properties to the basic widgets needed here. This is |
1015 ;; fine, as long as we are careful to stay within out own namespace. | 1148 ;; fine, as long as we are careful to stay within out own namespace. |
1084 (defconst custom-magic-alist '((nil "#" underline "\ | 1217 (defconst custom-magic-alist '((nil "#" underline "\ |
1085 uninitialized, you should not see this.") | 1218 uninitialized, you should not see this.") |
1086 (unknown "?" italic "\ | 1219 (unknown "?" italic "\ |
1087 unknown, you should not see this.") | 1220 unknown, you should not see this.") |
1088 (hidden "-" default "\ | 1221 (hidden "-" default "\ |
1089 hidden, invoke the dots above to show." "\ | 1222 hidden, invoke \"Show\" in the previous line to show." "\ |
1090 group now hidden, invoke the dots above to show contents.") | 1223 group now hidden, invoke \"Show\", above, to show contents.") |
1091 (invalid "x" custom-invalid-face "\ | 1224 (invalid "x" custom-invalid-face "\ |
1092 the value displayed for this %c is invalid and cannot be set.") | 1225 the value displayed for this %c is invalid and cannot be set.") |
1093 (modified "*" custom-modified-face "\ | 1226 (modified "*" custom-modified-face "\ |
1094 you have edited the value, and can now set the %c." "\ | 1227 you have edited the value, and can now set the %c." "\ |
1095 you have edited something in this group, and can now set it.") | 1228 you have edited something in this group, and can now set it.") |
1204 (match-string 2 text)))) | 1337 (match-string 2 text)))) |
1205 (when (and custom-magic-show | 1338 (when (and custom-magic-show |
1206 (or (not hidden) | 1339 (or (not hidden) |
1207 (memq category custom-magic-show-hidden))) | 1340 (memq category custom-magic-show-hidden))) |
1208 (insert " ") | 1341 (insert " ") |
1342 (when (eq category 'group) | |
1343 (insert-char ?\ (* custom-buffer-indent | |
1344 (widget-get parent :custom-level)))) | |
1209 (push (widget-create-child-and-convert | 1345 (push (widget-create-child-and-convert |
1210 widget 'choice-item | 1346 widget 'choice-item |
1211 :help-echo "Change the state of this item." | 1347 :help-echo "Change the state of this item." |
1212 :format (if hidden "%t" "%[%t%]") | 1348 :format (if hidden "%t" "%[%t%]") |
1213 :button-prefix 'widget-push-button-prefix | 1349 :button-prefix 'widget-push-button-prefix |
1220 (insert text) | 1356 (insert text) |
1221 (insert (symbol-name state))) | 1357 (insert (symbol-name state))) |
1222 (when lisp | 1358 (when lisp |
1223 (insert " (lisp)")) | 1359 (insert " (lisp)")) |
1224 (insert "\n")) | 1360 (insert "\n")) |
1361 (when (eq category 'group) | |
1362 (insert-char ?\ (* custom-buffer-indent | |
1363 (widget-get parent :custom-level)))) | |
1225 (when custom-magic-show-button | 1364 (when custom-magic-show-button |
1226 (when custom-magic-show | 1365 (when custom-magic-show |
1227 (let ((indent (widget-get parent :indent))) | 1366 (let ((indent (widget-get parent :indent))) |
1228 (when indent | 1367 (when indent |
1229 (insert-char ? indent)))) | 1368 (insert-char ? indent)))) |
1249 | 1388 |
1250 ;;; The `custom' Widget. | 1389 ;;; The `custom' Widget. |
1251 | 1390 |
1252 (define-widget 'custom 'default | 1391 (define-widget 'custom 'default |
1253 "Customize a user option." | 1392 "Customize a user option." |
1393 :format "%v" | |
1254 :convert-widget 'custom-convert-widget | 1394 :convert-widget 'custom-convert-widget |
1255 :format-handler 'custom-format-handler | |
1256 :notify 'custom-notify | 1395 :notify 'custom-notify |
1396 :custom-prefix "" | |
1257 :custom-level 1 | 1397 :custom-level 1 |
1258 :custom-state 'hidden | 1398 :custom-state 'hidden |
1259 :documentation-property 'widget-subclass-responsibility | 1399 :documentation-property 'widget-subclass-responsibility |
1260 :value-create 'widget-subclass-responsibility | 1400 :value-create 'widget-subclass-responsibility |
1261 :value-delete 'widget-children-value-delete | 1401 :value-delete 'widget-children-value-delete |
1270 (widget-put widget :value (widget-apply widget | 1410 (widget-put widget :value (widget-apply widget |
1271 :value-to-internal (car args))) | 1411 :value-to-internal (car args))) |
1272 (widget-put widget :tag (custom-unlispify-tag-name (car args))) | 1412 (widget-put widget :tag (custom-unlispify-tag-name (car args))) |
1273 (widget-put widget :args nil))) | 1413 (widget-put widget :args nil))) |
1274 widget) | 1414 widget) |
1275 | |
1276 (defun custom-format-handler (widget escape) | |
1277 ;; We recognize extra escape sequences. | |
1278 (let* ((buttons (widget-get widget :buttons)) | |
1279 (state (widget-get widget :custom-state)) | |
1280 (level (widget-get widget :custom-level))) | |
1281 (cond ((eq escape ?l) | |
1282 (when level | |
1283 (insert-char ?\ (1- level)) | |
1284 (if (eq state 'hidden) | |
1285 (insert-char ?- (1+ level)) | |
1286 (insert "/") | |
1287 (insert-char ?- level)))) | |
1288 ((eq escape ?e) | |
1289 (when (and level (not (eq state 'hidden))) | |
1290 (insert "\n") | |
1291 (insert-char ?\ (1- level)) | |
1292 (insert "\\") | |
1293 (insert-char ?- level) | |
1294 (insert " " (widget-get widget :tag) " group end ") | |
1295 (insert-char ?- (- 75 (current-column) level)) | |
1296 (insert "/\n"))) | |
1297 ((eq escape ?-) | |
1298 (when (and level (not (eq state 'hidden))) | |
1299 (insert-char ?- (- 76 (current-column) level)) | |
1300 (insert "\\"))) | |
1301 ((eq escape ?L) | |
1302 (push (widget-create-child-and-convert | |
1303 widget 'visibility | |
1304 :action 'custom-toggle-parent | |
1305 (not (eq state 'hidden))) | |
1306 buttons)) | |
1307 ((eq escape ?m) | |
1308 (and (eq (preceding-char) ?\n) | |
1309 (widget-get widget :indent) | |
1310 (insert-char ? (widget-get widget :indent))) | |
1311 (let ((magic (widget-create-child-and-convert | |
1312 widget 'custom-magic nil))) | |
1313 (widget-put widget :custom-magic magic) | |
1314 (push magic buttons) | |
1315 (widget-put widget :buttons buttons))) | |
1316 ((eq escape ?a) | |
1317 (unless (eq state 'hidden) | |
1318 (let* ((symbol (widget-get widget :value)) | |
1319 (links (get symbol 'custom-links)) | |
1320 (many (> (length links) 2))) | |
1321 (when links | |
1322 (and (eq (preceding-char) ?\n) | |
1323 (widget-get widget :indent) | |
1324 (insert-char ? (widget-get widget :indent))) | |
1325 (insert "See also ") | |
1326 (while links | |
1327 (push (widget-create-child-and-convert widget (car links)) | |
1328 buttons) | |
1329 (setq links (cdr links)) | |
1330 (cond ((null links) | |
1331 (insert ".\n")) | |
1332 ((null (cdr links)) | |
1333 (if many | |
1334 (insert ", and ") | |
1335 (insert " and "))) | |
1336 (t | |
1337 (insert ", ")))) | |
1338 (widget-put widget :buttons buttons))))) | |
1339 (t | |
1340 (widget-default-format-handler widget escape))))) | |
1341 | 1415 |
1342 (defun custom-notify (widget &rest args) | 1416 (defun custom-notify (widget &rest args) |
1343 "Keep track of changes." | 1417 "Keep track of changes." |
1344 (let ((state (widget-get widget :custom-state))) | 1418 (let ((state (widget-get widget :custom-state))) |
1345 (unless (eq state 'modified) | 1419 (unless (eq state 'modified) |
1369 | 1443 |
1370 (defun custom-redraw-magic (widget) | 1444 (defun custom-redraw-magic (widget) |
1371 "Redraw WIDGET state with current settings." | 1445 "Redraw WIDGET state with current settings." |
1372 (while widget | 1446 (while widget |
1373 (let ((magic (widget-get widget :custom-magic))) | 1447 (let ((magic (widget-get widget :custom-magic))) |
1374 (unless magic | 1448 (cond (magic |
1375 (debug)) | 1449 (widget-value-set magic (widget-value magic)) |
1376 (widget-value-set magic (widget-value magic)) | 1450 (when (setq widget (widget-get widget :group)) |
1377 (when (setq widget (widget-get widget :group)) | 1451 (custom-group-state-update widget))) |
1378 (custom-group-state-update widget)))) | 1452 (t |
1453 (setq widget nil))))) | |
1379 (widget-setup)) | 1454 (widget-setup)) |
1380 | 1455 |
1381 (defun custom-show (widget value) | 1456 (defun custom-show (widget value) |
1382 "Non-nil if WIDGET should be shown with VALUE by default." | 1457 "Non-nil if WIDGET should be shown with VALUE by default." |
1383 (let ((show (widget-get widget :custom-show))) | 1458 (let ((show (widget-get widget :custom-show))) |
1428 ((eq state 'hidden) | 1503 ((eq state 'hidden) |
1429 (widget-put widget :custom-state 'unknown)) | 1504 (widget-put widget :custom-state 'unknown)) |
1430 (t | 1505 (t |
1431 (widget-put widget :documentation-shown nil) | 1506 (widget-put widget :documentation-shown nil) |
1432 (widget-put widget :custom-state 'hidden))) | 1507 (widget-put widget :custom-state 'hidden))) |
1433 (custom-redraw widget))) | 1508 (custom-redraw widget) |
1509 (widget-setup))) | |
1434 | 1510 |
1435 (defun custom-toggle-parent (widget &rest ignore) | 1511 (defun custom-toggle-parent (widget &rest ignore) |
1436 "Toggle visibility of parent to WIDGET." | 1512 "Toggle visibility of parent to WIDGET." |
1437 (custom-toggle-hide (widget-get widget :parent))) | 1513 (custom-toggle-hide (widget-get widget :parent))) |
1438 | 1514 |
1515 (defun custom-add-see-also (widget &optional prefix) | |
1516 "Add `See also ...' to WIDGET if there are any links. | |
1517 Insert PREFIX first if non-nil." | |
1518 (let* ((symbol (widget-get widget :value)) | |
1519 (links (get symbol 'custom-links)) | |
1520 (many (> (length links) 2)) | |
1521 (buttons (widget-get widget :buttons)) | |
1522 (indent (widget-get widget :indent))) | |
1523 (when links | |
1524 (when indent | |
1525 (insert-char ?\ indent)) | |
1526 (when prefix | |
1527 (insert prefix)) | |
1528 (insert "See also ") | |
1529 (while links | |
1530 (push (widget-create-child-and-convert widget (car links)) | |
1531 buttons) | |
1532 (setq links (cdr links)) | |
1533 (cond ((null links) | |
1534 (insert ".\n")) | |
1535 ((null (cdr links)) | |
1536 (if many | |
1537 (insert ", and ") | |
1538 (insert " and "))) | |
1539 (t | |
1540 (insert ", ")))) | |
1541 (widget-put widget :buttons buttons)))) | |
1542 | |
1543 (defun custom-add-parent-links (widget) | |
1544 "Add `Parent groups: ...' to WIDGET." | |
1545 (let ((name (widget-value widget)) | |
1546 (type (widget-type widget)) | |
1547 (buttons (widget-get widget :buttons)) | |
1548 found) | |
1549 (insert "Parent groups:") | |
1550 (mapatoms (lambda (symbol) | |
1551 (let ((group (get symbol 'custom-group))) | |
1552 (when (assq name group) | |
1553 (when (eq type (nth 1 (assq name group))) | |
1554 (insert " ") | |
1555 (push (widget-create-child-and-convert | |
1556 widget 'custom-group-link | |
1557 :tag (custom-unlispify-tag-name symbol) | |
1558 symbol) | |
1559 buttons) | |
1560 (setq found t)))))) | |
1561 (widget-put widget :buttons buttons) | |
1562 (unless found | |
1563 (insert " (none)")) | |
1564 (insert "\n"))) | |
1565 | |
1439 ;;; The `custom-variable' Widget. | 1566 ;;; The `custom-variable' Widget. |
1440 | 1567 |
1441 (defface custom-variable-sample-face '((t (:underline t))) | 1568 (defface custom-variable-sample-face '((t (:underline t))) |
1442 "Face used for unpushable variable tags." | 1569 "Face used for unpushable variable tags." |
1443 :group 'custom-faces) | 1570 :group 'custom-faces) |
1446 "Face used for pushable variable tags." | 1573 "Face used for pushable variable tags." |
1447 :group 'custom-faces) | 1574 :group 'custom-faces) |
1448 | 1575 |
1449 (define-widget 'custom-variable 'custom | 1576 (define-widget 'custom-variable 'custom |
1450 "Customize variable." | 1577 "Customize variable." |
1451 :format "%v%m%h%a" | 1578 :format "%v" |
1452 :help-echo "Set or reset this variable." | 1579 :help-echo "Set or reset this variable." |
1453 :documentation-property 'variable-documentation | 1580 :documentation-property 'variable-documentation |
1454 :custom-category 'option | 1581 :custom-category 'option |
1455 :custom-state nil | 1582 :custom-state nil |
1456 :custom-menu 'custom-variable-menu-create | 1583 :custom-menu 'custom-variable-menu-create |
1489 (symbol (widget-get widget :value)) | 1616 (symbol (widget-get widget :value)) |
1490 (tag (widget-get widget :tag)) | 1617 (tag (widget-get widget :tag)) |
1491 (type (custom-variable-type symbol)) | 1618 (type (custom-variable-type symbol)) |
1492 (conv (widget-convert type)) | 1619 (conv (widget-convert type)) |
1493 (get (or (get symbol 'custom-get) 'default-value)) | 1620 (get (or (get symbol 'custom-get) 'default-value)) |
1621 (prefix (widget-get widget :custom-prefix)) | |
1622 (last (widget-get widget :custom-last)) | |
1494 (value (if (default-boundp symbol) | 1623 (value (if (default-boundp symbol) |
1495 (funcall get symbol) | 1624 (funcall get symbol) |
1496 (widget-get conv :value)))) | 1625 (widget-get conv :value)))) |
1497 ;; If the widget is new, the child determine whether it is hidden. | 1626 ;; If the widget is new, the child determine whether it is hidden. |
1498 (cond (state) | 1627 (cond (state) |
1504 (when (eq state 'unknown) | 1633 (when (eq state 'unknown) |
1505 (unless (widget-apply conv :match value) | 1634 (unless (widget-apply conv :match value) |
1506 ;; (widget-apply (widget-convert type) :match value) | 1635 ;; (widget-apply (widget-convert type) :match value) |
1507 (setq form 'lisp))) | 1636 (setq form 'lisp))) |
1508 ;; Now we can create the child widget. | 1637 ;; Now we can create the child widget. |
1509 (cond ((eq state 'hidden) | 1638 (cond ((eq custom-buffer-style 'tree) |
1639 (insert prefix (if last " `--- " " |--- ")) | |
1640 (push (widget-create-child-and-convert | |
1641 widget 'custom-tree-variable-tag) | |
1642 buttons) | |
1643 (insert " " tag "\n") | |
1644 (widget-put widget :buttons buttons)) | |
1645 ((eq state 'hidden) | |
1510 ;; Indicate hidden value. | 1646 ;; Indicate hidden value. |
1511 (push (widget-create-child-and-convert | 1647 (push (widget-create-child-and-convert |
1512 widget 'item | 1648 widget 'item |
1513 :format "%{%t%}: " | 1649 :format "%{%t%}: " |
1514 :sample-face 'custom-variable-sample-face | 1650 :sample-face 'custom-variable-sample-face |
1515 :tag tag | 1651 :tag tag |
1516 :parent widget) | 1652 :parent widget) |
1517 buttons) | 1653 buttons) |
1518 (push (widget-create-child-and-convert | 1654 (push (widget-create-child-and-convert |
1519 widget 'visibility | 1655 widget 'visibility |
1656 :help-echo "Show the value of this option." | |
1520 :action 'custom-toggle-parent | 1657 :action 'custom-toggle-parent |
1521 nil) | 1658 nil) |
1522 buttons)) | 1659 buttons)) |
1523 ((eq form 'lisp) | 1660 ((eq form 'lisp) |
1524 ;; In lisp mode edit the saved value when possible. | 1661 ;; In lisp mode edit the saved value when possible. |
1530 (custom-quote (funcall get symbol))) | 1667 (custom-quote (funcall get symbol))) |
1531 (t | 1668 (t |
1532 (custom-quote (widget-get conv :value)))))) | 1669 (custom-quote (widget-get conv :value)))))) |
1533 (insert (symbol-name symbol) ": ") | 1670 (insert (symbol-name symbol) ": ") |
1534 (push (widget-create-child-and-convert | 1671 (push (widget-create-child-and-convert |
1535 widget 'visibility | 1672 widget 'visibility |
1536 :action 'custom-toggle-parent | 1673 :help-echo "Hide the value of this option." |
1537 t) | 1674 :action 'custom-toggle-parent |
1538 buttons) | 1675 t) |
1676 buttons) | |
1539 (insert " ") | 1677 (insert " ") |
1540 (push (widget-create-child-and-convert | 1678 (push (widget-create-child-and-convert |
1541 widget 'sexp | 1679 widget 'sexp |
1542 :button-face 'custom-variable-button-face | 1680 :button-face 'custom-variable-button-face |
1543 :format "%v" | 1681 :format "%v" |
1555 (setq value-format (substring format (match-end 0))) | 1693 (setq value-format (substring format (match-end 0))) |
1556 (push (widget-create-child-and-convert | 1694 (push (widget-create-child-and-convert |
1557 widget 'item | 1695 widget 'item |
1558 :format tag-format | 1696 :format tag-format |
1559 :action 'custom-tag-action | 1697 :action 'custom-tag-action |
1698 :help-echo "Change value of this option." | |
1560 :mouse-down-action 'custom-tag-mouse-down-action | 1699 :mouse-down-action 'custom-tag-mouse-down-action |
1561 :button-face 'custom-variable-button-face | 1700 :button-face 'custom-variable-button-face |
1562 :sample-face 'custom-variable-sample-face | 1701 :sample-face 'custom-variable-sample-face |
1563 tag) | 1702 tag) |
1564 buttons) | 1703 buttons) |
1565 (insert " ") | 1704 (insert " ") |
1566 (push (widget-create-child-and-convert | 1705 (push (widget-create-child-and-convert |
1567 widget 'visibility | 1706 widget 'visibility |
1707 :help-echo "Hide the value of this option." | |
1568 :action 'custom-toggle-parent | 1708 :action 'custom-toggle-parent |
1569 t) | 1709 t) |
1570 buttons) | 1710 buttons) |
1571 (push (widget-create-child-and-convert | 1711 (push (widget-create-child-and-convert |
1572 widget type | 1712 widget type |
1573 :format value-format | 1713 :format value-format |
1574 :value value) | 1714 :value value) |
1575 children)))) | 1715 children)))) |
1576 ;; Now update the state. | 1716 (unless (eq custom-buffer-style 'tree) |
1577 (unless (eq (preceding-char) ?\n) | 1717 ;; Now update the state. |
1578 (widget-insert "\n")) | 1718 (unless (eq (preceding-char) ?\n) |
1579 (if (eq state 'hidden) | 1719 (widget-insert "\n")) |
1580 (widget-put widget :custom-state state) | 1720 (if (eq state 'hidden) |
1581 (custom-variable-state-set widget)) | 1721 (widget-put widget :custom-state state) |
1582 (widget-put widget :custom-form form) | 1722 (custom-variable-state-set widget)) |
1583 (widget-put widget :buttons buttons) | 1723 ;; Create the magic button. |
1584 (widget-put widget :children children))) | 1724 (let ((magic (widget-create-child-and-convert |
1725 widget 'custom-magic nil))) | |
1726 (widget-put widget :custom-magic magic) | |
1727 (push magic buttons)) | |
1728 ;; Update properties. | |
1729 (widget-put widget :custom-form form) | |
1730 (widget-put widget :buttons buttons) | |
1731 (widget-put widget :children children) | |
1732 ;; Insert documentation. | |
1733 (widget-default-format-handler widget ?h) | |
1734 ;; See also. | |
1735 (unless (eq state 'hidden) | |
1736 (when (eq (widget-get widget :custom-level) 1) | |
1737 (custom-add-parent-links widget)) | |
1738 (custom-add-see-also widget))))) | |
1585 | 1739 |
1586 (defun custom-tag-action (widget &rest args) | 1740 (defun custom-tag-action (widget &rest args) |
1587 "Pass :action to first child of WIDGET's parent." | 1741 "Pass :action to first child of WIDGET's parent." |
1588 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children)) | 1742 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children)) |
1589 :action args)) | 1743 :action args)) |
1621 'changed)) | 1775 'changed)) |
1622 (t 'rogue)))) | 1776 (t 'rogue)))) |
1623 (widget-put widget :custom-state state))) | 1777 (widget-put widget :custom-state state))) |
1624 | 1778 |
1625 (defvar custom-variable-menu | 1779 (defvar custom-variable-menu |
1626 '(("Edit" custom-variable-edit | 1780 '(("Set" custom-variable-set |
1627 (lambda (widget) | |
1628 (not (eq (widget-get widget :custom-form) 'edit)))) | |
1629 ("Edit Lisp" custom-variable-edit-lisp | |
1630 (lambda (widget) | |
1631 (not (eq (widget-get widget :custom-form) 'lisp)))) | |
1632 ("Set" custom-variable-set | |
1633 (lambda (widget) | 1781 (lambda (widget) |
1634 (eq (widget-get widget :custom-state) 'modified))) | 1782 (eq (widget-get widget :custom-state) 'modified))) |
1635 ("Save" custom-variable-save | 1783 ("Save" custom-variable-save |
1636 (lambda (widget) | 1784 (lambda (widget) |
1637 (memq (widget-get widget :custom-state) '(modified set changed rogue)))) | 1785 (memq (widget-get widget :custom-state) '(modified set changed rogue)))) |
1646 '(modified set changed rogue))))) | 1794 '(modified set changed rogue))))) |
1647 ("Reset to Standard Settings" custom-variable-reset-standard | 1795 ("Reset to Standard Settings" custom-variable-reset-standard |
1648 (lambda (widget) | 1796 (lambda (widget) |
1649 (and (get (widget-value widget) 'standard-value) | 1797 (and (get (widget-value widget) 'standard-value) |
1650 (memq (widget-get widget :custom-state) | 1798 (memq (widget-get widget :custom-state) |
1651 '(modified set changed saved rogue)))))) | 1799 '(modified set changed saved rogue))))) |
1800 ("---" ignore ignore) | |
1801 ("Don't show as Lisp expression" custom-variable-edit | |
1802 (lambda (widget) | |
1803 (not (eq (widget-get widget :custom-form) 'edit)))) | |
1804 ("Show as Lisp expression" custom-variable-edit-lisp | |
1805 (lambda (widget) | |
1806 (not (eq (widget-get widget :custom-form) 'lisp))))) | |
1652 "Alist of actions for the `custom-variable' widget. | 1807 "Alist of actions for the `custom-variable' widget. |
1653 Each entry has the form (NAME ACTION FILTER) where NAME is the name of | 1808 Each entry has the form (NAME ACTION FILTER) where NAME is the name of |
1654 the menu entry, ACTION is the function to call on the widget when the | 1809 the menu entry, ACTION is the function to call on the widget when the |
1655 menu is selected, and FILTER is a predicate which takes a `custom-variable' | 1810 menu is selected, and FILTER is a predicate which takes a `custom-variable' |
1656 widget as an argument, and returns non-nil if ACTION is valid on that | 1811 widget as an argument, and returns non-nil if ACTION is valid on that |
1854 "Face used for face tags." | 2009 "Face used for face tags." |
1855 :group 'custom-faces) | 2010 :group 'custom-faces) |
1856 | 2011 |
1857 (define-widget 'custom-face 'custom | 2012 (define-widget 'custom-face 'custom |
1858 "Customize face." | 2013 "Customize face." |
1859 :format "%{%t%}: %s %L\n%m%h%a%v" | |
1860 :format-handler 'custom-face-format-handler | |
1861 :sample-face 'custom-face-tag-face | 2014 :sample-face 'custom-face-tag-face |
1862 :help-echo "Set or reset this face." | 2015 :help-echo "Set or reset this face." |
1863 :documentation-property '(lambda (face) | 2016 :documentation-property '(lambda (face) |
1864 (face-doc-string face)) | 2017 (face-doc-string face)) |
1865 :value-create 'custom-face-value-create | 2018 :value-create 'custom-face-value-create |
1871 :custom-reset-current 'custom-redraw | 2024 :custom-reset-current 'custom-redraw |
1872 :custom-reset-saved 'custom-face-reset-saved | 2025 :custom-reset-saved 'custom-face-reset-saved |
1873 :custom-reset-standard 'custom-face-reset-standard | 2026 :custom-reset-standard 'custom-face-reset-standard |
1874 :custom-menu 'custom-face-menu-create) | 2027 :custom-menu 'custom-face-menu-create) |
1875 | 2028 |
1876 (defun custom-face-format-handler (widget escape) | |
1877 ;; We recognize extra escape sequences. | |
1878 (let (child | |
1879 (symbol (widget-get widget :value))) | |
1880 (cond ((eq escape ?s) | |
1881 (and (string-match "XEmacs" emacs-version) | |
1882 ;; XEmacs cannot display initialized faces. | |
1883 (not (custom-facep symbol)) | |
1884 (copy-face 'custom-face-empty symbol)) | |
1885 (setq child (widget-create-child-and-convert | |
1886 widget 'item | |
1887 :format "(%{%t%})" | |
1888 :sample-face symbol | |
1889 :tag "sample"))) | |
1890 (t | |
1891 (custom-format-handler widget escape))) | |
1892 (when child | |
1893 (widget-put widget | |
1894 :buttons (cons child (widget-get widget :buttons)))))) | |
1895 | |
1896 (define-widget 'custom-face-all 'editable-list | 2029 (define-widget 'custom-face-all 'editable-list |
1897 "An editable list of display specifications and attributes." | 2030 "An editable list of display specifications and attributes." |
1898 :entry-format "%i %d %v" | 2031 :entry-format "%i %d %v" |
1899 :insert-button-args '(:help-echo "Insert new display specification here.") | 2032 :insert-button-args '(:help-echo "Insert new display specification here.") |
1900 :append-button-args '(:help-echo "Append new display specification here.") | 2033 :append-button-args '(:help-echo "Append new display specification here.") |
1924 | 2057 |
1925 (defconst custom-face-selected (widget-convert 'custom-face-selected) | 2058 (defconst custom-face-selected (widget-convert 'custom-face-selected) |
1926 "Converted version of the `custom-face-selected' widget.") | 2059 "Converted version of the `custom-face-selected' widget.") |
1927 | 2060 |
1928 (defun custom-face-value-create (widget) | 2061 (defun custom-face-value-create (widget) |
1929 ;; Create a list of the display specifications. | 2062 "Create a list of the display specifications for WIDGET." |
1930 (unless (eq (preceding-char) ?\n) | 2063 (let ((buttons (widget-get widget :buttons)) |
1931 (insert "\n")) | 2064 (symbol (widget-get widget :value)) |
1932 (when (not (eq (widget-get widget :custom-state) 'hidden)) | 2065 (tag (widget-get widget :tag)) |
1933 (message "Creating face editor...") | 2066 (state (widget-get widget :custom-state)) |
1934 (custom-load-widget widget) | 2067 (begin (point)) |
1935 (let* ((symbol (widget-value widget)) | 2068 (is-last (widget-get widget :custom-last)) |
1936 (spec (or (get symbol 'saved-face) | 2069 (prefix (widget-get widget :custom-prefix))) |
1937 (get symbol 'face-defface-spec) | 2070 (unless tag |
1938 ;; Attempt to construct it. | 2071 (setq tag (prin1-to-string symbol))) |
1939 (list (list t (custom-face-attributes-get | 2072 (cond ((eq custom-buffer-style 'tree) |
1940 symbol (selected-frame)))))) | 2073 (insert prefix (if is-last " `--- " " |--- ")) |
1941 (form (widget-get widget :custom-form)) | 2074 (push (widget-create-child-and-convert |
1942 (indent (widget-get widget :indent)) | 2075 widget 'custom-tree-face-tag) |
1943 (edit (widget-create-child-and-convert | 2076 buttons) |
1944 widget | 2077 (insert " " tag "\n") |
1945 (cond ((and (eq form 'selected) | 2078 (widget-put widget :buttons buttons)) |
1946 (widget-apply custom-face-selected :match spec)) | 2079 (t |
1947 (when indent (insert-char ?\ indent)) | 2080 ;; Create tag. |
1948 'custom-face-selected) | 2081 (insert tag) |
1949 ((and (not (eq form 'lisp)) | 2082 (if (eq custom-buffer-style 'face) |
1950 (widget-apply custom-face-all :match spec)) | 2083 (insert " ") |
1951 'custom-face-all) | 2084 (widget-specify-sample widget begin (point)) |
1952 (t | 2085 (insert ": ")) |
1953 (when indent (insert-char ?\ indent)) | 2086 ;; Sample. |
1954 'sexp)) | 2087 (and (string-match "XEmacs" emacs-version) |
1955 :value spec))) | 2088 ;; XEmacs cannot display uninitialized faces. |
1956 (custom-face-state-set widget) | 2089 (not (custom-facep symbol)) |
1957 (widget-put widget :children (list edit))) | 2090 (copy-face 'custom-face-empty symbol)) |
1958 (message "Creating face editor...done"))) | 2091 (push (widget-create-child-and-convert widget 'item |
2092 :format "(%{%t%})" | |
2093 :sample-face symbol | |
2094 :tag "sample") | |
2095 buttons) | |
2096 ;; Visibility. | |
2097 (insert " ") | |
2098 (push (widget-create-child-and-convert | |
2099 widget 'visibility | |
2100 :help-echo "Hide or show this face." | |
2101 :action 'custom-toggle-parent | |
2102 (not (eq state 'hidden))) | |
2103 buttons) | |
2104 ;; Magic. | |
2105 (insert "\n") | |
2106 (let ((magic (widget-create-child-and-convert | |
2107 widget 'custom-magic nil))) | |
2108 (widget-put widget :custom-magic magic) | |
2109 (push magic buttons)) | |
2110 ;; Update buttons. | |
2111 (widget-put widget :buttons buttons) | |
2112 ;; Insert documentation. | |
2113 (widget-default-format-handler widget ?h) | |
2114 ;; See also. | |
2115 (unless (eq state 'hidden) | |
2116 (when (eq (widget-get widget :custom-level) 1) | |
2117 (custom-add-parent-links widget)) | |
2118 (custom-add-see-also widget)) | |
2119 ;; Editor. | |
2120 (unless (eq (preceding-char) ?\n) | |
2121 (insert "\n")) | |
2122 (unless (eq state 'hidden) | |
2123 (message "Creating face editor...") | |
2124 (custom-load-widget widget) | |
2125 (let* ((symbol (widget-value widget)) | |
2126 (spec (or (get symbol 'saved-face) | |
2127 (get symbol 'face-defface-spec) | |
2128 ;; Attempt to construct it. | |
2129 (list (list t (custom-face-attributes-get | |
2130 symbol (selected-frame)))))) | |
2131 (form (widget-get widget :custom-form)) | |
2132 (indent (widget-get widget :indent)) | |
2133 (edit (widget-create-child-and-convert | |
2134 widget | |
2135 (cond ((and (eq form 'selected) | |
2136 (widget-apply custom-face-selected | |
2137 :match spec)) | |
2138 (when indent (insert-char ?\ indent)) | |
2139 'custom-face-selected) | |
2140 ((and (not (eq form 'lisp)) | |
2141 (widget-apply custom-face-all | |
2142 :match spec)) | |
2143 'custom-face-all) | |
2144 (t | |
2145 (when indent (insert-char ?\ indent)) | |
2146 'sexp)) | |
2147 :value spec))) | |
2148 (custom-face-state-set widget) | |
2149 (widget-put widget :children (list edit))) | |
2150 (message "Creating face editor...done")))))) | |
1959 | 2151 |
1960 (defvar custom-face-menu | 2152 (defvar custom-face-menu |
1961 '(("Edit Selected" custom-face-edit-selected | 2153 '(("Set" custom-face-set) |
1962 (lambda (widget) | |
1963 (not (eq (widget-get widget :custom-form) 'selected)))) | |
1964 ("Edit All" custom-face-edit-all | |
1965 (lambda (widget) | |
1966 (not (eq (widget-get widget :custom-form) 'all)))) | |
1967 ("Edit Lisp" custom-face-edit-lisp | |
1968 (lambda (widget) | |
1969 (not (eq (widget-get widget :custom-form) 'lisp)))) | |
1970 ("Set" custom-face-set) | |
1971 ("Save" custom-face-save) | 2154 ("Save" custom-face-save) |
1972 ("Reset to Saved" custom-face-reset-saved | 2155 ("Reset to Saved" custom-face-reset-saved |
1973 (lambda (widget) | 2156 (lambda (widget) |
1974 (get (widget-value widget) 'saved-face))) | 2157 (get (widget-value widget) 'saved-face))) |
1975 ("Reset to Standard Setting" custom-face-reset-standard | 2158 ("Reset to Standard Setting" custom-face-reset-standard |
1976 (lambda (widget) | 2159 (lambda (widget) |
1977 (get (widget-value widget) 'face-defface-spec)))) | 2160 (get (widget-value widget) 'face-defface-spec))) |
2161 ("---" ignore ignore) | |
2162 ("Show all display specs" custom-face-edit-all | |
2163 (lambda (widget) | |
2164 (not (eq (widget-get widget :custom-form) 'all)))) | |
2165 ("Just current attributes" custom-face-edit-selected | |
2166 (lambda (widget) | |
2167 (not (eq (widget-get widget :custom-form) 'selected)))) | |
2168 ("Show as Lisp expression" custom-face-edit-lisp | |
2169 (lambda (widget) | |
2170 (not (eq (widget-get widget :custom-form) 'lisp))))) | |
1978 "Alist of actions for the `custom-face' widget. | 2171 "Alist of actions for the `custom-face' widget. |
1979 Each entry has the form (NAME ACTION FILTER) where NAME is the name of | 2172 Each entry has the form (NAME ACTION FILTER) where NAME is the name of |
1980 the menu entry, ACTION is the function to call on the widget when the | 2173 the menu entry, ACTION is the function to call on the widget when the |
1981 menu is selected, and FILTER is a predicate which takes a `custom-face' | 2174 menu is selected, and FILTER is a predicate which takes a `custom-face' |
1982 widget as an argument, and returns non-nil if ACTION is valid on that | 2175 widget as an argument, and returns non-nil if ACTION is valid on that |
2080 ;;; The `face' Widget. | 2273 ;;; The `face' Widget. |
2081 | 2274 |
2082 (define-widget 'face 'default | 2275 (define-widget 'face 'default |
2083 "Select and customize a face." | 2276 "Select and customize a face." |
2084 :convert-widget 'widget-value-convert-widget | 2277 :convert-widget 'widget-value-convert-widget |
2085 :format "%[%t%]: %v" | 2278 :button-prefix 'widget-push-button-prefix |
2279 :button-suffix 'widget-push-button-suffix | |
2280 :format "%t: %[select face%] %v" | |
2086 :tag "Face" | 2281 :tag "Face" |
2087 :value 'default | 2282 :value 'default |
2088 :value-create 'widget-face-value-create | 2283 :value-create 'widget-face-value-create |
2089 :value-delete 'widget-face-value-delete | 2284 :value-delete 'widget-face-value-delete |
2090 :value-get 'widget-value-value-get | 2285 :value-get 'widget-value-value-get |
2093 :match '(lambda (widget value) (symbolp value))) | 2288 :match '(lambda (widget value) (symbolp value))) |
2094 | 2289 |
2095 (defun widget-face-value-create (widget) | 2290 (defun widget-face-value-create (widget) |
2096 ;; Create a `custom-face' child. | 2291 ;; Create a `custom-face' child. |
2097 (let* ((symbol (widget-value widget)) | 2292 (let* ((symbol (widget-value widget)) |
2293 (custom-buffer-style 'face) | |
2098 (child (widget-create-child-and-convert | 2294 (child (widget-create-child-and-convert |
2099 widget 'custom-face | 2295 widget 'custom-face |
2100 :format "%t %s %L\n%m%h%v" | |
2101 :custom-level nil | 2296 :custom-level nil |
2102 :value symbol))) | 2297 :value symbol))) |
2103 (custom-magic-reset child) | 2298 (custom-magic-reset child) |
2104 (setq custom-options (cons child custom-options)) | 2299 (setq custom-options (cons child custom-options)) |
2105 (widget-put widget :children (list child)))) | 2300 (widget-put widget :children (list child)))) |
2147 other) | 2342 other) |
2148 (list other)))) | 2343 (list other)))) |
2149 (widget-put widget :args args) | 2344 (widget-put widget :args args) |
2150 widget)) | 2345 widget)) |
2151 | 2346 |
2347 ;;; The `custom-group-link' Widget. | |
2348 | |
2349 (define-widget 'custom-group-link 'link | |
2350 "Show parent in other window when activated." | |
2351 :help-echo "Create customize buffer for this group group." | |
2352 :action 'custom-group-link-action) | |
2353 | |
2354 (defun custom-group-link-action (widget &rest ignore) | |
2355 (customize-group (widget-value widget))) | |
2356 | |
2152 ;;; The `custom-group' Widget. | 2357 ;;; The `custom-group' Widget. |
2153 | 2358 |
2154 (defcustom custom-group-tag-faces '(custom-group-tag-face-1) | 2359 (defcustom custom-group-tag-faces '(custom-group-tag-face-1) |
2155 ;; In XEmacs, this ought to play games with font size. | 2360 ;; In XEmacs, this ought to play games with font size. |
2156 "Face used for group tags. | 2361 "Face used for group tags. |
2179 "Face used for low level group tags." | 2384 "Face used for low level group tags." |
2180 :group 'custom-faces) | 2385 :group 'custom-faces) |
2181 | 2386 |
2182 (define-widget 'custom-group 'custom | 2387 (define-widget 'custom-group 'custom |
2183 "Customize group." | 2388 "Customize group." |
2184 :format "%l %{%t%} group: %L %-\n%m%h%a%v%e" | 2389 :format "%v" |
2185 :sample-face-get 'custom-group-sample-face-get | 2390 :sample-face-get 'custom-group-sample-face-get |
2186 :documentation-property 'group-documentation | 2391 :documentation-property 'group-documentation |
2187 :help-echo "Set or reset all members of this group." | 2392 :help-echo "Set or reset all members of this group." |
2188 :value-create 'custom-group-value-create | 2393 :value-create 'custom-group-value-create |
2189 :action 'custom-group-action | 2394 :action 'custom-group-action |
2199 ;; Use :sample-face. | 2404 ;; Use :sample-face. |
2200 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces) | 2405 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces) |
2201 'custom-group-tag-face)) | 2406 'custom-group-tag-face)) |
2202 | 2407 |
2203 (defun custom-group-value-create (widget) | 2408 (defun custom-group-value-create (widget) |
2204 (let ((state (widget-get widget :custom-state))) | 2409 "Insert a customize group for WIDGET in the current buffer." |
2205 (unless (eq state 'hidden) | 2410 (let ((state (widget-get widget :custom-state)) |
2206 (message "Creating group...") | 2411 (level (widget-get widget :custom-level)) |
2207 (custom-load-widget widget) | 2412 (indent (widget-get widget :indent)) |
2208 (let* ((level (widget-get widget :custom-level)) | 2413 (prefix (widget-get widget :custom-prefix)) |
2209 (symbol (widget-value widget)) | 2414 (buttons (widget-get widget :buttons)) |
2210 (members (sort (sort (copy-sequence (get symbol 'custom-group)) | 2415 (tag (widget-get widget :tag)) |
2211 custom-buffer-sort-predicate) | 2416 (symbol (widget-value widget))) |
2212 custom-buffer-order-predicate)) | 2417 (cond ((and (eq custom-buffer-style 'tree) |
2213 (prefixes (widget-get widget :custom-prefixes)) | 2418 (eq state 'hidden)) |
2214 (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2419 (custom-tree-insert prefix) |
2215 (length (length members)) | 2420 (push (widget-create-child-and-convert |
2216 (count 0) | 2421 widget 'custom-tree-visibility |
2217 (children (mapcar (lambda (entry) | 2422 ;; :tag-glyph "plus" |
2218 (widget-insert "\n") | 2423 :tag "+") |
2219 (message "Creating group members... %2d%%" | 2424 buttons) |
2220 (/ (* 100.0 count) length)) | 2425 (insert "-- ") |
2221 (setq count (1+ count)) | 2426 ;; (widget-glyph-insert nil "-- " "horizontal") |
2222 (prog1 | 2427 (push (widget-create-child-and-convert |
2223 (widget-create-child-and-convert | 2428 widget 'custom-tree-group-tag) |
2224 widget (nth 1 entry) | 2429 buttons) |
2225 :group widget | 2430 (insert " " tag "\n") |
2226 :tag (custom-unlispify-tag-name | 2431 (widget-put widget :buttons buttons)) |
2227 (nth 0 entry)) | 2432 ((and (eq custom-buffer-style 'tree) |
2228 :custom-prefixes custom-prefix-list | 2433 (zerop (length (get symbol 'custom-group)))) |
2229 :custom-level (1+ level) | 2434 (custom-tree-insert prefix) |
2230 :value (nth 0 entry)) | 2435 (insert "[ ]-- ") |
2231 (unless (eq (preceding-char) ?\n) | 2436 ;; (widget-glyph-insert nil "[ ]" "empty") |
2232 (widget-insert "\n")))) | 2437 ;; (widget-glyph-insert nil "-- " "horizontal") |
2233 members))) | 2438 (push (widget-create-child-and-convert |
2234 (message "Creating group magic...") | 2439 widget 'custom-tree-group-tag) |
2235 (mapcar 'custom-magic-reset children) | 2440 buttons) |
2236 (message "Creating group state...") | 2441 (insert " " tag "\n") |
2237 (widget-put widget :children children) | 2442 (widget-put widget :buttons buttons)) |
2238 (custom-group-state-update widget) | 2443 ((eq custom-buffer-style 'tree) |
2239 (message "Creating group... done"))))) | 2444 (custom-tree-insert prefix) |
2445 (custom-load-widget widget) | |
2446 (if (zerop (length (get symbol 'custom-group))) | |
2447 (progn | |
2448 (custom-tree-insert prefix) | |
2449 (insert "[ ]-- ") | |
2450 ;; (widget-glyph-insert nil "[ ]" "empty") | |
2451 ;; (widget-glyph-insert nil "-- " "horizontal") | |
2452 (push (widget-create-child-and-convert | |
2453 widget 'custom-tree-group-tag) | |
2454 buttons) | |
2455 (insert " " tag "\n") | |
2456 (widget-put widget :buttons buttons)) | |
2457 (push (widget-create-child-and-convert | |
2458 widget 'custom-tree-visibility | |
2459 ;; :tag-glyph "minus" | |
2460 :tag "-") | |
2461 buttons) | |
2462 (insert "-+ ") | |
2463 ;; (widget-glyph-insert nil "-+ " "top") | |
2464 (push (widget-create-child-and-convert | |
2465 widget 'custom-tree-group-tag) | |
2466 buttons) | |
2467 (insert " " tag "\n") | |
2468 (widget-put widget :buttons buttons) | |
2469 (message "Creating group...") | |
2470 (let* ((members (sort (copy-sequence (get symbol 'custom-group)) | |
2471 'custom-browse-sort-predicate)) | |
2472 (prefixes (widget-get widget :custom-prefixes)) | |
2473 (custom-prefix-list (custom-prefix-add symbol prefixes)) | |
2474 (length (length members)) | |
2475 (extra-prefix (if (widget-get widget :custom-last) | |
2476 " " | |
2477 " | ")) | |
2478 (prefix (concat prefix extra-prefix)) | |
2479 children entry) | |
2480 (while members | |
2481 (setq entry (car members) | |
2482 members (cdr members)) | |
2483 (push (widget-create-child-and-convert | |
2484 widget (nth 1 entry) | |
2485 :group widget | |
2486 :tag (custom-unlispify-tag-name | |
2487 (nth 0 entry)) | |
2488 :custom-prefixes custom-prefix-list | |
2489 :custom-level (1+ level) | |
2490 :custom-last (null members) | |
2491 :value (nth 0 entry) | |
2492 :custom-prefix prefix) | |
2493 children)) | |
2494 (widget-put widget :children (reverse children))) | |
2495 (message "Creating group...done"))) | |
2496 ;; Nested style. | |
2497 ((eq state 'hidden) | |
2498 ;; Create level indicator. | |
2499 (insert-char ?\ (* custom-buffer-indent (1- level))) | |
2500 (insert "-- ") | |
2501 ;; Create tag. | |
2502 (let ((begin (point))) | |
2503 (insert tag) | |
2504 (widget-specify-sample widget begin (point))) | |
2505 (insert " group: ") | |
2506 ;; Create link/visibility indicator. | |
2507 (if (eq custom-buffer-style 'links) | |
2508 (push (widget-create-child-and-convert | |
2509 widget 'custom-group-link | |
2510 :tag "Show" | |
2511 symbol) | |
2512 buttons) | |
2513 (push (widget-create-child-and-convert | |
2514 widget 'visibility | |
2515 :help-echo "Show members of this group." | |
2516 :action 'custom-toggle-parent | |
2517 (not (eq state 'hidden))) | |
2518 buttons)) | |
2519 (insert " \n") | |
2520 ;; Create magic button. | |
2521 (let ((magic (widget-create-child-and-convert | |
2522 widget 'custom-magic nil))) | |
2523 (widget-put widget :custom-magic magic) | |
2524 (push magic buttons)) | |
2525 ;; Update buttons. | |
2526 (widget-put widget :buttons buttons) | |
2527 ;; Insert documentation. | |
2528 (widget-default-format-handler widget ?h)) | |
2529 ;; Nested style. | |
2530 (t ;Visible. | |
2531 ;; Create level indicator. | |
2532 (insert-char ?\ (* custom-buffer-indent (1- level))) | |
2533 (insert "/- ") | |
2534 ;; Create tag. | |
2535 (let ((start (point))) | |
2536 (insert tag) | |
2537 (widget-specify-sample widget start (point))) | |
2538 (insert " group: ") | |
2539 ;; Create visibility indicator. | |
2540 (unless (eq custom-buffer-style 'links) | |
2541 (insert "--------") | |
2542 (push (widget-create-child-and-convert | |
2543 widget 'visibility | |
2544 :help-echo "Hide members of this group." | |
2545 :action 'custom-toggle-parent | |
2546 (not (eq state 'hidden))) | |
2547 buttons) | |
2548 (insert " ")) | |
2549 ;; Create more dashes. | |
2550 ;; Use 76 instead of 75 to compensate for the temporary "<" | |
2551 ;; added by `widget-insert'. | |
2552 (insert-char ?- (- 76 (current-column) | |
2553 (* custom-buffer-indent level))) | |
2554 (insert "\\\n") | |
2555 ;; Create magic button. | |
2556 (let ((magic (widget-create-child-and-convert | |
2557 widget 'custom-magic | |
2558 :indent 0 | |
2559 nil))) | |
2560 (widget-put widget :custom-magic magic) | |
2561 (push magic buttons)) | |
2562 ;; Update buttons. | |
2563 (widget-put widget :buttons buttons) | |
2564 ;; Insert documentation. | |
2565 (widget-default-format-handler widget ?h) | |
2566 ;; Parents and See also. | |
2567 (when (eq level 1) | |
2568 (insert-char ?\ custom-buffer-indent) | |
2569 (custom-add-parent-links widget)) | |
2570 (custom-add-see-also widget | |
2571 (make-string (* custom-buffer-indent level) | |
2572 ?\ )) | |
2573 ;; Members. | |
2574 (message "Creating group...") | |
2575 (custom-load-widget widget) | |
2576 (let* ((members (sort (copy-sequence (get symbol 'custom-group)) | |
2577 'custom-buffer-sort-predicate)) | |
2578 (prefixes (widget-get widget :custom-prefixes)) | |
2579 (custom-prefix-list (custom-prefix-add symbol prefixes)) | |
2580 (length (length members)) | |
2581 (count 0) | |
2582 (children (mapcar (lambda (entry) | |
2583 (widget-insert "\n") | |
2584 (message "\ | |
2585 Creating group members... %2d%%" | |
2586 (/ (* 100.0 count) length)) | |
2587 (setq count (1+ count)) | |
2588 (prog1 | |
2589 (widget-create-child-and-convert | |
2590 widget (nth 1 entry) | |
2591 :group widget | |
2592 :tag (custom-unlispify-tag-name | |
2593 (nth 0 entry)) | |
2594 :custom-prefixes custom-prefix-list | |
2595 :custom-level (1+ level) | |
2596 :value (nth 0 entry)) | |
2597 (unless (eq (preceding-char) ?\n) | |
2598 (widget-insert "\n")))) | |
2599 members))) | |
2600 (message "Creating group magic...") | |
2601 (mapcar 'custom-magic-reset children) | |
2602 (message "Creating group state...") | |
2603 (widget-put widget :children children) | |
2604 (custom-group-state-update widget) | |
2605 (message "Creating group... done")) | |
2606 ;; End line | |
2607 (insert "\n") | |
2608 (insert-char ?\ (* custom-buffer-indent (1- level))) | |
2609 (insert "\\- " (widget-get widget :tag) " group end ") | |
2610 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level))) | |
2611 (insert "/\n"))))) | |
2240 | 2612 |
2241 (defvar custom-group-menu | 2613 (defvar custom-group-menu |
2242 '(("Set" custom-group-set | 2614 '(("Set" custom-group-set |
2243 (lambda (widget) | 2615 (lambda (widget) |
2244 (eq (widget-get widget :custom-state) 'modified))) | 2616 (eq (widget-get widget :custom-state) 'modified))) |
2335 (setq magics (cdr magics))))) | 2707 (setq magics (cdr magics))))) |
2336 (widget-put widget :custom-state found))) | 2708 (widget-put widget :custom-state found))) |
2337 (custom-magic-reset widget)) | 2709 (custom-magic-reset widget)) |
2338 | 2710 |
2339 ;;; The `custom-save-all' Function. | 2711 ;;; The `custom-save-all' Function. |
2340 | 2712 ;;;###autoload |
2341 (defcustom custom-file "~/.emacs" | 2713 (defcustom custom-file (if (featurep 'xemacs) |
2714 "~/.xemacs-custom" | |
2715 "~/.emacs") | |
2342 "File used for storing customization information. | 2716 "File used for storing customization information. |
2343 If you change this from the default \"~/.emacs\" you need to | 2717 If you change this from the default \"~/.emacs\" you need to |
2344 explicitly load that file for the settings to take effect." | 2718 explicitly load that file for the settings to take effect." |
2345 :type 'file | 2719 :type 'file |
2346 :group 'customize) | 2720 :group 'customize) |
2460 ;;; The Customize Menu. | 2834 ;;; The Customize Menu. |
2461 | 2835 |
2462 ;;; Menu support | 2836 ;;; Menu support |
2463 | 2837 |
2464 (unless (string-match "XEmacs" emacs-version) | 2838 (unless (string-match "XEmacs" emacs-version) |
2465 (defconst custom-help-menu '("Customize" | 2839 (defconst custom-help-menu |
2466 ["Update menu..." custom-menu-update t] | 2840 '("Customize" |
2467 ["Group..." customize-group t] | 2841 ["Update menu..." custom-menu-update t] |
2468 ["Variable..." customize-variable t] | 2842 ["Group..." customize-group t] |
2469 ["Face..." customize-face t] | 2843 ["Variable..." customize-variable t] |
2470 ["Saved..." customize-saved t] | 2844 ["Face..." customize-face t] |
2471 ["Set..." customize-customized t] | 2845 ["Saved..." customize-saved t] |
2472 ["Apropos..." customize-apropos t]) | 2846 ["Set..." customize-customized t] |
2847 ["--" custom-menu-sep t] | |
2848 ["Apropos..." customize-apropos t] | |
2849 ["Group apropos..." customize-apropos-groups t] | |
2850 ["Variable apropos..." customize-apropos-options t] | |
2851 ["Face apropos..." customize-apropos-faces t]) | |
2473 ;; This menu should be identical to the one defined in `menu-bar.el'. | 2852 ;; This menu should be identical to the one defined in `menu-bar.el'. |
2474 "Customize menu") | 2853 "Customize menu") |
2475 | 2854 |
2476 (defun custom-menu-reset () | 2855 (defun custom-menu-reset () |
2477 "Reset customize menu." | 2856 "Reset customize menu." |
2547 (if (and (or (not (boundp 'custom-menu-nesting)) | 2926 (if (and (or (not (boundp 'custom-menu-nesting)) |
2548 (>= custom-menu-nesting 0)) | 2927 (>= custom-menu-nesting 0)) |
2549 (< (length (get symbol 'custom-group)) widget-menu-max-size)) | 2928 (< (length (get symbol 'custom-group)) widget-menu-max-size)) |
2550 (let ((custom-prefix-list (custom-prefix-add symbol | 2929 (let ((custom-prefix-list (custom-prefix-add symbol |
2551 custom-prefix-list)) | 2930 custom-prefix-list)) |
2552 (members (sort (sort (copy-sequence (get symbol 'custom-group)) | 2931 (members (sort (copy-sequence (get symbol 'custom-group)) |
2553 custom-menu-sort-predicate) | 2932 'custom-menu-sort-predicate))) |
2554 custom-menu-order-predicate))) | |
2555 (custom-load-symbol symbol) | 2933 (custom-load-symbol symbol) |
2556 `(,(custom-unlispify-menu-entry symbol t) | 2934 `(,(custom-unlispify-menu-entry symbol t) |
2557 ,item | 2935 ,item |
2558 "--" | 2936 "--" |
2559 ,@(mapcar (lambda (entry) | 2937 ,@(mapcar (lambda (entry) |
2589 (setq custom-mode-map (make-sparse-keymap)) | 2967 (setq custom-mode-map (make-sparse-keymap)) |
2590 (set-keymap-parent custom-mode-map widget-keymap) | 2968 (set-keymap-parent custom-mode-map widget-keymap) |
2591 (suppress-keymap custom-mode-map) | 2969 (suppress-keymap custom-mode-map) |
2592 (define-key custom-mode-map "q" 'bury-buffer)) | 2970 (define-key custom-mode-map "q" 'bury-buffer)) |
2593 | 2971 |
2594 (easy-menu-define custom-mode-customize-menu | |
2595 custom-mode-map | |
2596 "Menu used to customize customization buffers." | |
2597 (customize-menu-create 'customize)) | |
2598 | |
2599 (easy-menu-define custom-mode-menu | 2972 (easy-menu-define custom-mode-menu |
2600 custom-mode-map | 2973 custom-mode-map |
2601 "Menu used in customization buffers." | 2974 "Menu used in customization buffers." |
2602 `("Custom" | 2975 `("Custom" |
2976 ,(customize-menu-create 'customize) | |
2603 ["Set" custom-set t] | 2977 ["Set" custom-set t] |
2604 ["Save" custom-save t] | 2978 ["Save" custom-save t] |
2605 ["Reset to Current" custom-reset-current t] | 2979 ["Reset to Current" custom-reset-current t] |
2606 ["Reset to Saved" custom-reset-saved t] | 2980 ["Reset to Saved" custom-reset-saved t] |
2607 ["Reset to Standard Settings" custom-reset-standard t] | 2981 ["Reset to Standard Settings" custom-reset-standard t] |
2631 if that value is non-nil." | 3005 if that value is non-nil." |
2632 (kill-all-local-variables) | 3006 (kill-all-local-variables) |
2633 (setq major-mode 'custom-mode | 3007 (setq major-mode 'custom-mode |
2634 mode-name "Custom") | 3008 mode-name "Custom") |
2635 (use-local-map custom-mode-map) | 3009 (use-local-map custom-mode-map) |
2636 (easy-menu-add custom-mode-customize-menu) | |
2637 (easy-menu-add custom-mode-menu) | 3010 (easy-menu-add custom-mode-menu) |
2638 (make-local-variable 'custom-options) | 3011 (make-local-variable 'custom-options) |
2639 (run-hooks 'custom-mode-hook)) | 3012 (run-hooks 'custom-mode-hook)) |
2640 | 3013 |
2641 ;;; The End. | 3014 ;;; The End. |