diff options
| author | Per Abrahamsen | 1997-06-25 15:30:27 +0000 |
|---|---|---|
| committer | Per Abrahamsen | 1997-06-25 15:30:27 +0000 |
| commit | da5ec617855514df05406f25b4d921e100f4b128 (patch) | |
| tree | 14344c06cc95dd5e8e0e001c075d398ae95f1ab8 | |
| parent | 8213742bb055f0983648731dc66cbc09dac2e810 (diff) | |
| download | emacs-da5ec617855514df05406f25b4d921e100f4b128.tar.gz emacs-da5ec617855514df05406f25b4d921e100f4b128.zip | |
Synched with 1.9936.
| -rw-r--r-- | lisp/cus-edit.el | 251 | ||||
| -rw-r--r-- | lisp/wid-edit.el | 98 |
2 files changed, 220 insertions, 129 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index abf575cf968..3433b03e206 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.9929 | 7 | ;; Version: 1.9936 |
| 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. |
| @@ -255,13 +255,18 @@ | |||
| 255 | :group 'customize | 255 | :group 'customize |
| 256 | :group 'faces) | 256 | :group 'faces) |
| 257 | 257 | ||
| 258 | (defgroup custom-browse nil | ||
| 259 | "Control customize browser." | ||
| 260 | :prefix "custom-" | ||
| 261 | :group 'customize) | ||
| 262 | |||
| 258 | (defgroup custom-buffer nil | 263 | (defgroup custom-buffer nil |
| 259 | "Control the customize buffers." | 264 | "Control customize buffers." |
| 260 | :prefix "custom-" | 265 | :prefix "custom-" |
| 261 | :group 'customize) | 266 | :group 'customize) |
| 262 | 267 | ||
| 263 | (defgroup custom-menu nil | 268 | (defgroup custom-menu nil |
| 264 | "Control how the customize menus." | 269 | "Control customize menus." |
| 265 | :prefix "custom-" | 270 | :prefix "custom-" |
| 266 | :group 'customize) | 271 | :group 'customize) |
| 267 | 272 | ||
| @@ -549,53 +554,74 @@ if that fails, the doc string with `custom-guess-doc-alist'." | |||
| 549 | 554 | ||
| 550 | ;;; Sorting. | 555 | ;;; Sorting. |
| 551 | 556 | ||
| 557 | (defcustom custom-browse-sort-alphabetically nil | ||
| 558 | "If non-nil, sort members of each customization group alphabetically." | ||
| 559 | :type 'boolean | ||
| 560 | :group 'custom-browse) | ||
| 561 | |||
| 562 | (defcustom custom-browse-order-groups nil | ||
| 563 | "If non-nil, order group members within each customization group. | ||
| 564 | If `first', order groups before non-groups. | ||
| 565 | If `last', order groups after non-groups." | ||
| 566 | :type '(choice (const first) | ||
| 567 | (const last) | ||
| 568 | (const :tag "none" nil)) | ||
| 569 | :group 'custom-browse) | ||
| 570 | |||
| 552 | (defcustom custom-buffer-sort-alphabetically nil | 571 | (defcustom custom-buffer-sort-alphabetically nil |
| 553 | "If non-nil, sort the members of each customization group alphabetically." | 572 | "If non-nil, sort members of each customization group alphabetically." |
| 554 | :type 'boolean | 573 | :type 'boolean |
| 555 | :group 'custom-buffer) | 574 | :group 'custom-buffer) |
| 556 | 575 | ||
| 557 | (defcustom custom-buffer-groups-last nil | 576 | (defcustom custom-buffer-order-groups 'last |
| 558 | "If non-nil, put subgroups after all ordinary options within a group." | 577 | "If non-nil, order group members within each customization group. |
| 559 | :type 'boolean | 578 | If `first', order groups before non-groups. |
| 579 | If `last', order groups after non-groups." | ||
| 580 | :type '(choice (const first) | ||
| 581 | (const last) | ||
| 582 | (const :tag "none" nil)) | ||
| 560 | :group 'custom-buffer) | 583 | :group 'custom-buffer) |
| 561 | 584 | ||
| 562 | (defcustom custom-menu-sort-alphabetically nil | 585 | (defcustom custom-menu-sort-alphabetically nil |
| 563 | "If non-nil, sort the members of each customization group alphabetically." | 586 | "If non-nil, sort members of each customization group alphabetically." |
| 564 | :type 'boolean | 587 | :type 'boolean |
| 565 | :group 'custom-menu) | 588 | :group 'custom-menu) |
| 566 | 589 | ||
| 567 | (defcustom custom-menu-groups-first t | 590 | (defcustom custom-menu-order-groups 'first |
| 568 | "If non-nil, put subgroups before all ordinary options within a group." | 591 | "If non-nil, order group members within each customization group. |
| 569 | :type 'boolean | 592 | If `first', order groups before non-groups. |
| 593 | If `last', order groups after non-groups." | ||
| 594 | :type '(choice (const first) | ||
| 595 | (const last) | ||
| 596 | (const :tag "none" nil)) | ||
| 570 | :group 'custom-menu) | 597 | :group 'custom-menu) |
| 571 | 598 | ||
| 572 | (defun custom-buffer-sort-predicate (a b) | 599 | (defun custom-sort-items (items sort-alphabetically order-groups) |
| 573 | "Return t iff A should come before B in a customization buffer. | 600 | "Return a sorted copy of ITEMS. |
| 574 | A and B should be members of a `custom-group' property." | 601 | ITEMS should be a `custom-group' property. |
| 575 | (cond ((and (not custom-buffer-groups-last) | 602 | If SORT-ALPHABETICALLY non-nil, sort alphabetically. |
| 576 | (not custom-buffer-sort-alphabetically)) | 603 | If ORDER-GROUPS is `first' order groups before non-groups, if `last' order |
| 577 | nil) | 604 | groups after non-groups, if nil do not order groups at all." |
| 578 | ((or (eq (eq (nth 1 a) 'custom-group) (eq (nth 1 b) 'custom-group)) | 605 | (sort (copy-sequence items) |
| 579 | (not custom-buffer-groups-last)) | 606 | (lambda (a b) |
| 580 | (if custom-buffer-sort-alphabetically | 607 | (let ((typea (nth 1 a)) (typeb (nth 1 b)) |
| 581 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))) | 608 | (namea (symbol-name (nth 0 a))) (nameb (symbol-name (nth 0 b)))) |
| 582 | nil)) | 609 | (cond ((not order-groups) |
| 583 | (t | 610 | ;; Since we don't care about A and B order, maybe sort. |
| 584 | (not (eq (nth 1 a) 'custom-group) )))) | 611 | (when sort-alphabetically |
| 585 | 612 | (string-lessp namea nameb))) | |
| 586 | (defun custom-menu-sort-predicate (a b) | 613 | ((eq typea 'custom-group) |
| 587 | "Return t iff A should come before B in a customization menu. | 614 | ;; If B is also a group, maybe sort. Otherwise, order A and B. |
| 588 | A and B should be members of a `custom-group' property." | 615 | (if (eq typeb 'custom-group) |
| 589 | (cond ((and (not custom-menu-groups-first) | 616 | (when sort-alphabetically |
| 590 | (not custom-menu-sort-alphabetically)) | 617 | (string-lessp namea nameb)) |
| 591 | nil) | 618 | (eq order-groups 'first))) |
| 592 | ((or (eq (eq (nth 1 a) 'custom-group) (eq (nth 1 b) 'custom-group)) | 619 | ((eq typeb 'custom-group) |
| 593 | (not custom-menu-groups-first)) | 620 | ;; Since A cannot be a group, order A and B. |
| 594 | (if custom-menu-sort-alphabetically | 621 | (eq order-groups 'last)) |
| 595 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))) | 622 | (sort-alphabetically |
| 596 | nil)) | 623 | ;; Since A and B cannot be groups, sort. |
| 597 | (t | 624 | (string-lessp namea nameb))))))) |
| 598 | (eq (nth 1 a) 'custom-group) ))) | ||
| 599 | 625 | ||
| 600 | ;;; Custom Mode Commands. | 626 | ;;; Custom Mode Commands. |
| 601 | 627 | ||
| @@ -813,17 +839,14 @@ If SYMBOL is nil, customize all faces." | |||
| 813 | (interactive (list (completing-read "Customize face: (default all) " | 839 | (interactive (list (completing-read "Customize face: (default all) " |
| 814 | obarray 'custom-facep))) | 840 | obarray 'custom-facep))) |
| 815 | (if (or (null symbol) (and (stringp symbol) (zerop (length symbol)))) | 841 | (if (or (null symbol) (and (stringp symbol) (zerop (length symbol)))) |
| 816 | (let ((found nil)) | 842 | (custom-buffer-create (custom-sort-items |
| 817 | (message "Looking for faces...") | 843 | (mapcar (lambda (symbol) |
| 818 | (mapcar (lambda (symbol) | 844 | (list symbol 'custom-face)) |
| 819 | (push (list symbol 'custom-face) found)) | 845 | (face-list)) |
| 820 | (nreverse (mapcar 'intern | 846 | t nil) |
| 821 | (sort (mapcar 'symbol-name (face-list)) | 847 | "*Customize Faces*") |
| 822 | 'string-lessp)))) | 848 | (when (stringp symbol) |
| 823 | 849 | (setq symbol (intern symbol))) | |
| 824 | (custom-buffer-create found "*Customize Faces*")) | ||
| 825 | (if (stringp symbol) | ||
| 826 | (setq symbol (intern symbol))) | ||
| 827 | (unless (symbolp symbol) | 850 | (unless (symbolp symbol) |
| 828 | (error "Should be a symbol %S" symbol)) | 851 | (error "Should be a symbol %S" symbol)) |
| 829 | (custom-buffer-create (list (list symbol 'custom-face)) | 852 | (custom-buffer-create (list (list symbol 'custom-face)) |
| @@ -857,9 +880,10 @@ If SYMBOL is nil, customize all faces." | |||
| 857 | (and (get symbol 'customized-value) | 880 | (and (get symbol 'customized-value) |
| 858 | (boundp symbol) | 881 | (boundp symbol) |
| 859 | (push (list symbol 'custom-variable) found)))) | 882 | (push (list symbol 'custom-variable) found)))) |
| 860 | (if found | 883 | (if (not found) |
| 861 | (custom-buffer-create found "*Customize Customized*") | 884 | (error "No customized user options") |
| 862 | (error "No customized user options")))) | 885 | (custom-buffer-create (custom-sort-items found t nil) |
| 886 | "*Customize Customized*")))) | ||
| 863 | 887 | ||
| 864 | ;;;###autoload | 888 | ;;;###autoload |
| 865 | (defun customize-saved () | 889 | (defun customize-saved () |
| @@ -873,9 +897,10 @@ If SYMBOL is nil, customize all faces." | |||
| 873 | (and (get symbol 'saved-value) | 897 | (and (get symbol 'saved-value) |
| 874 | (boundp symbol) | 898 | (boundp symbol) |
| 875 | (push (list symbol 'custom-variable) found)))) | 899 | (push (list symbol 'custom-variable) found)))) |
| 876 | (if found | 900 | (if (not found ) |
| 877 | (custom-buffer-create found "*Customize Saved*") | 901 | (error "No saved user options") |
| 878 | (error "No saved user options")))) | 902 | (custom-buffer-create (custom-sort-items found t nil) |
| 903 | "*Customize Saved*")))) | ||
| 879 | 904 | ||
| 880 | ;;;###autoload | 905 | ;;;###autoload |
| 881 | (defun customize-apropos (regexp &optional all) | 906 | (defun customize-apropos (regexp &optional all) |
| @@ -905,9 +930,9 @@ user-settable, as well as faces and groups." | |||
| 905 | (push (list symbol 'custom-variable) found))))) | 930 | (push (list symbol 'custom-variable) found))))) |
| 906 | (if (not found) | 931 | (if (not found) |
| 907 | (error "No matches") | 932 | (error "No matches") |
| 908 | (let ((custom-buffer-sort-alphabetically t)) | 933 | (custom-buffer-create (custom-sort-items found t |
| 909 | (custom-buffer-create (sort found 'custom-buffer-sort-predicate) | 934 | custom-buffer-order-groups) |
| 910 | "*Customize Apropos*"))))) | 935 | "*Customize Apropos*")))) |
| 911 | 936 | ||
| 912 | ;;;###autoload | 937 | ;;;###autoload |
| 913 | (defun customize-apropos-options (regexp &optional arg) | 938 | (defun customize-apropos-options (regexp &optional arg) |
| @@ -1073,9 +1098,19 @@ Reset all values in this buffer to their standard settings." | |||
| 1073 | ;;; The Tree Browser. | 1098 | ;;; The Tree Browser. |
| 1074 | 1099 | ||
| 1075 | ;;;###autoload | 1100 | ;;;###autoload |
| 1076 | (defun customize-browse () | 1101 | (defun customize-browse (group) |
| 1077 | "Create a tree browser for the customize hierarchy." | 1102 | "Create a tree browser for the customize hierarchy." |
| 1078 | (interactive) | 1103 | (interactive (list (let ((completion-ignore-case t)) |
| 1104 | (completing-read "Customize group: (default emacs) " | ||
| 1105 | obarray | ||
| 1106 | (lambda (symbol) | ||
| 1107 | (get symbol 'custom-group)) | ||
| 1108 | t)))) | ||
| 1109 | |||
| 1110 | (when (stringp group) | ||
| 1111 | (if (string-equal "" group) | ||
| 1112 | (setq group 'emacs) | ||
| 1113 | (setq group (intern group)))) | ||
| 1079 | (let ((name "*Customize Browser*")) | 1114 | (let ((name "*Customize Browser*")) |
| 1080 | (kill-buffer (get-buffer-create name)) | 1115 | (kill-buffer (get-buffer-create name)) |
| 1081 | (switch-to-buffer (get-buffer-create name))) | 1116 | (switch-to-buffer (get-buffer-create name))) |
| @@ -1088,15 +1123,13 @@ item in another window.\n\n") | |||
| 1088 | (widget-create 'custom-group | 1123 | (widget-create 'custom-group |
| 1089 | :custom-last t | 1124 | :custom-last t |
| 1090 | :custom-state 'unknown | 1125 | :custom-state 'unknown |
| 1091 | :tag (custom-unlispify-tag-name 'emacs) | 1126 | :tag (custom-unlispify-tag-name group) |
| 1092 | :value 'emacs)) | 1127 | :value group)) |
| 1093 | (goto-char (point-min))) | 1128 | (goto-char (point-min))) |
| 1094 | 1129 | ||
| 1095 | (define-widget 'custom-tree-visibility 'item | 1130 | (define-widget 'custom-tree-visibility 'item |
| 1096 | "Control visibility of of items in the customize tree browser." | 1131 | "Control visibility of of items in the customize tree browser." |
| 1097 | :button-prefix "[" | 1132 | :format "%[[%t]%]" |
| 1098 | :button-suffix "]" | ||
| 1099 | :format "%[%t%]" | ||
| 1100 | :action 'custom-tree-visibility-action) | 1133 | :action 'custom-tree-visibility-action) |
| 1101 | 1134 | ||
| 1102 | (defun custom-tree-visibility-action (widget &rest ignore) | 1135 | (defun custom-tree-visibility-action (widget &rest ignore) |
| @@ -1106,6 +1139,7 @@ item in another window.\n\n") | |||
| 1106 | (define-widget 'custom-tree-group-tag 'push-button | 1139 | (define-widget 'custom-tree-group-tag 'push-button |
| 1107 | "Show parent in other window when activated." | 1140 | "Show parent in other window when activated." |
| 1108 | :tag "Group" | 1141 | :tag "Group" |
| 1142 | :tag-glyph "folder" | ||
| 1109 | :action 'custom-tree-group-tag-action) | 1143 | :action 'custom-tree-group-tag-action) |
| 1110 | 1144 | ||
| 1111 | (defun custom-tree-group-tag-action (widget &rest ignore) | 1145 | (defun custom-tree-group-tag-action (widget &rest ignore) |
| @@ -1115,6 +1149,7 @@ item in another window.\n\n") | |||
| 1115 | (define-widget 'custom-tree-variable-tag 'push-button | 1149 | (define-widget 'custom-tree-variable-tag 'push-button |
| 1116 | "Show parent in other window when activated." | 1150 | "Show parent in other window when activated." |
| 1117 | :tag "Option" | 1151 | :tag "Option" |
| 1152 | :tag-glyph "option" | ||
| 1118 | :action 'custom-tree-variable-tag-action) | 1153 | :action 'custom-tree-variable-tag-action) |
| 1119 | 1154 | ||
| 1120 | (defun custom-tree-variable-tag-action (widget &rest ignore) | 1155 | (defun custom-tree-variable-tag-action (widget &rest ignore) |
| @@ -1124,12 +1159,34 @@ item in another window.\n\n") | |||
| 1124 | (define-widget 'custom-tree-face-tag 'push-button | 1159 | (define-widget 'custom-tree-face-tag 'push-button |
| 1125 | "Show parent in other window when activated." | 1160 | "Show parent in other window when activated." |
| 1126 | :tag "Face" | 1161 | :tag "Face" |
| 1162 | :tag-glyph "face" | ||
| 1127 | :action 'custom-tree-face-tag-action) | 1163 | :action 'custom-tree-face-tag-action) |
| 1128 | 1164 | ||
| 1129 | (defun custom-tree-face-tag-action (widget &rest ignore) | 1165 | (defun custom-tree-face-tag-action (widget &rest ignore) |
| 1130 | (let ((parent (widget-get widget :parent))) | 1166 | (let ((parent (widget-get widget :parent))) |
| 1131 | (customize-face-other-window (widget-value parent)))) | 1167 | (customize-face-other-window (widget-value parent)))) |
| 1132 | 1168 | ||
| 1169 | (defconst custom-tree-alist '((" " "space") | ||
| 1170 | (" | " "vertical") | ||
| 1171 | ("-\\ " "top") | ||
| 1172 | (" |-" "middle") | ||
| 1173 | (" `-" "bottom"))) | ||
| 1174 | |||
| 1175 | (defun custom-tree-insert-prefix (prefix) | ||
| 1176 | "Insert PREFIX. On XEmacs convert it to line graphics." | ||
| 1177 | (if nil ; (string-match "XEmacs" emacs-version) | ||
| 1178 | (progn | ||
| 1179 | (insert "*") | ||
| 1180 | (while (not (string-equal prefix "")) | ||
| 1181 | (let ((entry (substring prefix 0 3))) | ||
| 1182 | (setq prefix (substring prefix 3)) | ||
| 1183 | (let ((overlay (make-overlay (1- (point)) (point) nil t nil)) | ||
| 1184 | (name (nth 1 (assoc entry custom-tree-alist)))) | ||
| 1185 | (overlay-put overlay 'end-glyph (widget-glyph-find name entry)) | ||
| 1186 | (overlay-put overlay 'start-open t) | ||
| 1187 | (overlay-put overlay 'end-open t))))) | ||
| 1188 | (insert prefix))) | ||
| 1189 | |||
| 1133 | ;;; Modification of Basic Widgets. | 1190 | ;;; Modification of Basic Widgets. |
| 1134 | ;; | 1191 | ;; |
| 1135 | ;; We add extra properties to the basic widgets needed here. This is | 1192 | ;; We add extra properties to the basic widgets needed here. This is |
| @@ -1564,16 +1621,15 @@ If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"." | |||
| 1564 | found) | 1621 | found) |
| 1565 | (insert (or initial-string "Parent groups:")) | 1622 | (insert (or initial-string "Parent groups:")) |
| 1566 | (mapatoms (lambda (symbol) | 1623 | (mapatoms (lambda (symbol) |
| 1567 | (let ((group (get symbol 'custom-group))) | 1624 | (let ((entry (assq name (get symbol 'custom-group)))) |
| 1568 | (when (assq name group) | 1625 | (when (eq (nth 1 entry) type) |
| 1569 | (when (eq type (nth 1 (assq name group))) | 1626 | (insert " ") |
| 1570 | (insert " ") | 1627 | (push (widget-create-child-and-convert |
| 1571 | (push (widget-create-child-and-convert | 1628 | widget 'custom-group-link |
| 1572 | widget 'custom-group-link | 1629 | :tag (custom-unlispify-tag-name symbol) |
| 1573 | :tag (custom-unlispify-tag-name symbol) | 1630 | symbol) |
| 1574 | symbol) | 1631 | buttons) |
| 1575 | buttons) | 1632 | (setq found t))))) |
| 1576 | (setq found t)))))) | ||
| 1577 | (widget-put widget :buttons buttons) | 1633 | (widget-put widget :buttons buttons) |
| 1578 | (if found | 1634 | (if found |
| 1579 | (insert "\n") | 1635 | (insert "\n") |
| @@ -1659,7 +1715,7 @@ Otherwise, look up symbol in `custom-guess-type-alist'." | |||
| 1659 | (setq form 'lisp))) | 1715 | (setq form 'lisp))) |
| 1660 | ;; Now we can create the child widget. | 1716 | ;; Now we can create the child widget. |
| 1661 | (cond ((eq custom-buffer-style 'tree) | 1717 | (cond ((eq custom-buffer-style 'tree) |
| 1662 | (insert prefix (if last " +--- " " |--- ")) | 1718 | (insert prefix (if last " `--- " " |--- ")) |
| 1663 | (push (widget-create-child-and-convert | 1719 | (push (widget-create-child-and-convert |
| 1664 | widget 'custom-tree-variable-tag) | 1720 | widget 'custom-tree-variable-tag) |
| 1665 | buttons) | 1721 | buttons) |
| @@ -2093,7 +2149,7 @@ Match frames with dark backgrounds.") | |||
| 2093 | (unless tag | 2149 | (unless tag |
| 2094 | (setq tag (prin1-to-string symbol))) | 2150 | (setq tag (prin1-to-string symbol))) |
| 2095 | (cond ((eq custom-buffer-style 'tree) | 2151 | (cond ((eq custom-buffer-style 'tree) |
| 2096 | (insert prefix (if is-last " +--- " " |--- ")) | 2152 | (insert prefix (if is-last " `--- " " |--- ")) |
| 2097 | (push (widget-create-child-and-convert | 2153 | (push (widget-create-child-and-convert |
| 2098 | widget 'custom-tree-face-tag) | 2154 | widget 'custom-tree-face-tag) |
| 2099 | buttons) | 2155 | buttons) |
| @@ -2449,11 +2505,14 @@ and so forth. The remaining group tags are shown with | |||
| 2449 | (symbol (widget-value widget))) | 2505 | (symbol (widget-value widget))) |
| 2450 | (cond ((and (eq custom-buffer-style 'tree) | 2506 | (cond ((and (eq custom-buffer-style 'tree) |
| 2451 | (eq state 'hidden)) | 2507 | (eq state 'hidden)) |
| 2452 | (insert prefix) | 2508 | (custom-tree-insert-prefix prefix) |
| 2453 | (push (widget-create-child-and-convert | 2509 | (push (widget-create-child-and-convert |
| 2454 | widget 'custom-tree-visibility :tag "+") | 2510 | widget 'custom-tree-visibility |
| 2511 | ;; :tag-glyph "plus" | ||
| 2512 | :tag "+") | ||
| 2455 | buttons) | 2513 | buttons) |
| 2456 | (insert "-- ") | 2514 | (insert "-- ") |
| 2515 | ;; (widget-glyph-insert nil "-- " "horizontal") | ||
| 2457 | (push (widget-create-child-and-convert | 2516 | (push (widget-create-child-and-convert |
| 2458 | widget 'custom-tree-group-tag) | 2517 | widget 'custom-tree-group-tag) |
| 2459 | buttons) | 2518 | buttons) |
| @@ -2461,34 +2520,45 @@ and so forth. The remaining group tags are shown with | |||
| 2461 | (widget-put widget :buttons buttons)) | 2520 | (widget-put widget :buttons buttons)) |
| 2462 | ((and (eq custom-buffer-style 'tree) | 2521 | ((and (eq custom-buffer-style 'tree) |
| 2463 | (zerop (length (get symbol 'custom-group)))) | 2522 | (zerop (length (get symbol 'custom-group)))) |
| 2464 | (insert prefix "[ ]-- ") | 2523 | (custom-tree-insert-prefix prefix) |
| 2524 | (insert "[ ]-- ") | ||
| 2525 | ;; (widget-glyph-insert nil "[ ]" "empty") | ||
| 2526 | ;; (widget-glyph-insert nil "-- " "horizontal") | ||
| 2465 | (push (widget-create-child-and-convert | 2527 | (push (widget-create-child-and-convert |
| 2466 | widget 'custom-tree-group-tag) | 2528 | widget 'custom-tree-group-tag) |
| 2467 | buttons) | 2529 | buttons) |
| 2468 | (insert " " tag "\n") | 2530 | (insert " " tag "\n") |
| 2469 | (widget-put widget :buttons buttons)) | 2531 | (widget-put widget :buttons buttons)) |
| 2470 | ((eq custom-buffer-style 'tree) | 2532 | ((eq custom-buffer-style 'tree) |
| 2471 | (insert prefix) | 2533 | (custom-tree-insert-prefix prefix) |
| 2472 | (custom-load-widget widget) | 2534 | (custom-load-widget widget) |
| 2473 | (if (zerop (length (get symbol 'custom-group))) | 2535 | (if (zerop (length (get symbol 'custom-group))) |
| 2474 | (progn | 2536 | (progn |
| 2475 | (insert prefix "[ ]-- ") | 2537 | (custom-tree-insert-prefix prefix) |
| 2538 | (insert "[ ]-- ") | ||
| 2539 | ;; (widget-glyph-insert nil "[ ]" "empty") | ||
| 2540 | ;; (widget-glyph-insert nil "-- " "horizontal") | ||
| 2476 | (push (widget-create-child-and-convert | 2541 | (push (widget-create-child-and-convert |
| 2477 | widget 'custom-tree-group-tag) | 2542 | widget 'custom-tree-group-tag) |
| 2478 | buttons) | 2543 | buttons) |
| 2479 | (insert " " tag "\n") | 2544 | (insert " " tag "\n") |
| 2480 | (widget-put widget :buttons buttons)) | 2545 | (widget-put widget :buttons buttons)) |
| 2481 | (push (widget-create-child-and-convert | 2546 | (push (widget-create-child-and-convert |
| 2482 | widget 'custom-tree-visibility :tag "-") | 2547 | widget 'custom-tree-visibility |
| 2548 | ;; :tag-glyph "minus" | ||
| 2549 | :tag "-") | ||
| 2483 | buttons) | 2550 | buttons) |
| 2484 | (insert "-+ ") | 2551 | (insert "-\\ ") |
| 2552 | ;; (widget-glyph-insert nil "-\\ " "top") | ||
| 2485 | (push (widget-create-child-and-convert | 2553 | (push (widget-create-child-and-convert |
| 2486 | widget 'custom-tree-group-tag) | 2554 | widget 'custom-tree-group-tag) |
| 2487 | buttons) | 2555 | buttons) |
| 2488 | (insert " " tag "\n") | 2556 | (insert " " tag "\n") |
| 2489 | (widget-put widget :buttons buttons) | 2557 | (widget-put widget :buttons buttons) |
| 2490 | (message "Creating group...") | 2558 | (message "Creating group...") |
| 2491 | (let* ((members (copy-sequence (get symbol 'custom-group))) | 2559 | (let* ((members (custom-sort-items (get symbol 'custom-group) |
| 2560 | custom-browse-sort-alphabetically | ||
| 2561 | custom-browse-order-groups)) | ||
| 2492 | (prefixes (widget-get widget :custom-prefixes)) | 2562 | (prefixes (widget-get widget :custom-prefixes)) |
| 2493 | (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2563 | (custom-prefix-list (custom-prefix-add symbol prefixes)) |
| 2494 | (length (length members)) | 2564 | (length (length members)) |
| @@ -2605,8 +2675,9 @@ and so forth. The remaining group tags are shown with | |||
| 2605 | ;; Members. | 2675 | ;; Members. |
| 2606 | (message "Creating group...") | 2676 | (message "Creating group...") |
| 2607 | (custom-load-widget widget) | 2677 | (custom-load-widget widget) |
| 2608 | (let* ((members (sort (copy-sequence (get symbol 'custom-group)) | 2678 | (let* ((members (custom-sort-items (get symbol 'custom-group) |
| 2609 | 'custom-buffer-sort-predicate)) | 2679 | custom-buffer-sort-alphabetically |
| 2680 | custom-buffer-order-groups)) | ||
| 2610 | (prefixes (widget-get widget :custom-prefixes)) | 2681 | (prefixes (widget-get widget :custom-prefixes)) |
| 2611 | (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2682 | (custom-prefix-list (custom-prefix-add symbol prefixes)) |
| 2612 | (length (length members)) | 2683 | (length (length members)) |
| @@ -2871,6 +2942,7 @@ Leave point at the location of the call, or after the last expression." | |||
| 2871 | (defconst custom-help-menu | 2942 | (defconst custom-help-menu |
| 2872 | '("Customize" | 2943 | '("Customize" |
| 2873 | ["Update menu..." Custom-menu-update t] | 2944 | ["Update menu..." Custom-menu-update t] |
| 2945 | ["Browse..." (customize-browse 'emacs) t] | ||
| 2874 | ["Group..." customize-group t] | 2946 | ["Group..." customize-group t] |
| 2875 | ["Variable..." customize-variable t] | 2947 | ["Variable..." customize-variable t] |
| 2876 | ["Face..." customize-face t] | 2948 | ["Face..." customize-face t] |
| @@ -2960,8 +3032,9 @@ The menu is in a format applicable to `easy-menu-define'." | |||
| 2960 | (< (length (get symbol 'custom-group)) widget-menu-max-size)) | 3032 | (< (length (get symbol 'custom-group)) widget-menu-max-size)) |
| 2961 | (let ((custom-prefix-list (custom-prefix-add symbol | 3033 | (let ((custom-prefix-list (custom-prefix-add symbol |
| 2962 | custom-prefix-list)) | 3034 | custom-prefix-list)) |
| 2963 | (members (sort (copy-sequence (get symbol 'custom-group)) | 3035 | (members (custom-sort-items (get symbol 'custom-group) |
| 2964 | 'custom-menu-sort-predicate))) | 3036 | custom-menu-sort-alphabetically |
| 3037 | custom-menu-order-groups))) | ||
| 2965 | (custom-load-symbol symbol) | 3038 | (custom-load-symbol symbol) |
| 2966 | `(,(custom-unlispify-menu-entry symbol t) | 3039 | `(,(custom-unlispify-menu-entry symbol t) |
| 2967 | ,item | 3040 | ,item |
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index ccaae14b78a..e90d62e12b3 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.9929 | 7 | ;; Version: 1.9936 |
| 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. |
| @@ -335,6 +335,17 @@ size field." | |||
| 335 | :type 'boolean | 335 | :type 'boolean |
| 336 | :group 'widgets) | 336 | :group 'widgets) |
| 337 | 337 | ||
| 338 | (defcustom widget-field-use-before-change | ||
| 339 | (or (> emacs-minor-version 34) | ||
| 340 | (> emacs-major-version 20) | ||
| 341 | (string-match "XEmacs" emacs-version)) | ||
| 342 | "Non-nil means use `before-change-functions' to track editable fields. | ||
| 343 | This enables the use of undo, but doesn'f work on Emacs 19.34 and earlier. | ||
| 344 | Using before hooks also means that the :notify function can't know the | ||
| 345 | new value." | ||
| 346 | :type 'boolean | ||
| 347 | :group 'widgets) | ||
| 348 | |||
| 338 | (defun widget-specify-field (widget from to) | 349 | (defun widget-specify-field (widget from to) |
| 339 | "Specify editable button for WIDGET between FROM and TO." | 350 | "Specify editable button for WIDGET between FROM and TO." |
| 340 | (put-text-property from to 'read-only nil) | 351 | (put-text-property from to 'read-only nil) |
| @@ -691,14 +702,15 @@ provide the fallback TAG as a part of the instantiator yourself." | |||
| 691 | "In WIDGET, insert GLYPH. | 702 | "In WIDGET, insert GLYPH. |
| 692 | If optional arguments DOWN and INACTIVE are given, they should be | 703 | If optional arguments DOWN and INACTIVE are given, they should be |
| 693 | glyphs used when the widget is pushed and inactive, respectively." | 704 | glyphs used when the widget is pushed and inactive, respectively." |
| 694 | (set-glyph-property glyph 'widget widget) | 705 | (when widget |
| 695 | (when down | 706 | (set-glyph-property glyph 'widget widget) |
| 696 | (set-glyph-property down 'widget widget)) | 707 | (when down |
| 697 | (when inactive | 708 | (set-glyph-property down 'widget widget)) |
| 698 | (set-glyph-property inactive 'widget widget)) | 709 | (when inactive |
| 710 | (set-glyph-property inactive 'widget widget))) | ||
| 699 | (insert "*") | 711 | (insert "*") |
| 700 | (let ((ext (make-extent (point) (1- (point)))) | 712 | (let ((ext (make-extent (point) (1- (point)))) |
| 701 | (help-echo (widget-get widget :help-echo))) | 713 | (help-echo (and widget (widget-get widget :help-echo)))) |
| 702 | (set-extent-property ext 'invisible t) | 714 | (set-extent-property ext 'invisible t) |
| 703 | (set-extent-property ext 'start-open t) | 715 | (set-extent-property ext 'start-open t) |
| 704 | (set-extent-property ext 'end-open t) | 716 | (set-extent-property ext 'end-open t) |
| @@ -706,9 +718,10 @@ glyphs used when the widget is pushed and inactive, respectively." | |||
| 706 | (when help-echo | 718 | (when help-echo |
| 707 | (set-extent-property ext 'balloon-help help-echo) | 719 | (set-extent-property ext 'balloon-help help-echo) |
| 708 | (set-extent-property ext 'help-echo help-echo))) | 720 | (set-extent-property ext 'help-echo help-echo))) |
| 709 | (widget-put widget :glyph-up glyph) | 721 | (when widget |
| 710 | (when down (widget-put widget :glyph-down down)) | 722 | (widget-put widget :glyph-up glyph) |
| 711 | (when inactive (widget-put widget :glyph-inactive inactive))) | 723 | (when down (widget-put widget :glyph-down down)) |
| 724 | (when inactive (widget-put widget :glyph-inactive inactive)))) | ||
| 712 | 725 | ||
| 713 | ;;; Buttons. | 726 | ;;; Buttons. |
| 714 | 727 | ||
| @@ -979,24 +992,25 @@ Recommended as a parent keymap for modes using widgets.") | |||
| 979 | (widget-apply-action button event))) | 992 | (widget-apply-action button event))) |
| 980 | (overlay-put overlay 'face face) | 993 | (overlay-put overlay 'face face) |
| 981 | (overlay-put overlay 'mouse-face mouse-face))) | 994 | (overlay-put overlay 'mouse-face mouse-face))) |
| 982 | (let (command up) | 995 | (let ((up t) |
| 996 | command) | ||
| 983 | ;; Find the global command to run, and check whether it | 997 | ;; Find the global command to run, and check whether it |
| 984 | ;; is bound to an up event. | 998 | ;; is bound to an up event. |
| 985 | (cond ((setq command ;down event | 999 | (cond ((setq command ;down event |
| 986 | (lookup-key widget-global-map [ button2 ]))) | 1000 | (lookup-key widget-global-map [ button2 ])) |
| 1001 | (setq up nil)) | ||
| 987 | ((setq command ;down event | 1002 | ((setq command ;down event |
| 988 | (lookup-key widget-global-map [ down-mouse-2 ]))) | 1003 | (lookup-key widget-global-map [ down-mouse-2 ])) |
| 1004 | (setq up nil)) | ||
| 989 | ((setq command ;up event | 1005 | ((setq command ;up event |
| 990 | (lookup-key widget-global-map [ button2up ])) | 1006 | (lookup-key widget-global-map [ button2up ]))) |
| 991 | (setq up t)) | ||
| 992 | ((setq command ;up event | 1007 | ((setq command ;up event |
| 993 | (lookup-key widget-global-map [ mouse-2])) | 1008 | (lookup-key widget-global-map [ mouse-2])))) |
| 994 | (setq up t))) | 1009 | (when up |
| 995 | (when command | ||
| 996 | ;; Don't execute up events twice. | 1010 | ;; Don't execute up events twice. |
| 997 | (when up | 1011 | (while (not (button-release-event-p event)) |
| 998 | (while (not (button-release-event-p event)) | 1012 | (setq event (widget-read-event)))) |
| 999 | (setq event (widget-read-event)))) | 1013 | (when command |
| 1000 | (call-interactively command)))))) | 1014 | (call-interactively command)))))) |
| 1001 | (t | 1015 | (t |
| 1002 | (message "You clicked somewhere weird.")))) | 1016 | (message "You clicked somewhere weird.")))) |
| @@ -1188,11 +1202,12 @@ When not inside a field, move to the previous button or field." | |||
| 1188 | (widget-clear-undo) | 1202 | (widget-clear-undo) |
| 1189 | ;; We need to maintain text properties and size of the editing fields. | 1203 | ;; We need to maintain text properties and size of the editing fields. |
| 1190 | (make-local-variable 'after-change-functions) | 1204 | (make-local-variable 'after-change-functions) |
| 1191 | (make-local-variable 'before-change-functions) | ||
| 1192 | (setq after-change-functions | 1205 | (setq after-change-functions |
| 1193 | (if widget-field-list '(widget-after-change) nil)) | 1206 | (if widget-field-list '(widget-after-change) nil)) |
| 1194 | (setq before-change-functions | 1207 | (when widget-field-use-before-change |
| 1195 | (if widget-field-list '(widget-before-change) nil))) | 1208 | (make-local-variable 'before-change-functions) |
| 1209 | (setq before-change-functions | ||
| 1210 | (if widget-field-list '(widget-before-change) nil)))) | ||
| 1196 | 1211 | ||
| 1197 | (defvar widget-field-last nil) | 1212 | (defvar widget-field-last nil) |
| 1198 | ;; Last field containing point. | 1213 | ;; Last field containing point. |
| @@ -1665,30 +1680,33 @@ If END is omitted, it defaults to the length of LIST." | |||
| 1665 | ;; Insert text representing the `on' and `off' states. | 1680 | ;; Insert text representing the `on' and `off' states. |
| 1666 | (let* ((tag (or (widget-get widget :tag) | 1681 | (let* ((tag (or (widget-get widget :tag) |
| 1667 | (widget-get widget :value))) | 1682 | (widget-get widget :value))) |
| 1683 | (tag-glyph (widget-get widget :tag-glyph)) | ||
| 1668 | (text (concat widget-push-button-prefix | 1684 | (text (concat widget-push-button-prefix |
| 1669 | tag widget-push-button-suffix)) | 1685 | tag widget-push-button-suffix)) |
| 1670 | (gui (cdr (assoc tag widget-push-button-cache)))) | 1686 | (gui (cdr (assoc tag widget-push-button-cache)))) |
| 1671 | (if (and (fboundp 'make-gui-button) | 1687 | (cond (tag-glyph |
| 1688 | (widget-glyph-insert widget text tag-glyph)) | ||
| 1689 | ((and (fboundp 'make-gui-button) | ||
| 1672 | (fboundp 'make-glyph) | 1690 | (fboundp 'make-glyph) |
| 1673 | widget-push-button-gui | 1691 | widget-push-button-gui |
| 1674 | (fboundp 'device-on-window-system-p) | 1692 | (fboundp 'device-on-window-system-p) |
| 1675 | (device-on-window-system-p) | 1693 | (device-on-window-system-p) |
| 1676 | (string-match "XEmacs" emacs-version)) | 1694 | (string-match "XEmacs" emacs-version)) |
| 1677 | (progn | 1695 | (unless gui |
| 1678 | (unless gui | 1696 | (setq gui (make-gui-button tag 'widget-gui-action widget)) |
| 1679 | (setq gui (make-gui-button tag 'widget-gui-action widget)) | 1697 | (push (cons tag gui) widget-push-button-cache)) |
| 1680 | (push (cons tag gui) widget-push-button-cache)) | 1698 | (widget-glyph-insert-glyph widget |
| 1681 | (widget-glyph-insert-glyph widget | 1699 | (make-glyph |
| 1682 | (make-glyph | 1700 | (list (nth 0 (aref gui 1)) |
| 1683 | (list (nth 0 (aref gui 1)) | 1701 | (vector 'string ':data text))) |
| 1684 | (vector 'string ':data text))) | 1702 | (make-glyph |
| 1685 | (make-glyph | 1703 | (list (nth 1 (aref gui 1)) |
| 1686 | (list (nth 1 (aref gui 1)) | 1704 | (vector 'string ':data text))) |
| 1687 | (vector 'string ':data text))) | 1705 | (make-glyph |
| 1688 | (make-glyph | 1706 | (list (nth 2 (aref gui 1)) |
| 1689 | (list (nth 2 (aref gui 1)) | 1707 | (vector 'string ':data text))))) |
| 1690 | (vector 'string ':data text))))) | 1708 | (t |
| 1691 | (insert text)))) | 1709 | (insert text))))) |
| 1692 | 1710 | ||
| 1693 | (defun widget-gui-action (widget) | 1711 | (defun widget-gui-action (widget) |
| 1694 | "Apply :action for WIDGET." | 1712 | "Apply :action for WIDGET." |