diff options
| author | Per Abrahamsen | 1997-06-21 12:48:00 +0000 |
|---|---|---|
| committer | Per Abrahamsen | 1997-06-21 12:48:00 +0000 |
| commit | 944c91b6b349b73876522664c736fa01dab9d9eb (patch) | |
| tree | f8772904e989b1be0e7f8a2f0b9667505ab06ca7 | |
| parent | f23515e161b366ac32b8445f66c02022aa4c964d (diff) | |
| download | emacs-944c91b6b349b73876522664c736fa01dab9d9eb.tar.gz emacs-944c91b6b349b73876522664c736fa01dab9d9eb.zip | |
Synched with 1.9930.
| -rw-r--r-- | lisp/cus-edit.el | 838 | ||||
| -rw-r--r-- | lisp/wid-edit.el | 66 |
2 files changed, 553 insertions, 351 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 130498408f9..32d099c1c11 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.9924 | 7 | ;; Version: 1.9929 |
| 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. |
| @@ -45,7 +45,8 @@ | |||
| 45 | (require 'cus-start) | 45 | (require 'cus-start) |
| 46 | (error nil)) | 46 | (error nil)) |
| 47 | 47 | ||
| 48 | (define-widget-keywords :custom-category :custom-prefixes :custom-menu | 48 | (define-widget-keywords :custom-last :custom-prefix :custom-category |
| 49 | :custom-prefixes :custom-menu | ||
| 49 | :custom-show | 50 | :custom-show |
| 50 | :custom-magic :custom-state :custom-level :custom-form | 51 | :custom-magic :custom-state :custom-level :custom-form |
| 51 | :custom-set :custom-save :custom-reset-current :custom-reset-saved | 52 | :custom-set :custom-save :custom-reset-current :custom-reset-saved |
| @@ -343,6 +344,18 @@ | |||
| 343 | 344 | ||
| 344 | ;;; Utilities. | 345 | ;;; Utilities. |
| 345 | 346 | ||
| 347 | (defun custom-last (x &optional n) | ||
| 348 | ;; Stolen from `cl.el'. | ||
| 349 | "Returns the last link in the list LIST. | ||
| 350 | With optional argument N, returns Nth-to-last link (default 1)." | ||
| 351 | (if n | ||
| 352 | (let ((m 0) (p x)) | ||
| 353 | (while (consp p) (incf m) (pop p)) | ||
| 354 | (if (<= n 0) p | ||
| 355 | (if (< n m) (nthcdr (- m n) x) x))) | ||
| 356 | (while (consp (cdr x)) (pop x)) | ||
| 357 | x)) | ||
| 358 | |||
| 346 | (defun custom-quote (sexp) | 359 | (defun custom-quote (sexp) |
| 347 | "Quote SEXP iff it is not self quoting." | 360 | "Quote SEXP iff it is not self quoting." |
| 348 | (if (or (memq sexp '(t nil)) | 361 | (if (or (memq sexp '(t nil)) |
| @@ -532,59 +545,55 @@ if that fails, the doc string with `custom-guess-doc-alist'." | |||
| 532 | 545 | ||
| 533 | ;;; Sorting. | 546 | ;;; Sorting. |
| 534 | 547 | ||
| 535 | (defcustom custom-buffer-sort-predicate 'ignore | 548 | (defcustom custom-buffer-sort-alphabetically nil |
| 536 | "Function used for sorting group members in buffers. | 549 | "If non-nil, sort the members of each customization group alphabetically." |
| 537 | The value should be useful as a predicate for `sort'. | 550 | :type 'boolean |
| 538 | The list to be sorted is the value of the groups `custom-group' property." | ||
| 539 | :type '(radio (const :tag "Unsorted" ignore) | ||
| 540 | (const :tag "Alphabetic" custom-sort-items-alphabetically) | ||
| 541 | (function :tag "Other")) | ||
| 542 | :group 'custom-buffer) | 551 | :group 'custom-buffer) |
| 543 | 552 | ||
| 544 | (defcustom custom-buffer-order-predicate 'custom-sort-groups-last | 553 | (defcustom custom-buffer-groups-last nil |
| 545 | "Function used for sorting group members in buffers. | 554 | "If non-nil, put subgroups after all ordinary options within a group." |
| 546 | The value should be useful as a predicate for `sort'. | 555 | :type 'boolean |
| 547 | The list to be sorted is the value of the groups `custom-group' property." | ||
| 548 | :type '(radio (const :tag "Groups first" custom-sort-groups-first) | ||
| 549 | (const :tag "Groups last" custom-sort-groups-last) | ||
| 550 | (function :tag "Other")) | ||
| 551 | :group 'custom-buffer) | 556 | :group 'custom-buffer) |
| 552 | 557 | ||
| 553 | (defcustom custom-menu-sort-predicate 'ignore | 558 | (defcustom custom-menu-sort-alphabetically nil |
| 554 | "Function used for sorting group members in menus. | 559 | "If non-nil, sort the members of each customization group alphabetically." |
| 555 | The value should be useful as a predicate for `sort'. | 560 | :type 'boolean |
| 556 | The list to be sorted is the value of the groups `custom-group' property." | ||
| 557 | :type '(radio (const :tag "Unsorted" ignore) | ||
| 558 | (const :tag "Alphabetic" custom-sort-items-alphabetically) | ||
| 559 | (function :tag "Other")) | ||
| 560 | :group 'custom-menu) | 561 | :group 'custom-menu) |
| 561 | 562 | ||
| 562 | (defcustom custom-menu-order-predicate 'custom-sort-groups-first | 563 | (defcustom custom-menu-groups-first t |
| 563 | "Function used for sorting group members in menus. | 564 | "If non-nil, put subgroups before all ordinary options within a group." |
| 564 | The value should be useful as a predicate for `sort'. | 565 | :type 'boolean |
| 565 | The list to be sorted is the value of the groups `custom-group' property." | ||
| 566 | :type '(radio (const :tag "Groups first" custom-sort-groups-first) | ||
| 567 | (const :tag "Groups last" custom-sort-groups-last) | ||
| 568 | (function :tag "Other")) | ||
| 569 | :group 'custom-menu) | 566 | :group 'custom-menu) |
| 570 | 567 | ||
| 571 | (defun custom-sort-items-alphabetically (a b) | 568 | (defun custom-buffer-sort-predicate (a b) |
| 572 | "Return t iff A is alphabetically before B and the same custom type. | 569 | "Return t iff A should come before B in a customization buffer. |
| 573 | A and B should be members of a `custom-group' property." | 570 | A and B should be members of a `custom-group' property." |
| 574 | (and (eq (nth 1 a) (nth 1 b)) | 571 | (cond ((and (not custom-buffer-groups-last) |
| 575 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))))) | 572 | (not custom-buffer-sort-alphabetically)) |
| 573 | nil) | ||
| 574 | ((or (eq (eq (nth 1 a) 'custom-group) (eq (nth 1 b) 'custom-group)) | ||
| 575 | (not custom-buffer-groups-last)) | ||
| 576 | (if custom-buffer-sort-alphabetically | ||
| 577 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))) | ||
| 578 | nil)) | ||
| 579 | (t | ||
| 580 | (not (eq (nth 1 a) 'custom-group) )))) | ||
| 576 | 581 | ||
| 577 | (defun custom-sort-groups-first (a b) | 582 | (defalias 'custom-browse-sort-predicate 'ignore) |
| 578 | "Return t iff A a custom group and B is a not. | ||
| 579 | A and B should be members of a `custom-group' property." | ||
| 580 | (and (eq (nth 1 a) 'custom-group) | ||
| 581 | (not (eq (nth 1 b) 'custom-group)))) | ||
| 582 | 583 | ||
| 583 | (defun custom-sort-groups-last (a b) | 584 | (defun custom-menu-sort-predicate (a b) |
| 584 | "Return t iff B a custom group and A is a not. | 585 | "Return t iff A should come before B in a customization menu. |
| 585 | A and B should be members of a `custom-group' property." | 586 | A and B should be members of a `custom-group' property." |
| 586 | (and (eq (nth 1 b) 'custom-group) | 587 | (cond ((and (not custom-menu-groups-first) |
| 587 | (not (eq (nth 1 a) 'custom-group)))) | 588 | (not custom-menu-sort-alphabetically)) |
| 589 | nil) | ||
| 590 | ((or (eq (eq (nth 1 a) 'custom-group) (eq (nth 1 b) 'custom-group)) | ||
| 591 | (not custom-menu-groups-first)) | ||
| 592 | (if custom-menu-sort-alphabetically | ||
| 593 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))) | ||
| 594 | nil)) | ||
| 595 | (t | ||
| 596 | (eq (nth 1 a) 'custom-group) ))) | ||
| 588 | 597 | ||
| 589 | ;;; Custom Mode Commands. | 598 | ;;; Custom Mode Commands. |
| 590 | 599 | ||
| @@ -894,11 +903,9 @@ user-settable, as well as faces and groups." | |||
| 894 | (push (list symbol 'custom-variable) found))))) | 903 | (push (list symbol 'custom-variable) found))))) |
| 895 | (if (not found) | 904 | (if (not found) |
| 896 | (error "No matches") | 905 | (error "No matches") |
| 897 | (custom-buffer-create (sort (sort found | 906 | (let ((custom-buffer-sort-alphabetically t)) |
| 898 | ;; Apropos should always be sorted. | 907 | (custom-buffer-create (sort found 'custom-buffer-sort-predicate) |
| 899 | 'custom-sort-items-alphabetically) | 908 | "*Customize Apropos*"))))) |
| 900 | custom-buffer-order-predicate) | ||
| 901 | "*Customize Apropos*")))) | ||
| 902 | 909 | ||
| 903 | ;;;###autoload | 910 | ;;;###autoload |
| 904 | (defun customize-apropos-options (regexp &optional arg) | 911 | (defun customize-apropos-options (regexp &optional arg) |
| @@ -921,6 +928,21 @@ With prefix arg, include options which are not user-settable." | |||
| 921 | 928 | ||
| 922 | ;;; Buffer. | 929 | ;;; Buffer. |
| 923 | 930 | ||
| 931 | (defcustom custom-buffer-style 'links | ||
| 932 | "Control the presentation style for customization buffers. | ||
| 933 | The value should be a symbol, one of: | ||
| 934 | |||
| 935 | brackets: groups nest within each other with big horizontal brackets. | ||
| 936 | links: groups have links to subgroups." | ||
| 937 | :type '(radio (const brackets) | ||
| 938 | (const links)) | ||
| 939 | :group 'custom-buffer) | ||
| 940 | |||
| 941 | (defcustom custom-buffer-indent 3 | ||
| 942 | "Number of spaces to indent nested groups." | ||
| 943 | :type 'integer | ||
| 944 | :group 'custom-buffer) | ||
| 945 | |||
| 924 | ;;;###autoload | 946 | ;;;###autoload |
| 925 | (defun custom-buffer-create (options &optional name) | 947 | (defun custom-buffer-create (options &optional name) |
| 926 | "Create a buffer containing OPTIONS. | 948 | "Create a buffer containing OPTIONS. |
| @@ -1036,41 +1058,73 @@ Reset all visible items in this buffer to their standard settings." | |||
| 1036 | options)))) | 1058 | options)))) |
| 1037 | (unless (eq (preceding-char) ?\n) | 1059 | (unless (eq (preceding-char) ?\n) |
| 1038 | (widget-insert "\n")) | 1060 | (widget-insert "\n")) |
| 1039 | (when (= (length options) 1) | 1061 | (unless (eq custom-buffer-style 'tree) |
| 1040 | (message "Creating parent links...") | 1062 | (mapcar 'custom-magic-reset custom-options)) |
| 1041 | (let* ((entry (nth 0 options)) | ||
| 1042 | (name (nth 0 entry)) | ||
| 1043 | (type (nth 1 entry)) | ||
| 1044 | parents) | ||
| 1045 | (mapatoms (lambda (symbol) | ||
| 1046 | (let ((group (get symbol 'custom-group))) | ||
| 1047 | (when (assq name group) | ||
| 1048 | (when (eq type (nth 1 (assq name group))) | ||
| 1049 | (push symbol parents)))))) | ||
| 1050 | (when parents | ||
| 1051 | (goto-char (point-min)) | ||
| 1052 | (search-forward "[Set]") | ||
| 1053 | (forward-line 1) | ||
| 1054 | (widget-insert "\nParent groups:") | ||
| 1055 | (mapcar (lambda (group) | ||
| 1056 | (widget-insert " ") | ||
| 1057 | (widget-create 'link | ||
| 1058 | :tag (custom-unlispify-tag-name group) | ||
| 1059 | :help-echo (format "\ | ||
| 1060 | Create customize buffer for `%S' group." group) | ||
| 1061 | :action (lambda (widget &rest ignore) | ||
| 1062 | (customize-group | ||
| 1063 | (widget-value widget))) | ||
| 1064 | group)) | ||
| 1065 | parents) | ||
| 1066 | (widget-insert "\n")))) | ||
| 1067 | (message "Creating customization magic...") | ||
| 1068 | (mapcar 'custom-magic-reset custom-options) | ||
| 1069 | (message "Creating customization setup...") | 1063 | (message "Creating customization setup...") |
| 1070 | (widget-setup) | 1064 | (widget-setup) |
| 1071 | (goto-char (point-min)) | 1065 | (goto-char (point-min)) |
| 1072 | (message "Creating customization buffer...done")) | 1066 | (message "Creating customization buffer...done")) |
| 1073 | 1067 | ||
| 1068 | ;;; The Tree Browser. | ||
| 1069 | |||
| 1070 | ;;;###autoload | ||
| 1071 | (defun customize-browse () | ||
| 1072 | "Create a tree browser for the customize hierarchy." | ||
| 1073 | (interactive) | ||
| 1074 | (let ((name "*Customize Browser*")) | ||
| 1075 | (kill-buffer (get-buffer-create name)) | ||
| 1076 | (switch-to-buffer (get-buffer-create name))) | ||
| 1077 | (custom-mode) | ||
| 1078 | (widget-insert "\ | ||
| 1079 | Invoke [+] below to expand items, and [-] to collapse items. | ||
| 1080 | Invoke the [group], [face], and [option] buttons below to edit that | ||
| 1081 | item in another window.\n\n") | ||
| 1082 | (let ((custom-buffer-style 'tree)) | ||
| 1083 | (widget-create 'custom-group | ||
| 1084 | :custom-last t | ||
| 1085 | :custom-state 'unknown | ||
| 1086 | :tag (custom-unlispify-tag-name 'emacs) | ||
| 1087 | :value 'emacs)) | ||
| 1088 | (goto-char (point-min))) | ||
| 1089 | |||
| 1090 | (define-widget 'custom-tree-visibility 'item | ||
| 1091 | "Control visibility of of items in the customize tree browser." | ||
| 1092 | :button-prefix "[" | ||
| 1093 | :button-suffix "]" | ||
| 1094 | :format "%[%t%]" | ||
| 1095 | :action 'custom-tree-visibility-action) | ||
| 1096 | |||
| 1097 | (defun custom-tree-visibility-action (widget &rest ignore) | ||
| 1098 | (let ((custom-buffer-style 'tree)) | ||
| 1099 | (custom-toggle-parent widget))) | ||
| 1100 | |||
| 1101 | (define-widget 'custom-tree-group-tag 'push-button | ||
| 1102 | "Show parent in other window when activated." | ||
| 1103 | :tag "group" | ||
| 1104 | :action 'custom-tree-group-tag-action) | ||
| 1105 | |||
| 1106 | (defun custom-tree-group-tag-action (widget &rest ignore) | ||
| 1107 | (let ((parent (widget-get widget :parent))) | ||
| 1108 | (customize-group-other-window (widget-value parent)))) | ||
| 1109 | |||
| 1110 | (define-widget 'custom-tree-variable-tag 'push-button | ||
| 1111 | "Show parent in other window when activated." | ||
| 1112 | :tag "option" | ||
| 1113 | :action 'custom-tree-variable-tag-action) | ||
| 1114 | |||
| 1115 | (defun custom-tree-variable-tag-action (widget &rest ignore) | ||
| 1116 | (let ((parent (widget-get widget :parent))) | ||
| 1117 | (customize-variable-other-window (widget-value parent)))) | ||
| 1118 | |||
| 1119 | (define-widget 'custom-tree-face-tag 'push-button | ||
| 1120 | "Show parent in other window when activated." | ||
| 1121 | :tag "face" | ||
| 1122 | :action 'custom-tree-face-tag-action) | ||
| 1123 | |||
| 1124 | (defun custom-tree-face-tag-action (widget &rest ignore) | ||
| 1125 | (let ((parent (widget-get widget :parent))) | ||
| 1126 | (customize-face-other-window (widget-value parent)))) | ||
| 1127 | |||
| 1074 | ;;; Modification of Basic Widgets. | 1128 | ;;; Modification of Basic Widgets. |
| 1075 | ;; | 1129 | ;; |
| 1076 | ;; We add extra properties to the basic widgets needed here. This is | 1130 | ;; We add extra properties to the basic widgets needed here. This is |
| @@ -1269,7 +1323,8 @@ and `face'." | |||
| 1269 | (memq category custom-magic-show-hidden))) | 1323 | (memq category custom-magic-show-hidden))) |
| 1270 | (insert " ") | 1324 | (insert " ") |
| 1271 | (when (eq category 'group) | 1325 | (when (eq category 'group) |
| 1272 | (insert-char ?\ (1+ (* 2 (widget-get parent :custom-level))))) | 1326 | (insert-char ?\ (* custom-buffer-indent |
| 1327 | (widget-get parent :custom-level)))) | ||
| 1273 | (push (widget-create-child-and-convert | 1328 | (push (widget-create-child-and-convert |
| 1274 | widget 'choice-item | 1329 | widget 'choice-item |
| 1275 | :help-echo "Change the state of this item." | 1330 | :help-echo "Change the state of this item." |
| @@ -1286,6 +1341,9 @@ and `face'." | |||
| 1286 | (when lisp | 1341 | (when lisp |
| 1287 | (insert " (lisp)")) | 1342 | (insert " (lisp)")) |
| 1288 | (insert "\n")) | 1343 | (insert "\n")) |
| 1344 | (when (eq category 'group) | ||
| 1345 | (insert-char ?\ (* custom-buffer-indent | ||
| 1346 | (widget-get parent :custom-level)))) | ||
| 1289 | (when custom-magic-show-button | 1347 | (when custom-magic-show-button |
| 1290 | (when custom-magic-show | 1348 | (when custom-magic-show |
| 1291 | (let ((indent (widget-get parent :indent))) | 1349 | (let ((indent (widget-get parent :indent))) |
| @@ -1315,9 +1373,10 @@ and `face'." | |||
| 1315 | 1373 | ||
| 1316 | (define-widget 'custom 'default | 1374 | (define-widget 'custom 'default |
| 1317 | "Customize a user option." | 1375 | "Customize a user option." |
| 1376 | :format "%v" | ||
| 1318 | :convert-widget 'custom-convert-widget | 1377 | :convert-widget 'custom-convert-widget |
| 1319 | :format-handler 'custom-format-handler | ||
| 1320 | :notify 'custom-notify | 1378 | :notify 'custom-notify |
| 1379 | :custom-prefix "" | ||
| 1321 | :custom-level 1 | 1380 | :custom-level 1 |
| 1322 | :custom-state 'hidden | 1381 | :custom-state 'hidden |
| 1323 | :documentation-property 'widget-subclass-responsibility | 1382 | :documentation-property 'widget-subclass-responsibility |
| @@ -1327,13 +1386,6 @@ and `face'." | |||
| 1327 | :validate 'widget-children-validate | 1386 | :validate 'widget-children-validate |
| 1328 | :match (lambda (widget value) (symbolp value))) | 1387 | :match (lambda (widget value) (symbolp value))) |
| 1329 | 1388 | ||
| 1330 | (defcustom custom-nest-groups nil | ||
| 1331 | "*Non-nil means display nested groups in one customization buffer. | ||
| 1332 | A valoe of nil means show a subgroup in its own buffer | ||
| 1333 | rather than including it within its parent's customization buffer." | ||
| 1334 | :type 'boolean | ||
| 1335 | :group 'custom-buffer) | ||
| 1336 | |||
| 1337 | (defun custom-convert-widget (widget) | 1389 | (defun custom-convert-widget (widget) |
| 1338 | ;; Initialize :value and :tag from :args in WIDGET. | 1390 | ;; Initialize :value and :tag from :args in WIDGET. |
| 1339 | (let ((args (widget-get widget :args))) | 1391 | (let ((args (widget-get widget :args))) |
| @@ -1344,93 +1396,6 @@ rather than including it within its parent's customization buffer." | |||
| 1344 | (widget-put widget :args nil))) | 1396 | (widget-put widget :args nil))) |
| 1345 | widget) | 1397 | widget) |
| 1346 | 1398 | ||
| 1347 | (defun custom-format-handler (widget escape) | ||
| 1348 | ;; We recognize extra escape sequences. | ||
| 1349 | (let* ((buttons (widget-get widget :buttons)) | ||
| 1350 | (state (widget-get widget :custom-state)) | ||
| 1351 | (level (widget-get widget :custom-level)) | ||
| 1352 | (category (widget-get widget :custom-category))) | ||
| 1353 | (cond ((eq escape ?l) | ||
| 1354 | (if custom-nest-groups | ||
| 1355 | (when level | ||
| 1356 | (insert-char ?\ (* 3 (1- level))) | ||
| 1357 | (if (eq state 'hidden) | ||
| 1358 | (insert "-- ") | ||
| 1359 | (insert "/- "))) | ||
| 1360 | (unless (and level (> level 1)) | ||
| 1361 | (insert "/- ")))) | ||
| 1362 | ((eq escape ?e) | ||
| 1363 | (when (and level (not (eq state 'hidden))) | ||
| 1364 | (insert "\n") | ||
| 1365 | (if custom-nest-groups | ||
| 1366 | (insert-char ?\ (* 3 (1- level)))) | ||
| 1367 | (insert "\\-") | ||
| 1368 | (insert " " (widget-get widget :tag) " group end ") | ||
| 1369 | (insert-char ?- (- 75 (current-column) level)) | ||
| 1370 | (insert "/\n"))) | ||
| 1371 | ((eq escape ?-) | ||
| 1372 | (when (and level (not (eq state 'hidden))) | ||
| 1373 | ;; Add 1 to compensate for the extra < character | ||
| 1374 | ;; at the beginning of the line. | ||
| 1375 | (insert-char ?- (- (+ 75 1) (current-column) level)) | ||
| 1376 | (insert "\\"))) | ||
| 1377 | ((eq escape ?i) | ||
| 1378 | (if custom-nest-groups | ||
| 1379 | (insert-char ?\ (* 3 level)) | ||
| 1380 | (unless (and level (> level 1)) | ||
| 1381 | (insert " ")))) | ||
| 1382 | ((eq escape ?L) | ||
| 1383 | (if custom-nest-groups | ||
| 1384 | (push (widget-create-child-and-convert | ||
| 1385 | widget 'group-visibility | ||
| 1386 | :help-echo "Show or hide this group." | ||
| 1387 | :action 'custom-toggle-parent | ||
| 1388 | (not (eq state 'hidden))) | ||
| 1389 | buttons) | ||
| 1390 | (push (widget-create-child-and-convert | ||
| 1391 | widget 'group-link | ||
| 1392 | :help-echo "Select the contents of this group." | ||
| 1393 | :value (widget-get widget :value) | ||
| 1394 | :tag "Switch to Group" | ||
| 1395 | (not (eq state 'hidden))) | ||
| 1396 | buttons))) | ||
| 1397 | ((eq escape ?m) | ||
| 1398 | (and (eq (preceding-char) ?\n) | ||
| 1399 | (widget-get widget :indent) | ||
| 1400 | (insert-char ? (widget-get widget :indent))) | ||
| 1401 | (let ((magic (widget-create-child-and-convert | ||
| 1402 | widget 'custom-magic nil))) | ||
| 1403 | (widget-put widget :custom-magic magic) | ||
| 1404 | (push magic buttons) | ||
| 1405 | (widget-put widget :buttons buttons))) | ||
| 1406 | ((eq escape ?a) | ||
| 1407 | (unless (eq state 'hidden) | ||
| 1408 | (let* ((symbol (widget-get widget :value)) | ||
| 1409 | (links (get symbol 'custom-links)) | ||
| 1410 | (many (> (length links) 2))) | ||
| 1411 | (when links | ||
| 1412 | (and (eq (preceding-char) ?\n) | ||
| 1413 | (widget-get widget :indent) | ||
| 1414 | (insert-char ? (widget-get widget :indent))) | ||
| 1415 | (when (eq category 'group) | ||
| 1416 | (insert-char ?\ (1+ (* 2 level)))) | ||
| 1417 | (insert "See also ") | ||
| 1418 | (while links | ||
| 1419 | (push (widget-create-child-and-convert widget (car links)) | ||
| 1420 | buttons) | ||
| 1421 | (setq links (cdr links)) | ||
| 1422 | (cond ((null links) | ||
| 1423 | (insert ".\n")) | ||
| 1424 | ((null (cdr links)) | ||
| 1425 | (if many | ||
| 1426 | (insert ", and ") | ||
| 1427 | (insert " and "))) | ||
| 1428 | (t | ||
| 1429 | (insert ", ")))) | ||
| 1430 | (widget-put widget :buttons buttons))))) | ||
| 1431 | (t | ||
| 1432 | (widget-default-format-handler widget escape))))) | ||
| 1433 | |||
| 1434 | (defun custom-notify (widget &rest args) | 1399 | (defun custom-notify (widget &rest args) |
| 1435 | "Keep track of changes." | 1400 | "Keep track of changes." |
| 1436 | (let ((state (widget-get widget :custom-state))) | 1401 | (let ((state (widget-get widget :custom-state))) |
| @@ -1463,11 +1428,12 @@ rather than including it within its parent's customization buffer." | |||
| 1463 | "Redraw WIDGET state with current settings." | 1428 | "Redraw WIDGET state with current settings." |
| 1464 | (while widget | 1429 | (while widget |
| 1465 | (let ((magic (widget-get widget :custom-magic))) | 1430 | (let ((magic (widget-get widget :custom-magic))) |
| 1466 | (unless magic | 1431 | (cond (magic |
| 1467 | (debug)) | 1432 | (widget-value-set magic (widget-value magic)) |
| 1468 | (widget-value-set magic (widget-value magic)) | 1433 | (when (setq widget (widget-get widget :group)) |
| 1469 | (when (setq widget (widget-get widget :group)) | 1434 | (custom-group-state-update widget))) |
| 1470 | (custom-group-state-update widget)))) | 1435 | (t |
| 1436 | (setq widget nil))))) | ||
| 1471 | (widget-setup)) | 1437 | (widget-setup)) |
| 1472 | 1438 | ||
| 1473 | (defun custom-show (widget value) | 1439 | (defun custom-show (widget value) |
| @@ -1529,6 +1495,57 @@ rather than including it within its parent's customization buffer." | |||
| 1529 | "Toggle visibility of parent to WIDGET." | 1495 | "Toggle visibility of parent to WIDGET." |
| 1530 | (custom-toggle-hide (widget-get widget :parent))) | 1496 | (custom-toggle-hide (widget-get widget :parent))) |
| 1531 | 1497 | ||
| 1498 | (defun custom-add-see-also (widget &optional prefix) | ||
| 1499 | "Add `See also ...' to WIDGET if there are any links. | ||
| 1500 | Insert PREFIX first if non-nil." | ||
| 1501 | (let* ((symbol (widget-get widget :value)) | ||
| 1502 | (links (get symbol 'custom-links)) | ||
| 1503 | (many (> (length links) 2)) | ||
| 1504 | (buttons (widget-get widget :buttons)) | ||
| 1505 | (indent (widget-get widget :indent))) | ||
| 1506 | (when links | ||
| 1507 | (when indent | ||
| 1508 | (insert-char ?\ indent)) | ||
| 1509 | (when prefix | ||
| 1510 | (insert prefix)) | ||
| 1511 | (insert "See also ") | ||
| 1512 | (while links | ||
| 1513 | (push (widget-create-child-and-convert widget (car links)) | ||
| 1514 | buttons) | ||
| 1515 | (setq links (cdr links)) | ||
| 1516 | (cond ((null links) | ||
| 1517 | (insert ".\n")) | ||
| 1518 | ((null (cdr links)) | ||
| 1519 | (if many | ||
| 1520 | (insert ", and ") | ||
| 1521 | (insert " and "))) | ||
| 1522 | (t | ||
| 1523 | (insert ", ")))) | ||
| 1524 | (widget-put widget :buttons buttons)))) | ||
| 1525 | |||
| 1526 | (defun custom-add-parent-links (widget) | ||
| 1527 | "Add `Parent groups: ...' to WIDGET." | ||
| 1528 | (let ((name (widget-value widget)) | ||
| 1529 | (type (widget-type widget)) | ||
| 1530 | (buttons (widget-get widget :buttons)) | ||
| 1531 | found) | ||
| 1532 | (insert "Parent groups:") | ||
| 1533 | (mapatoms (lambda (symbol) | ||
| 1534 | (let ((group (get symbol 'custom-group))) | ||
| 1535 | (when (assq name group) | ||
| 1536 | (when (eq type (nth 1 (assq name group))) | ||
| 1537 | (insert " ") | ||
| 1538 | (push (widget-create-child-and-convert | ||
| 1539 | widget 'custom-group-link | ||
| 1540 | :tag (custom-unlispify-tag-name symbol) | ||
| 1541 | symbol) | ||
| 1542 | buttons) | ||
| 1543 | (setq found t)))))) | ||
| 1544 | (widget-put widget :buttons buttons) | ||
| 1545 | (unless found | ||
| 1546 | (insert " (none)")) | ||
| 1547 | (insert "\n"))) | ||
| 1548 | |||
| 1532 | ;;; The `custom-variable' Widget. | 1549 | ;;; The `custom-variable' Widget. |
| 1533 | 1550 | ||
| 1534 | (defface custom-variable-sample-face '((t (:underline t))) | 1551 | (defface custom-variable-sample-face '((t (:underline t))) |
| @@ -1541,7 +1558,7 @@ rather than including it within its parent's customization buffer." | |||
| 1541 | 1558 | ||
| 1542 | (define-widget 'custom-variable 'custom | 1559 | (define-widget 'custom-variable 'custom |
| 1543 | "Customize variable." | 1560 | "Customize variable." |
| 1544 | :format "%v%m%h%a" | 1561 | :format "%v" |
| 1545 | :help-echo "Set or reset this variable." | 1562 | :help-echo "Set or reset this variable." |
| 1546 | :documentation-property 'variable-documentation | 1563 | :documentation-property 'variable-documentation |
| 1547 | :custom-category 'option | 1564 | :custom-category 'option |
| @@ -1584,6 +1601,8 @@ Otherwise, look up symbol in `custom-guess-type-alist'." | |||
| 1584 | (type (custom-variable-type symbol)) | 1601 | (type (custom-variable-type symbol)) |
| 1585 | (conv (widget-convert type)) | 1602 | (conv (widget-convert type)) |
| 1586 | (get (or (get symbol 'custom-get) 'default-value)) | 1603 | (get (or (get symbol 'custom-get) 'default-value)) |
| 1604 | (prefix (widget-get widget :custom-prefix)) | ||
| 1605 | (last (widget-get widget :custom-last)) | ||
| 1587 | (value (if (default-boundp symbol) | 1606 | (value (if (default-boundp symbol) |
| 1588 | (funcall get symbol) | 1607 | (funcall get symbol) |
| 1589 | (widget-get conv :value)))) | 1608 | (widget-get conv :value)))) |
| @@ -1599,7 +1618,14 @@ Otherwise, look up symbol in `custom-guess-type-alist'." | |||
| 1599 | ;; (widget-apply (widget-convert type) :match value) | 1618 | ;; (widget-apply (widget-convert type) :match value) |
| 1600 | (setq form 'lisp))) | 1619 | (setq form 'lisp))) |
| 1601 | ;; Now we can create the child widget. | 1620 | ;; Now we can create the child widget. |
| 1602 | (cond ((eq state 'hidden) | 1621 | (cond ((eq custom-buffer-style 'tree) |
| 1622 | (insert prefix (if last " +--- " " |--- ")) | ||
| 1623 | (push (widget-create-child-and-convert | ||
| 1624 | widget 'custom-tree-variable-tag) | ||
| 1625 | buttons) | ||
| 1626 | (insert " " tag "\n") | ||
| 1627 | (widget-put widget :buttons buttons)) | ||
| 1628 | ((eq state 'hidden) | ||
| 1603 | ;; Indicate hidden value. | 1629 | ;; Indicate hidden value. |
| 1604 | (push (widget-create-child-and-convert | 1630 | (push (widget-create-child-and-convert |
| 1605 | widget 'item | 1631 | widget 'item |
| @@ -1626,11 +1652,11 @@ Otherwise, look up symbol in `custom-guess-type-alist'." | |||
| 1626 | (custom-quote (widget-get conv :value)))))) | 1652 | (custom-quote (widget-get conv :value)))))) |
| 1627 | (insert (symbol-name symbol) ": ") | 1653 | (insert (symbol-name symbol) ": ") |
| 1628 | (push (widget-create-child-and-convert | 1654 | (push (widget-create-child-and-convert |
| 1629 | widget 'visibility | 1655 | widget 'visibility |
| 1630 | :help-echo "Hide the value of this option." | 1656 | :help-echo "Hide the value of this option." |
| 1631 | :action 'custom-toggle-parent | 1657 | :action 'custom-toggle-parent |
| 1632 | t) | 1658 | t) |
| 1633 | buttons) | 1659 | buttons) |
| 1634 | (insert " ") | 1660 | (insert " ") |
| 1635 | (push (widget-create-child-and-convert | 1661 | (push (widget-create-child-and-convert |
| 1636 | widget 'sexp | 1662 | widget 'sexp |
| @@ -1670,15 +1696,29 @@ Otherwise, look up symbol in `custom-guess-type-alist'." | |||
| 1670 | :format value-format | 1696 | :format value-format |
| 1671 | :value value) | 1697 | :value value) |
| 1672 | children)))) | 1698 | children)))) |
| 1673 | ;; Now update the state. | 1699 | (unless (eq custom-buffer-style 'tree) |
| 1674 | (unless (eq (preceding-char) ?\n) | 1700 | ;; Now update the state. |
| 1675 | (widget-insert "\n")) | 1701 | (unless (eq (preceding-char) ?\n) |
| 1676 | (if (eq state 'hidden) | 1702 | (widget-insert "\n")) |
| 1677 | (widget-put widget :custom-state state) | 1703 | (if (eq state 'hidden) |
| 1678 | (custom-variable-state-set widget)) | 1704 | (widget-put widget :custom-state state) |
| 1679 | (widget-put widget :custom-form form) | 1705 | (custom-variable-state-set widget)) |
| 1680 | (widget-put widget :buttons buttons) | 1706 | ;; Create the magic button. |
| 1681 | (widget-put widget :children children))) | 1707 | (let ((magic (widget-create-child-and-convert |
| 1708 | widget 'custom-magic nil))) | ||
| 1709 | (widget-put widget :custom-magic magic) | ||
| 1710 | (push magic buttons)) | ||
| 1711 | ;; Update properties. | ||
| 1712 | (widget-put widget :custom-form form) | ||
| 1713 | (widget-put widget :buttons buttons) | ||
| 1714 | (widget-put widget :children children) | ||
| 1715 | ;; Insert documentation. | ||
| 1716 | (widget-default-format-handler widget ?h) | ||
| 1717 | ;; See also. | ||
| 1718 | (unless (eq state 'hidden) | ||
| 1719 | (when (eq (widget-get widget :custom-level) 1) | ||
| 1720 | (custom-add-parent-links widget)) | ||
| 1721 | (custom-add-see-also widget))))) | ||
| 1682 | 1722 | ||
| 1683 | (defun custom-tag-action (widget &rest args) | 1723 | (defun custom-tag-action (widget &rest args) |
| 1684 | "Pass :action to first child of WIDGET's parent." | 1724 | "Pass :action to first child of WIDGET's parent." |
| @@ -1954,8 +1994,6 @@ Match frames with dark backgrounds.") | |||
| 1954 | 1994 | ||
| 1955 | (define-widget 'custom-face 'custom | 1995 | (define-widget 'custom-face 'custom |
| 1956 | "Customize face." | 1996 | "Customize face." |
| 1957 | :format "%{%t%}: %s %L\n%m%h%a%v" | ||
| 1958 | :format-handler 'custom-face-format-handler | ||
| 1959 | :sample-face 'custom-face-tag-face | 1997 | :sample-face 'custom-face-tag-face |
| 1960 | :help-echo "Set or reset this face." | 1998 | :help-echo "Set or reset this face." |
| 1961 | :documentation-property '(lambda (face) | 1999 | :documentation-property '(lambda (face) |
| @@ -1971,26 +2009,6 @@ Match frames with dark backgrounds.") | |||
| 1971 | :custom-reset-standard 'custom-face-reset-standard | 2009 | :custom-reset-standard 'custom-face-reset-standard |
| 1972 | :custom-menu 'custom-face-menu-create) | 2010 | :custom-menu 'custom-face-menu-create) |
| 1973 | 2011 | ||
| 1974 | (defun custom-face-format-handler (widget escape) | ||
| 1975 | ;; We recognize extra escape sequences. | ||
| 1976 | (let (child | ||
| 1977 | (symbol (widget-get widget :value))) | ||
| 1978 | (cond ((eq escape ?s) | ||
| 1979 | (and (string-match "XEmacs" emacs-version) | ||
| 1980 | ;; XEmacs cannot display initialized faces. | ||
| 1981 | (not (custom-facep symbol)) | ||
| 1982 | (copy-face 'custom-face-empty symbol)) | ||
| 1983 | (setq child (widget-create-child-and-convert | ||
| 1984 | widget 'item | ||
| 1985 | :format "(%{%t%})" | ||
| 1986 | :sample-face symbol | ||
| 1987 | :tag "sample"))) | ||
| 1988 | (t | ||
| 1989 | (custom-format-handler widget escape))) | ||
| 1990 | (when child | ||
| 1991 | (widget-put widget | ||
| 1992 | :buttons (cons child (widget-get widget :buttons)))))) | ||
| 1993 | |||
| 1994 | (define-widget 'custom-face-all 'editable-list | 2012 | (define-widget 'custom-face-all 'editable-list |
| 1995 | "An editable list of display specifications and attributes." | 2013 | "An editable list of display specifications and attributes." |
| 1996 | :entry-format "%i %d %v" | 2014 | :entry-format "%i %d %v" |
| @@ -2024,36 +2042,95 @@ Match frames with dark backgrounds.") | |||
| 2024 | "Converted version of the `custom-face-selected' widget.") | 2042 | "Converted version of the `custom-face-selected' widget.") |
| 2025 | 2043 | ||
| 2026 | (defun custom-face-value-create (widget) | 2044 | (defun custom-face-value-create (widget) |
| 2027 | ;; Create a list of the display specifications. | 2045 | "Create a list of the display specifications for WIDGET." |
| 2028 | (unless (eq (preceding-char) ?\n) | 2046 | (let ((buttons (widget-get widget :buttons)) |
| 2029 | (insert "\n")) | 2047 | (symbol (widget-get widget :value)) |
| 2030 | (when (not (eq (widget-get widget :custom-state) 'hidden)) | 2048 | (tag (widget-get widget :tag)) |
| 2031 | (message "Creating face editor...") | 2049 | (state (widget-get widget :custom-state)) |
| 2032 | (custom-load-widget widget) | 2050 | (begin (point)) |
| 2033 | (let* ((symbol (widget-value widget)) | 2051 | (is-last (widget-get widget :custom-last)) |
| 2034 | (spec (or (get symbol 'saved-face) | 2052 | (prefix (widget-get widget :custom-prefix))) |
| 2035 | (get symbol 'face-defface-spec) | 2053 | (unless tag |
| 2036 | ;; Attempt to construct it. | 2054 | (setq tag (prin1-to-string symbol))) |
| 2037 | (list (list t (custom-face-attributes-get | 2055 | (cond ((eq custom-buffer-style 'tree) |
| 2038 | symbol (selected-frame)))))) | 2056 | (insert prefix (if is-last " +--- " " |--- ")) |
| 2039 | (form (widget-get widget :custom-form)) | 2057 | (push (widget-create-child-and-convert |
| 2040 | (indent (widget-get widget :indent)) | 2058 | widget 'custom-tree-face-tag) |
| 2041 | (edit (widget-create-child-and-convert | 2059 | buttons) |
| 2042 | widget | 2060 | (insert " " tag "\n") |
| 2043 | (cond ((and (eq form 'selected) | 2061 | (widget-put widget :buttons buttons)) |
| 2044 | (widget-apply custom-face-selected :match spec)) | 2062 | (t |
| 2045 | (when indent (insert-char ?\ indent)) | 2063 | ;; Create tag. |
| 2046 | 'custom-face-selected) | 2064 | (insert tag) |
| 2047 | ((and (not (eq form 'lisp)) | 2065 | (if (eq custom-buffer-style 'face) |
| 2048 | (widget-apply custom-face-all :match spec)) | 2066 | (insert " ") |
| 2049 | 'custom-face-all) | 2067 | (widget-specify-sample widget begin (point)) |
| 2050 | (t | 2068 | (insert ": ")) |
| 2051 | (when indent (insert-char ?\ indent)) | 2069 | ;; Sample. |
| 2052 | 'sexp)) | 2070 | (and (string-match "XEmacs" emacs-version) |
| 2053 | :value spec))) | 2071 | ;; XEmacs cannot display uninitialized faces. |
| 2054 | (custom-face-state-set widget) | 2072 | (not (custom-facep symbol)) |
| 2055 | (widget-put widget :children (list edit))) | 2073 | (copy-face 'custom-face-empty symbol)) |
| 2056 | (message "Creating face editor...done"))) | 2074 | (push (widget-create-child-and-convert widget 'item |
| 2075 | :format "(%{%t%})" | ||
| 2076 | :sample-face symbol | ||
| 2077 | :tag "sample") | ||
| 2078 | buttons) | ||
| 2079 | ;; Visibility. | ||
| 2080 | (insert " ") | ||
| 2081 | (push (widget-create-child-and-convert | ||
| 2082 | widget 'visibility | ||
| 2083 | :help-echo "Hide or show this face." | ||
| 2084 | :action 'custom-toggle-parent | ||
| 2085 | (not (eq state 'hidden))) | ||
| 2086 | buttons) | ||
| 2087 | ;; Magic. | ||
| 2088 | (insert "\n") | ||
| 2089 | (let ((magic (widget-create-child-and-convert | ||
| 2090 | widget 'custom-magic nil))) | ||
| 2091 | (widget-put widget :custom-magic magic) | ||
| 2092 | (push magic buttons)) | ||
| 2093 | ;; Update buttons. | ||
| 2094 | (widget-put widget :buttons buttons) | ||
| 2095 | ;; Insert documentation. | ||
| 2096 | (widget-default-format-handler widget ?h) | ||
| 2097 | ;; See also. | ||
| 2098 | (unless (eq state 'hidden) | ||
| 2099 | (when (eq (widget-get widget :custom-level) 1) | ||
| 2100 | (custom-add-parent-links widget)) | ||
| 2101 | (custom-add-see-also widget)) | ||
| 2102 | ;; Editor. | ||
| 2103 | (unless (eq (preceding-char) ?\n) | ||
| 2104 | (insert "\n")) | ||
| 2105 | (unless (eq state 'hidden) | ||
| 2106 | (message "Creating face editor...") | ||
| 2107 | (custom-load-widget widget) | ||
| 2108 | (let* ((symbol (widget-value widget)) | ||
| 2109 | (spec (or (get symbol 'saved-face) | ||
| 2110 | (get symbol 'face-defface-spec) | ||
| 2111 | ;; Attempt to construct it. | ||
| 2112 | (list (list t (custom-face-attributes-get | ||
| 2113 | symbol (selected-frame)))))) | ||
| 2114 | (form (widget-get widget :custom-form)) | ||
| 2115 | (indent (widget-get widget :indent)) | ||
| 2116 | (edit (widget-create-child-and-convert | ||
| 2117 | widget | ||
| 2118 | (cond ((and (eq form 'selected) | ||
| 2119 | (widget-apply custom-face-selected | ||
| 2120 | :match spec)) | ||
| 2121 | (when indent (insert-char ?\ indent)) | ||
| 2122 | 'custom-face-selected) | ||
| 2123 | ((and (not (eq form 'lisp)) | ||
| 2124 | (widget-apply custom-face-all | ||
| 2125 | :match spec)) | ||
| 2126 | 'custom-face-all) | ||
| 2127 | (t | ||
| 2128 | (when indent (insert-char ?\ indent)) | ||
| 2129 | 'sexp)) | ||
| 2130 | :value spec))) | ||
| 2131 | (custom-face-state-set widget) | ||
| 2132 | (widget-put widget :children (list edit))) | ||
| 2133 | (message "Creating face editor...done")))))) | ||
| 2057 | 2134 | ||
| 2058 | (defvar custom-face-menu | 2135 | (defvar custom-face-menu |
| 2059 | '(("Set" custom-face-set) | 2136 | '(("Set" custom-face-set) |
| @@ -2181,7 +2258,9 @@ Optional EVENT is the location for the menu." | |||
| 2181 | (define-widget 'face 'default | 2258 | (define-widget 'face 'default |
| 2182 | "Select and customize a face." | 2259 | "Select and customize a face." |
| 2183 | :convert-widget 'widget-value-convert-widget | 2260 | :convert-widget 'widget-value-convert-widget |
| 2184 | :format "%[%t%]: %v" | 2261 | :button-prefix 'widget-push-button-prefix |
| 2262 | :button-suffix 'widget-push-button-suffix | ||
| 2263 | :format "%t: %[select face%] %v" | ||
| 2185 | :tag "Face" | 2264 | :tag "Face" |
| 2186 | :value 'default | 2265 | :value 'default |
| 2187 | :value-create 'widget-face-value-create | 2266 | :value-create 'widget-face-value-create |
| @@ -2194,9 +2273,9 @@ Optional EVENT is the location for the menu." | |||
| 2194 | (defun widget-face-value-create (widget) | 2273 | (defun widget-face-value-create (widget) |
| 2195 | ;; Create a `custom-face' child. | 2274 | ;; Create a `custom-face' child. |
| 2196 | (let* ((symbol (widget-value widget)) | 2275 | (let* ((symbol (widget-value widget)) |
| 2276 | (custom-buffer-style 'face) | ||
| 2197 | (child (widget-create-child-and-convert | 2277 | (child (widget-create-child-and-convert |
| 2198 | widget 'custom-face | 2278 | widget 'custom-face |
| 2199 | :format "%t %s %L\n%m%h%v" | ||
| 2200 | :custom-level nil | 2279 | :custom-level nil |
| 2201 | :value symbol))) | 2280 | :value symbol))) |
| 2202 | (custom-magic-reset child) | 2281 | (custom-magic-reset child) |
| @@ -2248,6 +2327,16 @@ Optional EVENT is the location for the menu." | |||
| 2248 | (widget-put widget :args args) | 2327 | (widget-put widget :args args) |
| 2249 | widget)) | 2328 | widget)) |
| 2250 | 2329 | ||
| 2330 | ;;; The `custom-group-link' Widget. | ||
| 2331 | |||
| 2332 | (define-widget 'custom-group-link 'link | ||
| 2333 | "Show parent in other window when activated." | ||
| 2334 | :help-echo "Create customize buffer for this group group." | ||
| 2335 | :action 'custom-group-link-action) | ||
| 2336 | |||
| 2337 | (defun custom-group-link-action (widget &rest ignore) | ||
| 2338 | (customize-group (widget-value widget))) | ||
| 2339 | |||
| 2251 | ;;; The `custom-group' Widget. | 2340 | ;;; The `custom-group' Widget. |
| 2252 | 2341 | ||
| 2253 | (defcustom custom-group-tag-faces '(custom-group-tag-face-1) | 2342 | (defcustom custom-group-tag-faces '(custom-group-tag-face-1) |
| @@ -2280,7 +2369,7 @@ and so forth. The remaining group tags are shown with | |||
| 2280 | 2369 | ||
| 2281 | (define-widget 'custom-group 'custom | 2370 | (define-widget 'custom-group 'custom |
| 2282 | "Customize group." | 2371 | "Customize group." |
| 2283 | :format "%l%{%t%} group: %L %-\n%m%i%h%a%v%e" | 2372 | :format "%v" |
| 2284 | :sample-face-get 'custom-group-sample-face-get | 2373 | :sample-face-get 'custom-group-sample-face-get |
| 2285 | :documentation-property 'group-documentation | 2374 | :documentation-property 'group-documentation |
| 2286 | :help-echo "Set or reset all members of this group." | 2375 | :help-echo "Set or reset all members of this group." |
| @@ -2300,42 +2389,197 @@ and so forth. The remaining group tags are shown with | |||
| 2300 | 'custom-group-tag-face)) | 2389 | 'custom-group-tag-face)) |
| 2301 | 2390 | ||
| 2302 | (defun custom-group-value-create (widget) | 2391 | (defun custom-group-value-create (widget) |
| 2303 | (let ((state (widget-get widget :custom-state))) | 2392 | "Insert a customize group for WIDGET in the current buffer." |
| 2304 | (unless (eq state 'hidden) | 2393 | (let ((state (widget-get widget :custom-state)) |
| 2305 | (message "Creating group...") | 2394 | (level (widget-get widget :custom-level)) |
| 2306 | (custom-load-widget widget) | 2395 | (indent (widget-get widget :indent)) |
| 2307 | (let* ((level (widget-get widget :custom-level)) | 2396 | (prefix (widget-get widget :custom-prefix)) |
| 2308 | (symbol (widget-value widget)) | 2397 | (buttons (widget-get widget :buttons)) |
| 2309 | (members (sort (sort (copy-sequence (get symbol 'custom-group)) | 2398 | (tag (widget-get widget :tag)) |
| 2310 | custom-buffer-sort-predicate) | 2399 | (symbol (widget-value widget))) |
| 2311 | custom-buffer-order-predicate)) | 2400 | (cond ((and (eq custom-buffer-style 'tree) |
| 2312 | (prefixes (widget-get widget :custom-prefixes)) | 2401 | (eq state 'hidden)) |
| 2313 | (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2402 | (insert prefix) |
| 2314 | (length (length members)) | 2403 | (push (widget-create-child-and-convert |
| 2315 | (count 0) | 2404 | widget 'custom-tree-visibility :tag "+") |
| 2316 | (children (mapcar (lambda (entry) | 2405 | buttons) |
| 2317 | (widget-insert "\n") | 2406 | (insert "-- ") |
| 2318 | (message "Creating group members... %2d%%" | 2407 | (push (widget-create-child-and-convert |
| 2319 | (/ (* 100.0 count) length)) | 2408 | widget 'custom-tree-group-tag) |
| 2320 | (setq count (1+ count)) | 2409 | buttons) |
| 2321 | (prog1 | 2410 | (insert " " tag "\n") |
| 2322 | (widget-create-child-and-convert | 2411 | (widget-put widget :buttons buttons)) |
| 2323 | widget (nth 1 entry) | 2412 | ((and (eq custom-buffer-style 'tree) |
| 2324 | :group widget | 2413 | (zerop (length (get symbol 'custom-group)))) |
| 2325 | :tag (custom-unlispify-tag-name | 2414 | (insert prefix "[ ]-- ") |
| 2326 | (nth 0 entry)) | 2415 | (push (widget-create-child-and-convert |
| 2327 | :custom-prefixes custom-prefix-list | 2416 | widget 'custom-tree-group-tag) |
| 2328 | :custom-level (1+ level) | 2417 | buttons) |
| 2329 | :value (nth 0 entry)) | 2418 | (insert " " tag "\n") |
| 2330 | (unless (eq (preceding-char) ?\n) | 2419 | (widget-put widget :buttons buttons)) |
| 2331 | (widget-insert "\n")))) | 2420 | ((eq custom-buffer-style 'tree) |
| 2332 | members))) | 2421 | (insert prefix) |
| 2333 | (message "Creating group magic...") | 2422 | (custom-load-widget widget) |
| 2334 | (mapcar 'custom-magic-reset children) | 2423 | (if (zerop (length (get symbol 'custom-group))) |
| 2335 | (message "Creating group state...") | 2424 | (progn |
| 2336 | (widget-put widget :children children) | 2425 | (insert prefix "[ ]-- ") |
| 2337 | (custom-group-state-update widget) | 2426 | (push (widget-create-child-and-convert |
| 2338 | (message "Creating group... done"))))) | 2427 | widget 'custom-tree-group-tag) |
| 2428 | buttons) | ||
| 2429 | (insert " " tag "\n") | ||
| 2430 | (widget-put widget :buttons buttons)) | ||
| 2431 | (push (widget-create-child-and-convert | ||
| 2432 | widget 'custom-tree-visibility :tag "-") | ||
| 2433 | buttons) | ||
| 2434 | (insert "-+ ") | ||
| 2435 | (push (widget-create-child-and-convert | ||
| 2436 | widget 'custom-tree-group-tag) | ||
| 2437 | buttons) | ||
| 2438 | (insert " " tag "\n") | ||
| 2439 | (widget-put widget :buttons buttons) | ||
| 2440 | (message "Creating group...") | ||
| 2441 | (let* ((members (sort (copy-sequence (get symbol 'custom-group)) | ||
| 2442 | 'custom-browse-sort-predicate)) | ||
| 2443 | (prefixes (widget-get widget :custom-prefixes)) | ||
| 2444 | (custom-prefix-list (custom-prefix-add symbol prefixes)) | ||
| 2445 | (length (length members)) | ||
| 2446 | (extra-prefix (if (widget-get widget :custom-last) | ||
| 2447 | " " | ||
| 2448 | " | ")) | ||
| 2449 | (prefix (concat prefix extra-prefix)) | ||
| 2450 | children entry) | ||
| 2451 | (while members | ||
| 2452 | (setq entry (car members) | ||
| 2453 | members (cdr members)) | ||
| 2454 | (push (widget-create-child-and-convert | ||
| 2455 | widget (nth 1 entry) | ||
| 2456 | :group widget | ||
| 2457 | :tag (custom-unlispify-tag-name | ||
| 2458 | (nth 0 entry)) | ||
| 2459 | :custom-prefixes custom-prefix-list | ||
| 2460 | :custom-level (1+ level) | ||
| 2461 | :custom-last (null members) | ||
| 2462 | :value (nth 0 entry) | ||
| 2463 | :custom-prefix prefix) | ||
| 2464 | children)) | ||
| 2465 | (widget-put widget :children (reverse children))) | ||
| 2466 | (message "Creating group...done"))) | ||
| 2467 | ;; Nested style. | ||
| 2468 | ((eq state 'hidden) | ||
| 2469 | ;; Create level indicator. | ||
| 2470 | (insert-char ?\ (* custom-buffer-indent (1- level))) | ||
| 2471 | (insert "-- ") | ||
| 2472 | ;; Create tag. | ||
| 2473 | (let ((begin (point))) | ||
| 2474 | (insert tag) | ||
| 2475 | (widget-specify-sample widget begin (point))) | ||
| 2476 | (insert " group: ") | ||
| 2477 | ;; Create link/visibility indicator. | ||
| 2478 | (if (eq custom-buffer-style 'links) | ||
| 2479 | (push (widget-create-child-and-convert | ||
| 2480 | widget 'custom-group-link | ||
| 2481 | :tag "Show" | ||
| 2482 | symbol) | ||
| 2483 | buttons) | ||
| 2484 | (push (widget-create-child-and-convert | ||
| 2485 | widget 'visibility | ||
| 2486 | :help-echo "Show members of this group." | ||
| 2487 | :action 'custom-toggle-parent | ||
| 2488 | (not (eq state 'hidden))) | ||
| 2489 | buttons)) | ||
| 2490 | (insert " \n") | ||
| 2491 | ;; Create magic button. | ||
| 2492 | (let ((magic (widget-create-child-and-convert | ||
| 2493 | widget 'custom-magic nil))) | ||
| 2494 | (widget-put widget :custom-magic magic) | ||
| 2495 | (push magic buttons)) | ||
| 2496 | ;; Update buttons. | ||
| 2497 | (widget-put widget :buttons buttons) | ||
| 2498 | ;; Insert documentation. | ||
| 2499 | (widget-default-format-handler widget ?h)) | ||
| 2500 | ;; Nested style. | ||
| 2501 | (t ;Visible. | ||
| 2502 | ;; Create level indicator. | ||
| 2503 | (insert-char ?\ (* custom-buffer-indent (1- level))) | ||
| 2504 | (insert "/- ") | ||
| 2505 | ;; Create tag. | ||
| 2506 | (let ((start (point))) | ||
| 2507 | (insert tag) | ||
| 2508 | (widget-specify-sample widget start (point))) | ||
| 2509 | (insert " group: ") | ||
| 2510 | ;; Create visibility indicator. | ||
| 2511 | (unless (eq custom-buffer-style 'links) | ||
| 2512 | (insert "--------") | ||
| 2513 | (push (widget-create-child-and-convert | ||
| 2514 | widget 'visibility | ||
| 2515 | :help-echo "Hide members of this group." | ||
| 2516 | :action 'custom-toggle-parent | ||
| 2517 | (not (eq state 'hidden))) | ||
| 2518 | buttons) | ||
| 2519 | (insert " ")) | ||
| 2520 | ;; Create more dashes. | ||
| 2521 | ;; Use 76 instead of 75 to compensate for the temporary "<" | ||
| 2522 | ;; added by `widget-insert'. | ||
| 2523 | (insert-char ?- (- 76 (current-column) | ||
| 2524 | (* custom-buffer-indent level))) | ||
| 2525 | (insert "\\\n") | ||
| 2526 | ;; Create magic button. | ||
| 2527 | (let ((magic (widget-create-child-and-convert | ||
| 2528 | widget 'custom-magic | ||
| 2529 | :indent 0 | ||
| 2530 | nil))) | ||
| 2531 | (widget-put widget :custom-magic magic) | ||
| 2532 | (push magic buttons)) | ||
| 2533 | ;; Update buttons. | ||
| 2534 | (widget-put widget :buttons buttons) | ||
| 2535 | ;; Insert documentation. | ||
| 2536 | (widget-default-format-handler widget ?h) | ||
| 2537 | ;; Parents and See also. | ||
| 2538 | (when (eq level 1) | ||
| 2539 | (insert-char ?\ custom-buffer-indent) | ||
| 2540 | (custom-add-parent-links widget)) | ||
| 2541 | (custom-add-see-also widget | ||
| 2542 | (make-string (* custom-buffer-indent level) | ||
| 2543 | ?\ )) | ||
| 2544 | ;; Members. | ||
| 2545 | (message "Creating group...") | ||
| 2546 | (custom-load-widget widget) | ||
| 2547 | (let* ((members (sort (copy-sequence (get symbol 'custom-group)) | ||
| 2548 | 'custom-buffer-sort-predicate)) | ||
| 2549 | (prefixes (widget-get widget :custom-prefixes)) | ||
| 2550 | (custom-prefix-list (custom-prefix-add symbol prefixes)) | ||
| 2551 | (length (length members)) | ||
| 2552 | (count 0) | ||
| 2553 | (children (mapcar (lambda (entry) | ||
| 2554 | (widget-insert "\n") | ||
| 2555 | (message "\ | ||
| 2556 | Creating group members... %2d%%" | ||
| 2557 | (/ (* 100.0 count) length)) | ||
| 2558 | (setq count (1+ count)) | ||
| 2559 | (prog1 | ||
| 2560 | (widget-create-child-and-convert | ||
| 2561 | widget (nth 1 entry) | ||
| 2562 | :group widget | ||
| 2563 | :tag (custom-unlispify-tag-name | ||
| 2564 | (nth 0 entry)) | ||
| 2565 | :custom-prefixes custom-prefix-list | ||
| 2566 | :custom-level (1+ level) | ||
| 2567 | :value (nth 0 entry)) | ||
| 2568 | (unless (eq (preceding-char) ?\n) | ||
| 2569 | (widget-insert "\n")))) | ||
| 2570 | members))) | ||
| 2571 | (message "Creating group magic...") | ||
| 2572 | (mapcar 'custom-magic-reset children) | ||
| 2573 | (message "Creating group state...") | ||
| 2574 | (widget-put widget :children children) | ||
| 2575 | (custom-group-state-update widget) | ||
| 2576 | (message "Creating group... done")) | ||
| 2577 | ;; End line | ||
| 2578 | (insert "\n") | ||
| 2579 | (insert-char ?\ (* custom-buffer-indent (1- level))) | ||
| 2580 | (insert "\\- " (widget-get widget :tag) " group end ") | ||
| 2581 | (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level))) | ||
| 2582 | (insert "/\n"))))) | ||
| 2339 | 2583 | ||
| 2340 | (defvar custom-group-menu | 2584 | (defvar custom-group-menu |
| 2341 | '(("Set" custom-group-set | 2585 | '(("Set" custom-group-set |
| @@ -2655,9 +2899,8 @@ The menu is in a format applicable to `easy-menu-define'." | |||
| 2655 | (< (length (get symbol 'custom-group)) widget-menu-max-size)) | 2899 | (< (length (get symbol 'custom-group)) widget-menu-max-size)) |
| 2656 | (let ((custom-prefix-list (custom-prefix-add symbol | 2900 | (let ((custom-prefix-list (custom-prefix-add symbol |
| 2657 | custom-prefix-list)) | 2901 | custom-prefix-list)) |
| 2658 | (members (sort (sort (copy-sequence (get symbol 'custom-group)) | 2902 | (members (sort (copy-sequence (get symbol 'custom-group)) |
| 2659 | custom-menu-sort-predicate) | 2903 | 'custom-menu-sort-predicate))) |
| 2660 | custom-menu-order-predicate))) | ||
| 2661 | (custom-load-symbol symbol) | 2904 | (custom-load-symbol symbol) |
| 2662 | `(,(custom-unlispify-menu-entry symbol t) | 2905 | `(,(custom-unlispify-menu-entry symbol t) |
| 2663 | ,item | 2906 | ,item |
| @@ -2682,7 +2925,9 @@ The format is suitable for use with `easy-menu-define'." | |||
| 2682 | ;; We can delay it under XEmacs. | 2925 | ;; We can delay it under XEmacs. |
| 2683 | `(,name | 2926 | `(,name |
| 2684 | :filter (lambda (&rest junk) | 2927 | :filter (lambda (&rest junk) |
| 2685 | (cdr (custom-menu-create ',symbol)))))) | 2928 | (cdr (custom-menu-create ',symbol)))) |
| 2929 | ;; But we must create it now under Emacs. | ||
| 2930 | (cons name (cdr (custom-menu-create symbol))))) | ||
| 2686 | 2931 | ||
| 2687 | ;;; The Custom Mode. | 2932 | ;;; The Custom Mode. |
| 2688 | 2933 | ||
| @@ -2695,20 +2940,11 @@ The format is suitable for use with `easy-menu-define'." | |||
| 2695 | (suppress-keymap custom-mode-map) | 2940 | (suppress-keymap custom-mode-map) |
| 2696 | (define-key custom-mode-map "q" 'bury-buffer)) | 2941 | (define-key custom-mode-map "q" 'bury-buffer)) |
| 2697 | 2942 | ||
| 2698 | (defvar custom-mode-customize-menu) | ||
| 2699 | (let ((menu (customize-menu-create 'customize))) | ||
| 2700 | ;; In Emacs, this returns nil, so don't make this menu. | ||
| 2701 | (if menu | ||
| 2702 | (easy-menu-define custom-mode-customize-menu | ||
| 2703 | custom-mode-map | ||
| 2704 | "Menu used to customize customization buffers." | ||
| 2705 | menu) | ||
| 2706 | (setq custom-mode-customize-menu nil))) | ||
| 2707 | |||
| 2708 | (easy-menu-define custom-mode-menu | 2943 | (easy-menu-define custom-mode-menu |
| 2709 | custom-mode-map | 2944 | custom-mode-map |
| 2710 | "Menu used in customization buffers." | 2945 | "Menu used in customization buffers." |
| 2711 | `("Custom" | 2946 | `("Custom" |
| 2947 | ,(customize-menu-create 'customize) | ||
| 2712 | ["Set" custom-set t] | 2948 | ["Set" custom-set t] |
| 2713 | ["Save" custom-save t] | 2949 | ["Save" custom-save t] |
| 2714 | ["Reset to Current" custom-reset-current t] | 2950 | ["Reset to Current" custom-reset-current t] |
| @@ -2742,8 +2978,6 @@ if that value is non-nil." | |||
| 2742 | (setq major-mode 'custom-mode | 2978 | (setq major-mode 'custom-mode |
| 2743 | mode-name "Custom") | 2979 | mode-name "Custom") |
| 2744 | (use-local-map custom-mode-map) | 2980 | (use-local-map custom-mode-map) |
| 2745 | (if custom-mode-customize-menu | ||
| 2746 | (easy-menu-add custom-mode-customize-menu)) | ||
| 2747 | (easy-menu-add custom-mode-menu) | 2981 | (easy-menu-add custom-mode-menu) |
| 2748 | (make-local-variable 'custom-options) | 2982 | (make-local-variable 'custom-options) |
| 2749 | (run-hooks 'custom-mode-hook)) | 2983 | (run-hooks 'custom-mode-hook)) |
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 44bc0b9bd17..f7926ba3d45 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.9924 | 7 | ;; Version: 1.9929 |
| 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. |
| @@ -439,6 +439,15 @@ later with `widget-put'." | |||
| 439 | (setq missing nil)))) | 439 | (setq missing nil)))) |
| 440 | value)) | 440 | value)) |
| 441 | 441 | ||
| 442 | (defun widget-get-indirect (widget property) | ||
| 443 | "In WIDGET, get the value of PROPERTY. | ||
| 444 | If the value is a symbol, return its binding. | ||
| 445 | Otherwise, just return the value." | ||
| 446 | (let ((value (widget-get widget property))) | ||
| 447 | (if (symbolp value) | ||
| 448 | (symbol-value value) | ||
| 449 | value))) | ||
| 450 | |||
| 442 | (defun widget-member (widget property) | 451 | (defun widget-member (widget property) |
| 443 | "Non-nil iff there is a definition in WIDGET for PROPERTY." | 452 | "Non-nil iff there is a definition in WIDGET for PROPERTY." |
| 444 | (cond ((widget-plist-member (cdr widget) property) | 453 | (cond ((widget-plist-member (cdr widget) property) |
| @@ -667,14 +676,6 @@ glyphs used when the widget is pushed and inactive, respectively." | |||
| 667 | :type 'string | 676 | :type 'string |
| 668 | :group 'widget-button) | 677 | :group 'widget-button) |
| 669 | 678 | ||
| 670 | (defun widget-button-insert-indirect (widget key) | ||
| 671 | "Insert value of WIDGET's KEY property." | ||
| 672 | (let ((val (widget-get widget key))) | ||
| 673 | (while (and val (symbolp val)) | ||
| 674 | (setq val (symbol-value val))) | ||
| 675 | (when val | ||
| 676 | (insert val)))) | ||
| 677 | |||
| 678 | ;;; Creating Widgets. | 679 | ;;; Creating Widgets. |
| 679 | 680 | ||
| 680 | ;;;###autoload | 681 | ;;;###autoload |
| @@ -1185,13 +1186,13 @@ Unlike (get-char-property POS 'field) this, works with empty fields too." | |||
| 1185 | (setq found field)))) | 1186 | (setq found field)))) |
| 1186 | found)) | 1187 | found)) |
| 1187 | 1188 | ||
| 1188 | ;; This is how, for example, a variable changes its state to "set" | ||
| 1189 | ;; when it is being edited. | ||
| 1190 | (defun widget-before-change (from &rest ignore) | 1189 | (defun widget-before-change (from &rest ignore) |
| 1190 | ;; This is how, for example, a variable changes its state to `modified'. | ||
| 1191 | ;; when it is being edited. | ||
| 1191 | (condition-case nil | 1192 | (condition-case nil |
| 1192 | (let ((field (widget-field-find from))) | 1193 | (let ((field (widget-field-find from))) |
| 1193 | (widget-apply field :notify field)) | 1194 | (widget-apply field :notify field)) |
| 1194 | (error (debug "After Change")))) | 1195 | (error (debug "Before Change")))) |
| 1195 | 1196 | ||
| 1196 | (defun widget-after-change (from to old) | 1197 | (defun widget-after-change (from to old) |
| 1197 | ;; Adjust field size and text properties. | 1198 | ;; Adjust field size and text properties. |
| @@ -1236,7 +1237,8 @@ Unlike (get-char-property POS 'field) this, works with empty fields too." | |||
| 1236 | (unless (eq old secret) | 1237 | (unless (eq old secret) |
| 1237 | (subst-char-in-region begin (1+ begin) old secret) | 1238 | (subst-char-in-region begin (1+ begin) old secret) |
| 1238 | (put-text-property begin (1+ begin) 'secret old)) | 1239 | (put-text-property begin (1+ begin) 'secret old)) |
| 1239 | (setq begin (1+ begin))))))))) | 1240 | (setq begin (1+ begin))))))) |
| 1241 | (widget-apply field :notify field))) | ||
| 1240 | (error (debug "After Change")))) | 1242 | (error (debug "After Change")))) |
| 1241 | 1243 | ||
| 1242 | ;;; Widget Functions | 1244 | ;;; Widget Functions |
| @@ -1337,9 +1339,9 @@ If that does not exists, call the value of `widget-complete-field'." | |||
| 1337 | (insert "%")) | 1339 | (insert "%")) |
| 1338 | ((eq escape ?\[) | 1340 | ((eq escape ?\[) |
| 1339 | (setq button-begin (point)) | 1341 | (setq button-begin (point)) |
| 1340 | (widget-button-insert-indirect widget :button-prefix)) | 1342 | (insert (widget-get-indirect widget :button-prefix))) |
| 1341 | ((eq escape ?\]) | 1343 | ((eq escape ?\]) |
| 1342 | (widget-button-insert-indirect widget :button-suffix) | 1344 | (insert (widget-get-indirect widget :button-suffix)) |
| 1343 | (setq button-end (point))) | 1345 | (setq button-end (point))) |
| 1344 | ((eq escape ?\{) | 1346 | ((eq escape ?\{) |
| 1345 | (setq sample-begin (point))) | 1347 | (setq sample-begin (point))) |
| @@ -1649,22 +1651,6 @@ If END is omitted, it defaults to the length of LIST." | |||
| 1649 | "Open the info node specified by WIDGET." | 1651 | "Open the info node specified by WIDGET." |
| 1650 | (Info-goto-node (widget-value widget))) | 1652 | (Info-goto-node (widget-value widget))) |
| 1651 | 1653 | ||
| 1652 | ;;; The `group-link' Widget. | ||
| 1653 | |||
| 1654 | (define-widget 'group-link 'link | ||
| 1655 | "A link to a customization group." | ||
| 1656 | :create 'widget-group-link-create | ||
| 1657 | :action 'widget-group-link-action) | ||
| 1658 | |||
| 1659 | (defun widget-group-link-create (widget) | ||
| 1660 | (let ((state (widget-get (widget-get widget :parent) :custom-state))) | ||
| 1661 | (if (eq state 'hidden) | ||
| 1662 | (widget-default-create widget)))) | ||
| 1663 | |||
| 1664 | (defun widget-group-link-action (widget &optional event) | ||
| 1665 | "Open the info node specified by WIDGET." | ||
| 1666 | (customize-group (widget-value widget))) | ||
| 1667 | |||
| 1668 | ;;; The `url-link' Widget. | 1654 | ;;; The `url-link' Widget. |
| 1669 | 1655 | ||
| 1670 | (define-widget 'url-link 'link | 1656 | (define-widget 'url-link 'link |
| @@ -2635,24 +2621,6 @@ when he invoked the menu." | |||
| 2635 | (widget-glyph-insert widget on "down" "down-pushed") | 2621 | (widget-glyph-insert widget on "down" "down-pushed") |
| 2636 | (widget-glyph-insert widget off "right" "right-pushed")))) | 2622 | (widget-glyph-insert widget off "right" "right-pushed")))) |
| 2637 | 2623 | ||
| 2638 | (define-widget 'group-visibility 'item | ||
| 2639 | "An indicator and manipulator for hidden group contents." | ||
| 2640 | :format "%[%v%]" | ||
| 2641 | :create 'widget-group-visibility-create | ||
| 2642 | :button-prefix "" | ||
| 2643 | :button-suffix "" | ||
| 2644 | :on "Hide" | ||
| 2645 | :off "Show" | ||
| 2646 | :value-create 'widget-visibility-value-create | ||
| 2647 | :action 'widget-toggle-action | ||
| 2648 | :match (lambda (widget value) t)) | ||
| 2649 | |||
| 2650 | (defun widget-group-visibility-create (widget) | ||
| 2651 | (let ((visible (widget-value widget))) | ||
| 2652 | (if visible | ||
| 2653 | (insert "--------"))) | ||
| 2654 | (widget-default-create widget)) | ||
| 2655 | |||
| 2656 | ;;; The `documentation-link' Widget. | 2624 | ;;; The `documentation-link' Widget. |
| 2657 | ;; | 2625 | ;; |
| 2658 | ;; This is a helper widget for `documentation-string'. | 2626 | ;; This is a helper widget for `documentation-string'. |