Mercurial > emacs
comparison lisp/cus-edit.el @ 18244:909a0f9169b8
Synched with 1.9914.
author | Per Abrahamsen <abraham@dina.kvl.dk> |
---|---|
date | Sat, 14 Jun 1997 10:21:01 +0000 |
parents | ee3c0d09dcd3 |
children | e83bc8150072 |
comparison
equal
deleted
inserted
replaced
18243:7ebbc72852df | 18244:909a0f9169b8 |
---|---|
2 ;; | 2 ;; |
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. |
4 ;; | 4 ;; |
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | 5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> |
6 ;; Keywords: help, faces | 6 ;; Keywords: help, faces |
7 ;; Version: 1.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. |
11 | 11 |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
243 | 243 |
244 (defgroup custom-faces nil | 244 (defgroup custom-faces nil |
245 "Faces used by customize." | 245 "Faces used by customize." |
246 :group 'customize | 246 :group 'customize |
247 :group 'faces) | 247 :group 'faces) |
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) | |
248 | 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) |
252 | 262 |
399 (defvar custom-prefix-list nil | 409 (defvar custom-prefix-list nil |
400 "List of prefixes that should be ignored by `custom-unlispify'") | 410 "List of prefixes that should be ignored by `custom-unlispify'") |
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) |
408 "Convert symbol into a menu entry." | 418 "Convert symbol into a menu entry." |
409 (cond ((not custom-unlispify-menu-entries) | 419 (cond ((not custom-unlispify-menu-entries) |
438 (insert "...")) | 448 (insert "...")) |
439 (buffer-string))))) | 449 (buffer-string))))) |
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) |
447 "Convert symbol into a menu entry." | 457 "Convert symbol into a menu entry." |
448 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names)) | 458 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names)) |
516 docs nil)))))) | 526 docs nil)))))) |
517 found)) | 527 found)) |
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) | 548 |
538 (not (eq (nth 1 a) 'custom-group))) | 549 (defcustom custom-menu-sort-predicate 'ignore |
539 t) | |
540 (t | |
541 (string-lessp (symbol-name (nth 0 a)) (symbol-name (nth 0 b)))))) | |
542 | |
543 (defcustom custom-menu-sort-predicate 'custom-menu-sort-alphabetically | |
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 |
567 (defvar custom-options nil | 587 (defvar custom-options nil |
568 "Customization widgets in the current buffer.") | 588 "Customization widgets in the current buffer.") |
895 | 915 |
896 (defcustom custom-reset-button-menu nil | 916 (defcustom custom-reset-button-menu nil |
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...") |
904 (custom-mode) | 924 (custom-mode) |
905 (widget-insert "This is a customization buffer. | 925 (widget-insert "This is a customization buffer. |
1015 :help-echo "Read the manual entry for this option." | 1035 :help-echo "Read the manual entry for this option." |
1016 :tag "Manual") | 1036 :tag "Manual") |
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.") |
1055 (unknown "?" italic "\ | 1086 (unknown "?" italic "\ |
1056 unknown, you should not see this.") | 1087 unknown, you should not see this.") |
1121 "If non-nil, show textual description of the state. | 1152 "If non-nil, show textual description of the state. |
1122 If non-nil and not the symbol `long', only show first word." | 1153 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. |
1130 The value should be a list with the custom categories where the state | 1161 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." |
1143 :format "%v" | 1174 :format "%v" |
1144 :action 'widget-parent-action | 1175 :action 'widget-parent-action |
2174 (unless (eq state 'hidden) | 2205 (unless (eq state 'hidden) |
2175 (message "Creating group...") | 2206 (message "Creating group...") |
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)) |
2184 (count 0) | 2216 (count 0) |
2185 (children (mapcar (lambda (entry) | 2217 (children (mapcar (lambda (entry) |
2197 :custom-level (1+ level) | 2229 :custom-level (1+ level) |
2198 :value (nth 0 entry)) | 2230 :value (nth 0 entry)) |
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...") |
2206 (widget-put widget :children children) | 2237 (widget-put widget :children children) |
2207 (custom-group-state-update widget) | 2238 (custom-group-state-update widget) |
2463 (cons (car menu) map)))))) | 2494 (cons (car menu) map)))))) |
2464 | 2495 |
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." |
2472 (vector (custom-unlispify-menu-entry symbol) | 2503 (vector (custom-unlispify-menu-entry symbol) |
2473 `(customize-face ',symbol) | 2504 `(customize-face ',symbol) |
2516 (if (and (or (not (boundp 'custom-menu-nesting)) | 2547 (if (and (or (not (boundp 'custom-menu-nesting)) |
2517 (>= custom-menu-nesting 0)) | 2548 (>= custom-menu-nesting 0)) |
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 |
2527 "--" | 2558 "--" |
2528 ,@(mapcar (lambda (entry) | 2559 ,@(mapcar (lambda (entry) |
2577 ["Info" (Info-goto-node "(custom)The Customization Buffer") t])) | 2608 ["Info" (Info-goto-node "(custom)The Customization Buffer") t])) |
2578 | 2609 |
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. |
2586 | 2617 |
2587 The following commands are available: | 2618 The following commands are available: |