diff options
| author | Per Abrahamsen | 1997-05-30 00:39:40 +0000 |
|---|---|---|
| committer | Per Abrahamsen | 1997-05-30 00:39:40 +0000 |
| commit | 25ac13b5bd3d9226964793f68bceaba91184ce33 (patch) | |
| tree | 88ec168f9d68c43fe77d6115c88a7d2f22b41e36 | |
| parent | eedc23361055b5d8e2421243af6bb5d6e26d69eb (diff) | |
| download | emacs-25ac13b5bd3d9226964793f68bceaba91184ce33.tar.gz emacs-25ac13b5bd3d9226964793f68bceaba91184ce33.zip | |
Synched with version 1.9900.
| -rw-r--r-- | lisp/cus-edit.el | 451 | ||||
| -rw-r--r-- | lisp/custom.el | 10 | ||||
| -rw-r--r-- | lisp/wid-edit.el | 222 | ||||
| -rw-r--r-- | lisp/widget.el | 8 |
4 files changed, 344 insertions, 347 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 1ff037d9b4d..f181568779c 100644 --- a/lisp/cus-edit.el +++ b/lisp/cus-edit.el | |||
| @@ -4,7 +4,7 @@ | |||
| 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.97 | 7 | ;; Version: 1.9900 |
| 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. |
| @@ -37,9 +37,6 @@ | |||
| 37 | (require 'easymenu) | 37 | (require 'easymenu) |
| 38 | (eval-when-compile (require 'cl)) | 38 | (eval-when-compile (require 'cl)) |
| 39 | 39 | ||
| 40 | (or (fboundp 'custom-face-display-set) | ||
| 41 | (defalias 'custom-face-display-set 'face-spec-set)) | ||
| 42 | |||
| 43 | (condition-case nil | 40 | (condition-case nil |
| 44 | (require 'cus-load) | 41 | (require 'cus-load) |
| 45 | (error nil)) | 42 | (error nil)) |
| @@ -47,10 +44,10 @@ | |||
| 47 | (define-widget-keywords :custom-prefixes :custom-menu :custom-show | 44 | (define-widget-keywords :custom-prefixes :custom-menu :custom-show |
| 48 | :custom-magic :custom-state :custom-level :custom-form | 45 | :custom-magic :custom-state :custom-level :custom-form |
| 49 | :custom-set :custom-save :custom-reset-current :custom-reset-saved | 46 | :custom-set :custom-save :custom-reset-current :custom-reset-saved |
| 50 | :custom-reset-factory) | 47 | :custom-reset-standard) |
| 51 | 48 | ||
| 52 | (put 'custom-define-hook 'custom-type 'hook) | 49 | (put 'custom-define-hook 'custom-type 'hook) |
| 53 | (put 'custom-define-hook 'factory-value '(nil)) | 50 | (put 'custom-define-hook 'standard-value '(nil)) |
| 54 | (custom-add-to-group 'customize 'custom-define-hook 'custom-variable) | 51 | (custom-add-to-group 'customize 'custom-define-hook 'custom-variable) |
| 55 | 52 | ||
| 56 | ;;; Customization Groups. | 53 | ;;; Customization Groups. |
| @@ -317,6 +314,10 @@ | |||
| 317 | "Basic stuff dealing with processes." | 314 | "Basic stuff dealing with processes." |
| 318 | :group 'processes) | 315 | :group 'processes) |
| 319 | 316 | ||
| 317 | (defgroup mule nil | ||
| 318 | "MULE Emacs internationalization." | ||
| 319 | :group 'emacs) | ||
| 320 | |||
| 320 | (defgroup windows nil | 321 | (defgroup windows nil |
| 321 | "Windows within a frame." | 322 | "Windows within a frame." |
| 322 | :group 'environment) | 323 | :group 'environment) |
| @@ -509,6 +510,52 @@ if that fails, the doc string with `custom-guess-doc-alist'." | |||
| 509 | docs nil)))))) | 510 | docs nil)))))) |
| 510 | found)) | 511 | found)) |
| 511 | 512 | ||
| 513 | ;;; Sorting. | ||
| 514 | |||
| 515 | (defcustom custom-buffer-sort-predicate 'custom-buffer-sort-alphabetically | ||
| 516 | "Function used for sorting group members in buffers. | ||
| 517 | The value should be useful as a predicate for `sort'. | ||
| 518 | The list to be sorted is the value of the groups `custom-group' property." | ||
| 519 | :type '(radio (function-item 'custom-buffer-sort-alphabetically) | ||
| 520 | (function :tag "Other")) | ||
| 521 | :group 'customize) | ||
| 522 | |||
| 523 | (defun custom-buffer-sort-alphabetically (a b) | ||
| 524 | "Return t iff is A should be before B. | ||
| 525 | A and B should be members of a `custom-group' property. | ||
| 526 | The members are sorted alphabetically, except that all groups are | ||
| 527 | sorted after all non-groups." | ||
| 528 | (cond ((and (eq (nth 1 a) 'custom-group) | ||
| 529 | (not (eq (nth 1 b) 'custom-group))) | ||
| 530 | nil) | ||
| 531 | ((and (eq (nth 1 b) 'custom-group) | ||
| 532 | (not (eq (nth 1 a) 'custom-group))) | ||
| 533 | t) | ||
| 534 | (t | ||
| 535 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b)))))) | ||
| 536 | |||
| 537 | (defcustom custom-menu-sort-predicate 'custom-menu-sort-alphabetically | ||
| 538 | "Function used for sorting group members in menus. | ||
| 539 | The value should be useful as a predicate for `sort'. | ||
| 540 | The list to be sorted is the value of the groups `custom-group' property." | ||
| 541 | :type '(radio (function-item 'custom-menu-sort-alphabetically) | ||
| 542 | (function :tag "Other")) | ||
| 543 | :group 'customize) | ||
| 544 | |||
| 545 | (defun custom-menu-sort-alphabetically (a b) | ||
| 546 | "Return t iff is A should be before B. | ||
| 547 | A and B should be members of a `custom-group' property. | ||
| 548 | The members are sorted alphabetically, except that all groups are | ||
| 549 | sorted before all non-groups." | ||
| 550 | (cond ((and (eq (nth 1 a) 'custom-group) | ||
| 551 | (not (eq (nth 1 b) 'custom-group))) | ||
| 552 | t) | ||
| 553 | ((and (eq (nth 1 b) 'custom-group) | ||
| 554 | (not (eq (nth 1 a) 'custom-group))) | ||
| 555 | nil) | ||
| 556 | (t | ||
| 557 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b)))))) | ||
| 558 | |||
| 512 | ;;; Custom Mode Commands. | 559 | ;;; Custom Mode Commands. |
| 513 | 560 | ||
| 514 | (defvar custom-options nil | 561 | (defvar custom-options nil |
| @@ -536,7 +583,7 @@ if that fails, the doc string with `custom-guess-doc-alist'." | |||
| 536 | (defvar custom-reset-menu | 583 | (defvar custom-reset-menu |
| 537 | '(("Current" . custom-reset-current) | 584 | '(("Current" . custom-reset-current) |
| 538 | ("Saved" . custom-reset-saved) | 585 | ("Saved" . custom-reset-saved) |
| 539 | ("Factory Settings" . custom-reset-factory)) | 586 | ("Standard Settings" . custom-reset-standard)) |
| 540 | "Alist of actions for the `Reset' button. | 587 | "Alist of actions for the `Reset' button. |
| 541 | The key is a string containing the name of the action, the value is a | 588 | The key is a string containing the name of the action, the value is a |
| 542 | lisp function taking the widget as an element which will be called | 589 | lisp function taking the widget as an element which will be called |
| @@ -569,7 +616,7 @@ when the action is chosen.") | |||
| 569 | (widget-apply child :custom-reset-current))) | 616 | (widget-apply child :custom-reset-current))) |
| 570 | children))) | 617 | children))) |
| 571 | 618 | ||
| 572 | (defun custom-reset-factory () | 619 | (defun custom-reset-standard () |
| 573 | "Reset all modified, set, or saved group members to their standard settings." | 620 | "Reset all modified, set, or saved group members to their standard settings." |
| 574 | (interactive) | 621 | (interactive) |
| 575 | (let ((children custom-options)) | 622 | (let ((children custom-options)) |
| @@ -675,7 +722,7 @@ are shown; the contents of those subgroups are initially hidden." | |||
| 675 | (custom-unlispify-tag-name group)))) | 722 | (custom-unlispify-tag-name group)))) |
| 676 | 723 | ||
| 677 | ;;;###autoload | 724 | ;;;###autoload |
| 678 | (defun customize-other-window (symbol) | 725 | (defun customize-group-other-window (symbol) |
| 679 | "Customize SYMBOL, which must be a customization group." | 726 | "Customize SYMBOL, which must be a customization group." |
| 680 | (interactive (list (completing-read "Customize group: (default emacs) " | 727 | (interactive (list (completing-read "Customize group: (default emacs) " |
| 681 | obarray | 728 | obarray |
| @@ -796,7 +843,7 @@ user-settable." | |||
| 796 | (setq found (cons (list symbol 'custom-face) found))) | 843 | (setq found (cons (list symbol 'custom-face) found))) |
| 797 | (when (and (boundp symbol) | 844 | (when (and (boundp symbol) |
| 798 | (or (get symbol 'saved-value) | 845 | (or (get symbol 'saved-value) |
| 799 | (get symbol 'factory-value) | 846 | (get symbol 'standard-value) |
| 800 | (if all | 847 | (if all |
| 801 | (get symbol 'variable-documentation) | 848 | (get symbol 'variable-documentation) |
| 802 | (user-variable-p symbol)))) | 849 | (user-variable-p symbol)))) |
| @@ -846,6 +893,33 @@ Push RET or click mouse-2 on the word ") | |||
| 846 | :help-echo "Read the online help." | 893 | :help-echo "Read the online help." |
| 847 | "(emacs)Easy Customization") | 894 | "(emacs)Easy Customization") |
| 848 | (widget-insert " for more information.\n\n") | 895 | (widget-insert " for more information.\n\n") |
| 896 | (message "Creating customization buttons...") | ||
| 897 | (widget-create 'push-button | ||
| 898 | :tag "Set" | ||
| 899 | :help-echo "Set all modifications for this session." | ||
| 900 | :action (lambda (widget &optional event) | ||
| 901 | (custom-set))) | ||
| 902 | (widget-insert " ") | ||
| 903 | (widget-create 'push-button | ||
| 904 | :tag "Save" | ||
| 905 | :help-echo "\ | ||
| 906 | Make the modifications default for future sessions." | ||
| 907 | :action (lambda (widget &optional event) | ||
| 908 | (custom-save))) | ||
| 909 | (widget-insert " ") | ||
| 910 | (widget-create 'push-button | ||
| 911 | :tag "Reset" | ||
| 912 | :help-echo "Undo all modifications." | ||
| 913 | :action (lambda (widget &optional event) | ||
| 914 | (custom-reset event))) | ||
| 915 | (widget-insert " ") | ||
| 916 | (widget-create 'push-button | ||
| 917 | :tag "Done" | ||
| 918 | :help-echo "Bury the buffer." | ||
| 919 | :action (lambda (widget &optional event) | ||
| 920 | (bury-buffer))) | ||
| 921 | (widget-insert "\n\n") | ||
| 922 | (message "Creating customization items...") | ||
| 849 | (setq custom-options | 923 | (setq custom-options |
| 850 | (if (= (length options) 1) | 924 | (if (= (length options) 1) |
| 851 | (mapcar (lambda (entry) | 925 | (mapcar (lambda (entry) |
| @@ -872,35 +946,8 @@ Push RET or click mouse-2 on the word ") | |||
| 872 | options)))) | 946 | options)))) |
| 873 | (unless (eq (preceding-char) ?\n) | 947 | (unless (eq (preceding-char) ?\n) |
| 874 | (widget-insert "\n")) | 948 | (widget-insert "\n")) |
| 875 | (widget-insert "\n") | ||
| 876 | (message "Creating customization magic...") | 949 | (message "Creating customization magic...") |
| 877 | (mapcar 'custom-magic-reset custom-options) | 950 | (mapcar 'custom-magic-reset custom-options) |
| 878 | (message "Creating customization buttons...") | ||
| 879 | (widget-create 'push-button | ||
| 880 | :tag "Set" | ||
| 881 | :help-echo "Set all modifications for this session." | ||
| 882 | :action (lambda (widget &optional event) | ||
| 883 | (custom-set))) | ||
| 884 | (widget-insert " ") | ||
| 885 | (widget-create 'push-button | ||
| 886 | :tag "Save" | ||
| 887 | :help-echo "\ | ||
| 888 | Make the modifications default for future sessions." | ||
| 889 | :action (lambda (widget &optional event) | ||
| 890 | (custom-save))) | ||
| 891 | (widget-insert " ") | ||
| 892 | (widget-create 'push-button | ||
| 893 | :tag "Reset" | ||
| 894 | :help-echo "Undo all modifications." | ||
| 895 | :action (lambda (widget &optional event) | ||
| 896 | (custom-reset event))) | ||
| 897 | (widget-insert " ") | ||
| 898 | (widget-create 'push-button | ||
| 899 | :tag "Done" | ||
| 900 | :help-echo "Bury the buffer." | ||
| 901 | :action (lambda (widget &optional event) | ||
| 902 | (bury-buffer))) | ||
| 903 | (widget-insert "\n") | ||
| 904 | (message "Creating customization setup...") | 951 | (message "Creating customization setup...") |
| 905 | (widget-setup) | 952 | (widget-setup) |
| 906 | (goto-char (point-min)) | 953 | (goto-char (point-min)) |
| @@ -975,130 +1022,35 @@ Make the modifications default for future sessions." | |||
| 975 | (defface custom-saved-face '((t (:underline t))) | 1022 | (defface custom-saved-face '((t (:underline t))) |
| 976 | "Face used when the customize item has been saved.") | 1023 | "Face used when the customize item has been saved.") |
| 977 | 1024 | ||
| 978 | (defcustom custom-magic-alist '((nil "#" underline "\ | 1025 | (defconst custom-magic-alist '((nil "#" underline "\ |
| 979 | uninitialized, you should not see this.") | 1026 | uninitialized, you should not see this.") |
| 980 | (unknown "?" italic "\ | 1027 | (unknown "?" italic "\ |
| 981 | unknown, you should not see this.") | 1028 | unknown, you should not see this.") |
| 982 | (hidden "-" default "\ | 1029 | (hidden "-" default "\ |
| 983 | hidden, press the state button to show.") | 1030 | hidden, invoke the state button to show." "\ |
| 984 | (invalid "x" custom-invalid-face "\ | 1031 | group now hidden, invoke the state button to show contents.") |
| 1032 | (invalid "x" custom-invalid-face "\ | ||
| 985 | the value displayed for this item is invalid and cannot be set.") | 1033 | the value displayed for this item is invalid and cannot be set.") |
| 986 | (modified "*" custom-modified-face "\ | 1034 | (modified "*" custom-modified-face "\ |
| 987 | you have edited the item, and can now set it.") | 1035 | you have edited the item, and can now set it." "\ |
| 988 | (set "+" custom-set-face "\ | ||
| 989 | you have set this item, but not saved it.") | ||
| 990 | (changed ":" custom-changed-face "\ | ||
| 991 | this item has been changed outside customize.") | ||
| 992 | (saved "!" custom-saved-face "\ | ||
| 993 | this item has been saved.") | ||
| 994 | (rogue "@" custom-rogue-face "\ | ||
| 995 | this item is not prepared for customization.") | ||
| 996 | (factory " " nil "\ | ||
| 997 | this item is unchanged from its standard setting.")) | ||
| 998 | "Alist of customize option states. | ||
| 999 | Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where | ||
| 1000 | |||
| 1001 | STATE is one of the following symbols: | ||
| 1002 | |||
| 1003 | `nil' | ||
| 1004 | For internal use, should never occur. | ||
| 1005 | `unknown' | ||
| 1006 | For internal use, should never occur. | ||
| 1007 | `hidden' | ||
| 1008 | This item is not being displayed. | ||
| 1009 | `invalid' | ||
| 1010 | This item is modified, but has an invalid form. | ||
| 1011 | `modified' | ||
| 1012 | This item is modified, and has a valid form. | ||
| 1013 | `set' | ||
| 1014 | This item has been set but not saved. | ||
| 1015 | `changed' | ||
| 1016 | The current value of this item has been changed temporarily. | ||
| 1017 | `saved' | ||
| 1018 | This item is marked for saving. | ||
| 1019 | `rogue' | ||
| 1020 | This item has no customization information. | ||
| 1021 | `factory' | ||
| 1022 | This item is unchanged from the standard setting. | ||
| 1023 | |||
| 1024 | MAGIC is a string used to present that state. | ||
| 1025 | |||
| 1026 | FACE is a face used to present the state. | ||
| 1027 | |||
| 1028 | DESCRIPTION is a string describing the state. | ||
| 1029 | |||
| 1030 | The list should be sorted most significant first." | ||
| 1031 | :type '(list (checklist :inline t | ||
| 1032 | (group (const nil) | ||
| 1033 | (string :tag "Magic") | ||
| 1034 | face | ||
| 1035 | (string :tag "Description")) | ||
| 1036 | (group (const unknown) | ||
| 1037 | (string :tag "Magic") | ||
| 1038 | face | ||
| 1039 | (string :tag "Description")) | ||
| 1040 | (group (const hidden) | ||
| 1041 | (string :tag "Magic") | ||
| 1042 | face | ||
| 1043 | (string :tag "Description")) | ||
| 1044 | (group (const invalid) | ||
| 1045 | (string :tag "Magic") | ||
| 1046 | face | ||
| 1047 | (string :tag "Description")) | ||
| 1048 | (group (const modified) | ||
| 1049 | (string :tag "Magic") | ||
| 1050 | face | ||
| 1051 | (string :tag "Description")) | ||
| 1052 | (group (const set) | ||
| 1053 | (string :tag "Magic") | ||
| 1054 | face | ||
| 1055 | (string :tag "Description")) | ||
| 1056 | (group (const changed) | ||
| 1057 | (string :tag "Magic") | ||
| 1058 | face | ||
| 1059 | (string :tag "Description")) | ||
| 1060 | (group (const saved) | ||
| 1061 | (string :tag "Magic") | ||
| 1062 | face | ||
| 1063 | (string :tag "Description")) | ||
| 1064 | (group (const rogue) | ||
| 1065 | (string :tag "Magic") | ||
| 1066 | face | ||
| 1067 | (string :tag "Description")) | ||
| 1068 | (group (const factory) | ||
| 1069 | (string :tag "Magic") | ||
| 1070 | face | ||
| 1071 | (string :tag "Description"))) | ||
| 1072 | (editable-list :inline t | ||
| 1073 | (group symbol | ||
| 1074 | (string :tag "Magic") | ||
| 1075 | face | ||
| 1076 | (string :tag "Description")))) | ||
| 1077 | :group 'customize | ||
| 1078 | :group 'custom-faces) | ||
| 1079 | |||
| 1080 | (defcustom custom-group-magic-alist '((nil "#" underline "\ | ||
| 1081 | uninitialized, you should not see this.") | ||
| 1082 | (unknown "?" italic "\ | ||
| 1083 | unknown, you should not see this.") | ||
| 1084 | (hidden "-" default "\ | ||
| 1085 | group now hidden; click on the asterisks above to show contents.") | ||
| 1086 | (invalid "x" custom-invalid-face "\ | ||
| 1087 | the value displayed for this item is invalid and cannot be set.") | ||
| 1088 | (modified "*" custom-modified-face "\ | ||
| 1089 | you have edited something in this group, and can now set it.") | 1036 | you have edited something in this group, and can now set it.") |
| 1090 | (set "+" custom-set-face "\ | 1037 | (set "+" custom-set-face "\ |
| 1038 | you have set this item, but not saved it." "\ | ||
| 1091 | something in this group has been set, but not yet saved.") | 1039 | something in this group has been set, but not yet saved.") |
| 1092 | (changed ":" custom-changed-face "\ | 1040 | (changed ":" custom-changed-face "\ |
| 1093 | this item has been changed outside customize.") | 1041 | this item has been changed outside customize." "\ |
| 1094 | (saved "!" custom-saved-face "\ | 1042 | something in this group has been changed outside customize.") |
| 1043 | (saved "!" custom-saved-face "\ | ||
| 1044 | this item has been set and saved." "\ | ||
| 1095 | something in this group has been set and saved.") | 1045 | something in this group has been set and saved.") |
| 1096 | (rogue "@" custom-rogue-face "\ | 1046 | (rogue "@" custom-rogue-face "\ |
| 1097 | this item is not prepared for customization.") | 1047 | this item has not been changed with customize." "\ |
| 1098 | (factory " " nil "\ | 1048 | something in this group is not prepared for customization.") |
| 1099 | nothing in this group has been changed.")) | 1049 | (standard " " nil "\ |
| 1050 | this item is unchanged from its standard setting." "\ | ||
| 1051 | the visible members of this group are all at standard settings.")) | ||
| 1100 | "Alist of customize option states. | 1052 | "Alist of customize option states. |
| 1101 | Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where | 1053 | Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where |
| 1102 | 1054 | ||
| 1103 | STATE is one of the following symbols: | 1055 | STATE is one of the following symbols: |
| 1104 | 1056 | ||
| @@ -1120,64 +1072,19 @@ STATE is one of the following symbols: | |||
| 1120 | This item is marked for saving. | 1072 | This item is marked for saving. |
| 1121 | `rogue' | 1073 | `rogue' |
| 1122 | This item has no customization information. | 1074 | This item has no customization information. |
| 1123 | `factory' | 1075 | `standard' |
| 1124 | This item is unchanged from the standard setting. | 1076 | This item is unchanged from the standard setting. |
| 1125 | 1077 | ||
| 1126 | MAGIC is a string used to present that state. | 1078 | MAGIC is a string used to present that state. |
| 1127 | 1079 | ||
| 1128 | FACE is a face used to present the state. | 1080 | FACE is a face used to present the state. |
| 1129 | 1081 | ||
| 1130 | DESCRIPTION is a string describing the state. | 1082 | ITEM-DESC is a string describing the state for options. |
| 1131 | 1083 | ||
| 1132 | The list should be sorted most significant first." | 1084 | GROUP-DESC is a string describing the state for groups. If this is |
| 1133 | :type '(list (checklist :inline t | 1085 | left out, ITEM-DESC will be used. |
| 1134 | (group (const nil) | 1086 | |
| 1135 | (string :tag "Magic") | 1087 | The list should be sorted most significant first.") |
| 1136 | face | ||
| 1137 | (string :tag "Description")) | ||
| 1138 | (group (const unknown) | ||
| 1139 | (string :tag "Magic") | ||
| 1140 | face | ||
| 1141 | (string :tag "Description")) | ||
| 1142 | (group (const hidden) | ||
| 1143 | (string :tag "Magic") | ||
| 1144 | face | ||
| 1145 | (string :tag "Description")) | ||
| 1146 | (group (const invalid) | ||
| 1147 | (string :tag "Magic") | ||
| 1148 | face | ||
| 1149 | (string :tag "Description")) | ||
| 1150 | (group (const modified) | ||
| 1151 | (string :tag "Magic") | ||
| 1152 | face | ||
| 1153 | (string :tag "Description")) | ||
| 1154 | (group (const set) | ||
| 1155 | (string :tag "Magic") | ||
| 1156 | face | ||
| 1157 | (string :tag "Description")) | ||
| 1158 | (group (const changed) | ||
| 1159 | (string :tag "Magic") | ||
| 1160 | face | ||
| 1161 | (string :tag "Description")) | ||
| 1162 | (group (const saved) | ||
| 1163 | (string :tag "Magic") | ||
| 1164 | face | ||
| 1165 | (string :tag "Description")) | ||
| 1166 | (group (const rogue) | ||
| 1167 | (string :tag "Magic") | ||
| 1168 | face | ||
| 1169 | (string :tag "Description")) | ||
| 1170 | (group (const factory) | ||
| 1171 | (string :tag "Magic") | ||
| 1172 | face | ||
| 1173 | (string :tag "Description"))) | ||
| 1174 | (editable-list :inline t | ||
| 1175 | (group symbol | ||
| 1176 | (string :tag "Magic") | ||
| 1177 | face | ||
| 1178 | (string :tag "Description")))) | ||
| 1179 | :group 'customize | ||
| 1180 | :group 'custom-faces) | ||
| 1181 | 1088 | ||
| 1182 | (defcustom custom-magic-show 'long | 1089 | (defcustom custom-magic-show 'long |
| 1183 | "Show long description of the state of each customization option." | 1090 | "Show long description of the state of each customization option." |
| @@ -1186,7 +1093,7 @@ The list should be sorted most significant first." | |||
| 1186 | (const long)) | 1093 | (const long)) |
| 1187 | :group 'customize) | 1094 | :group 'customize) |
| 1188 | 1095 | ||
| 1189 | (defcustom custom-magic-show-button t | 1096 | (defcustom custom-magic-show-button nil |
| 1190 | "Show a magic button indicating the state of each customization option." | 1097 | "Show a magic button indicating the state of each customization option." |
| 1191 | :type 'boolean | 1098 | :type 'boolean |
| 1192 | :group 'customize) | 1099 | :group 'customize) |
| @@ -1210,20 +1117,23 @@ The list should be sorted most significant first." | |||
| 1210 | ;; Create compact status report for WIDGET. | 1117 | ;; Create compact status report for WIDGET. |
| 1211 | (let* ((parent (widget-get widget :parent)) | 1118 | (let* ((parent (widget-get widget :parent)) |
| 1212 | (state (widget-get parent :custom-state)) | 1119 | (state (widget-get parent :custom-state)) |
| 1213 | (entry (assq state (if (eq (car parent) 'custom-group) | 1120 | (entry (assq state custom-magic-alist)) |
| 1214 | custom-group-magic-alist | ||
| 1215 | custom-magic-alist))) | ||
| 1216 | (magic (nth 1 entry)) | 1121 | (magic (nth 1 entry)) |
| 1217 | (face (nth 2 entry)) | 1122 | (face (nth 2 entry)) |
| 1218 | (text (nth 3 entry)) | 1123 | (text (or (and (eq (widget-type parent) 'custom-group) |
| 1124 | (nth 4 entry)) | ||
| 1125 | (nth 3 entry))) | ||
| 1219 | (lisp (eq (widget-get parent :custom-form) 'lisp)) | 1126 | (lisp (eq (widget-get parent :custom-form) 'lisp)) |
| 1220 | children) | 1127 | children) |
| 1221 | (when custom-magic-show | 1128 | (when custom-magic-show |
| 1129 | (insert " ") | ||
| 1222 | (push (widget-create-child-and-convert | 1130 | (push (widget-create-child-and-convert |
| 1223 | widget 'choice-item | 1131 | widget 'choice-item |
| 1224 | :help-echo "\ | 1132 | :help-echo "\ |
| 1225 | Change the state of this item." | 1133 | Change the state of this item." |
| 1226 | :format "%[%t%]" | 1134 | :format "%[%t%]" |
| 1135 | :button-prefix 'widget-push-button-prefix | ||
| 1136 | :button-suffix 'widget-push-button-suffix | ||
| 1227 | :mouse-down-action 'widget-magic-mouse-down-action | 1137 | :mouse-down-action 'widget-magic-mouse-down-action |
| 1228 | :tag "State") | 1138 | :tag "State") |
| 1229 | children) | 1139 | children) |
| @@ -1257,24 +1167,11 @@ Change the state of this item." | |||
| 1257 | (let ((magic (widget-get widget :custom-magic))) | 1167 | (let ((magic (widget-get widget :custom-magic))) |
| 1258 | (widget-value-set magic (widget-value magic)))) | 1168 | (widget-value-set magic (widget-value magic)))) |
| 1259 | 1169 | ||
| 1260 | ;;; The `custom-level' Widget. | ||
| 1261 | |||
| 1262 | (define-widget 'custom-level 'item | ||
| 1263 | "The custom level buttons." | ||
| 1264 | :format "%[%t%]" | ||
| 1265 | :help-echo "Expand or collapse this item." | ||
| 1266 | :action 'custom-level-action) | ||
| 1267 | |||
| 1268 | (defun custom-level-action (widget &optional event) | ||
| 1269 | "Toggle visibility for parent to WIDGET." | ||
| 1270 | (custom-toggle-hide (widget-get widget :parent))) | ||
| 1271 | |||
| 1272 | ;;; The `custom' Widget. | 1170 | ;;; The `custom' Widget. |
| 1273 | 1171 | ||
| 1274 | (define-widget 'custom 'default | 1172 | (define-widget 'custom 'default |
| 1275 | "Customize a user option." | 1173 | "Customize a user option." |
| 1276 | :convert-widget 'custom-convert-widget | 1174 | :convert-widget 'custom-convert-widget |
| 1277 | :format "%l%[%t%]: %v%m%h%a" | ||
| 1278 | :format-handler 'custom-format-handler | 1175 | :format-handler 'custom-format-handler |
| 1279 | :notify 'custom-notify | 1176 | :notify 'custom-notify |
| 1280 | :custom-level 1 | 1177 | :custom-level 1 |
| @@ -1304,9 +1201,8 @@ Change the state of this item." | |||
| 1304 | (cond ((eq escape ?l) | 1201 | (cond ((eq escape ?l) |
| 1305 | (when level | 1202 | (when level |
| 1306 | (push (widget-create-child-and-convert | 1203 | (push (widget-create-child-and-convert |
| 1307 | widget 'custom-level (make-string level ?*)) | 1204 | widget 'item :format "%v " (make-string level ?*)) |
| 1308 | buttons) | 1205 | buttons) |
| 1309 | (widget-insert " ") | ||
| 1310 | (widget-put widget :buttons buttons))) | 1206 | (widget-put widget :buttons buttons))) |
| 1311 | ((eq escape ?L) | 1207 | ((eq escape ?L) |
| 1312 | (when (eq state 'hidden) | 1208 | (when (eq state 'hidden) |
| @@ -1442,7 +1338,7 @@ Change the state of this item." | |||
| 1442 | 1338 | ||
| 1443 | (define-widget 'custom-variable 'custom | 1339 | (define-widget 'custom-variable 'custom |
| 1444 | "Customize variable." | 1340 | "Customize variable." |
| 1445 | :format "%l%v%m%h%a" | 1341 | :format "%v%m%h%a" |
| 1446 | :help-echo "Set or reset this variable." | 1342 | :help-echo "Set or reset this variable." |
| 1447 | :documentation-property 'variable-documentation | 1343 | :documentation-property 'variable-documentation |
| 1448 | :custom-state nil | 1344 | :custom-state nil |
| @@ -1454,14 +1350,14 @@ Change the state of this item." | |||
| 1454 | :custom-save 'custom-variable-save | 1350 | :custom-save 'custom-variable-save |
| 1455 | :custom-reset-current 'custom-redraw | 1351 | :custom-reset-current 'custom-redraw |
| 1456 | :custom-reset-saved 'custom-variable-reset-saved | 1352 | :custom-reset-saved 'custom-variable-reset-saved |
| 1457 | :custom-reset-factory 'custom-variable-reset-factory) | 1353 | :custom-reset-standard 'custom-variable-reset-standard) |
| 1458 | 1354 | ||
| 1459 | (defun custom-variable-type (symbol) | 1355 | (defun custom-variable-type (symbol) |
| 1460 | "Return a widget suitable for editing the value of SYMBOL. | 1356 | "Return a widget suitable for editing the value of SYMBOL. |
| 1461 | If SYMBOL has a `custom-type' property, use that. | 1357 | If SYMBOL has a `custom-type' property, use that. |
| 1462 | Otherwise, look up symbol in `custom-guess-type-alist'." | 1358 | Otherwise, look up symbol in `custom-guess-type-alist'." |
| 1463 | (let* ((type (or (get symbol 'custom-type) | 1359 | (let* ((type (or (get symbol 'custom-type) |
| 1464 | (and (not (get symbol 'factory-value)) | 1360 | (and (not (get symbol 'standard-value)) |
| 1465 | (custom-guess-type symbol)) | 1361 | (custom-guess-type symbol)) |
| 1466 | 'sexp)) | 1362 | 'sexp)) |
| 1467 | (options (get symbol 'custom-options)) | 1363 | (options (get symbol 'custom-options)) |
| @@ -1512,8 +1408,8 @@ Otherwise, look up symbol in `custom-guess-type-alist'." | |||
| 1512 | ;; In lisp mode edit the saved value when possible. | 1408 | ;; In lisp mode edit the saved value when possible. |
| 1513 | (let* ((value (cond ((get symbol 'saved-value) | 1409 | (let* ((value (cond ((get symbol 'saved-value) |
| 1514 | (car (get symbol 'saved-value))) | 1410 | (car (get symbol 'saved-value))) |
| 1515 | ((get symbol 'factory-value) | 1411 | ((get symbol 'standard-value) |
| 1516 | (car (get symbol 'factory-value))) | 1412 | (car (get symbol 'standard-value))) |
| 1517 | ((default-boundp symbol) | 1413 | ((default-boundp symbol) |
| 1518 | (custom-quote (funcall get symbol))) | 1414 | (custom-quote (funcall get symbol))) |
| 1519 | (t | 1415 | (t |
| @@ -1564,11 +1460,11 @@ Otherwise, look up symbol in `custom-guess-type-alist'." | |||
| 1564 | (error nil)) | 1460 | (error nil)) |
| 1565 | 'saved | 1461 | 'saved |
| 1566 | 'changed)) | 1462 | 'changed)) |
| 1567 | ((setq tmp (get symbol 'factory-value)) | 1463 | ((setq tmp (get symbol 'standard-value)) |
| 1568 | (if (condition-case nil | 1464 | (if (condition-case nil |
| 1569 | (equal value (eval (car tmp))) | 1465 | (equal value (eval (car tmp))) |
| 1570 | (error nil)) | 1466 | (error nil)) |
| 1571 | 'factory | 1467 | 'standard |
| 1572 | 'changed)) | 1468 | 'changed)) |
| 1573 | (t 'rogue)))) | 1469 | (t 'rogue)))) |
| 1574 | (widget-put widget :custom-state state))) | 1470 | (widget-put widget :custom-state state))) |
| @@ -1598,9 +1494,9 @@ Otherwise, look up symbol in `custom-guess-type-alist'." | |||
| 1598 | (and (get (widget-value widget) 'saved-value) | 1494 | (and (get (widget-value widget) 'saved-value) |
| 1599 | (memq (widget-get widget :custom-state) | 1495 | (memq (widget-get widget :custom-state) |
| 1600 | '(modified set changed rogue))))) | 1496 | '(modified set changed rogue))))) |
| 1601 | ("Reset to Standard Settings" custom-variable-reset-factory | 1497 | ("Reset to Standard Settings" custom-variable-reset-standard |
| 1602 | (lambda (widget) | 1498 | (lambda (widget) |
| 1603 | (and (get (widget-value widget) 'factory-value) | 1499 | (and (get (widget-value widget) 'standard-value) |
| 1604 | (memq (widget-get widget :custom-state) | 1500 | (memq (widget-get widget :custom-state) |
| 1605 | '(modified set changed saved rogue)))))) | 1501 | '(modified set changed saved rogue)))))) |
| 1606 | "Alist of actions for the `custom-variable' widget. | 1502 | "Alist of actions for the `custom-variable' widget. |
| @@ -1619,8 +1515,9 @@ Optional EVENT is the location for the menu." | |||
| 1619 | (custom-variable-state-set widget)) | 1515 | (custom-variable-state-set widget)) |
| 1620 | (custom-redraw-magic widget) | 1516 | (custom-redraw-magic widget) |
| 1621 | (let* ((completion-ignore-case t) | 1517 | (let* ((completion-ignore-case t) |
| 1622 | (answer (widget-choose (custom-unlispify-tag-name | 1518 | (answer (widget-choose (concat "Operation on " |
| 1623 | (widget-get widget :value)) | 1519 | (custom-unlispify-tag-name |
| 1520 | (widget-get widget :value))) | ||
| 1624 | (custom-menu-filter custom-variable-menu | 1521 | (custom-menu-filter custom-variable-menu |
| 1625 | widget) | 1522 | widget) |
| 1626 | event))) | 1523 | event))) |
| @@ -1700,12 +1597,12 @@ Optional EVENT is the location for the menu." | |||
| 1700 | (widget-put widget :custom-state 'unknown) | 1597 | (widget-put widget :custom-state 'unknown) |
| 1701 | (custom-redraw widget))) | 1598 | (custom-redraw widget))) |
| 1702 | 1599 | ||
| 1703 | (defun custom-variable-reset-factory (widget) | 1600 | (defun custom-variable-reset-standard (widget) |
| 1704 | "Restore the standard setting for the variable being edited by WIDGET." | 1601 | "Restore the standard setting for the variable being edited by WIDGET." |
| 1705 | (let* ((symbol (widget-value widget)) | 1602 | (let* ((symbol (widget-value widget)) |
| 1706 | (set (or (get symbol 'custom-set) 'set-default))) | 1603 | (set (or (get symbol 'custom-set) 'set-default))) |
| 1707 | (if (get symbol 'factory-value) | 1604 | (if (get symbol 'standard-value) |
| 1708 | (funcall set symbol (eval (car (get symbol 'factory-value)))) | 1605 | (funcall set symbol (eval (car (get symbol 'standard-value)))) |
| 1709 | (error "No standard setting known for %S" symbol)) | 1606 | (error "No standard setting known for %S" symbol)) |
| 1710 | (put symbol 'customized-value nil) | 1607 | (put symbol 'customized-value nil) |
| 1711 | (when (get symbol 'saved-value) | 1608 | (when (get symbol 'saved-value) |
| @@ -1809,7 +1706,7 @@ Match frames with dark backgrounds.") | |||
| 1809 | 1706 | ||
| 1810 | (define-widget 'custom-face 'custom | 1707 | (define-widget 'custom-face 'custom |
| 1811 | "Customize face." | 1708 | "Customize face." |
| 1812 | :format "%l%{%t%}: %s%m%h%a%v" | 1709 | :format "%{%t%}: %s%m%h%a%v" |
| 1813 | :format-handler 'custom-face-format-handler | 1710 | :format-handler 'custom-face-format-handler |
| 1814 | :sample-face 'custom-face-tag-face | 1711 | :sample-face 'custom-face-tag-face |
| 1815 | :help-echo "Set or reset this face." | 1712 | :help-echo "Set or reset this face." |
| @@ -1822,7 +1719,7 @@ Match frames with dark backgrounds.") | |||
| 1822 | :custom-save 'custom-face-save | 1719 | :custom-save 'custom-face-save |
| 1823 | :custom-reset-current 'custom-redraw | 1720 | :custom-reset-current 'custom-redraw |
| 1824 | :custom-reset-saved 'custom-face-reset-saved | 1721 | :custom-reset-saved 'custom-face-reset-saved |
| 1825 | :custom-reset-factory 'custom-face-reset-factory | 1722 | :custom-reset-standard 'custom-face-reset-standard |
| 1826 | :custom-menu 'custom-face-menu-create) | 1723 | :custom-menu 'custom-face-menu-create) |
| 1827 | 1724 | ||
| 1828 | (defun custom-face-format-handler (widget escape) | 1725 | (defun custom-face-format-handler (widget escape) |
| @@ -1927,7 +1824,7 @@ Match frames with dark backgrounds.") | |||
| 1927 | ("Reset to Saved" custom-face-reset-saved | 1824 | ("Reset to Saved" custom-face-reset-saved |
| 1928 | (lambda (widget) | 1825 | (lambda (widget) |
| 1929 | (get (widget-value widget) 'saved-face))) | 1826 | (get (widget-value widget) 'saved-face))) |
| 1930 | ("Reset to Standard Setting" custom-face-reset-factory | 1827 | ("Reset to Standard Setting" custom-face-reset-standard |
| 1931 | (lambda (widget) | 1828 | (lambda (widget) |
| 1932 | (get (widget-value widget) 'face-defface-spec)))) | 1829 | (get (widget-value widget) 'face-defface-spec)))) |
| 1933 | "Alist of actions for the `custom-face' widget. | 1830 | "Alist of actions for the `custom-face' widget. |
| @@ -1963,7 +1860,7 @@ widget. If FILTER is nil, ACTION is always valid.") | |||
| 1963 | ((get symbol 'saved-face) | 1860 | ((get symbol 'saved-face) |
| 1964 | 'saved) | 1861 | 'saved) |
| 1965 | ((get symbol 'face-defface-spec) | 1862 | ((get symbol 'face-defface-spec) |
| 1966 | 'factory) | 1863 | 'standard) |
| 1967 | (t | 1864 | (t |
| 1968 | 'rogue))))) | 1865 | 'rogue))))) |
| 1969 | 1866 | ||
| @@ -1974,7 +1871,8 @@ Optional EVENT is the location for the menu." | |||
| 1974 | (custom-toggle-hide widget) | 1871 | (custom-toggle-hide widget) |
| 1975 | (let* ((completion-ignore-case t) | 1872 | (let* ((completion-ignore-case t) |
| 1976 | (symbol (widget-get widget :value)) | 1873 | (symbol (widget-get widget :value)) |
| 1977 | (answer (widget-choose (custom-unlispify-tag-name symbol) | 1874 | (answer (widget-choose (concat "Operation on " |
| 1875 | (custom-unlispify-tag-name symbol)) | ||
| 1978 | (custom-menu-filter custom-face-menu | 1876 | (custom-menu-filter custom-face-menu |
| 1979 | widget) | 1877 | widget) |
| 1980 | event))) | 1878 | event))) |
| @@ -1987,7 +1885,7 @@ Optional EVENT is the location for the menu." | |||
| 1987 | (child (car (widget-get widget :children))) | 1885 | (child (car (widget-get widget :children))) |
| 1988 | (value (widget-value child))) | 1886 | (value (widget-value child))) |
| 1989 | (put symbol 'customized-face value) | 1887 | (put symbol 'customized-face value) |
| 1990 | (custom-face-display-set symbol value) | 1888 | (face-spec-set symbol value) |
| 1991 | (custom-face-state-set widget) | 1889 | (custom-face-state-set widget) |
| 1992 | (custom-redraw-magic widget))) | 1890 | (custom-redraw-magic widget))) |
| 1993 | 1891 | ||
| @@ -1996,7 +1894,7 @@ Optional EVENT is the location for the menu." | |||
| 1996 | (let* ((symbol (widget-value widget)) | 1894 | (let* ((symbol (widget-value widget)) |
| 1997 | (child (car (widget-get widget :children))) | 1895 | (child (car (widget-get widget :children))) |
| 1998 | (value (widget-value child))) | 1896 | (value (widget-value child))) |
| 1999 | (custom-face-display-set symbol value) | 1897 | (face-spec-set symbol value) |
| 2000 | (put symbol 'saved-face value) | 1898 | (put symbol 'saved-face value) |
| 2001 | (put symbol 'customized-face nil) | 1899 | (put symbol 'customized-face nil) |
| 2002 | (custom-face-state-set widget) | 1900 | (custom-face-state-set widget) |
| @@ -2010,12 +1908,12 @@ Optional EVENT is the location for the menu." | |||
| 2010 | (unless value | 1908 | (unless value |
| 2011 | (error "No saved value for this face")) | 1909 | (error "No saved value for this face")) |
| 2012 | (put symbol 'customized-face nil) | 1910 | (put symbol 'customized-face nil) |
| 2013 | (custom-face-display-set symbol value) | 1911 | (face-spec-set symbol value) |
| 2014 | (widget-value-set child value) | 1912 | (widget-value-set child value) |
| 2015 | (custom-face-state-set widget) | 1913 | (custom-face-state-set widget) |
| 2016 | (custom-redraw-magic widget))) | 1914 | (custom-redraw-magic widget))) |
| 2017 | 1915 | ||
| 2018 | (defun custom-face-reset-factory (widget) | 1916 | (defun custom-face-reset-standard (widget) |
| 2019 | "Restore WIDGET to the face's standard settings." | 1917 | "Restore WIDGET to the face's standard settings." |
| 2020 | (let* ((symbol (widget-value widget)) | 1918 | (let* ((symbol (widget-value widget)) |
| 2021 | (child (car (widget-get widget :children))) | 1919 | (child (car (widget-get widget :children))) |
| @@ -2026,7 +1924,7 @@ Optional EVENT is the location for the menu." | |||
| 2026 | (when (get symbol 'saved-face) | 1924 | (when (get symbol 'saved-face) |
| 2027 | (put symbol 'saved-face nil) | 1925 | (put symbol 'saved-face nil) |
| 2028 | (custom-save-all)) | 1926 | (custom-save-all)) |
| 2029 | (custom-face-display-set symbol value) | 1927 | (face-spec-set symbol value) |
| 2030 | (widget-value-set child value) | 1928 | (widget-value-set child value) |
| 2031 | (custom-face-state-set widget) | 1929 | (custom-face-state-set widget) |
| 2032 | (custom-redraw-magic widget))) | 1930 | (custom-redraw-magic widget))) |
| @@ -2145,7 +2043,7 @@ and so forth. The remaining group tags are shown with | |||
| 2145 | :custom-save 'custom-group-save | 2043 | :custom-save 'custom-group-save |
| 2146 | :custom-reset-current 'custom-group-reset-current | 2044 | :custom-reset-current 'custom-group-reset-current |
| 2147 | :custom-reset-saved 'custom-group-reset-saved | 2045 | :custom-reset-saved 'custom-group-reset-saved |
| 2148 | :custom-reset-factory 'custom-group-reset-factory | 2046 | :custom-reset-standard 'custom-group-reset-standard |
| 2149 | :custom-menu 'custom-group-menu-create) | 2047 | :custom-menu 'custom-group-menu-create) |
| 2150 | 2048 | ||
| 2151 | (defun custom-group-sample-face-get (widget) | 2049 | (defun custom-group-sample-face-get (widget) |
| @@ -2160,7 +2058,8 @@ and so forth. The remaining group tags are shown with | |||
| 2160 | (custom-load-widget widget) | 2058 | (custom-load-widget widget) |
| 2161 | (let* ((level (widget-get widget :custom-level)) | 2059 | (let* ((level (widget-get widget :custom-level)) |
| 2162 | (symbol (widget-value widget)) | 2060 | (symbol (widget-value widget)) |
| 2163 | (members (get symbol 'custom-group)) | 2061 | (members (sort (get symbol 'custom-group) |
| 2062 | custom-buffer-sort-predicate)) | ||
| 2164 | (prefixes (widget-get widget :custom-prefixes)) | 2063 | (prefixes (widget-get widget :custom-prefixes)) |
| 2165 | (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2064 | (custom-prefix-list (custom-prefix-add symbol prefixes)) |
| 2166 | (length (length members)) | 2065 | (length (length members)) |
| @@ -2182,6 +2081,7 @@ and so forth. The remaining group tags are shown with | |||
| 2182 | (unless (eq (preceding-char) ?\n) | 2081 | (unless (eq (preceding-char) ?\n) |
| 2183 | (widget-insert "\n")))) | 2082 | (widget-insert "\n")))) |
| 2184 | members))) | 2083 | members))) |
| 2084 | (put symbol 'custom-group members) | ||
| 2185 | (message "Creating group magic...") | 2085 | (message "Creating group magic...") |
| 2186 | (mapcar 'custom-magic-reset children) | 2086 | (mapcar 'custom-magic-reset children) |
| 2187 | (message "Creating group state...") | 2087 | (message "Creating group state...") |
| @@ -2205,7 +2105,7 @@ and so forth. The remaining group tags are shown with | |||
| 2205 | ("Reset to Saved" custom-group-reset-saved | 2105 | ("Reset to Saved" custom-group-reset-saved |
| 2206 | (lambda (widget) | 2106 | (lambda (widget) |
| 2207 | (memq (widget-get widget :custom-state) '(modified set)))) | 2107 | (memq (widget-get widget :custom-state) '(modified set)))) |
| 2208 | ("Reset to standard setting" custom-group-reset-factory | 2108 | ("Reset to standard setting" custom-group-reset-standard |
| 2209 | (lambda (widget) | 2109 | (lambda (widget) |
| 2210 | (memq (widget-get widget :custom-state) '(modified set saved))))) | 2110 | (memq (widget-get widget :custom-state) '(modified set saved))))) |
| 2211 | "Alist of actions for the `custom-group' widget. | 2111 | "Alist of actions for the `custom-group' widget. |
| @@ -2221,8 +2121,9 @@ Optional EVENT is the location for the menu." | |||
| 2221 | (if (eq (widget-get widget :custom-state) 'hidden) | 2121 | (if (eq (widget-get widget :custom-state) 'hidden) |
| 2222 | (custom-toggle-hide widget) | 2122 | (custom-toggle-hide widget) |
| 2223 | (let* ((completion-ignore-case t) | 2123 | (let* ((completion-ignore-case t) |
| 2224 | (answer (widget-choose (custom-unlispify-tag-name | 2124 | (answer (widget-choose (concat "Operation on " |
| 2225 | (widget-get widget :value)) | 2125 | (custom-unlispify-tag-name |
| 2126 | (widget-get widget :value))) | ||
| 2226 | (custom-menu-filter custom-group-menu | 2127 | (custom-menu-filter custom-group-menu |
| 2227 | widget) | 2128 | widget) |
| 2228 | event))) | 2129 | event))) |
| @@ -2261,13 +2162,13 @@ Optional EVENT is the location for the menu." | |||
| 2261 | (widget-apply child :custom-reset-saved))) | 2162 | (widget-apply child :custom-reset-saved))) |
| 2262 | children ))) | 2163 | children ))) |
| 2263 | 2164 | ||
| 2264 | (defun custom-group-reset-factory (widget) | 2165 | (defun custom-group-reset-standard (widget) |
| 2265 | "Reset all modified, set, or saved group members." | 2166 | "Reset all modified, set, or saved group members." |
| 2266 | (let ((children (widget-get widget :children))) | 2167 | (let ((children (widget-get widget :children))) |
| 2267 | (mapcar (lambda (child) | 2168 | (mapcar (lambda (child) |
| 2268 | (when (memq (widget-get child :custom-state) | 2169 | (when (memq (widget-get child :custom-state) |
| 2269 | '(modified set saved)) | 2170 | '(modified set saved)) |
| 2270 | (widget-apply child :custom-reset-factory))) | 2171 | (widget-apply child :custom-reset-standard))) |
| 2271 | children ))) | 2172 | children ))) |
| 2272 | 2173 | ||
| 2273 | (defun custom-group-state-update (widget) | 2174 | (defun custom-group-state-update (widget) |
| @@ -2277,8 +2178,8 @@ Optional EVENT is the location for the menu." | |||
| 2277 | (states (mapcar (lambda (child) | 2178 | (states (mapcar (lambda (child) |
| 2278 | (widget-get child :custom-state)) | 2179 | (widget-get child :custom-state)) |
| 2279 | children)) | 2180 | children)) |
| 2280 | (magics custom-group-magic-alist) | 2181 | (magics custom-magic-alist) |
| 2281 | (found 'factory)) | 2182 | (found 'standard)) |
| 2282 | (while magics | 2183 | (while magics |
| 2283 | (let ((magic (car (car magics)))) | 2184 | (let ((magic (car (car magics)))) |
| 2284 | (if (and (not (eq magic 'hidden)) | 2185 | (if (and (not (eq magic 'hidden)) |
| @@ -2327,7 +2228,7 @@ Leave point at the location of the call, or after the last expression." | |||
| 2327 | (mapatoms (lambda (symbol) | 2228 | (mapatoms (lambda (symbol) |
| 2328 | (let ((value (get symbol 'saved-value)) | 2229 | (let ((value (get symbol 'saved-value)) |
| 2329 | (requests (get symbol 'custom-requests)) | 2230 | (requests (get symbol 'custom-requests)) |
| 2330 | (now (not (or (get symbol 'factory-value) | 2231 | (now (not (or (get symbol 'standard-value) |
| 2331 | (and (not (boundp symbol)) | 2232 | (and (not (boundp symbol)) |
| 2332 | (not (get symbol 'force-value))))))) | 2233 | (not (get symbol 'force-value))))))) |
| 2333 | (when value | 2234 | (when value |
| @@ -2417,10 +2318,11 @@ Leave point at the location of the call, or after the last expression." | |||
| 2417 | (unless (string-match "XEmacs" emacs-version) | 2318 | (unless (string-match "XEmacs" emacs-version) |
| 2418 | (defconst custom-help-menu '("Customize" | 2319 | (defconst custom-help-menu '("Customize" |
| 2419 | ["Update menu..." custom-menu-update t] | 2320 | ["Update menu..." custom-menu-update t] |
| 2420 | ["Group..." customize t] | 2321 | ["Group..." customize-group t] |
| 2421 | ["Variable..." customize-variable t] | 2322 | ["Variable..." customize-variable t] |
| 2422 | ["Face..." customize-face t] | 2323 | ["Face..." customize-face t] |
| 2423 | ["Saved..." customize-customized t] | 2324 | ["Saved..." customize-saved t] |
| 2325 | ["Set..." customize-customized t] | ||
| 2424 | ["Apropos..." customize-apropos t]) | 2326 | ["Apropos..." customize-apropos t]) |
| 2425 | ;; This menu should be identical to the one defined in `menu-bar.el'. | 2327 | ;; This menu should be identical to the one defined in `menu-bar.el'. |
| 2426 | "Customize menu") | 2328 | "Customize menu") |
| @@ -2443,12 +2345,12 @@ Leave point at the location of the call, or after the last expression." | |||
| 2443 | ,@(cdr (cdr custom-help-menu))))) | 2345 | ,@(cdr (cdr custom-help-menu))))) |
| 2444 | (let ((map (easy-menu-create-keymaps (car menu) (cdr menu)))) | 2346 | (let ((map (easy-menu-create-keymaps (car menu) (cdr menu)))) |
| 2445 | (define-key global-map [menu-bar help-menu customize-menu] | 2347 | (define-key global-map [menu-bar help-menu customize-menu] |
| 2446 | (cons (car menu) map))))) | 2348 | (cons (car menu) map)))))) |
| 2447 | 2349 | ||
| 2448 | (defcustom custom-menu-nesting 2 | 2350 | (defcustom custom-menu-nesting 2 |
| 2449 | "Maximum nesting in custom menus." | 2351 | "Maximum nesting in custom menus." |
| 2450 | :type 'integer | 2352 | :type 'integer |
| 2451 | :group 'customize)) | 2353 | :group 'customize) |
| 2452 | 2354 | ||
| 2453 | (defun custom-face-menu-create (widget symbol) | 2355 | (defun custom-face-menu-create (widget symbol) |
| 2454 | "Ignoring WIDGET, create a menu entry for customization face SYMBOL." | 2356 | "Ignoring WIDGET, create a menu entry for customization face SYMBOL." |
| @@ -2500,7 +2402,10 @@ The menu is in a format applicable to `easy-menu-define'." | |||
| 2500 | (>= custom-menu-nesting 0)) | 2402 | (>= custom-menu-nesting 0)) |
| 2501 | (< (length (get symbol 'custom-group)) widget-menu-max-size)) | 2403 | (< (length (get symbol 'custom-group)) widget-menu-max-size)) |
| 2502 | (let ((custom-prefix-list (custom-prefix-add symbol | 2404 | (let ((custom-prefix-list (custom-prefix-add symbol |
| 2503 | custom-prefix-list))) | 2405 | custom-prefix-list)) |
| 2406 | (members (sort (get symbol 'custom-group) | ||
| 2407 | custom-menu-sort-predicate))) | ||
| 2408 | (put symbol 'custom-group members) | ||
| 2504 | (custom-load-symbol symbol) | 2409 | (custom-load-symbol symbol) |
| 2505 | `(,(custom-unlispify-menu-entry symbol t) | 2410 | `(,(custom-unlispify-menu-entry symbol t) |
| 2506 | ,item | 2411 | ,item |
| @@ -2510,7 +2415,7 @@ The menu is in a format applicable to `easy-menu-define'." | |||
| 2510 | (nth 1 entry) | 2415 | (nth 1 entry) |
| 2511 | (list (nth 1 entry))) | 2416 | (list (nth 1 entry))) |
| 2512 | :custom-menu (nth 0 entry))) | 2417 | :custom-menu (nth 0 entry))) |
| 2513 | (get symbol 'custom-group)))) | 2418 | members))) |
| 2514 | item))) | 2419 | item))) |
| 2515 | 2420 | ||
| 2516 | ;;;###autoload | 2421 | ;;;###autoload |
| @@ -2552,7 +2457,7 @@ The format is suitable for use with `easy-menu-define'." | |||
| 2552 | ["Save" custom-save t] | 2457 | ["Save" custom-save t] |
| 2553 | ["Reset to Current" custom-reset-current t] | 2458 | ["Reset to Current" custom-reset-current t] |
| 2554 | ["Reset to Saved" custom-reset-saved t] | 2459 | ["Reset to Saved" custom-reset-saved t] |
| 2555 | ["Reset to Standard Settings" custom-reset-factory t] | 2460 | ["Reset to Standard Settings" custom-reset-standard t] |
| 2556 | ["Info" (Info-goto-node "(custom)The Customization Buffer") t])) | 2461 | ["Info" (Info-goto-node "(custom)The Customization Buffer") t])) |
| 2557 | 2462 | ||
| 2558 | (defcustom custom-mode-hook nil | 2463 | (defcustom custom-mode-hook nil |
| @@ -2567,13 +2472,13 @@ The following commands are available: | |||
| 2567 | 2472 | ||
| 2568 | Move to next button or editable field. \\[widget-forward] | 2473 | Move to next button or editable field. \\[widget-forward] |
| 2569 | Move to previous button or editable field. \\[widget-backward] | 2474 | Move to previous button or editable field. \\[widget-backward] |
| 2570 | Activate button under the mouse pointer. \\[widget-button-click] | 2475 | Invoke button under the mouse pointer. \\[widget-button-click] |
| 2571 | Activate button under point. \\[widget-button-press] | 2476 | Invoke button under point. \\[widget-button-press] |
| 2572 | Set all modifications. \\[custom-set] | 2477 | Set all modifications. \\[custom-set] |
| 2573 | Make all modifications default. \\[custom-save] | 2478 | Make all modifications default. \\[custom-save] |
| 2574 | Reset all modified options. \\[custom-reset-current] | 2479 | Reset all modified options. \\[custom-reset-current] |
| 2575 | Reset all modified or set options. \\[custom-reset-saved] | 2480 | Reset all modified or set options. \\[custom-reset-saved] |
| 2576 | Reset all options. \\[custom-reset-factory] | 2481 | Reset all options. \\[custom-reset-standard] |
| 2577 | 2482 | ||
| 2578 | Entry to this mode calls the value of `custom-mode-hook' | 2483 | Entry to this mode calls the value of `custom-mode-hook' |
| 2579 | if that value is non-nil." | 2484 | if that value is non-nil." |
diff --git a/lisp/custom.el b/lisp/custom.el index 5db6caa655f..1d93305c22e 100644 --- a/lisp/custom.el +++ b/lisp/custom.el | |||
| @@ -4,7 +4,7 @@ | |||
| 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.97 | 7 | ;; Version: 1.9900 |
| 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. |
| @@ -56,7 +56,7 @@ the car of that and used as the default binding for symbol. | |||
| 56 | Otherwise, VALUE will be evaluated and used as the default binding for | 56 | Otherwise, VALUE will be evaluated and used as the default binding for |
| 57 | symbol." | 57 | symbol." |
| 58 | (unless (default-boundp symbol) | 58 | (unless (default-boundp symbol) |
| 59 | ;; Use the saved value if it exists, otherwise the factory setting. | 59 | ;; Use the saved value if it exists, otherwise the standard setting. |
| 60 | (set-default symbol (if (get symbol 'saved-value) | 60 | (set-default symbol (if (get symbol 'saved-value) |
| 61 | (eval (car (get symbol 'saved-value))) | 61 | (eval (car (get symbol 'saved-value))) |
| 62 | (eval value))))) | 62 | (eval value))))) |
| @@ -89,7 +89,7 @@ Like `custom-initialize-set', but use the function specified by | |||
| 89 | (defun custom-initialize-changed (symbol value) | 89 | (defun custom-initialize-changed (symbol value) |
| 90 | "Initialize SYMBOL with VALUE. | 90 | "Initialize SYMBOL with VALUE. |
| 91 | Like `custom-initialize-reset', but only use the `:set' function if the | 91 | Like `custom-initialize-reset', but only use the `:set' function if the |
| 92 | not using the factory setting. Otherwise, use the `set-default'." | 92 | not using the standard setting. Otherwise, use the `set-default'." |
| 93 | (cond ((default-boundp symbol) | 93 | (cond ((default-boundp symbol) |
| 94 | (funcall (or (get symbol 'custom-set) 'set-default) | 94 | (funcall (or (get symbol 'custom-set) 'set-default) |
| 95 | symbol | 95 | symbol |
| @@ -104,8 +104,8 @@ not using the factory setting. Otherwise, use the `set-default'." | |||
| 104 | 104 | ||
| 105 | (defun custom-declare-variable (symbol value doc &rest args) | 105 | (defun custom-declare-variable (symbol value doc &rest args) |
| 106 | "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments." | 106 | "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments." |
| 107 | ;; Remember the factory setting. | 107 | ;; Remember the standard setting. |
| 108 | (put symbol 'factory-value (list value)) | 108 | (put symbol 'standard-value (list value)) |
| 109 | ;; Maybe this option was rogue in an earlier version. It no longer is. | 109 | ;; Maybe this option was rogue in an earlier version. It no longer is. |
| 110 | (when (get symbol 'force-value) | 110 | (when (get symbol 'force-value) |
| 111 | ;; It no longer is. | 111 | ;; It no longer is. |
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 9542df9089e..9198ceed8e8 100644 --- a/lisp/wid-edit.el +++ b/lisp/wid-edit.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | ;; | 4 | ;; |
| 5 | ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | 5 | ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> |
| 6 | ;; Keywords: extensions | 6 | ;; Keywords: extensions |
| 7 | ;; Version: 1.97 | 7 | ;; Version: 1.9900 |
| 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. |
| @@ -31,8 +31,7 @@ | |||
| 31 | ;;; Code: | 31 | ;;; Code: |
| 32 | 32 | ||
| 33 | (require 'widget) | 33 | (require 'widget) |
| 34 | 34 | (require 'cl) | |
| 35 | (eval-when-compile (require 'cl)) | ||
| 36 | 35 | ||
| 37 | ;;; Compatibility. | 36 | ;;; Compatibility. |
| 38 | 37 | ||
| @@ -146,7 +145,7 @@ and `end-open' if it should sticky to the front." | |||
| 146 | (:background "gray85")) | 145 | (:background "gray85")) |
| 147 | (((class grayscale color) | 146 | (((class grayscale color) |
| 148 | (background dark)) | 147 | (background dark)) |
| 149 | (:background "dark gray")) | 148 | (:background "dim gray")) |
| 150 | (t | 149 | (t |
| 151 | (:italic t))) | 150 | (:italic t))) |
| 152 | "Face used for editable fields." | 151 | "Face used for editable fields." |
| @@ -542,7 +541,7 @@ This is only meaningful for radio buttons or checkboxes in a list." | |||
| 542 | (defcustom widget-glyph-directory (concat data-directory "custom/") | 541 | (defcustom widget-glyph-directory (concat data-directory "custom/") |
| 543 | "Where widget glyphs are located. | 542 | "Where widget glyphs are located. |
| 544 | If this variable is nil, widget will try to locate the directory | 543 | If this variable is nil, widget will try to locate the directory |
| 545 | automatically. This does not work yet." | 544 | automatically." |
| 546 | :group 'widgets | 545 | :group 'widgets |
| 547 | :type 'directory) | 546 | :type 'directory) |
| 548 | 547 | ||
| @@ -551,47 +550,75 @@ automatically. This does not work yet." | |||
| 551 | :group 'widgets | 550 | :group 'widgets |
| 552 | :type 'boolean) | 551 | :type 'boolean) |
| 553 | 552 | ||
| 553 | (defcustom widget-image-conversion | ||
| 554 | '((xpm ".xpm") (gif ".gif") (png ".png") (jpeg ".jpg" ".jpeg") | ||
| 555 | (xbm ".xbm")) | ||
| 556 | "Conversion alist from image formats to file name suffixes." | ||
| 557 | :group 'widgets | ||
| 558 | :type '(repeat (cons :format "%v" | ||
| 559 | (symbol :tag "Image Format" unknown) | ||
| 560 | (repeat :tag "Suffixes" | ||
| 561 | (string :format "%v"))))) | ||
| 562 | |||
| 554 | (defun widget-glyph-insert (widget tag image) | 563 | (defun widget-glyph-insert (widget tag image) |
| 555 | "In WIDGET, insert the text TAG or, if supported, IMAGE. | 564 | "In WIDGET, insert the text TAG or, if supported, IMAGE. |
| 556 | IMAGE should either be a glyph, or a name sans extension of an xpm or | 565 | IMAGE should either be a glyph, an image instantiator, or an image file |
| 557 | xbm file located in `widget-glyph-directory'. | 566 | name sans extension (xpm, xbm, gif, jpg, or png) located in |
| 567 | `widget-glyph-directory'. | ||
| 558 | 568 | ||
| 559 | WARNING: If you call this with a glyph, and you want the user to be | 569 | WARNING: If you call this with a glyph, and you want the user to be |
| 560 | able to activate the glyph, make sure it is unique. If you use the | 570 | able to invoke the glyph, make sure it is unique. If you use the |
| 561 | same glyph for multiple widgets, activating any of the glyphs will | 571 | same glyph for multiple widgets, invoking any of the glyphs will |
| 562 | cause the last created widget to be activated." | 572 | cause the last created widget to be invoked." |
| 563 | (cond ((not (and (string-match "XEmacs" emacs-version) | 573 | (cond ((not (and (string-match "XEmacs" emacs-version) |
| 564 | widget-glyph-enable | 574 | widget-glyph-enable |
| 565 | (fboundp 'make-glyph) | 575 | (fboundp 'make-glyph) |
| 576 | (fboundp 'locate-file) | ||
| 566 | image)) | 577 | image)) |
| 567 | ;; We don't want or can't use glyphs. | 578 | ;; We don't want or can't use glyphs. |
| 568 | (insert tag)) | 579 | (insert tag)) |
| 569 | ((and (fboundp 'glyphp) | 580 | ((and (fboundp 'glyphp) |
| 570 | (glyphp image)) | 581 | (glyphp image)) |
| 571 | ;; Already a glyph. Insert it. | 582 | ;; Already a glyph. Insert it. |
| 572 | (widget-glyph-insert-glyph widget tag image)) | 583 | (widget-glyph-insert-glyph widget image)) |
| 584 | ((stringp image) | ||
| 585 | ;; A string. Look it up in relevant directories. | ||
| 586 | (let* ((dirlist (list (or widget-glyph-directory | ||
| 587 | (concat data-directory | ||
| 588 | "custom/")) | ||
| 589 | data-directory)) | ||
| 590 | (formats widget-image-conversion) | ||
| 591 | file) | ||
| 592 | (while (and formats (not file)) | ||
| 593 | (if (valid-image-instantiator-format-p (car (car formats))) | ||
| 594 | (setq file (locate-file image dirlist | ||
| 595 | (mapconcat 'identity (cdr (car formats)) | ||
| 596 | ":"))) | ||
| 597 | (setq formats (cdr formats)))) | ||
| 598 | ;; We create a glyph with the file as the default image | ||
| 599 | ;; instantiator, and the TAG fallback | ||
| 600 | (widget-glyph-insert-glyph | ||
| 601 | widget | ||
| 602 | (make-glyph (if file | ||
| 603 | (list (vector (car (car formats)) ':file file) | ||
| 604 | (vector 'string ':data tag)) | ||
| 605 | (vector 'string ':data tag)))))) | ||
| 606 | ((valid-instantiator-p image 'image) | ||
| 607 | ;; A valid image instantiator (e.g. [gif :file "somefile"] etc.) | ||
| 608 | (widget-glyph-insert-glyph | ||
| 609 | widget | ||
| 610 | (make-glyph (list image | ||
| 611 | (vector 'string ':data tag))))) | ||
| 573 | (t | 612 | (t |
| 574 | ;; A string. Look it up in. | 613 | ;; Oh well. |
| 575 | (let ((file (concat widget-glyph-directory | 614 | (insert tag)))) |
| 576 | (if (string-match "/\\'" widget-glyph-directory) | 615 | |
| 577 | "" | 616 | (defun widget-glyph-insert-glyph (widget glyph &optional down inactive) |
| 578 | "/") | ||
| 579 | image | ||
| 580 | (if (featurep 'xpm) ".xpm" ".xbm")))) | ||
| 581 | (if (file-readable-p file) | ||
| 582 | (widget-glyph-insert-glyph widget tag (make-glyph file)) | ||
| 583 | ;; File not readable, give up. | ||
| 584 | (insert tag)))))) | ||
| 585 | |||
| 586 | (defun widget-glyph-insert-glyph (widget tag glyph &optional down inactive) | ||
| 587 | "In WIDGET, with alternative text TAG, insert GLYPH." | 617 | "In WIDGET, with alternative text TAG, insert GLYPH." |
| 588 | (set-glyph-image glyph (cons 'tty tag)) | ||
| 589 | (set-glyph-property glyph 'widget widget) | 618 | (set-glyph-property glyph 'widget widget) |
| 590 | (when down | 619 | (when down |
| 591 | (set-glyph-image down (cons 'tty tag)) | ||
| 592 | (set-glyph-property down 'widget widget)) | 620 | (set-glyph-property down 'widget widget)) |
| 593 | (when inactive | 621 | (when inactive |
| 594 | (set-glyph-image inactive (cons 'tty tag)) | ||
| 595 | (set-glyph-property inactive 'widget widget)) | 622 | (set-glyph-property inactive 'widget widget)) |
| 596 | (insert "*") | 623 | (insert "*") |
| 597 | (add-text-properties (1- (point)) (point) | 624 | (add-text-properties (1- (point)) (point) |
| @@ -610,6 +637,30 @@ cause the last created widget to be activated." | |||
| 610 | help-echo | 637 | help-echo |
| 611 | 'widget-mouse-help)))))) | 638 | 'widget-mouse-help)))))) |
| 612 | 639 | ||
| 640 | ;;; Buttons. | ||
| 641 | |||
| 642 | (defgroup widget-button nil | ||
| 643 | "The look of various kinds of buttons." | ||
| 644 | :group 'widgets) | ||
| 645 | |||
| 646 | (defcustom widget-button-prefix "" | ||
| 647 | "String used as prefix for buttons." | ||
| 648 | :type 'string | ||
| 649 | :group 'widgets) | ||
| 650 | |||
| 651 | (defcustom widget-button-suffix "" | ||
| 652 | "String used as suffix for buttons." | ||
| 653 | :type 'string | ||
| 654 | :group 'widgets) | ||
| 655 | |||
| 656 | (defun widget-button-insert-indirect (widget key) | ||
| 657 | "Insert value of WIDGET's KEY property." | ||
| 658 | (let ((val (widget-get widget key))) | ||
| 659 | (while (and val (symbolp val)) | ||
| 660 | (setq val (symbol-value val))) | ||
| 661 | (when val | ||
| 662 | (insert val)))) | ||
| 663 | |||
| 613 | ;;; Creating Widgets. | 664 | ;;; Creating Widgets. |
| 614 | 665 | ||
| 615 | ;;;###autoload | 666 | ;;;###autoload |
| @@ -762,7 +813,7 @@ Recommended as a parent keymap for modes using widgets.") | |||
| 762 | (set-keymap-parent widget-text-keymap global-map)) | 813 | (set-keymap-parent widget-text-keymap global-map)) |
| 763 | 814 | ||
| 764 | (defun widget-field-activate (pos &optional event) | 815 | (defun widget-field-activate (pos &optional event) |
| 765 | "Activate the ediable field at point." | 816 | "Invoke the ediable field at point." |
| 766 | (interactive "@d") | 817 | (interactive "@d") |
| 767 | (let ((field (get-text-property pos 'field))) | 818 | (let ((field (get-text-property pos 'field))) |
| 768 | (if field | 819 | (if field |
| @@ -779,7 +830,7 @@ Recommended as a parent keymap for modes using widgets.") | |||
| 779 | :group 'widgets) | 830 | :group 'widgets) |
| 780 | 831 | ||
| 781 | (defun widget-button-click (event) | 832 | (defun widget-button-click (event) |
| 782 | "Activate button below mouse pointer." | 833 | "Invoke button below mouse pointer." |
| 783 | (interactive "@e") | 834 | (interactive "@e") |
| 784 | (cond ((and (fboundp 'event-glyph) | 835 | (cond ((and (fboundp 'event-glyph) |
| 785 | (event-glyph event)) | 836 | (event-glyph event)) |
| @@ -828,7 +879,7 @@ Recommended as a parent keymap for modes using widgets.") | |||
| 828 | (message "You clicked somewhere weird.")))) | 879 | (message "You clicked somewhere weird.")))) |
| 829 | 880 | ||
| 830 | (defun widget-button1-click (event) | 881 | (defun widget-button1-click (event) |
| 831 | "Activate glyph below mouse pointer." | 882 | "Invoke glyph below mouse pointer." |
| 832 | (interactive "@e") | 883 | (interactive "@e") |
| 833 | (if (and (fboundp 'event-glyph) | 884 | (if (and (fboundp 'event-glyph) |
| 834 | (event-glyph event)) | 885 | (event-glyph event)) |
| @@ -863,7 +914,7 @@ Recommended as a parent keymap for modes using widgets.") | |||
| 863 | (widget-apply-action widget event))))))) | 914 | (widget-apply-action widget event))))))) |
| 864 | 915 | ||
| 865 | (defun widget-button-press (pos &optional event) | 916 | (defun widget-button-press (pos &optional event) |
| 866 | "Activate button at POS." | 917 | "Invoke button at POS." |
| 867 | (interactive "@d") | 918 | (interactive "@d") |
| 868 | (let ((button (get-text-property pos 'button))) | 919 | (let ((button (get-text-property pos 'button))) |
| 869 | (if button | 920 | (if button |
| @@ -1136,6 +1187,8 @@ Optional EVENT is the event that triggered the action." | |||
| 1136 | "Basic widget other widgets are derived from." | 1187 | "Basic widget other widgets are derived from." |
| 1137 | :value-to-internal (lambda (widget value) value) | 1188 | :value-to-internal (lambda (widget value) value) |
| 1138 | :value-to-external (lambda (widget value) value) | 1189 | :value-to-external (lambda (widget value) value) |
| 1190 | :button-prefix 'widget-button-prefix | ||
| 1191 | :button-suffix 'widget-button-suffix | ||
| 1139 | :create 'widget-default-create | 1192 | :create 'widget-default-create |
| 1140 | :indent nil | 1193 | :indent nil |
| 1141 | :offset 0 | 1194 | :offset 0 |
| @@ -1159,9 +1212,6 @@ Optional EVENT is the event that triggered the action." | |||
| 1159 | "Create WIDGET at point in the current buffer." | 1212 | "Create WIDGET at point in the current buffer." |
| 1160 | (widget-specify-insert | 1213 | (widget-specify-insert |
| 1161 | (let ((from (point)) | 1214 | (let ((from (point)) |
| 1162 | (tag (widget-get widget :tag)) | ||
| 1163 | (glyph (widget-get widget :tag-glyph)) | ||
| 1164 | (doc (widget-get widget :doc)) | ||
| 1165 | button-begin button-end | 1215 | button-begin button-end |
| 1166 | sample-begin sample-end | 1216 | sample-begin sample-end |
| 1167 | doc-begin doc-end | 1217 | doc-begin doc-end |
| @@ -1175,8 +1225,10 @@ Optional EVENT is the event that triggered the action." | |||
| 1175 | (cond ((eq escape ?%) | 1225 | (cond ((eq escape ?%) |
| 1176 | (insert "%")) | 1226 | (insert "%")) |
| 1177 | ((eq escape ?\[) | 1227 | ((eq escape ?\[) |
| 1178 | (setq button-begin (point))) | 1228 | (setq button-begin (point)) |
| 1229 | (widget-button-insert-indirect widget :button-prefix)) | ||
| 1179 | ((eq escape ?\]) | 1230 | ((eq escape ?\]) |
| 1231 | (widget-button-insert-indirect widget :button-suffix) | ||
| 1180 | (setq button-end (point))) | 1232 | (setq button-end (point))) |
| 1181 | ((eq escape ?\{) | 1233 | ((eq escape ?\{) |
| 1182 | (setq sample-begin (point))) | 1234 | (setq sample-begin (point))) |
| @@ -1187,21 +1239,24 @@ Optional EVENT is the event that triggered the action." | |||
| 1187 | (insert "\n") | 1239 | (insert "\n") |
| 1188 | (insert-char ? (widget-get widget :indent)))) | 1240 | (insert-char ? (widget-get widget :indent)))) |
| 1189 | ((eq escape ?t) | 1241 | ((eq escape ?t) |
| 1190 | (cond (glyph | 1242 | (let ((glyph (widget-get widget :tag-glyph)) |
| 1191 | (widget-glyph-insert widget (or tag "image") glyph)) | 1243 | (tag (widget-get widget :tag))) |
| 1192 | (tag | 1244 | (cond (glyph |
| 1193 | (insert tag)) | 1245 | (widget-glyph-insert widget (or tag "image") glyph)) |
| 1194 | (t | 1246 | (tag |
| 1195 | (let ((standard-output (current-buffer))) | 1247 | (insert tag)) |
| 1196 | (princ (widget-get widget :value)))))) | 1248 | (t |
| 1249 | (let ((standard-output (current-buffer))) | ||
| 1250 | (princ (widget-get widget :value))))))) | ||
| 1197 | ((eq escape ?d) | 1251 | ((eq escape ?d) |
| 1198 | (when doc | 1252 | (let ((doc (widget-get widget :doc))) |
| 1199 | (setq doc-begin (point)) | 1253 | (when doc |
| 1200 | (insert doc) | 1254 | (setq doc-begin (point)) |
| 1201 | (while (eq (preceding-char) ?\n) | 1255 | (insert doc) |
| 1202 | (delete-backward-char 1)) | 1256 | (while (eq (preceding-char) ?\n) |
| 1203 | (insert "\n") | 1257 | (delete-backward-char 1)) |
| 1204 | (setq doc-end (point)))) | 1258 | (insert "\n") |
| 1259 | (setq doc-end (point))))) | ||
| 1205 | ((eq escape ?v) | 1260 | ((eq escape ?v) |
| 1206 | (if (and button-begin (not button-end)) | 1261 | (if (and button-begin (not button-end)) |
| 1207 | (widget-apply widget :value-create) | 1262 | (widget-apply widget :value-create) |
| @@ -1386,17 +1441,29 @@ Optional EVENT is the event that triggered the action." | |||
| 1386 | ;; Cache already created GUI objects. | 1441 | ;; Cache already created GUI objects. |
| 1387 | (defvar widget-push-button-cache nil) | 1442 | (defvar widget-push-button-cache nil) |
| 1388 | 1443 | ||
| 1444 | (defcustom widget-push-button-prefix "[" | ||
| 1445 | "String used as prefix for buttons." | ||
| 1446 | :type 'string | ||
| 1447 | :group 'widget-button) | ||
| 1448 | |||
| 1449 | (defcustom widget-push-button-suffix "]" | ||
| 1450 | "String used as suffix for buttons." | ||
| 1451 | :type 'string | ||
| 1452 | :group 'widget-button) | ||
| 1453 | |||
| 1389 | (define-widget 'push-button 'item | 1454 | (define-widget 'push-button 'item |
| 1390 | "A pushable button." | 1455 | "A pushable button." |
| 1456 | :button-prefix "" | ||
| 1457 | :button-suffix "" | ||
| 1391 | :value-create 'widget-push-button-value-create | 1458 | :value-create 'widget-push-button-value-create |
| 1392 | :text-format "[%s]" | ||
| 1393 | :format "%[%v%]") | 1459 | :format "%[%v%]") |
| 1394 | 1460 | ||
| 1395 | (defun widget-push-button-value-create (widget) | 1461 | (defun widget-push-button-value-create (widget) |
| 1396 | ;; Insert text representing the `on' and `off' states. | 1462 | ;; Insert text representing the `on' and `off' states. |
| 1397 | (let* ((tag (or (widget-get widget :tag) | 1463 | (let* ((tag (or (widget-get widget :tag) |
| 1398 | (widget-get widget :value))) | 1464 | (widget-get widget :value))) |
| 1399 | (text (format (widget-get widget :text-format) tag)) | 1465 | (text (concat widget-push-button-prefix |
| 1466 | tag widget-push-button-suffix)) | ||
| 1400 | (gui (cdr (assoc tag widget-push-button-cache)))) | 1467 | (gui (cdr (assoc tag widget-push-button-cache)))) |
| 1401 | (if (and (fboundp 'make-gui-button) | 1468 | (if (and (fboundp 'make-gui-button) |
| 1402 | (fboundp 'make-glyph) | 1469 | (fboundp 'make-glyph) |
| @@ -1408,10 +1475,16 @@ Optional EVENT is the event that triggered the action." | |||
| 1408 | (unless gui | 1475 | (unless gui |
| 1409 | (setq gui (make-gui-button tag 'widget-gui-action widget)) | 1476 | (setq gui (make-gui-button tag 'widget-gui-action widget)) |
| 1410 | (push (cons tag gui) widget-push-button-cache)) | 1477 | (push (cons tag gui) widget-push-button-cache)) |
| 1411 | (widget-glyph-insert-glyph widget text | 1478 | (widget-glyph-insert-glyph widget |
| 1412 | (make-glyph (nth 0 (aref gui 1))) | 1479 | (make-glyph |
| 1413 | (make-glyph (nth 1 (aref gui 1))) | 1480 | (list (nth 0 (aref gui 1)) |
| 1414 | (make-glyph (nth 2 (aref gui 1))))) | 1481 | (vector 'string ':data text))) |
| 1482 | (make-glyph | ||
| 1483 | (list (nth 1 (aref gui 1)) | ||
| 1484 | (vector 'string ':data text))) | ||
| 1485 | (make-glyph | ||
| 1486 | (list (nth 2 (aref gui 1)) | ||
| 1487 | (vector 'string ':data text))))) | ||
| 1415 | (insert text)))) | 1488 | (insert text)))) |
| 1416 | 1489 | ||
| 1417 | (defun widget-gui-action (widget) | 1490 | (defun widget-gui-action (widget) |
| @@ -1420,10 +1493,22 @@ Optional EVENT is the event that triggered the action." | |||
| 1420 | 1493 | ||
| 1421 | ;;; The `link' Widget. | 1494 | ;;; The `link' Widget. |
| 1422 | 1495 | ||
| 1496 | (defcustom widget-link-prefix "[" | ||
| 1497 | "String used as prefix for links." | ||
| 1498 | :type 'string | ||
| 1499 | :group 'widget-button) | ||
| 1500 | |||
| 1501 | (defcustom widget-link-suffix "]" | ||
| 1502 | "String used as suffix for links." | ||
| 1503 | :type 'string | ||
| 1504 | :group 'widget-button) | ||
| 1505 | |||
| 1423 | (define-widget 'link 'item | 1506 | (define-widget 'link 'item |
| 1424 | "An embedded link." | 1507 | "An embedded link." |
| 1508 | :button-prefix 'widget-link-prefix | ||
| 1509 | :button-suffix 'widget-link-suffix | ||
| 1425 | :help-echo "Follow the link." | 1510 | :help-echo "Follow the link." |
| 1426 | :format "%[_%t_%]") | 1511 | :format "%[%t%]") |
| 1427 | 1512 | ||
| 1428 | ;;; The `info-link' Widget. | 1513 | ;;; The `info-link' Widget. |
| 1429 | 1514 | ||
| @@ -1627,7 +1712,7 @@ Optional EVENT is the event that triggered the action." | |||
| 1627 | (defcustom widget-choice-toggle nil | 1712 | (defcustom widget-choice-toggle nil |
| 1628 | "If non-nil, a binary choice will just toggle between the values. | 1713 | "If non-nil, a binary choice will just toggle between the values. |
| 1629 | Otherwise, the user will explicitly have to choose between the values | 1714 | Otherwise, the user will explicitly have to choose between the values |
| 1630 | when he activate the menu." | 1715 | when he invoked the menu." |
| 1631 | :type 'boolean | 1716 | :type 'boolean |
| 1632 | :group 'widgets) | 1717 | :group 'widgets) |
| 1633 | 1718 | ||
| @@ -1756,6 +1841,8 @@ when he activate the menu." | |||
| 1756 | 1841 | ||
| 1757 | (define-widget 'checkbox 'toggle | 1842 | (define-widget 'checkbox 'toggle |
| 1758 | "A checkbox toggle." | 1843 | "A checkbox toggle." |
| 1844 | :button-suffix "" | ||
| 1845 | :button-prefix "" | ||
| 1759 | :format "%[%v%]" | 1846 | :format "%[%v%]" |
| 1760 | :on "[X]" | 1847 | :on "[X]" |
| 1761 | :on-glyph "check1" | 1848 | :on-glyph "check1" |
| @@ -1940,6 +2027,8 @@ when he activate the menu." | |||
| 1940 | "A radio button for use in the `radio' widget." | 2027 | "A radio button for use in the `radio' widget." |
| 1941 | :notify 'widget-radio-button-notify | 2028 | :notify 'widget-radio-button-notify |
| 1942 | :format "%[%v%]" | 2029 | :format "%[%v%]" |
| 2030 | :button-suffix "" | ||
| 2031 | :button-prefix "" | ||
| 1943 | :on "(*)" | 2032 | :on "(*)" |
| 1944 | :on-glyph "radio1" | 2033 | :on-glyph "radio1" |
| 1945 | :off "( )" | 2034 | :off "( )" |
| @@ -2376,7 +2465,7 @@ when he activate the menu." | |||
| 2376 | 2465 | ||
| 2377 | (define-widget 'widget-help 'push-button | 2466 | (define-widget 'widget-help 'push-button |
| 2378 | "The widget documentation button." | 2467 | "The widget documentation button." |
| 2379 | :format "%[[%t]%] %d" | 2468 | :format "%[%v%] %d" |
| 2380 | :help-echo "Toggle display of documentation." | 2469 | :help-echo "Toggle display of documentation." |
| 2381 | :action 'widget-help-action) | 2470 | :action 'widget-help-action) |
| 2382 | 2471 | ||
| @@ -2446,7 +2535,7 @@ when he activate the menu." | |||
| 2446 | 2535 | ||
| 2447 | (define-widget 'file 'string | 2536 | (define-widget 'file 'string |
| 2448 | "A file widget. | 2537 | "A file widget. |
| 2449 | It will read a file name from the minibuffer when activated." | 2538 | It will read a file name from the minibuffer when invoked." |
| 2450 | :prompt-value 'widget-file-prompt-value | 2539 | :prompt-value 'widget-file-prompt-value |
| 2451 | :format "%{%t%}: %v" | 2540 | :format "%{%t%}: %v" |
| 2452 | :tag "File" | 2541 | :tag "File" |
| @@ -2478,7 +2567,7 @@ It will read a file name from the minibuffer when activated." | |||
| 2478 | 2567 | ||
| 2479 | (define-widget 'directory 'file | 2568 | (define-widget 'directory 'file |
| 2480 | "A directory widget. | 2569 | "A directory widget. |
| 2481 | It will read a directory name from the minibuffer when activated." | 2570 | It will read a directory name from the minibuffer when invoked." |
| 2482 | :tag "Directory") | 2571 | :tag "Directory") |
| 2483 | 2572 | ||
| 2484 | (defvar widget-symbol-prompt-value-history nil | 2573 | (defvar widget-symbol-prompt-value-history nil |
| @@ -2755,11 +2844,14 @@ It will read a directory name from the minibuffer when activated." | |||
| 2755 | :sample-face-get 'widget-color-item-button-face-get) | 2844 | :sample-face-get 'widget-color-item-button-face-get) |
| 2756 | 2845 | ||
| 2757 | (defun widget-color-item-button-face-get (widget) | 2846 | (defun widget-color-item-button-face-get (widget) |
| 2758 | ;; We create a face from the value. | 2847 | (let ((symbol (intern (concat "fg:" (widget-value widget))))) |
| 2759 | (require 'facemenu) | 2848 | (if (string-match "XEmacs" emacs-version) |
| 2760 | (condition-case nil | 2849 | (prog1 symbol |
| 2761 | (facemenu-get-face (intern (concat "fg:" (widget-value widget)))) | 2850 | (or (find-face symbol) |
| 2762 | (error 'default))) | 2851 | (set-face-foreground (make-face symbol) (widget-value widget)))) |
| 2852 | (condition-case nil | ||
| 2853 | (facemenu-get-face symbol) | ||
| 2854 | (error 'default))))) | ||
| 2763 | 2855 | ||
| 2764 | (define-widget 'color 'push-button | 2856 | (define-widget 'color 'push-button |
| 2765 | "Choose a color name (with sample)." | 2857 | "Choose a color name (with sample)." |
diff --git a/lisp/widget.el b/lisp/widget.el index f65b6603615..1be690a6d36 100644 --- a/lisp/widget.el +++ b/lisp/widget.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | ;; | 4 | ;; |
| 5 | ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | 5 | ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> |
| 6 | ;; Keywords: help, extensions, faces, hypermedia | 6 | ;; Keywords: help, extensions, faces, hypermedia |
| 7 | ;; Version: 1.97 | 7 | ;; Version: 1.9900 |
| 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. |
| @@ -44,10 +44,10 @@ | |||
| 44 | (set (car keywords) (car keywords))) | 44 | (set (car keywords) (car keywords))) |
| 45 | (setq keywords (cdr keywords))))))) | 45 | (setq keywords (cdr keywords))))))) |
| 46 | 46 | ||
| 47 | (define-widget-keywords :mouse-down-action :glyph-up :glyph-down | 47 | (define-widget-keywords :button-prefix :button-suffix |
| 48 | :glyph-inactive | 48 | :mouse-down-action :glyph-up :glyph-down :glyph-inactive |
| 49 | :prompt-internal :prompt-history :prompt-match | 49 | :prompt-internal :prompt-history :prompt-match |
| 50 | :prompt-value :text-format :deactivate :active | 50 | :prompt-value :deactivate :active |
| 51 | :inactive :activate :sibling-args :delete-button-args | 51 | :inactive :activate :sibling-args :delete-button-args |
| 52 | :insert-button-args :append-button-args :button-args | 52 | :insert-button-args :append-button-args :button-args |
| 53 | :tag-glyph :off-glyph :on-glyph :valid-regexp | 53 | :tag-glyph :off-glyph :on-glyph :valid-regexp |