diff options
| author | Per Abrahamsen | 1997-06-14 10:21:01 +0000 |
|---|---|---|
| committer | Per Abrahamsen | 1997-06-14 10:21:01 +0000 |
| commit | 6aaedd123065d146fee819d3d1f0e26433185c5b (patch) | |
| tree | 95bd8ecb99ddf14f3a1623952d017f167f7abd1d /lisp | |
| parent | 996169356bd886272f21d37bab286af0a351c42f (diff) | |
| download | emacs-6aaedd123065d146fee819d3d1f0e26433185c5b.tar.gz emacs-6aaedd123065d146fee819d3d1f0e26433185c5b.zip | |
Synched with 1.9914.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/cus-edit.el | 137 | ||||
| -rw-r--r-- | lisp/wid-browse.el | 4 | ||||
| -rw-r--r-- | lisp/wid-edit.el | 176 |
3 files changed, 220 insertions, 97 deletions
diff --git a/lisp/cus-edit.el b/lisp/cus-edit.el index 7d545ba68ec..701a5a8c0f5 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.9908 | 7 | ;; Version: 1.9914 |
| 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. |
| @@ -246,6 +246,16 @@ | |||
| 246 | :group 'customize | 246 | :group 'customize |
| 247 | :group 'faces) | 247 | :group 'faces) |
| 248 | 248 | ||
| 249 | (defgroup custom-buffer nil | ||
| 250 | "Control the customize buffers." | ||
| 251 | :prefix "custom-" | ||
| 252 | :group 'customize) | ||
| 253 | |||
| 254 | (defgroup custom-menu nil | ||
| 255 | "Control how the customize menus." | ||
| 256 | :prefix "custom-" | ||
| 257 | :group 'customize) | ||
| 258 | |||
| 249 | (defgroup abbrev-mode nil | 259 | (defgroup abbrev-mode nil |
| 250 | "Word abbreviations mode." | 260 | "Word abbreviations mode." |
| 251 | :group 'abbrev) | 261 | :group 'abbrev) |
| @@ -401,7 +411,7 @@ WIDGET is the widget to apply the filter entries of MENU on." | |||
| 401 | 411 | ||
| 402 | (defcustom custom-unlispify-menu-entries t | 412 | (defcustom custom-unlispify-menu-entries t |
| 403 | "Display menu entries as words instead of symbols if non nil." | 413 | "Display menu entries as words instead of symbols if non nil." |
| 404 | :group 'customize | 414 | :group 'custom-menu |
| 405 | :type 'boolean) | 415 | :type 'boolean) |
| 406 | 416 | ||
| 407 | (defun custom-unlispify-menu-entry (symbol &optional no-suffix) | 417 | (defun custom-unlispify-menu-entry (symbol &optional no-suffix) |
| @@ -440,7 +450,7 @@ WIDGET is the widget to apply the filter entries of MENU on." | |||
| 440 | 450 | ||
| 441 | (defcustom custom-unlispify-tag-names t | 451 | (defcustom custom-unlispify-tag-names t |
| 442 | "Display tag names as words instead of symbols if non nil." | 452 | "Display tag names as words instead of symbols if non nil." |
| 443 | :group 'customize | 453 | :group 'custom-buffer |
| 444 | :type 'boolean) | 454 | :type 'boolean) |
| 445 | 455 | ||
| 446 | (defun custom-unlispify-tag-name (symbol) | 456 | (defun custom-unlispify-tag-name (symbol) |
| @@ -518,49 +528,59 @@ if that fails, the doc string with `custom-guess-doc-alist'." | |||
| 518 | 528 | ||
| 519 | ;;; Sorting. | 529 | ;;; Sorting. |
| 520 | 530 | ||
| 521 | (defcustom custom-buffer-sort-predicate 'custom-buffer-sort-alphabetically | 531 | (defcustom custom-buffer-sort-predicate 'ignore |
| 522 | "Function used for sorting group members in buffers. | 532 | "Function used for sorting group members in buffers. |
| 523 | The value should be useful as a predicate for `sort'. | 533 | The value should be useful as a predicate for `sort'. |
| 524 | The list to be sorted is the value of the groups `custom-group' property." | 534 | The list to be sorted is the value of the groups `custom-group' property." |
| 525 | :type '(radio (function-item custom-buffer-sort-alphabetically) | 535 | :type '(radio (const :tag "Unsorted" ignore) |
| 536 | (const :tag "Alphabetic" custom-sort-items-alphabetically) | ||
| 526 | (function :tag "Other")) | 537 | (function :tag "Other")) |
| 527 | :group 'customize) | 538 | :group 'custom-buffer) |
| 528 | 539 | ||
| 529 | (defun custom-buffer-sort-alphabetically (a b) | 540 | (defcustom custom-buffer-order-predicate 'custom-sort-groups-last |
| 530 | "Return t iff is A should be before B. | 541 | "Function used for sorting group members in buffers. |
| 531 | A and B should be members of a `custom-group' property. | 542 | The value should be useful as a predicate for `sort'. |
| 532 | The members are sorted alphabetically, except that all groups are | 543 | The list to be sorted is the value of the groups `custom-group' property." |
| 533 | sorted after all non-groups." | 544 | :type '(radio (const :tag "Groups first" custom-sort-groups-first) |
| 534 | (cond ((and (eq (nth 1 a) 'custom-group) | 545 | (const :tag "Groups last" custom-sort-groups-last) |
| 535 | (not (eq (nth 1 b) 'custom-group))) | 546 | (function :tag "Other")) |
| 536 | nil) | 547 | :group 'custom-buffer) |
| 537 | ((and (eq (nth 1 b) 'custom-group) | ||
| 538 | (not (eq (nth 1 a) 'custom-group))) | ||
| 539 | t) | ||
| 540 | (t | ||
| 541 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b)))))) | ||
| 542 | 548 | ||
| 543 | (defcustom custom-menu-sort-predicate 'custom-menu-sort-alphabetically | 549 | (defcustom custom-menu-sort-predicate 'ignore |
| 544 | "Function used for sorting group members in menus. | 550 | "Function used for sorting group members in menus. |
| 545 | The value should be useful as a predicate for `sort'. | 551 | The value should be useful as a predicate for `sort'. |
| 546 | The list to be sorted is the value of the groups `custom-group' property." | 552 | The list to be sorted is the value of the groups `custom-group' property." |
| 547 | :type '(radio (function-item custom-menu-sort-alphabetically) | 553 | :type '(radio (const :tag "Unsorted" ignore) |
| 554 | (const :tag "Alphabetic" custom-sort-items-alphabetically) | ||
| 548 | (function :tag "Other")) | 555 | (function :tag "Other")) |
| 549 | :group 'customize) | 556 | :group 'custom-menu) |
| 550 | 557 | ||
| 551 | (defun custom-menu-sort-alphabetically (a b) | 558 | (defcustom custom-menu-order-predicate 'custom-sort-groups-first |
| 552 | "Return t iff is A should be before B. | 559 | "Function used for sorting group members in menus. |
| 553 | A and B should be members of a `custom-group' property. | 560 | The value should be useful as a predicate for `sort'. |
| 554 | The members are sorted alphabetically, except that all groups are | 561 | The list to be sorted is the value of the groups `custom-group' property." |
| 555 | sorted before all non-groups." | 562 | :type '(radio (const :tag "Groups first" custom-sort-groups-first) |
| 556 | (cond ((and (eq (nth 1 a) 'custom-group) | 563 | (const :tag "Groups last" custom-sort-groups-last) |
| 557 | (not (eq (nth 1 b) 'custom-group))) | 564 | (function :tag "Other")) |
| 558 | t) | 565 | :group 'custom-menu) |
| 559 | ((and (eq (nth 1 b) 'custom-group) | 566 | |
| 560 | (not (eq (nth 1 a) 'custom-group))) | 567 | (defun custom-sort-items-alphabetically (a b) |
| 561 | nil) | 568 | "Return t iff A is alphabetically before B and the same custom type. |
| 562 | (t | 569 | A and B should be members of a `custom-group' property." |
| 563 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b)))))) | 570 | (and (eq (nth 1 a) (nth 1 b)) |
| 571 | (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b))))) | ||
| 572 | |||
| 573 | (defun custom-sort-groups-first (a b) | ||
| 574 | "Return t iff A a custom group and B is a not. | ||
| 575 | A and B should be members of a `custom-group' property." | ||
| 576 | (and (eq (nth 1 a) 'custom-group) | ||
| 577 | (not (eq (nth 1 b) 'custom-group)))) | ||
| 578 | |||
| 579 | (defun custom-sort-groups-last (a b) | ||
| 580 | "Return t iff B a custom group and A is a not. | ||
| 581 | A and B should be members of a `custom-group' property." | ||
| 582 | (and (eq (nth 1 b) 'custom-group) | ||
| 583 | (not (eq (nth 1 a) 'custom-group)))) | ||
| 564 | 584 | ||
| 565 | ;;; Custom Mode Commands. | 585 | ;;; Custom Mode Commands. |
| 566 | 586 | ||
| @@ -897,7 +917,7 @@ that option." | |||
| 897 | "If non-nil, only show a single reset button in customize buffers. | 917 | "If non-nil, only show a single reset button in customize buffers. |
| 898 | This button will have a menu with all three reset operations." | 918 | This button will have a menu with all three reset operations." |
| 899 | :type 'boolean | 919 | :type 'boolean |
| 900 | :group 'customize) | 920 | :group 'custom-buffer) |
| 901 | 921 | ||
| 902 | (defun custom-buffer-create-internal (options) | 922 | (defun custom-buffer-create-internal (options) |
| 903 | (message "Creating customization buffer...") | 923 | (message "Creating customization buffer...") |
| @@ -1017,38 +1037,49 @@ Reset all visible items in this buffer to their standard settings." | |||
| 1017 | 1037 | ||
| 1018 | ;;; The `custom-magic' Widget. | 1038 | ;;; The `custom-magic' Widget. |
| 1019 | 1039 | ||
| 1040 | (defgroup custom-magic-faces nil | ||
| 1041 | "Faces used by the magic button." | ||
| 1042 | :group 'custom-faces | ||
| 1043 | :group 'custom-buffer) | ||
| 1044 | |||
| 1020 | (defface custom-invalid-face '((((class color)) | 1045 | (defface custom-invalid-face '((((class color)) |
| 1021 | (:foreground "yellow" :background "red")) | 1046 | (:foreground "yellow" :background "red")) |
| 1022 | (t | 1047 | (t |
| 1023 | (:bold t :italic t :underline t))) | 1048 | (:bold t :italic t :underline t))) |
| 1024 | "Face used when the customize item is invalid.") | 1049 | "Face used when the customize item is invalid." |
| 1050 | :group 'custom-magic-faces) | ||
| 1025 | 1051 | ||
| 1026 | (defface custom-rogue-face '((((class color)) | 1052 | (defface custom-rogue-face '((((class color)) |
| 1027 | (:foreground "pink" :background "black")) | 1053 | (:foreground "pink" :background "black")) |
| 1028 | (t | 1054 | (t |
| 1029 | (:underline t))) | 1055 | (:underline t))) |
| 1030 | "Face used when the customize item is not defined for customization.") | 1056 | "Face used when the customize item is not defined for customization." |
| 1057 | :group 'custom-magic-faces) | ||
| 1031 | 1058 | ||
| 1032 | (defface custom-modified-face '((((class color)) | 1059 | (defface custom-modified-face '((((class color)) |
| 1033 | (:foreground "white" :background "blue")) | 1060 | (:foreground "white" :background "blue")) |
| 1034 | (t | 1061 | (t |
| 1035 | (:italic t :bold))) | 1062 | (:italic t :bold))) |
| 1036 | "Face used when the customize item has been modified.") | 1063 | "Face used when the customize item has been modified." |
| 1064 | :group 'custom-magic-faces) | ||
| 1037 | 1065 | ||
| 1038 | (defface custom-set-face '((((class color)) | 1066 | (defface custom-set-face '((((class color)) |
| 1039 | (:foreground "blue" :background "white")) | 1067 | (:foreground "blue" :background "white")) |
| 1040 | (t | 1068 | (t |
| 1041 | (:italic t))) | 1069 | (:italic t))) |
| 1042 | "Face used when the customize item has been set.") | 1070 | "Face used when the customize item has been set." |
| 1071 | :group 'custom-magic-faces) | ||
| 1043 | 1072 | ||
| 1044 | (defface custom-changed-face '((((class color)) | 1073 | (defface custom-changed-face '((((class color)) |
| 1045 | (:foreground "white" :background "blue")) | 1074 | (:foreground "white" :background "blue")) |
| 1046 | (t | 1075 | (t |
| 1047 | (:italic t))) | 1076 | (:italic t))) |
| 1048 | "Face used when the customize item has been changed.") | 1077 | "Face used when the customize item has been changed." |
| 1078 | :group 'custom-magic-faces) | ||
| 1049 | 1079 | ||
| 1050 | (defface custom-saved-face '((t (:underline t))) | 1080 | (defface custom-saved-face '((t (:underline t))) |
| 1051 | "Face used when the customize item has been saved.") | 1081 | "Face used when the customize item has been saved." |
| 1082 | :group 'custom-magic-faces) | ||
| 1052 | 1083 | ||
| 1053 | (defconst custom-magic-alist '((nil "#" underline "\ | 1084 | (defconst custom-magic-alist '((nil "#" underline "\ |
| 1054 | uninitialized, you should not see this.") | 1085 | uninitialized, you should not see this.") |
| @@ -1123,7 +1154,7 @@ If non-nil and not the symbol `long', only show first word." | |||
| 1123 | :type '(choice (const :tag "no" nil) | 1154 | :type '(choice (const :tag "no" nil) |
| 1124 | (const short) | 1155 | (const short) |
| 1125 | (const long)) | 1156 | (const long)) |
| 1126 | :group 'customize) | 1157 | :group 'custom-buffer) |
| 1127 | 1158 | ||
| 1128 | (defcustom custom-magic-show-hidden '(option face) | 1159 | (defcustom custom-magic-show-hidden '(option face) |
| 1129 | "Control whether the state button is shown for hidden items. | 1160 | "Control whether the state button is shown for hidden items. |
| @@ -1131,12 +1162,12 @@ The value should be a list with the custom categories where the state | |||
| 1131 | button should be visible. Possible categories are `group', `option', | 1162 | button should be visible. Possible categories are `group', `option', |
| 1132 | and `face'." | 1163 | and `face'." |
| 1133 | :type '(set (const group) (const option) (const face)) | 1164 | :type '(set (const group) (const option) (const face)) |
| 1134 | :group 'customize) | 1165 | :group 'custom-buffer) |
| 1135 | 1166 | ||
| 1136 | (defcustom custom-magic-show-button nil | 1167 | (defcustom custom-magic-show-button nil |
| 1137 | "Show a magic button indicating the state of each customization option." | 1168 | "Show a magic button indicating the state of each customization option." |
| 1138 | :type 'boolean | 1169 | :type 'boolean |
| 1139 | :group 'customize) | 1170 | :group 'custom-buffer) |
| 1140 | 1171 | ||
| 1141 | (define-widget 'custom-magic 'default | 1172 | (define-widget 'custom-magic 'default |
| 1142 | "Show and manipulate state for a customization option." | 1173 | "Show and manipulate state for a customization option." |
| @@ -2176,8 +2207,9 @@ and so forth. The remaining group tags are shown with | |||
| 2176 | (custom-load-widget widget) | 2207 | (custom-load-widget widget) |
| 2177 | (let* ((level (widget-get widget :custom-level)) | 2208 | (let* ((level (widget-get widget :custom-level)) |
| 2178 | (symbol (widget-value widget)) | 2209 | (symbol (widget-value widget)) |
| 2179 | (members (sort (get symbol 'custom-group) | 2210 | (members (sort (sort (copy-sequence (get symbol 'custom-group)) |
| 2180 | custom-buffer-sort-predicate)) | 2211 | custom-buffer-sort-predicate) |
| 2212 | custom-buffer-order-predicate)) | ||
| 2181 | (prefixes (widget-get widget :custom-prefixes)) | 2213 | (prefixes (widget-get widget :custom-prefixes)) |
| 2182 | (custom-prefix-list (custom-prefix-add symbol prefixes)) | 2214 | (custom-prefix-list (custom-prefix-add symbol prefixes)) |
| 2183 | (length (length members)) | 2215 | (length (length members)) |
| @@ -2199,7 +2231,6 @@ and so forth. The remaining group tags are shown with | |||
| 2199 | (unless (eq (preceding-char) ?\n) | 2231 | (unless (eq (preceding-char) ?\n) |
| 2200 | (widget-insert "\n")))) | 2232 | (widget-insert "\n")))) |
| 2201 | members))) | 2233 | members))) |
| 2202 | (put symbol 'custom-group members) | ||
| 2203 | (message "Creating group magic...") | 2234 | (message "Creating group magic...") |
| 2204 | (mapcar 'custom-magic-reset children) | 2235 | (mapcar 'custom-magic-reset children) |
| 2205 | (message "Creating group state...") | 2236 | (message "Creating group state...") |
| @@ -2465,7 +2496,7 @@ Leave point at the location of the call, or after the last expression." | |||
| 2465 | (defcustom custom-menu-nesting 2 | 2496 | (defcustom custom-menu-nesting 2 |
| 2466 | "Maximum nesting in custom menus." | 2497 | "Maximum nesting in custom menus." |
| 2467 | :type 'integer | 2498 | :type 'integer |
| 2468 | :group 'customize) | 2499 | :group 'custom-menu) |
| 2469 | 2500 | ||
| 2470 | (defun custom-face-menu-create (widget symbol) | 2501 | (defun custom-face-menu-create (widget symbol) |
| 2471 | "Ignoring WIDGET, create a menu entry for customization face SYMBOL." | 2502 | "Ignoring WIDGET, create a menu entry for customization face SYMBOL." |
| @@ -2518,9 +2549,9 @@ The menu is in a format applicable to `easy-menu-define'." | |||
| 2518 | (< (length (get symbol 'custom-group)) widget-menu-max-size)) | 2549 | (< (length (get symbol 'custom-group)) widget-menu-max-size)) |
| 2519 | (let ((custom-prefix-list (custom-prefix-add symbol | 2550 | (let ((custom-prefix-list (custom-prefix-add symbol |
| 2520 | custom-prefix-list)) | 2551 | custom-prefix-list)) |
| 2521 | (members (sort (get symbol 'custom-group) | 2552 | (members (sort (sort (copy-sequence (get symbol 'custom-group)) |
| 2522 | custom-menu-sort-predicate))) | 2553 | custom-menu-sort-predicate) |
| 2523 | (put symbol 'custom-group members) | 2554 | custom-menu-order-predicate))) |
| 2524 | (custom-load-symbol symbol) | 2555 | (custom-load-symbol symbol) |
| 2525 | `(,(custom-unlispify-menu-entry symbol t) | 2556 | `(,(custom-unlispify-menu-entry symbol t) |
| 2526 | ,item | 2557 | ,item |
| @@ -2579,7 +2610,7 @@ The format is suitable for use with `easy-menu-define'." | |||
| 2579 | (defcustom custom-mode-hook nil | 2610 | (defcustom custom-mode-hook nil |
| 2580 | "Hook called when entering custom-mode." | 2611 | "Hook called when entering custom-mode." |
| 2581 | :type 'hook | 2612 | :type 'hook |
| 2582 | :group 'customize) | 2613 | :group 'custom-buffer ) |
| 2583 | 2614 | ||
| 2584 | (defun custom-mode () | 2615 | (defun custom-mode () |
| 2585 | "Major mode for editing customization buffers. | 2616 | "Major mode for editing customization buffers. |
diff --git a/lisp/wid-browse.el b/lisp/wid-browse.el index 09a5a6617bd..cf98e2b3764 100644 --- a/lisp/wid-browse.el +++ b/lisp/wid-browse.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.9905 | 7 | ;; Version: 1.9914 |
| 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. |
| @@ -282,7 +282,7 @@ With arg, turn widget mode on if and only if arg is positive." | |||
| 282 | (interactive "P") | 282 | (interactive "P") |
| 283 | (cond ((null arg) | 283 | (cond ((null arg) |
| 284 | (setq widget-minor-mode (not widget-minor-mode))) | 284 | (setq widget-minor-mode (not widget-minor-mode))) |
| 285 | ((<= 0 arg) | 285 | ((<= arg 0) |
| 286 | (setq widget-minor-mode nil)) | 286 | (setq widget-minor-mode nil)) |
| 287 | (t | 287 | (t |
| 288 | (setq widget-minor-mode t))) | 288 | (setq widget-minor-mode t))) |
diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el index 35c0ffd0e13..af6c5e7d2be 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.9908 | 7 | ;; Version: 1.9914 |
| 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. |
| @@ -123,17 +123,21 @@ is the string or buffer containing the text." | |||
| 123 | "http://www.dina.kvl.dk/~abraham/custom/") | 123 | "http://www.dina.kvl.dk/~abraham/custom/") |
| 124 | :prefix "widget-" | 124 | :prefix "widget-" |
| 125 | :group 'extensions | 125 | :group 'extensions |
| 126 | :group 'faces | ||
| 127 | :group 'hypermedia) | 126 | :group 'hypermedia) |
| 128 | 127 | ||
| 128 | (defgroup widget-faces nil | ||
| 129 | "Faces used by the widget library." | ||
| 130 | :group 'widgets | ||
| 131 | :group 'faces) | ||
| 132 | |||
| 129 | (defface widget-button-face '((t (:bold t))) | 133 | (defface widget-button-face '((t (:bold t))) |
| 130 | "Face used for widget buttons." | 134 | "Face used for widget buttons." |
| 131 | :group 'widgets) | 135 | :group 'widget-faces) |
| 132 | 136 | ||
| 133 | (defcustom widget-mouse-face 'highlight | 137 | (defcustom widget-mouse-face 'highlight |
| 134 | "Face used for widget buttons when the mouse is above them." | 138 | "Face used for widget buttons when the mouse is above them." |
| 135 | :type 'face | 139 | :type 'face |
| 136 | :group 'widgets) | 140 | :group 'widget-faces) |
| 137 | 141 | ||
| 138 | (defface widget-field-face '((((class grayscale color) | 142 | (defface widget-field-face '((((class grayscale color) |
| 139 | (background light)) | 143 | (background light)) |
| @@ -144,7 +148,7 @@ is the string or buffer containing the text." | |||
| 144 | (t | 148 | (t |
| 145 | (:italic t))) | 149 | (:italic t))) |
| 146 | "Face used for editable fields." | 150 | "Face used for editable fields." |
| 147 | :group 'widgets) | 151 | :group 'widget-faces) |
| 148 | 152 | ||
| 149 | ;;; Utility functions. | 153 | ;;; Utility functions. |
| 150 | ;; | 154 | ;; |
| @@ -347,14 +351,15 @@ minibuffer." | |||
| 347 | (t | 351 | (t |
| 348 | (:italic t))) | 352 | (:italic t))) |
| 349 | "Face used for inactive widgets." | 353 | "Face used for inactive widgets." |
| 350 | :group 'widgets) | 354 | :group 'widget-faces) |
| 351 | 355 | ||
| 352 | (defun widget-specify-inactive (widget from to) | 356 | (defun widget-specify-inactive (widget from to) |
| 353 | "Make WIDGET inactive for user modifications." | 357 | "Make WIDGET inactive for user modifications." |
| 354 | (unless (widget-get widget :inactive) | 358 | (unless (widget-get widget :inactive) |
| 355 | (let ((overlay (make-overlay from to nil t nil))) | 359 | (let ((overlay (make-overlay from to nil t nil))) |
| 356 | (overlay-put overlay 'face 'widget-inactive-face) | 360 | (overlay-put overlay 'face 'widget-inactive-face) |
| 357 | (overlay-put overlay 'mouse-face 'widget-inactive-face) | 361 | ;; This is disabled, as it makes the mouse cursor change shape. |
| 362 | ;; (overlay-put overlay 'mouse-face 'widget-inactive-face) | ||
| 358 | (overlay-put overlay 'evaporate t) | 363 | (overlay-put overlay 'evaporate t) |
| 359 | (overlay-put overlay 'priority 100) | 364 | (overlay-put overlay 'priority 100) |
| 360 | (overlay-put overlay (if (string-match "XEmacs" emacs-version) | 365 | (overlay-put overlay (if (string-match "XEmacs" emacs-version) |
| @@ -474,6 +479,26 @@ This is only meaningful for radio buttons or checkboxes in a list." | |||
| 474 | (throw 'child child))) | 479 | (throw 'child child))) |
| 475 | nil))) | 480 | nil))) |
| 476 | 481 | ||
| 482 | (defun widget-map-buttons (function &optional buffer maparg) | ||
| 483 | "Map FUNCTION over the buttons in BUFFER. | ||
| 484 | FUNCTION is called with the arguments WIDGET and MAPARG. | ||
| 485 | |||
| 486 | If FUNCTION returns non-nil, the walk is cancelled. | ||
| 487 | |||
| 488 | The arguments MAPARG, and BUFFER default to nil and (current-buffer), | ||
| 489 | respectively." | ||
| 490 | (let ((cur (point-min)) | ||
| 491 | (widget nil) | ||
| 492 | (parent nil) | ||
| 493 | (overlays (if buffer | ||
| 494 | (save-excursion (set-buffer buffer) (overlay-lists)) | ||
| 495 | (overlay-lists)))) | ||
| 496 | (setq overlays (append (car overlays) (cdr overlays))) | ||
| 497 | (while (setq cur (pop overlays)) | ||
| 498 | (setq widget (overlay-get cur 'button)) | ||
| 499 | (if (and widget (funcall function widget maparg)) | ||
| 500 | (setq overlays nil))))) | ||
| 501 | |||
| 477 | ;;; Glyphs. | 502 | ;;; Glyphs. |
| 478 | 503 | ||
| 479 | (defcustom widget-glyph-directory (concat data-directory "custom/") | 504 | (defcustom widget-glyph-directory (concat data-directory "custom/") |
| @@ -720,6 +745,31 @@ The optional ARGS are additional keyword arguments." | |||
| 720 | (apply 'insert args) | 745 | (apply 'insert args) |
| 721 | (widget-specify-text from (point)))) | 746 | (widget-specify-text from (point)))) |
| 722 | 747 | ||
| 748 | (defun widget-convert-text (type from to &optional button-from button-to) | ||
| 749 | "Return a widget of type TYPE with endpoint FROM TO. | ||
| 750 | No text will be inserted to the buffer, instead the text between FROM | ||
| 751 | and TO will be used as the widgets end points. If optional arguments | ||
| 752 | BUTTON-FROM and BUTTON-TO are given, these will be used as the widgets | ||
| 753 | button end points." | ||
| 754 | (let ((widget (widget-convert type)) | ||
| 755 | (from (copy-marker from)) | ||
| 756 | (to (copy-marker to))) | ||
| 757 | (widget-specify-text from to) | ||
| 758 | (set-marker-insertion-type from t) | ||
| 759 | (set-marker-insertion-type to nil) | ||
| 760 | (widget-put widget :from from) | ||
| 761 | (widget-put widget :to to) | ||
| 762 | (when button-from | ||
| 763 | (widget-specify-button widget button-from button-to)) | ||
| 764 | widget)) | ||
| 765 | |||
| 766 | (defun widget-convert-button (type from to) | ||
| 767 | "Return a widget of type TYPE with endpoint FROM TO. | ||
| 768 | No text will be inserted to the buffer, instead the text between FROM | ||
| 769 | and TO will be used as the widgets end points, as well as the widgets | ||
| 770 | button end points." | ||
| 771 | (widget-convert-text type from to from to)) | ||
| 772 | |||
| 723 | ;;; Keymap and Commands. | 773 | ;;; Keymap and Commands. |
| 724 | 774 | ||
| 725 | (defvar widget-keymap nil | 775 | (defvar widget-keymap nil |
| @@ -783,7 +833,7 @@ Recommended as a parent keymap for modes using widgets.") | |||
| 783 | (t | 833 | (t |
| 784 | (:bold t :underline t))) | 834 | (:bold t :underline t))) |
| 785 | "Face used for pressed buttons." | 835 | "Face used for pressed buttons." |
| 786 | :group 'widgets) | 836 | :group 'widget-faces) |
| 787 | 837 | ||
| 788 | (defun widget-button-click (event) | 838 | (defun widget-button-click (event) |
| 789 | "Invoke button below mouse pointer." | 839 | "Invoke button below mouse pointer." |
| @@ -1017,7 +1067,8 @@ When not inside a field, move to the previous button or field." | |||
| 1017 | widget-field-list (cons field widget-field-list)) | 1067 | widget-field-list (cons field widget-field-list)) |
| 1018 | (let ((from (car (widget-get field :field-overlay))) | 1068 | (let ((from (car (widget-get field :field-overlay))) |
| 1019 | (to (cdr (widget-get field :field-overlay)))) | 1069 | (to (cdr (widget-get field :field-overlay)))) |
| 1020 | (widget-specify-field field from to) | 1070 | (widget-specify-field field |
| 1071 | (marker-position from) (marker-position to)) | ||
| 1021 | (set-marker from nil) | 1072 | (set-marker from nil) |
| 1022 | (set-marker to nil)))) | 1073 | (set-marker to nil)))) |
| 1023 | (widget-clear-undo) | 1074 | (widget-clear-undo) |
| @@ -1037,16 +1088,19 @@ When not inside a field, move to the previous button or field." | |||
| 1037 | 1088 | ||
| 1038 | (defun widget-field-buffer (widget) | 1089 | (defun widget-field-buffer (widget) |
| 1039 | "Return the start of WIDGET's editing field." | 1090 | "Return the start of WIDGET's editing field." |
| 1040 | (overlay-buffer (widget-get widget :field-overlay))) | 1091 | (let ((overlay (widget-get widget :field-overlay))) |
| 1092 | (and overlay (overlay-buffer overlay)))) | ||
| 1041 | 1093 | ||
| 1042 | (defun widget-field-start (widget) | 1094 | (defun widget-field-start (widget) |
| 1043 | "Return the start of WIDGET's editing field." | 1095 | "Return the start of WIDGET's editing field." |
| 1044 | (overlay-start (widget-get widget :field-overlay))) | 1096 | (let ((overlay (widget-get widget :field-overlay))) |
| 1097 | (and overlay (overlay-start overlay)))) | ||
| 1045 | 1098 | ||
| 1046 | (defun widget-field-end (widget) | 1099 | (defun widget-field-end (widget) |
| 1047 | "Return the end of WIDGET's editing field." | 1100 | "Return the end of WIDGET's editing field." |
| 1048 | ;; Don't subtract one if local-map works at the end of the overlay. | 1101 | (let ((overlay (widget-get widget :field-overlay))) |
| 1049 | (1- (overlay-end (widget-get widget :field-overlay)))) | 1102 | ;; Don't subtract one if local-map works at the end of the overlay. |
| 1103 | (and overlay (1- (overlay-end overlay))))) | ||
| 1050 | 1104 | ||
| 1051 | (defun widget-field-find (pos) | 1105 | (defun widget-field-find (pos) |
| 1052 | "Return the field at POS. | 1106 | "Return the field at POS. |
| @@ -1253,32 +1307,34 @@ If that does not exists, call the value of `widget-complete-field'." | |||
| 1253 | 1307 | ||
| 1254 | (defun widget-default-format-handler (widget escape) | 1308 | (defun widget-default-format-handler (widget escape) |
| 1255 | ;; We recognize the %h escape by default. | 1309 | ;; We recognize the %h escape by default. |
| 1256 | (let* ((buttons (widget-get widget :buttons)) | 1310 | (let* ((buttons (widget-get widget :buttons))) |
| 1257 | (doc-property (widget-get widget :documentation-property)) | ||
| 1258 | (doc-try (cond ((widget-get widget :doc)) | ||
| 1259 | ((symbolp doc-property) | ||
| 1260 | (documentation-property (widget-get widget :value) | ||
| 1261 | doc-property)) | ||
| 1262 | (t | ||
| 1263 | (funcall doc-property (widget-get widget :value))))) | ||
| 1264 | (doc-text (and (stringp doc-try) | ||
| 1265 | (> (length doc-try) 1) | ||
| 1266 | doc-try))) | ||
| 1267 | (cond ((eq escape ?h) | 1311 | (cond ((eq escape ?h) |
| 1268 | (when doc-text | 1312 | (let* ((doc-property (widget-get widget :documentation-property)) |
| 1269 | (and (eq (preceding-char) ?\n) | 1313 | (doc-try (cond ((widget-get widget :doc)) |
| 1270 | (widget-get widget :indent) | 1314 | ((symbolp doc-property) |
| 1271 | (insert-char ? (widget-get widget :indent))) | 1315 | (documentation-property |
| 1272 | ;; The `*' in the beginning is redundant. | 1316 | (widget-get widget :value) |
| 1273 | (when (eq (aref doc-text 0) ?*) | 1317 | doc-property)) |
| 1274 | (setq doc-text (substring doc-text 1))) | 1318 | (t |
| 1275 | ;; Get rid of trailing newlines. | 1319 | (funcall doc-property |
| 1276 | (when (string-match "\n+\\'" doc-text) | 1320 | (widget-get widget :value))))) |
| 1277 | (setq doc-text (substring doc-text 0 (match-beginning 0)))) | 1321 | (doc-text (and (stringp doc-try) |
| 1278 | (push (widget-create-child-and-convert | 1322 | (> (length doc-try) 1) |
| 1279 | widget 'documentation-string | 1323 | doc-try))) |
| 1280 | doc-text) | 1324 | (when doc-text |
| 1281 | buttons))) | 1325 | (and (eq (preceding-char) ?\n) |
| 1326 | (widget-get widget :indent) | ||
| 1327 | (insert-char ? (widget-get widget :indent))) | ||
| 1328 | ;; The `*' in the beginning is redundant. | ||
| 1329 | (when (eq (aref doc-text 0) ?*) | ||
| 1330 | (setq doc-text (substring doc-text 1))) | ||
| 1331 | ;; Get rid of trailing newlines. | ||
| 1332 | (when (string-match "\n+\\'" doc-text) | ||
| 1333 | (setq doc-text (substring doc-text 0 (match-beginning 0)))) | ||
| 1334 | (push (widget-create-child-and-convert | ||
| 1335 | widget 'documentation-string | ||
| 1336 | doc-text) | ||
| 1337 | buttons)))) | ||
| 1282 | (t | 1338 | (t |
| 1283 | (error "Unknown escape `%c'" escape))) | 1339 | (error "Unknown escape `%c'" escape))) |
| 1284 | (widget-put widget :buttons buttons))) | 1340 | (widget-put widget :buttons buttons))) |
| @@ -2476,7 +2532,7 @@ when he invoked the menu." | |||
| 2476 | (:foreground "dark green")) | 2532 | (:foreground "dark green")) |
| 2477 | (t nil)) | 2533 | (t nil)) |
| 2478 | "Face used for documentation text." | 2534 | "Face used for documentation text." |
| 2479 | :group 'widgets) | 2535 | :group 'widget-faces) |
| 2480 | 2536 | ||
| 2481 | (define-widget 'documentation-string 'item | 2537 | (define-widget 'documentation-string 'item |
| 2482 | "A documentation string." | 2538 | "A documentation string." |
| @@ -2488,11 +2544,11 @@ when he invoked the menu." | |||
| 2488 | (defun widget-documentation-string-value-create (widget) | 2544 | (defun widget-documentation-string-value-create (widget) |
| 2489 | ;; Insert documentation string. | 2545 | ;; Insert documentation string. |
| 2490 | (let ((doc (widget-value widget)) | 2546 | (let ((doc (widget-value widget)) |
| 2491 | (shown (widget-get (widget-get widget :parent) :documentation-shown))) | 2547 | (shown (widget-get (widget-get widget :parent) :documentation-shown)) |
| 2548 | (start (point))) | ||
| 2492 | (if (string-match "\n" doc) | 2549 | (if (string-match "\n" doc) |
| 2493 | (let ((before (substring doc 0 (match-beginning 0))) | 2550 | (let ((before (substring doc 0 (match-beginning 0))) |
| 2494 | (after (substring doc (match-beginning 0))) | 2551 | (after (substring doc (match-beginning 0))) |
| 2495 | (start (point)) | ||
| 2496 | buttons) | 2552 | buttons) |
| 2497 | (insert before " ") | 2553 | (insert before " ") |
| 2498 | (widget-specify-doc widget start (point)) | 2554 | (widget-specify-doc widget start (point)) |
| @@ -2507,7 +2563,8 @@ when he invoked the menu." | |||
| 2507 | (insert after) | 2563 | (insert after) |
| 2508 | (widget-specify-doc widget start (point))) | 2564 | (widget-specify-doc widget start (point))) |
| 2509 | (widget-put widget :buttons buttons)) | 2565 | (widget-put widget :buttons buttons)) |
| 2510 | (insert doc))) | 2566 | (insert doc) |
| 2567 | (widget-specify-doc widget start (point)))) | ||
| 2511 | (insert "\n")) | 2568 | (insert "\n")) |
| 2512 | 2569 | ||
| 2513 | (defun widget-documentation-string-action (widget &rest ignore) | 2570 | (defun widget-documentation-string-action (widget &rest ignore) |
| @@ -2666,6 +2723,41 @@ It will read a directory name from the minibuffer when invoked." | |||
| 2666 | :prompt-history 'widget-variable-prompt-value-history | 2723 | :prompt-history 'widget-variable-prompt-value-history |
| 2667 | :tag "Variable") | 2724 | :tag "Variable") |
| 2668 | 2725 | ||
| 2726 | (when (featurep 'mule) | ||
| 2727 | (defvar widget-coding-system-prompt-value-history nil | ||
| 2728 | "History of input to `widget-coding-system-prompt-value'.") | ||
| 2729 | |||
| 2730 | (define-widget 'coding-system 'symbol | ||
| 2731 | "A MULE coding-system." | ||
| 2732 | :format "%{%t%}: %v" | ||
| 2733 | :tag "Coding system" | ||
| 2734 | :prompt-history 'widget-coding-system-prompt-value-history | ||
| 2735 | :prompt-value 'widget-coding-system-prompt-value | ||
| 2736 | :action 'widget-coding-system-action) | ||
| 2737 | |||
| 2738 | (defun widget-coding-system-prompt-value (widget prompt value unbound) | ||
| 2739 | ;; Read coding-system from minibuffer. | ||
| 2740 | (intern | ||
| 2741 | (completing-read (format "%s (default %s) " prompt value) | ||
| 2742 | (mapcar (function | ||
| 2743 | (lambda (sym) | ||
| 2744 | (list (symbol-name sym)) | ||
| 2745 | )) | ||
| 2746 | (coding-system-list))))) | ||
| 2747 | |||
| 2748 | (defun widget-coding-system-action (widget &optional event) | ||
| 2749 | ;; Read a file name from the minibuffer. | ||
| 2750 | (let ((answer | ||
| 2751 | (widget-coding-system-prompt-value | ||
| 2752 | widget | ||
| 2753 | (widget-apply widget :menu-tag-get) | ||
| 2754 | (widget-value widget) | ||
| 2755 | t))) | ||
| 2756 | (widget-value-set widget answer) | ||
| 2757 | (widget-apply widget :notify widget event) | ||
| 2758 | (widget-setup))) | ||
| 2759 | ) | ||
| 2760 | |||
| 2669 | (define-widget 'sexp 'editable-field | 2761 | (define-widget 'sexp 'editable-field |
| 2670 | "An arbitrary lisp expression." | 2762 | "An arbitrary lisp expression." |
| 2671 | :tag "Lisp expression" | 2763 | :tag "Lisp expression" |