annotate lisp/gnus/custom-edit.el @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1 ;;; custom-edit.el --- Tools for customization Emacs.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
2 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
4 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
6 ;; Keywords: help, faces
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
7 ;; Version: 1.20
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
9
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
10 ;;; Commentary:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
11 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
12 ;; See `custom.el'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
13
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
14 ;;; Code:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
15
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
16 (require 'custom)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
17 (require 'widget-edit)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
18 (require 'easymenu)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
19
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
20 (define-widget-keywords :custom-prefixes :custom-menu :custom-show
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
21 :custom-magic :custom-state :custom-level :custom-form
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
22 :custom-set :custom-save :custom-reset-current :custom-reset-saved
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
23 :custom-reset-factory)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
24
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
25 ;;; Utilities.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
26
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
27 (defun custom-quote (sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
28 "Quote SEXP iff it is not self quoting."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
29 (if (or (memq sexp '(t nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
30 (and (symbolp sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
31 (eq (aref (symbol-name sexp) 0) ?:))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
32 (and (listp sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
33 (memq (car sexp) '(lambda)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
34 (stringp sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
35 (numberp sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
36 (and (fboundp 'characterp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
37 (funcall (intern "characterp") sexp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
38 sexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
39 (list 'quote sexp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
40
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
41 (defun custom-split-regexp-maybe (regexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
42 "If REGEXP is a string, split it to a list at `\\|'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
43 You can get the original back with from the result with:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
44 (mapconcat 'identity result \"\\|\")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
45
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
46 IF REGEXP is not a string, return it unchanged."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
47 (if (stringp regexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
48 (let ((start 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
49 all)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
50 (while (string-match "\\\\|" regexp start)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
51 (setq all (cons (substring regexp start (match-beginning 0)) all)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
52 start (match-end 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
53 (nreverse (cons (substring regexp start) all)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
54 regexp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
55
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
56 (defvar custom-prefix-list nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
57 "List of prefixes that should be ignored by `custom-unlispify'")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
58
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
59 (defcustom custom-unlispify-menu-entries t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
60 "Display menu entries as words instead of symbols if non nil."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
61 :group 'customize
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
62 :type 'boolean)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
63
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
64 (defun custom-unlispify-menu-entry (symbol &optional no-suffix)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
65 "Convert symbol into a menu entry."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
66 (cond ((not custom-unlispify-menu-entries)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
67 (symbol-name symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
68 ((get symbol 'custom-tag)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
69 (if no-suffix
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
70 (get symbol 'custom-tag)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
71 (concat (get symbol 'custom-tag) "...")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
72 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
73 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
74 (set-buffer (get-buffer-create " *Custom-Work*"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
75 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
76 (princ symbol (current-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
77 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
78 (let ((prefixes custom-prefix-list)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
79 prefix)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
80 (while prefixes
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
81 (setq prefix (car prefixes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
82 (if (search-forward prefix (+ (point) (length prefix)) t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
83 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
84 (setq prefixes nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
85 (delete-region (point-min) (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
86 (setq prefixes (cdr prefixes)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
87 (subst-char-in-region (point-min) (point-max) ?- ?\ t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
88 (capitalize-region (point-min) (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
89 (unless no-suffix
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
90 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
91 (insert "..."))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
92 (buffer-string)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
93
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
94 (defcustom custom-unlispify-tag-names t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
95 "Display tag names as words instead of symbols if non nil."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
96 :group 'customize
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
97 :type 'boolean)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
98
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
99 (defun custom-unlispify-tag-name (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
100 "Convert symbol into a menu entry."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
101 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
102 (custom-unlispify-menu-entry symbol t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
103
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
104 (defun custom-prefix-add (symbol prefixes)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
105 ;; Addd SYMBOL to list of ignored PREFIXES.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
106 (cons (or (get symbol 'custom-prefix)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
107 (concat (symbol-name symbol) "-"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
108 prefixes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
109
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
110 ;;; The Custom Mode.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
111
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
112 (defvar custom-options nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
113 "Customization widgets in the current buffer.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
114
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
115 (defvar custom-mode-map nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
116 "Keymap for `custom-mode'.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
117
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
118 (unless custom-mode-map
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
119 (setq custom-mode-map (make-sparse-keymap))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
120 (set-keymap-parent custom-mode-map widget-keymap))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
121
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
122 (easy-menu-define custom-mode-menu
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
123 custom-mode-map
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
124 "Menu used in customization buffers."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
125 '("Custom"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
126 ["Set" custom-set t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
127 ["Save" custom-save t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
128 ["Reset to Current" custom-reset-current t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
129 ["Reset to Saved" custom-reset-saved t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
130 ["Reset to Factory Settings" custom-reset-factory t]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
131 ["Info" (Info-goto-node "(custom)The Customization Buffer") t]))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
132
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
133 (defcustom custom-mode-hook nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
134 "Hook called when entering custom-mode."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
135 :type 'hook
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
136 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
137
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
138 (defun custom-mode ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
139 "Major mode for editing customization buffers.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
140
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
141 The following commands are available:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
142
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
143 \\[widget-forward] Move to next button or editable field.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
144 \\[widget-backward] Move to previous button or editable field.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
145 \\[widget-button-click] Activate button under the mouse pointer.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
146 \\[widget-button-press] Activate button under point.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
147 \\[custom-set] Set all modifications.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
148 \\[custom-save] Make all modifications default.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
149 \\[custom-reset-current] Reset all modified options.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
150 \\[custom-reset-saved] Reset all modified or set options.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
151 \\[custom-reset-factory] Reset all options.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
152
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
153 Entry to this mode calls the value of `custom-mode-hook'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
154 if that value is non-nil."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
155 (kill-all-local-variables)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
156 (setq major-mode 'custom-mode
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
157 mode-name "Custom")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
158 (use-local-map custom-mode-map)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
159 (make-local-variable 'custom-options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
160 (run-hooks 'custom-mode-hook))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
161
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
162 ;;; Custom Mode Commands.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
163
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
164 (defun custom-set ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
165 "Set changes in all modified options."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
166 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
167 (let ((children custom-options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
168 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
169 (when (eq (widget-get child :custom-state) 'modified)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
170 (widget-apply child :custom-set)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
171 children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
172
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
173 (defun custom-save ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
174 "Set all modified group members and save them."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
175 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
176 (let ((children custom-options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
177 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
178 (when (memq (widget-get child :custom-state) '(modified set))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
179 (widget-apply child :custom-save)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
180 children))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
181 (custom-save-all))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
182
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
183 (defvar custom-reset-menu
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
184 '(("Current" . custom-reset-current)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
185 ("Saved" . custom-reset-saved)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
186 ("Factory Settings" . custom-reset-factory))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
187 "Alist of actions for the `Reset' button.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
188 The key is a string containing the name of the action, the value is a
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
189 lisp function taking the widget as an element which will be called
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
190 when the action is chosen.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
191
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
192 (defun custom-reset (event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
193 "Select item from reset menu."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
194 (let* ((completion-ignore-case t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
195 (answer (widget-choose "Reset to"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
196 custom-reset-menu
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
197 event)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
198 (if answer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
199 (funcall answer))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
200
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
201 (defun custom-reset-current ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
202 "Reset all modified group members to their current value."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
203 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
204 (let ((children custom-options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
205 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
206 (when (eq (widget-get child :custom-state) 'modified)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
207 (widget-apply child :custom-reset-current)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
208 children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
209
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
210 (defun custom-reset-saved ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
211 "Reset all modified or set group members to their saved value."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
212 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
213 (let ((children custom-options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
214 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
215 (when (eq (widget-get child :custom-state) 'modified)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
216 (widget-apply child :custom-reset-current)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
217 children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
218
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
219 (defun custom-reset-factory ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
220 "Reset all modified, set, or saved group members to their factory settings."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
221 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
222 (let ((children custom-options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
223 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
224 (when (eq (widget-get child :custom-state) 'modified)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
225 (widget-apply child :custom-reset-current)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
226 children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
227
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
228 ;;; The Customize Commands
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
229
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
230 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
231 (defun customize (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
232 "Customize SYMBOL, which must be a customization group."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
233 (interactive (list (completing-read "Customize group: (default emacs) "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
234 obarray
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
235 (lambda (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
236 (get symbol 'custom-group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
237 t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
238
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
239 (when (stringp symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
240 (if (string-equal "" symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
241 (setq symbol 'emacs)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
242 (setq symbol (intern symbol))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
243 (custom-buffer-create (list (list symbol 'custom-group))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
244
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
245 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
246 (defun customize-variable (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
247 "Customize SYMBOL, which must be a variable."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
248 (interactive
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
249 ;; Code stolen from `help.el'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
250 (let ((v (variable-at-point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
251 (enable-recursive-minibuffers t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
252 val)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
253 (setq val (completing-read
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
254 (if v
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
255 (format "Customize variable (default %s): " v)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
256 "Customize variable: ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
257 obarray 'boundp t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
258 (list (if (equal val "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
259 v (intern val)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
260 (custom-buffer-create (list (list symbol 'custom-variable))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
261
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
262 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
263 (defun customize-face (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
264 "Customize FACE."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
265 (interactive (list (completing-read "Customize face: "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
266 obarray 'custom-facep)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
267 (if (stringp symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
268 (setq symbol (intern symbol)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
269 (unless (symbolp symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
270 (error "Should be a symbol %S" symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
271 (custom-buffer-create (list (list symbol 'custom-face))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
272
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
273 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
274 (defun customize-customized ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
275 "Customize all already customized user options."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
276 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
277 (let ((found nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
278 (mapatoms (lambda (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
279 (and (get symbol 'saved-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
280 (custom-facep symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
281 (setq found (cons (list symbol 'custom-face) found)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
282 (and (get symbol 'saved-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
283 (boundp symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
284 (setq found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
285 (cons (list symbol 'custom-variable) found)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
286 (if found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
287 (custom-buffer-create found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
288 (error "No customized user options"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
289
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
290 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
291 (defun customize-apropos (regexp &optional all)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
292 "Customize all user options matching REGEXP.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
293 If ALL (e.g., started with a prefix key), include options which are not
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
294 user-settable."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
295 (interactive "sCustomize regexp: \nP")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
296 (let ((found nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
297 (mapatoms (lambda (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
298 (when (string-match regexp (symbol-name symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
299 (when (get symbol 'custom-group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
300 (setq found (cons (list symbol 'custom-group) found)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
301 (when (custom-facep symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
302 (setq found (cons (list symbol 'custom-face) found)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
303 (when (and (boundp symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
304 (or (get symbol 'saved-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
305 (get symbol 'factory-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
306 (if all
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
307 (get symbol 'variable-documentation)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
308 (user-variable-p symbol))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
309 (setq found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
310 (cons (list symbol 'custom-variable) found))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
311 (if found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
312 (custom-buffer-create found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
313 (error "No matches"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
314
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
315 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
316 (defun custom-buffer-create (options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
317 "Create a buffer containing OPTIONS.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
318 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
319 SYMBOL is a customization option, and WIDGET is a widget for editing
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
320 that option."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
321 (kill-buffer (get-buffer-create "*Customization*"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
322 (switch-to-buffer (get-buffer-create "*Customization*"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
323 (custom-mode)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
324 (widget-insert "This is a customization buffer.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
325 Push RET or click mouse-2 on the word ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
326 (widget-create 'info-link
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
327 :tag "help"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
328 :help-echo "Push me for help."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
329 "(custom)The Customization Buffer")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
330 (widget-insert " for more information.\n\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
331 (setq custom-options
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
332 (mapcar (lambda (entry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
333 (prog1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
334 (if (> (length options) 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
335 (widget-create (nth 1 entry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
336 :tag (custom-unlispify-tag-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
337 (nth 0 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
338 :value (nth 0 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
339 ;; If there is only one entry, don't hide it!
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
340 (widget-create (nth 1 entry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
341 :custom-state 'unknown
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
342 :tag (custom-unlispify-tag-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
343 (nth 0 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
344 :value (nth 0 entry)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
345 (unless (eq (preceding-char) ?\n)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
346 (widget-insert "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
347 (widget-insert "\n")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
348 options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
349 (mapcar 'custom-magic-reset custom-options)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
350 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
351 :tag "Set"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
352 :help-echo "Push me to set all modifications."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
353 :action (lambda (widget &optional event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
354 (custom-set)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
355 (widget-insert " ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
356 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
357 :tag "Save"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
358 :help-echo "Push me to make the modifications default."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
359 :action (lambda (widget &optional event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
360 (custom-save)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
361 (widget-insert " ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
362 (widget-create 'push-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
363 :tag "Reset"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
364 :help-echo "Push me to undo all modifications.."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
365 :action (lambda (widget &optional event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
366 (custom-reset event)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
367 (widget-insert "\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
368 (widget-setup))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
369
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
370 ;;; Modification of Basic Widgets.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
371 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
372 ;; We add extra properties to the basic widgets needed here. This is
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
373 ;; fine, as long as we are careful to stay within out own namespace.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
374 ;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
375 ;; We want simple widgets to be displayed by default, but complex
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
376 ;; widgets to be hidden.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
377
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
378 (widget-put (get 'item 'widget-type) :custom-show t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
379 (widget-put (get 'editable-field 'widget-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
380 :custom-show (lambda (widget value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
381 (let ((pp (pp-to-string value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
382 (cond ((string-match "\n" pp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
383 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
384 ((> (length pp) 40)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
385 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
386 (t t)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
387 (widget-put (get 'menu-choice 'widget-type) :custom-show t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
388
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
389 ;;; The `custom-manual' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
390
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
391 (define-widget 'custom-manual 'info-link
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
392 "Link to the manual entry for this customization option."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
393 :help-echo "Push me to read the manual."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
394 :tag "Manual")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
395
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
396 ;;; The `custom-magic' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
397
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
398 (defface custom-invalid-face '((((class color))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
399 (:foreground "yellow" :background "red"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
400 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
401 (:bold t :italic t :underline t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
402 "Face used when the customize item is invalid.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
403
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
404 (defface custom-rogue-face '((((class color))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
405 (:foreground "pink" :background "black"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
406 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
407 (:underline t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
408 "Face used when the customize item is not defined for customization.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
409
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
410 (defface custom-modified-face '((((class color))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
411 (:foreground "white" :background "blue"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
412 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
413 (:italic t :bold)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
414 "Face used when the customize item has been modified.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
415
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
416 (defface custom-set-face '((((class color))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
417 (:foreground "blue" :background "white"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
418 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
419 (:italic t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
420 "Face used when the customize item has been set.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
421
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
422 (defface custom-changed-face '((((class color))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
423 (:foreground "white" :background "blue"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
424 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
425 (:italic t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
426 "Face used when the customize item has been changed.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
427
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
428 (defface custom-saved-face '((t (:underline t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
429 "Face used when the customize item has been saved.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
430
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
431 (defcustom custom-magic-alist '((nil "#" underline "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
432 uninitialized, you should not see this.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
433 (unknown "?" italic "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
434 unknown, you should not see this.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
435 (hidden "-" default "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
436 hidden, press the state button to show.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
437 (invalid "x" custom-invalid-face "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
438 the value displayed for this item is invalid and cannot be set.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
439 (modified "*" custom-modified-face "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
440 you have edited the item, and can now set it.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
441 (set "+" custom-set-face "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
442 you have set this item, but not saved it.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
443 (changed ":" custom-changed-face "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
444 this item has been changed outside customize.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
445 (saved "!" custom-saved-face "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
446 this item has been saved.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
447 (rogue "@" custom-rogue-face "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
448 this item is not prepared for customization.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
449 (factory " " nil "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
450 this item is unchanged from its factory setting."))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
451 "Alist of customize option states.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
452 Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
453
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
454 STATE is one of the following symbols:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
455
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
456 `nil'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
457 For internal use, should never occur.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
458 `unknown'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
459 For internal use, should never occur.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
460 `hidden'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
461 This item is not being displayed.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
462 `invalid'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
463 This item is modified, but has an invalid form.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
464 `modified'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
465 This item is modified, and has a valid form.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
466 `set'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
467 This item has been set but not saved.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
468 `changed'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
469 The current value of this item has been changed temporarily.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
470 `saved'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
471 This item is marked for saving.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
472 `rogue'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
473 This item has no customization information.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
474 `factory'
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
475 This item is unchanged from the factory default.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
476
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
477 MAGIC is a string used to present that state.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
478
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
479 FACE is a face used to present the state.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
480
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
481 DESCRIPTION is a string describing the state.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
482
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
483 The list should be sorted most significant first."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
484 :type '(list (checklist :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
485 (group (const nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
486 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
487 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
488 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
489 (group (const unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
490 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
491 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
492 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
493 (group (const hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
494 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
495 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
496 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
497 (group (const invalid)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
498 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
499 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
500 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
501 (group (const modified)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
502 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
503 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
504 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
505 (group (const set)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
506 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
507 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
508 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
509 (group (const changed)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
510 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
511 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
512 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
513 (group (const saved)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
514 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
515 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
516 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
517 (group (const rogue)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
518 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
519 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
520 (string :tag "Description"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
521 (group (const factory)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
522 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
523 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
524 (string :tag "Description")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
525 (editable-list :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
526 (group symbol
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
527 (string :tag "Magic")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
528 face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
529 (string :tag "Description"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
530 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
531
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
532 (defcustom custom-magic-show 'long
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
533 "Show long description of the state of each customization option."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
534 :type '(choice (const :tag "no" nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
535 (const short)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
536 (const long))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
537 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
538
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
539 (defcustom custom-magic-show-button t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
540 "Show a magic button indicating the state of each customization option."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
541 :type 'boolean
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
542 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
543
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
544 (define-widget 'custom-magic 'default
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
545 "Show and manipulate state for a customization option."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
546 :format "%v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
547 :action 'widget-choice-item-action
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
548 :value-get 'ignore
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
549 :value-create 'custom-magic-value-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
550 :value-delete 'widget-children-value-delete)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
551
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
552 (defun custom-magic-value-create (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
553 ;; Create compact status report for WIDGET.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
554 (let* ((parent (widget-get widget :parent))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
555 (state (widget-get parent :custom-state))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
556 (entry (assq state custom-magic-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
557 (magic (nth 1 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
558 (face (nth 2 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
559 (text (nth 3 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
560 (lisp (eq (widget-get parent :custom-form) 'lisp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
561 children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
562 (when custom-magic-show
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
563 (push (widget-create-child-and-convert widget 'choice-item
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
564 :help-echo "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
565 Push me to change the state of this item."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
566 :format "%[%t%]"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
567 :tag "State")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
568 children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
569 (insert ": ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
570 (if (eq custom-magic-show 'long)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
571 (insert text)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
572 (insert (symbol-name state)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
573 (when lisp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
574 (insert " (lisp)"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
575 (insert "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
576 (when custom-magic-show-button
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
577 (when custom-magic-show
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
578 (let ((indent (widget-get parent :indent)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
579 (when indent
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
580 (insert-char ? indent))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
581 (push (widget-create-child-and-convert widget 'choice-item
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
582 :button-face face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
583 :help-echo "\
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
584 Push me to change the state."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
585 :format "%[%t%]"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
586 :tag (if lisp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
587 (concat "(" magic ")")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
588 (concat "[" magic "]")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
589 children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
590 (insert " "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
591 (widget-put widget :children children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
592
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
593 (defun custom-magic-reset (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
594 "Redraw the :custom-magic property of WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
595 (let ((magic (widget-get widget :custom-magic)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
596 (widget-value-set magic (widget-value magic))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
597
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
598 ;;; The `custom-level' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
599
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
600 (define-widget 'custom-level 'item
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
601 "The custom level buttons."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
602 :format "%[%t%]"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
603 :help-echo "Push me to expand or collapse this item."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
604 :action 'custom-level-action)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
605
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
606 (defun custom-level-action (widget &optional event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
607 "Toggle visibility for parent to WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
608 (let* ((parent (widget-get widget :parent))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
609 (state (widget-get parent :custom-state)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
610 (cond ((memq state '(invalid modified))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
611 (error "There are unset changes"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
612 ((eq state 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
613 (widget-put parent :custom-state 'unknown))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
614 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
615 (widget-put parent :custom-state 'hidden)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
616 (custom-redraw parent)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
617
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
618 ;;; The `custom' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
619
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
620 (define-widget 'custom 'default
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
621 "Customize a user option."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
622 :convert-widget 'custom-convert-widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
623 :format "%l%[%t%]: %v%m%h%a"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
624 :format-handler 'custom-format-handler
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
625 :notify 'custom-notify
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
626 :custom-level 1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
627 :custom-state 'hidden
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
628 :documentation-property 'widget-subclass-responsibility
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
629 :value-create 'widget-subclass-responsibility
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
630 :value-delete 'widget-children-value-delete
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
631 :value-get 'widget-item-value-get
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
632 :validate 'widget-editable-list-validate
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
633 :match (lambda (widget value) (symbolp value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
634
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
635 (defun custom-convert-widget (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
636 ;; Initialize :value and :tag from :args in WIDGET.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
637 (let ((args (widget-get widget :args)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
638 (when args
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
639 (widget-put widget :value (widget-apply widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
640 :value-to-internal (car args)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
641 (widget-put widget :tag (custom-unlispify-tag-name (car args)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
642 (widget-put widget :args nil)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
643 widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
644
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
645 (defun custom-format-handler (widget escape)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
646 ;; We recognize extra escape sequences.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
647 (let* ((buttons (widget-get widget :buttons))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
648 (state (widget-get widget :custom-state))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
649 (level (widget-get widget :custom-level)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
650 (cond ((eq escape ?l)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
651 (when level
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
652 (push (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
653 widget 'custom-level (make-string level ?*))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
654 buttons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
655 (widget-insert " ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
656 (widget-put widget :buttons buttons)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
657 ((eq escape ?L)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
658 (when (eq state 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
659 (widget-insert " ...")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
660 ((eq escape ?m)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
661 (and (eq (preceding-char) ?\n)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
662 (widget-get widget :indent)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
663 (insert-char ? (widget-get widget :indent)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
664 (let ((magic (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
665 widget 'custom-magic nil)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
666 (widget-put widget :custom-magic magic)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
667 (push magic buttons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
668 (widget-put widget :buttons buttons)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
669 ((eq escape ?a)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
670 (let* ((symbol (widget-get widget :value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
671 (links (get symbol 'custom-links))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
672 (many (> (length links) 2)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
673 (when links
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
674 (and (eq (preceding-char) ?\n)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
675 (widget-get widget :indent)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
676 (insert-char ? (widget-get widget :indent)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
677 (insert "See also ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
678 (while links
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
679 (push (widget-create-child-and-convert widget (car links))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
680 buttons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
681 (setq links (cdr links))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
682 (cond ((null links)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
683 (insert ".\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
684 ((null (cdr links))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
685 (if many
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
686 (insert ", and ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
687 (insert " and ")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
688 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
689 (insert ", "))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
690 (widget-put widget :buttons buttons))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
691 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
692 (widget-default-format-handler widget escape)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
693
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
694 (defun custom-notify (widget &rest args)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
695 "Keep track of changes."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
696 (widget-put widget :custom-state 'modified)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
697 (let ((buffer-undo-list t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
698 (custom-magic-reset widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
699 (apply 'widget-default-notify widget args))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
700
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
701 (defun custom-redraw (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
702 "Redraw WIDGET with current settings."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
703 (widget-value-set widget (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
704 (custom-redraw-magic widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
705
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
706 (defun custom-redraw-magic (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
707 "Redraw WIDGET state with current settings."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
708 (while widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
709 (let ((magic (widget-get widget :custom-magic)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
710 (unless magic
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
711 (debug))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
712 (widget-value-set magic (widget-value magic))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
713 (when (setq widget (widget-get widget :group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
714 (custom-group-state-update widget))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
715 (widget-setup))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
716
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
717 (defun custom-show (widget value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
718 "Non-nil if WIDGET should be shown with VALUE by default."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
719 (let ((show (widget-get widget :custom-show)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
720 (cond ((null show)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
721 nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
722 ((eq t show)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
723 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
724 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
725 (funcall show widget value)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
726
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
727 (defun custom-load-symbol (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
728 "Load all dependencies for SYMBOL."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
729 (let ((loads (get symbol 'custom-loads))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
730 load)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
731 (while loads
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
732 (setq load (car loads)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
733 loads (cdr loads))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
734 (cond ((symbolp load)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
735 (condition-case nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
736 (require load)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
737 (error nil)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
738 ((assoc load load-history))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
739 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
740 (condition-case nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
741 (load-library load)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
742 (error nil)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
743
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
744 (defun custom-load-widget (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
745 "Load all dependencies for WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
746 (custom-load-symbol (widget-value widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
747
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
748 ;;; The `custom-variable' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
749
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
750 (defface custom-variable-sample-face '((t (:underline t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
751 "Face used for unpushable variable tags."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
752 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
753
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
754 (defface custom-variable-button-face '((t (:underline t :bold t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
755 "Face used for pushable variable tags."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
756 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
757
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
758 (define-widget 'custom-variable 'custom
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
759 "Customize variable."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
760 :format "%l%v%m%h%a"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
761 :help-echo "Push me to set or reset this variable."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
762 :documentation-property 'variable-documentation
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
763 :custom-state nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
764 :custom-menu 'custom-variable-menu-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
765 :custom-form 'edit
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
766 :value-create 'custom-variable-value-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
767 :action 'custom-variable-action
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
768 :custom-set 'custom-variable-set
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
769 :custom-save 'custom-variable-save
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
770 :custom-reset-current 'custom-redraw
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
771 :custom-reset-saved 'custom-variable-reset-saved
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
772 :custom-reset-factory 'custom-variable-reset-factory)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
773
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
774 (defun custom-variable-value-create (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
775 "Here is where you edit the variables value."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
776 (custom-load-widget widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
777 (let* ((buttons (widget-get widget :buttons))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
778 (children (widget-get widget :children))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
779 (form (widget-get widget :custom-form))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
780 (state (widget-get widget :custom-state))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
781 (symbol (widget-get widget :value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
782 (options (get symbol 'custom-options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
783 (child-type (or (get symbol 'custom-type) 'sexp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
784 (tag (widget-get widget :tag))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
785 (type (let ((tmp (if (listp child-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
786 (copy-list child-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
787 (list child-type))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
788 (when options
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
789 (widget-put tmp :options options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
790 tmp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
791 (conv (widget-convert type))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
792 (value (if (default-boundp symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
793 (default-value symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
794 (widget-get conv :value))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
795 ;; If the widget is new, the child determine whether it is hidden.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
796 (cond (state)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
797 ((custom-show type value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
798 (setq state 'unknown))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
799 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
800 (setq state 'hidden)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
801 ;; If we don't know the state, see if we need to edit it in lisp form.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
802 (when (eq state 'unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
803 (unless (widget-apply conv :match value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
804 ;; (widget-apply (widget-convert type) :match value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
805 (setq form 'lisp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
806 ;; Now we can create the child widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
807 (cond ((eq state 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
808 ;; Indicate hidden value.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
809 (push (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
810 widget 'item
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
811 :format "%{%t%}: ..."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
812 :sample-face 'custom-variable-sample-face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
813 :tag tag
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
814 :parent widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
815 children))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
816 ((eq form 'lisp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
817 ;; In lisp mode edit the saved value when possible.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
818 (let* ((value (cond ((get symbol 'saved-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
819 (car (get symbol 'saved-value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
820 ((get symbol 'factory-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
821 (car (get symbol 'factory-value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
822 ((default-boundp symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
823 (custom-quote (default-value symbol)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
824 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
825 (custom-quote (widget-get conv :value))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
826 (push (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
827 widget 'sexp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
828 :button-face 'custom-variable-button-face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
829 :tag (symbol-name symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
830 :parent widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
831 :value value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
832 children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
833 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
834 ;; Edit mode.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
835 (push (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
836 widget type
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
837 :tag tag
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
838 :button-face 'custom-variable-button-face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
839 :sample-face 'custom-variable-sample-face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
840 :value value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
841 children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
842 ;; Now update the state.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
843 (unless (eq (preceding-char) ?\n)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
844 (widget-insert "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
845 (if (eq state 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
846 (widget-put widget :custom-state state)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
847 (custom-variable-state-set widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
848 (widget-put widget :custom-form form)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
849 (widget-put widget :buttons buttons)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
850 (widget-put widget :children children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
851
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
852 (defun custom-variable-state-set (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
853 "Set the state of WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
854 (let* ((symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
855 (value (if (default-boundp symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
856 (default-value symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
857 (widget-get widget :value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
858 tmp
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
859 (state (cond ((setq tmp (get symbol 'customized-value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
860 (if (condition-case nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
861 (equal value (eval (car tmp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
862 (error nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
863 'saved
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
864 'set))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
865 ((setq tmp (get symbol 'saved-value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
866 (if (condition-case nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
867 (equal value (eval (car tmp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
868 (error nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
869 'saved
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
870 'set))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
871 ((setq tmp (get symbol 'factory-value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
872 (if (condition-case nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
873 (equal value (eval (car tmp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
874 (error nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
875 'factory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
876 'set))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
877 (t 'rogue))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
878 (widget-put widget :custom-state state)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
879
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
880 (defvar custom-variable-menu
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
881 '(("Edit" . custom-variable-edit)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
882 ("Edit Lisp" . custom-variable-edit-lisp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
883 ("Set" . custom-variable-set)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
884 ("Save" . custom-variable-save)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
885 ("Reset to Current" . custom-redraw)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
886 ("Reset to Saved" . custom-variable-reset-saved)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
887 ("Reset to Factory Settings" . custom-variable-reset-factory))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
888 "Alist of actions for the `custom-variable' widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
889 The key is a string containing the name of the action, the value is a
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
890 lisp function taking the widget as an element which will be called
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
891 when the action is chosen.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
892
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
893 (defun custom-variable-action (widget &optional event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
894 "Show the menu for `custom-variable' WIDGET.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
895 Optional EVENT is the location for the menu."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
896 (if (eq (widget-get widget :custom-state) 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
897 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
898 (widget-put widget :custom-state 'unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
899 (custom-redraw widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
900 (let* ((completion-ignore-case t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
901 (answer (widget-choose (symbol-name (widget-get widget :value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
902 custom-variable-menu
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
903 event)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
904 (if answer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
905 (funcall answer widget)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
906
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
907 (defun custom-variable-edit (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
908 "Edit value of WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
909 (widget-put widget :custom-state 'unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
910 (widget-put widget :custom-form 'edit)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
911 (custom-redraw widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
912
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
913 (defun custom-variable-edit-lisp (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
914 "Edit the lisp representation of the value of WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
915 (widget-put widget :custom-state 'unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
916 (widget-put widget :custom-form 'lisp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
917 (custom-redraw widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
918
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
919 (defun custom-variable-set (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
920 "Set the current value for the variable being edited by WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
921 (let ((form (widget-get widget :custom-form))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
922 (state (widget-get widget :custom-state))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
923 (child (car (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
924 (symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
925 val)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
926 (cond ((eq state 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
927 (error "Cannot set hidden variable."))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
928 ((setq val (widget-apply child :validate))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
929 (error "Invalid %S" val))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
930 ((eq form 'lisp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
931 (set symbol (eval (setq val (widget-value child))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
932 (put symbol 'customized-value (list val)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
933 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
934 (set symbol (widget-value child))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
935 (put symbol 'customized-value (list (custom-quote val)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
936 (custom-variable-state-set widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
937 (custom-redraw-magic widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
938
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
939 (defun custom-variable-save (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
940 "Set the default value for the variable being edited by WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
941 (let ((form (widget-get widget :custom-form))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
942 (state (widget-get widget :custom-state))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
943 (child (car (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
944 (symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
945 val)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
946 (cond ((eq state 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
947 (error "Cannot set hidden variable."))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
948 ((setq val (widget-apply child :validate))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
949 (error "Invalid %S" val))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
950 ((eq form 'lisp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
951 (put symbol 'saved-value (list (widget-value child)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
952 (set symbol (eval (widget-value child))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
953 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
954 (put symbol
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
955 'saved-value (list (custom-quote (widget-value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
956 child))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
957 (set symbol (widget-value child))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
958 (put symbol 'customized-value nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
959 (custom-save-all)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
960 (custom-variable-state-set widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
961 (custom-redraw-magic widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
962
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
963 (defun custom-variable-reset-saved (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
964 "Restore the saved value for the variable being edited by WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
965 (let ((symbol (widget-value widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
966 (if (get symbol 'saved-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
967 (condition-case nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
968 (set symbol (eval (car (get symbol 'saved-value))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
969 (error nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
970 (error "No saved value for %s" symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
971 (put symbol 'customized-value nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
972 (widget-put widget :custom-state 'unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
973 (custom-redraw widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
974
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
975 (defun custom-variable-reset-factory (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
976 "Restore the factory setting for the variable being edited by WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
977 (let ((symbol (widget-value widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
978 (if (get symbol 'factory-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
979 (set symbol (eval (car (get symbol 'factory-value))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
980 (error "No factory default for %S" symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
981 (put symbol 'customized-value nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
982 (when (get symbol 'saved-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
983 (put symbol 'saved-value nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
984 (custom-save-all))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
985 (widget-put widget :custom-state 'unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
986 (custom-redraw widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
987
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
988 ;;; The `custom-face-edit' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
989
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
990 (defvar custom-face-edit-args
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
991 (mapcar (lambda (att)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
992 (list 'group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
993 :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
994 (list 'const :format "" :value (nth 0 att))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
995 (nth 1 att)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
996 custom-face-attributes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
997
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
998 (define-widget 'custom-face-edit 'checklist
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
999 "Edit face attributes."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1000 :format "%t: %v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1001 :tag "Attributes"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1002 :extra-offset 12
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1003 :args (mapcar (lambda (att)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1004 (list 'group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1005 :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1006 (list 'const :format "" :value (nth 0 att))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1007 (nth 1 att)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1008 custom-face-attributes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1009
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1010 ;;; The `custom-display' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1011
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1012 (define-widget 'custom-display 'menu-choice
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1013 "Select a display type."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1014 :tag "Display"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1015 :value t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1016 :args '((const :tag "all" t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1017 (checklist :offset 0
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1018 :extra-offset 9
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1019 :args ((group (const :format "Type: " type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1020 (checklist :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1021 :offset 0
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1022 (const :format "X "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1023 x)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1024 (const :format "PM "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1025 pm)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1026 (const :format "Win32 "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1027 win32)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1028 (const :format "DOS "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1029 pc)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1030 (const :format "TTY%n"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1031 tty)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1032 (group (const :format "Class: " class)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1033 (checklist :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1034 :offset 0
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1035 (const :format "Color "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1036 color)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1037 (const :format
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1038 "Grayscale "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1039 grayscale)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1040 (const :format "Monochrome%n"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1041 mono)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1042 (group (const :format "Background: " background)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1043 (checklist :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1044 :offset 0
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1045 (const :format "Light "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1046 light)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1047 (const :format "Dark\n"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1048 dark)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1049
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1050 ;;; The `custom-face' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1051
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1052 (defface custom-face-tag-face '((t (:underline t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1053 "Face used for face tags."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1054 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1055
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1056 (define-widget 'custom-face 'custom
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1057 "Customize face."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1058 :format "%l%{%t%}: %s%m%h%a%v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1059 :format-handler 'custom-face-format-handler
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1060 :sample-face 'custom-face-tag-face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1061 :help-echo "Push me to set or reset this face."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1062 :documentation-property 'face-documentation
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1063 :value-create 'custom-face-value-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1064 :action 'custom-face-action
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1065 :custom-set 'custom-face-set
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1066 :custom-save 'custom-face-save
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1067 :custom-reset-current 'custom-redraw
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1068 :custom-reset-saved 'custom-face-reset-saved
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1069 :custom-reset-factory 'custom-face-reset-factory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1070 :custom-menu 'custom-face-menu-create)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1071
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1072 (defun custom-face-format-handler (widget escape)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1073 ;; We recognize extra escape sequences.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1074 (let (child
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1075 (state (widget-get widget :custom-state))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1076 (symbol (widget-get widget :value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1077 (cond ((eq escape ?s)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1078 (and (string-match "XEmacs" emacs-version)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1079 ;; XEmacs cannot display initialized faces.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1080 (not (custom-facep symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1081 (copy-face 'custom-face-empty symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1082 (setq child (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1083 widget 'item
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1084 :format "(%{%t%})\n"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1085 :sample-face symbol
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1086 :tag "sample")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1087 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1088 (custom-format-handler widget escape)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1089 (when child
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1090 (widget-put widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1091 :buttons (cons child (widget-get widget :buttons))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1092
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1093 (defun custom-face-value-create (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1094 ;; Create a list of the display specifications.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1095 (unless (eq (preceding-char) ?\n)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1096 (insert "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1097 (when (not (eq (widget-get widget :custom-state) 'hidden))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1098 (custom-load-widget widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1099 (let* ((symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1100 (edit (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1101 widget 'editable-list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1102 :entry-format "%i %d %v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1103 :value (or (get symbol 'saved-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1104 (get symbol 'factory-face))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1105 '(group :format "%v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1106 custom-display custom-face-edit))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1107 (custom-face-state-set widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1108 (widget-put widget :children (list edit)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1109
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1110 (defvar custom-face-menu
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1111 '(("Set" . custom-face-set)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1112 ("Save" . custom-face-save)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1113 ("Reset to Saved" . custom-face-reset-saved)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1114 ("Reset to Factory Setting" . custom-face-reset-factory))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1115 "Alist of actions for the `custom-face' widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1116 The key is a string containing the name of the action, the value is a
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1117 lisp function taking the widget as an element which will be called
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1118 when the action is chosen.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1119
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1120 (defun custom-face-state-set (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1121 "Set the state of WIDGET."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1122 (let ((symbol (widget-value widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1123 (widget-put widget :custom-state (cond ((get symbol 'customized-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1124 'set)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1125 ((get symbol 'saved-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1126 'saved)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1127 ((get symbol 'factory-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1128 'factory)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1129 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1130 'rogue)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1131
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1132 (defun custom-face-action (widget &optional event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1133 "Show the menu for `custom-face' WIDGET.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1134 Optional EVENT is the location for the menu."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1135 (if (eq (widget-get widget :custom-state) 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1136 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1137 (widget-put widget :custom-state 'unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1138 (custom-redraw widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1139 (let* ((completion-ignore-case t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1140 (symbol (widget-get widget :value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1141 (answer (widget-choose (symbol-name symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1142 custom-face-menu event)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1143 (if answer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1144 (funcall answer widget)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1145
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1146 (defun custom-face-set (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1147 "Make the face attributes in WIDGET take effect."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1148 (let* ((symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1149 (child (car (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1150 (value (widget-value child)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1151 (put symbol 'customized-face value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1152 (custom-face-display-set symbol value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1153 (custom-face-state-set widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1154 (custom-redraw-magic widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1155
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1156 (defun custom-face-save (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1157 "Make the face attributes in WIDGET default."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1158 (let* ((symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1159 (child (car (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1160 (value (widget-value child)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1161 (custom-face-display-set symbol value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1162 (put symbol 'saved-face value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1163 (put symbol 'customized-face nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1164 (custom-face-state-set widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1165 (custom-redraw-magic widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1166
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1167 (defun custom-face-reset-saved (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1168 "Restore WIDGET to the face's default attributes."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1169 (let* ((symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1170 (child (car (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1171 (value (get symbol 'saved-face)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1172 (unless value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1173 (error "No saved value for this face"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1174 (put symbol 'customized-face nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1175 (custom-face-display-set symbol value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1176 (widget-value-set child value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1177 (custom-face-state-set widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1178 (custom-redraw-magic widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1179
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1180 (defun custom-face-reset-factory (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1181 "Restore WIDGET to the face's factory settings."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1182 (let* ((symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1183 (child (car (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1184 (value (get symbol 'factory-face)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1185 (unless value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1186 (error "No factory default for this face"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1187 (put symbol 'customized-face nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1188 (when (get symbol 'saved-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1189 (put symbol 'saved-face nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1190 (custom-save-all))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1191 (custom-face-display-set symbol value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1192 (widget-value-set child value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1193 (custom-face-state-set widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1194 (custom-redraw-magic widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1195
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1196 ;;; The `face' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1197
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1198 (define-widget 'face 'default
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1199 "Select and customize a face."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1200 :convert-widget 'widget-item-convert-widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1201 :format "%[%t%]: %v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1202 :tag "Face"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1203 :value 'default
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1204 :value-create 'widget-face-value-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1205 :value-delete 'widget-face-value-delete
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1206 :value-get 'widget-item-value-get
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1207 :validate 'widget-editable-list-validate
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1208 :action 'widget-face-action
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1209 :match '(lambda (widget value) (symbolp value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1210
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1211 (defun widget-face-value-create (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1212 ;; Create a `custom-face' child.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1213 (let* ((symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1214 (child (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1215 widget 'custom-face
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1216 :format "%t %s%m%h%v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1217 :custom-level nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1218 :value symbol)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1219 (custom-magic-reset child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1220 (setq custom-options (cons child custom-options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1221 (widget-put widget :children (list child))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1222
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1223 (defun widget-face-value-delete (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1224 ;; Remove the child from the options.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1225 (let ((child (car (widget-get widget :children))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1226 (setq custom-options (delq child custom-options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1227 (widget-children-value-delete widget)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1228
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1229 (defvar face-history nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1230 "History of entered face names.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1231
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1232 (defun widget-face-action (widget &optional event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1233 "Prompt for a face."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1234 (let ((answer (completing-read "Face: "
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1235 (mapcar (lambda (face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1236 (list (symbol-name face)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1237 (face-list))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1238 nil nil nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1239 'face-history)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1240 (unless (zerop (length answer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1241 (widget-value-set widget (intern answer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1242 (widget-apply widget :notify widget event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1243 (widget-setup))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1244
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1245 ;;; The `hook' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1246
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1247 (define-widget 'hook 'list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1248 "A emacs lisp hook"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1249 :convert-widget 'custom-hook-convert-widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1250 :tag "Hook")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1251
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1252 (defun custom-hook-convert-widget (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1253 ;; Handle `:custom-options'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1254 (let* ((options (widget-get widget :options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1255 (other `(editable-list :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1256 :entry-format "%i %d%v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1257 (function :format " %v")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1258 (args (if options
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1259 (list `(checklist :inline t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1260 ,@(mapcar (lambda (entry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1261 `(function-item ,entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1262 options))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1263 other)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1264 (list other))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1265 (widget-put widget :args args)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1266 widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1267
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1268 ;;; The `custom-group' Widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1269
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1270 (defcustom custom-group-tag-faces '(custom-group-tag-face-1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1271 ;; In XEmacs, this ought to play games with font size.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1272 "Face used for group tags.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1273 The first member is used for level 1 groups, the second for level 2,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1274 and so forth. The remaining group tags are shown with
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1275 `custom-group-tag-face'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1276 :type '(repeat face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1277 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1278
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1279 (defface custom-group-tag-face-1 '((((class color)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1280 (background dark))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1281 (:foreground "pink" :underline t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1282 (((class color)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1283 (background light))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1284 (:foreground "red" :underline t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1285 (t (:underline t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1286 "Face used for group tags.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1287
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1288 (defface custom-group-tag-face '((((class color)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1289 (background dark))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1290 (:foreground "light blue" :underline t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1291 (((class color)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1292 (background light))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1293 (:foreground "blue" :underline t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1294 (t (:underline t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1295 "Face used for low level group tags."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1296 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1297
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1298 (define-widget 'custom-group 'custom
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1299 "Customize group."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1300 :format "%l%{%t%}:%L\n%m%h%a%v"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1301 :sample-face-get 'custom-group-sample-face-get
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1302 :documentation-property 'group-documentation
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1303 :help-echo "Push me to set or reset all members of this group."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1304 :value-create 'custom-group-value-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1305 :action 'custom-group-action
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1306 :custom-set 'custom-group-set
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1307 :custom-save 'custom-group-save
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1308 :custom-reset-current 'custom-group-reset-current
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1309 :custom-reset-saved 'custom-group-reset-saved
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1310 :custom-reset-factory 'custom-group-reset-factory
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1311 :custom-menu 'custom-group-menu-create)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1312
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1313 (defun custom-group-sample-face-get (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1314 ;; Use :sample-face.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1315 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1316 'custom-group-tag-face))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1317
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1318 (defun custom-group-value-create (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1319 (let ((state (widget-get widget :custom-state)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1320 (unless (eq state 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1321 (custom-load-widget widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1322 (let* ((level (widget-get widget :custom-level))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1323 (symbol (widget-value widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1324 (members (get symbol 'custom-group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1325 (prefixes (widget-get widget :custom-prefixes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1326 (custom-prefix-list (custom-prefix-add symbol prefixes))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1327 (children (mapcar (lambda (entry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1328 (widget-insert "\n")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1329 (prog1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1330 (widget-create-child-and-convert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1331 widget (nth 1 entry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1332 :group widget
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1333 :tag (custom-unlispify-tag-name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1334 (nth 0 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1335 :custom-prefixes custom-prefix-list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1336 :custom-level (1+ level)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1337 :value (nth 0 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1338 (unless (eq (preceding-char) ?\n)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1339 (widget-insert "\n"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1340 members)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1341 (mapcar 'custom-magic-reset children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1342 (widget-put widget :children children)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1343 (custom-group-state-update widget)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1344
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1345 (defvar custom-group-menu
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1346 '(("Set" . custom-group-set)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1347 ("Save" . custom-group-save)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1348 ("Reset to Current" . custom-group-reset-current)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1349 ("Reset to Saved" . custom-group-reset-saved)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1350 ("Reset to Factory" . custom-group-reset-factory))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1351 "Alist of actions for the `custom-group' widget.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1352 The key is a string containing the name of the action, the value is a
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1353 lisp function taking the widget as an element which will be called
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1354 when the action is chosen.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1355
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1356 (defun custom-group-action (widget &optional event)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1357 "Show the menu for `custom-group' WIDGET.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1358 Optional EVENT is the location for the menu."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1359 (if (eq (widget-get widget :custom-state) 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1360 (progn
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1361 (widget-put widget :custom-state 'unknown)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1362 (custom-redraw widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1363 (let* ((completion-ignore-case t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1364 (answer (widget-choose (symbol-name (widget-get widget :value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1365 custom-group-menu
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1366 event)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1367 (if answer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1368 (funcall answer widget)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1369
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1370 (defun custom-group-set (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1371 "Set changes in all modified group members."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1372 (let ((children (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1373 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1374 (when (eq (widget-get child :custom-state) 'modified)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1375 (widget-apply child :custom-set)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1376 children )))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1377
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1378 (defun custom-group-save (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1379 "Save all modified group members."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1380 (let ((children (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1381 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1382 (when (memq (widget-get child :custom-state) '(modified set))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1383 (widget-apply child :custom-save)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1384 children )))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1385
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1386 (defun custom-group-reset-current (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1387 "Reset all modified group members."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1388 (let ((children (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1389 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1390 (when (eq (widget-get child :custom-state) 'modified)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1391 (widget-apply child :custom-reset-current)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1392 children )))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1393
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1394 (defun custom-group-reset-saved (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1395 "Reset all modified or set group members."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1396 (let ((children (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1397 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1398 (when (memq (widget-get child :custom-state) '(modified set))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1399 (widget-apply child :custom-reset-saved)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1400 children )))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1401
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1402 (defun custom-group-reset-factory (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1403 "Reset all modified, set, or saved group members."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1404 (let ((children (widget-get widget :children)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1405 (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1406 (when (memq (widget-get child :custom-state)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1407 '(modified set saved))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1408 (widget-apply child :custom-reset-factory)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1409 children )))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1410
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1411 (defun custom-group-state-update (widget)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1412 "Update magic."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1413 (unless (eq (widget-get widget :custom-state) 'hidden)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1414 (let* ((children (widget-get widget :children))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1415 (states (mapcar (lambda (child)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1416 (widget-get child :custom-state))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1417 children))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1418 (magics custom-magic-alist)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1419 (found 'factory))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1420 (while magics
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1421 (let ((magic (car (car magics))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1422 (if (and (not (eq magic 'hidden))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1423 (memq magic states))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1424 (setq found magic
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1425 magics nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1426 (setq magics (cdr magics)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1427 (widget-put widget :custom-state found)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1428 (custom-magic-reset widget))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1429
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1430 ;;; The `custom-save-all' Function.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1431
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1432 (defcustom custom-file "~/.emacs"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1433 "File used for storing customization information.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1434 If you change this from the default \"~/.emacs\" you need to
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1435 explicitly load that file for the settings to take effect."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1436 :type 'file
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1437 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1438
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1439 (defun custom-save-delete (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1440 "Delete the call to SYMBOL form `custom-file'.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1441 Leave point at the location of the call, or after the last expression."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1442 (set-buffer (find-file-noselect custom-file))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1443 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1444 (catch 'found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1445 (while t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1446 (let ((sexp (condition-case nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1447 (read (current-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1448 (end-of-file (throw 'found nil)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1449 (when (and (listp sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1450 (eq (car sexp) symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1451 (delete-region (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1452 (backward-sexp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1453 (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1454 (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1455 (throw 'found nil))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1456
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1457 (defun custom-save-variables ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1458 "Save all customized variables in `custom-file'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1459 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1460 (custom-save-delete 'custom-set-variables)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1461 (let ((standard-output (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1462 (unless (bolp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1463 (princ "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1464 (princ "(custom-set-variables")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1465 (mapatoms (lambda (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1466 (let ((value (get symbol 'saved-value)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1467 (when value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1468 (princ "\n '(")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1469 (princ symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1470 (princ " ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1471 (prin1 (car value))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1472 (if (or (get symbol 'factory-value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1473 (and (not (boundp symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1474 (not (get symbol 'force-value))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1475 (princ ")")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1476 (princ " t)"))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1477 (princ ")")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1478 (unless (eolp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1479 (princ "\n")))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1480
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1481 (defun custom-save-faces ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1482 "Save all customized faces in `custom-file'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1483 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1484 (custom-save-delete 'custom-set-faces)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1485 (let ((standard-output (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1486 (unless (bolp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1487 (princ "\n"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1488 (princ "(custom-set-faces")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1489 (mapatoms (lambda (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1490 (let ((value (get symbol 'saved-face)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1491 (when value
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1492 (princ "\n '(")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1493 (princ symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1494 (princ " ")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1495 (prin1 value)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1496 (if (or (get symbol 'factory-face)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1497 (and (not (custom-facep symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1498 (not (get symbol 'force-face))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1499 (princ ")")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1500 (princ " t)"))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1501 (princ ")")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1502 (unless (eolp)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1503 (princ "\n")))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1504
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1505 (defun custom-save-all ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1506 "Save all customizations in `custom-file'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1507 (custom-save-variables)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1508 (custom-save-faces)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1509 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1510 (set-buffer (find-file-noselect custom-file))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1511 (save-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1512
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1513 ;;; The Customize Menu.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1514
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1515 (defcustom custom-menu-nesting 2
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1516 "Maximum nesting in custom menus."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1517 :type 'integer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1518 :group 'customize)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1519
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1520 (defun custom-face-menu-create (widget symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1521 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1522 (vector (custom-unlispify-menu-entry symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1523 `(custom-buffer-create '((,symbol custom-face)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1524 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1525
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1526 (defun custom-variable-menu-create (widget symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1527 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1528 (let ((type (get symbol 'custom-type)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1529 (unless (listp type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1530 (setq type (list type)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1531 (if (and type (widget-get type :custom-menu))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1532 (widget-apply type :custom-menu symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1533 (vector (custom-unlispify-menu-entry symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1534 `(custom-buffer-create '((,symbol custom-variable)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1535 t))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1536
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1537 (widget-put (get 'boolean 'widget-type)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1538 :custom-menu (lambda (widget symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1539 (vector (custom-unlispify-menu-entry symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1540 `(custom-buffer-create
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1541 '((,symbol custom-variable)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1542 ':style 'toggle
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1543 ':selected symbol)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1544
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1545 (defun custom-group-menu-create (widget symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1546 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1547 (custom-menu-create symbol))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1548
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1549 (defun custom-menu-create (symbol &optional name)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1550 "Create menu for customization group SYMBOL.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1551 If optional NAME is given, use that as the name of the menu.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1552 Otherwise make up a name from SYMBOL.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1553 The menu is in a format applicable to `easy-menu-define'."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1554 (unless name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1555 (setq name (custom-unlispify-menu-entry symbol)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1556 (let ((item (vector name
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1557 `(custom-buffer-create '((,symbol custom-group)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1558 t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1559 (if (and (> custom-menu-nesting 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1560 (< (length (get symbol 'custom-group)) widget-menu-max-size))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1561 (let ((custom-menu-nesting (1- custom-menu-nesting))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1562 (custom-prefix-list (custom-prefix-add symbol
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1563 custom-prefix-list)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1564 (custom-load-symbol symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1565 `(,(custom-unlispify-menu-entry symbol t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1566 ,item
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1567 "--"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1568 ,@(mapcar (lambda (entry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1569 (widget-apply (if (listp (nth 1 entry))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1570 (nth 1 entry)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1571 (list (nth 1 entry)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1572 :custom-menu (nth 0 entry)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1573 (get symbol 'custom-group))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1574 item)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1575
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1576 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1577 (defun custom-menu-update ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1578 "Update customize menu."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1579 (interactive)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1580 (add-hook 'custom-define-hook 'custom-menu-reset)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1581 (let ((menu `(,(car custom-help-menu)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1582 ,(widget-apply '(custom-group) :custom-menu 'emacs)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1583 ,@(cdr (cdr custom-help-menu)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1584 (if (fboundp 'add-submenu)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1585 (add-submenu '("Help") menu)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1586 (define-key global-map [menu-bar help-menu customize-menu]
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1587 (cons (car menu) (easy-menu-create-keymaps (car menu) (cdr menu)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1588
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1589 ;;; Dependencies.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1590
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1591 ;;;###autoload
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1592 (defun custom-make-dependencies ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1593 "Batch function to extract custom dependencies from .el files.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1594 Usage: emacs -batch *.el -f custom-make-dependencies > deps.el"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1595 (let ((buffers (buffer-list)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1596 (while buffers
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1597 (set-buffer (car buffers))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1598 (setq buffers (cdr buffers))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1599 (let ((file (buffer-file-name)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1600 (when (and file (string-match "\\`\\(.*\\)\\.el\\'" file))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1601 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1602 (condition-case nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1603 (let ((name (file-name-nondirectory (match-string 1 file))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1604 (while t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1605 (let ((expr (read (current-buffer))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1606 (when (and (listp expr)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1607 (memq (car expr) '(defcustom defface defgroup)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1608 (eval expr)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1609 (put (nth 1 expr) 'custom-where name)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1610 (error nil))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1611 (mapatoms (lambda (symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1612 (let ((members (get symbol 'custom-group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1613 item where found)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1614 (when members
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1615 (princ "(put '")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1616 (princ symbol)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1617 (princ " 'custom-loads '(")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1618 (while members
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1619 (setq item (car (car members))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1620 members (cdr members)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1621 where (get item 'custom-where))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1622 (unless (or (null where)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1623 (member where found))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1624 (when found
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1625 (princ " "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1626 (prin1 where)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1627 (push where found)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1628 (princ "))\n"))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1629
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1630 ;;; The End.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1631
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1632 (provide 'custom-edit)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1633
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1634 ;; custom-edit.el ends here