Mercurial > emacs
annotate lisp/cus-edit.el @ 17800:ebc3066cd381
Restored code lost in merge.
author | Per Abrahamsen <abraham@dina.kvl.dk> |
---|---|
date | Wed, 14 May 1997 17:38:51 +0000 |
parents | f59c9a63514b |
children | fd3f0a7e79b9 |
rev | line source |
---|---|
17334 | 1 ;;; cus-edit.el --- Tools for customization Emacs. |
2 ;; | |
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. | |
4 ;; | |
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | |
6 ;; Keywords: help, faces | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
7 ;; Version: 1.97 |
17334 | 8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ |
9 | |
17521
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
11 |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
14 ;; the Free Software Foundation; either version 2, or (at your option) |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
15 ;; any later version. |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
16 |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
20 ;; GNU General Public License for more details. |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
21 |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
25 ;; Boston, MA 02111-1307, USA. |
ddce9ecc6f6a
(custom-face-set): Don't copy an empty face,
Richard M. Stallman <rms@gnu.org>
parents:
17415
diff
changeset
|
26 |
17334 | 27 ;;; Commentary: |
28 ;; | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
29 ;; This file implements the code to create and edit customize buffers. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
30 ;; |
17334 | 31 ;; See `custom.el'. |
32 | |
33 ;;; Code: | |
34 | |
35 (require 'cus-face) | |
36 (require 'wid-edit) | |
37 (require 'easymenu) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
38 (eval-when-compile (require 'cl)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
39 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
40 (condition-case nil |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
41 (require 'cus-load) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
42 (error nil)) |
17334 | 43 |
44 (define-widget-keywords :custom-prefixes :custom-menu :custom-show | |
45 :custom-magic :custom-state :custom-level :custom-form | |
46 :custom-set :custom-save :custom-reset-current :custom-reset-saved | |
47 :custom-reset-factory) | |
48 | |
17415 | 49 (put 'custom-define-hook 'custom-type 'hook) |
50 (put 'custom-define-hook 'factory-value '(nil)) | |
51 (custom-add-to-group 'customize 'custom-define-hook 'custom-variable) | |
52 | |
17334 | 53 ;;; Customization Groups. |
54 | |
55 (defgroup emacs nil | |
56 "Customization of the One True Editor." | |
57 :link '(custom-manual "(emacs)Top")) | |
58 | |
59 ;; Most of these groups are stolen from `finder.el', | |
60 (defgroup editing nil | |
61 "Basic text editing facilities." | |
62 :group 'emacs) | |
63 | |
64 (defgroup abbrev nil | |
65 "Abbreviation handling, typing shortcuts, macros." | |
66 :tag "Abbreviations" | |
67 :group 'editing) | |
68 | |
69 (defgroup matching nil | |
70 "Various sorts of searching and matching." | |
71 :group 'editing) | |
72 | |
73 (defgroup emulations nil | |
74 "Emulations of other editors." | |
75 :group 'editing) | |
76 | |
77 (defgroup mouse nil | |
78 "Mouse support." | |
79 :group 'editing) | |
80 | |
81 (defgroup outlines nil | |
82 "Support for hierarchical outlining." | |
83 :group 'editing) | |
84 | |
85 (defgroup external nil | |
86 "Interfacing to external utilities." | |
87 :group 'emacs) | |
88 | |
89 (defgroup bib nil | |
90 "Code related to the `bib' bibliography processor." | |
91 :tag "Bibliography" | |
92 :group 'external) | |
93 | |
94 (defgroup processes nil | |
95 "Process, subshell, compilation, and job control support." | |
96 :group 'external | |
97 :group 'development) | |
98 | |
99 (defgroup programming nil | |
100 "Support for programming in other languages." | |
101 :group 'emacs) | |
102 | |
103 (defgroup languages nil | |
104 "Specialized modes for editing programming languages." | |
105 :group 'programming) | |
106 | |
107 (defgroup lisp nil | |
108 "Lisp support, including Emacs Lisp." | |
109 :group 'languages | |
110 :group 'development) | |
111 | |
112 (defgroup c nil | |
113 "Support for the C language and related languages." | |
114 :group 'languages) | |
115 | |
116 (defgroup tools nil | |
117 "Programming tools." | |
118 :group 'programming) | |
119 | |
120 (defgroup oop nil | |
121 "Support for object-oriented programming." | |
122 :group 'programming) | |
123 | |
124 (defgroup applications nil | |
125 "Applications written in Emacs." | |
126 :group 'emacs) | |
127 | |
128 (defgroup calendar nil | |
129 "Calendar and time management support." | |
130 :group 'applications) | |
131 | |
132 (defgroup mail nil | |
133 "Modes for electronic-mail handling." | |
134 :group 'applications) | |
135 | |
136 (defgroup news nil | |
137 "Support for netnews reading and posting." | |
138 :group 'applications) | |
139 | |
140 (defgroup games nil | |
141 "Games, jokes and amusements." | |
142 :group 'applications) | |
143 | |
144 (defgroup development nil | |
145 "Support for further development of Emacs." | |
146 :group 'emacs) | |
147 | |
148 (defgroup docs nil | |
149 "Support for Emacs documentation." | |
150 :group 'development) | |
151 | |
152 (defgroup extensions nil | |
153 "Emacs Lisp language extensions." | |
154 :group 'development) | |
155 | |
156 (defgroup internal nil | |
157 "Code for Emacs internals, build process, defaults." | |
158 :group 'development) | |
159 | |
160 (defgroup maint nil | |
161 "Maintenance aids for the Emacs development group." | |
162 :tag "Maintenance" | |
163 :group 'development) | |
164 | |
165 (defgroup environment nil | |
166 "Fitting Emacs with its environment." | |
167 :group 'emacs) | |
168 | |
169 (defgroup comm nil | |
170 "Communications, networking, remote access to files." | |
171 :tag "Communication" | |
172 :group 'environment) | |
173 | |
174 (defgroup hardware nil | |
175 "Support for interfacing with exotic hardware." | |
176 :group 'environment) | |
177 | |
178 (defgroup terminals nil | |
179 "Support for terminal types." | |
180 :group 'environment) | |
181 | |
182 (defgroup unix nil | |
183 "Front-ends/assistants for, or emulators of, UNIX features." | |
184 :group 'environment) | |
185 | |
186 (defgroup vms nil | |
187 "Support code for vms." | |
188 :group 'environment) | |
189 | |
190 (defgroup i18n nil | |
191 "Internationalization and alternate character-set support." | |
192 :group 'environment | |
193 :group 'editing) | |
194 | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
195 (defgroup x nil |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
196 "The X Window system." |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
197 :group 'environment) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
198 |
17334 | 199 (defgroup frames nil |
200 "Support for Emacs frames and window systems." | |
201 :group 'environment) | |
202 | |
203 (defgroup data nil | |
204 "Support editing files of data." | |
205 :group 'emacs) | |
206 | |
207 (defgroup wp nil | |
208 "Word processing." | |
209 :group 'emacs) | |
210 | |
211 (defgroup tex nil | |
212 "Code related to the TeX formatter." | |
213 :group 'wp) | |
214 | |
215 (defgroup faces nil | |
216 "Support for multiple fonts." | |
217 :group 'emacs) | |
218 | |
219 (defgroup hypermedia nil | |
220 "Support for links between text or other media types." | |
221 :group 'emacs) | |
222 | |
223 (defgroup help nil | |
224 "Support for on-line help systems." | |
225 :group 'emacs) | |
226 | |
227 (defgroup local nil | |
228 "Code local to your site." | |
229 :group 'emacs) | |
230 | |
231 (defgroup customize '((widgets custom-group)) | |
232 "Customization of the Customization support." | |
233 :link '(custom-manual "(custom)Top") | |
234 :link '(url-link :tag "Development Page" | |
235 "http://www.dina.kvl.dk/~abraham/custom/") | |
236 :prefix "custom-" | |
17415 | 237 :group 'help) |
238 | |
239 (defgroup custom-faces nil | |
240 "Faces used by customize." | |
241 :group 'customize | |
17334 | 242 :group 'faces) |
243 | |
17415 | 244 (defgroup abbrev-mode nil |
245 "Word abbreviations mode." | |
246 :group 'abbrev) | |
247 | |
248 (defgroup alloc nil | |
249 "Storage allocation and gc for GNU Emacs Lisp interpreter." | |
250 :tag "Storage Allocation" | |
251 :group 'internal) | |
252 | |
253 (defgroup undo nil | |
254 "Undoing changes in buffers." | |
255 :group 'editing) | |
256 | |
257 (defgroup modeline nil | |
258 "Content of the modeline." | |
259 :group 'environment) | |
260 | |
261 (defgroup fill nil | |
262 "Indenting and filling text." | |
263 :group 'editing) | |
264 | |
265 (defgroup editing-basics nil | |
266 "Most basic editing facilities." | |
267 :group 'editing) | |
268 | |
269 (defgroup display nil | |
270 "How characters are displayed in buffers." | |
271 :group 'environment) | |
272 | |
273 (defgroup execute nil | |
274 "Executing external commands." | |
275 :group 'processes) | |
276 | |
277 (defgroup installation nil | |
278 "The Emacs installation." | |
279 :group 'environment) | |
280 | |
281 (defgroup dired nil | |
282 "Directory editing." | |
283 :group 'environment) | |
284 | |
285 (defgroup limits nil | |
286 "Internal Emacs limits." | |
287 :group 'internal) | |
288 | |
289 (defgroup debug nil | |
290 "Debugging Emacs itself." | |
291 :group 'development) | |
292 | |
293 (defgroup minibuffer nil | |
294 "Controling the behaviour of the minibuffer." | |
295 :group 'environment) | |
296 | |
297 (defgroup keyboard nil | |
298 "Input from the keyboard." | |
299 :group 'environment) | |
300 | |
301 (defgroup mouse nil | |
302 "Input from the mouse." | |
303 :group 'environment) | |
304 | |
305 (defgroup menu nil | |
306 "Input from the menus." | |
307 :group 'environment) | |
308 | |
309 (defgroup auto-save nil | |
310 "Preventing accidential loss of data." | |
311 :group 'data) | |
312 | |
313 (defgroup processes-basics nil | |
314 "Basic stuff dealing with processes." | |
315 :group 'processes) | |
316 | |
317 (defgroup windows nil | |
318 "Windows within a frame." | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
319 :group 'environment) |
17415 | 320 |
17334 | 321 ;;; Utilities. |
322 | |
323 (defun custom-quote (sexp) | |
324 "Quote SEXP iff it is not self quoting." | |
325 (if (or (memq sexp '(t nil)) | |
326 (and (symbolp sexp) | |
327 (eq (aref (symbol-name sexp) 0) ?:)) | |
328 (and (listp sexp) | |
329 (memq (car sexp) '(lambda))) | |
330 (stringp sexp) | |
331 (numberp sexp) | |
332 (and (fboundp 'characterp) | |
333 (characterp sexp))) | |
334 sexp | |
335 (list 'quote sexp))) | |
336 | |
337 (defun custom-split-regexp-maybe (regexp) | |
338 "If REGEXP is a string, split it to a list at `\\|'. | |
339 You can get the original back with from the result with: | |
340 (mapconcat 'identity result \"\\|\") | |
341 | |
342 IF REGEXP is not a string, return it unchanged." | |
343 (if (stringp regexp) | |
344 (let ((start 0) | |
345 all) | |
346 (while (string-match "\\\\|" regexp start) | |
347 (setq all (cons (substring regexp start (match-beginning 0)) all) | |
348 start (match-end 0))) | |
349 (nreverse (cons (substring regexp start) all))) | |
350 regexp)) | |
351 | |
17415 | 352 (defun custom-variable-prompt () |
353 ;; Code stolen from `help.el'. | |
354 "Prompt for a variable, defaulting to the variable at point. | |
355 Return a list suitable for use in `interactive'." | |
356 (let ((v (variable-at-point)) | |
357 (enable-recursive-minibuffers t) | |
358 val) | |
359 (setq val (completing-read | |
360 (if v | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
361 (format "Customize variable: (default %s) " v) |
17415 | 362 "Customize variable: ") |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
363 obarray (lambda (symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
364 (and (boundp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
365 (or (get symbol 'custom-type) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
366 (user-variable-p symbol)))))) |
17415 | 367 (list (if (equal val "") |
368 v (intern val))))) | |
369 | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
370 (defun custom-menu-filter (menu widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
371 "Convert MENU to the form used by `widget-choose'. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
372 MENU should be in the same format as `custom-variable-menu'. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
373 WIDGET is the widget to apply the filter entries of MENU on." |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
374 (let ((result nil) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
375 current name action filter) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
376 (while menu |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
377 (setq current (car menu) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
378 name (nth 0 current) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
379 action (nth 1 current) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
380 filter (nth 2 current) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
381 menu (cdr menu)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
382 (if (or (null filter) (funcall filter widget)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
383 (push (cons name action) result) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
384 (push name result))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
385 (nreverse result))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
386 |
17415 | 387 ;;; Unlispify. |
388 | |
17334 | 389 (defvar custom-prefix-list nil |
390 "List of prefixes that should be ignored by `custom-unlispify'") | |
391 | |
392 (defcustom custom-unlispify-menu-entries t | |
393 "Display menu entries as words instead of symbols if non nil." | |
394 :group 'customize | |
395 :type 'boolean) | |
396 | |
397 (defun custom-unlispify-menu-entry (symbol &optional no-suffix) | |
398 "Convert symbol into a menu entry." | |
399 (cond ((not custom-unlispify-menu-entries) | |
400 (symbol-name symbol)) | |
401 ((get symbol 'custom-tag) | |
402 (if no-suffix | |
403 (get symbol 'custom-tag) | |
404 (concat (get symbol 'custom-tag) "..."))) | |
405 (t | |
406 (save-excursion | |
407 (set-buffer (get-buffer-create " *Custom-Work*")) | |
408 (erase-buffer) | |
409 (princ symbol (current-buffer)) | |
410 (goto-char (point-min)) | |
17415 | 411 (when (and (eq (get symbol 'custom-type) 'boolean) |
412 (re-search-forward "-p\\'" nil t)) | |
413 (replace-match "" t t) | |
414 (goto-char (point-min))) | |
17334 | 415 (let ((prefixes custom-prefix-list) |
416 prefix) | |
417 (while prefixes | |
418 (setq prefix (car prefixes)) | |
419 (if (search-forward prefix (+ (point) (length prefix)) t) | |
420 (progn | |
421 (setq prefixes nil) | |
422 (delete-region (point-min) (point))) | |
423 (setq prefixes (cdr prefixes))))) | |
424 (subst-char-in-region (point-min) (point-max) ?- ?\ t) | |
425 (capitalize-region (point-min) (point-max)) | |
426 (unless no-suffix | |
427 (goto-char (point-max)) | |
428 (insert "...")) | |
429 (buffer-string))))) | |
430 | |
431 (defcustom custom-unlispify-tag-names t | |
432 "Display tag names as words instead of symbols if non nil." | |
433 :group 'customize | |
434 :type 'boolean) | |
435 | |
436 (defun custom-unlispify-tag-name (symbol) | |
437 "Convert symbol into a menu entry." | |
438 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names)) | |
439 (custom-unlispify-menu-entry symbol t))) | |
440 | |
441 (defun custom-prefix-add (symbol prefixes) | |
442 ;; Addd SYMBOL to list of ignored PREFIXES. | |
443 (cons (or (get symbol 'custom-prefix) | |
444 (concat (symbol-name symbol) "-")) | |
445 prefixes)) | |
446 | |
17415 | 447 ;;; Guess. |
448 | |
449 (defcustom custom-guess-name-alist | |
450 '(("-p\\'" boolean) | |
451 ("-hook\\'" hook) | |
452 ("-face\\'" face) | |
453 ("-file\\'" file) | |
454 ("-function\\'" function) | |
455 ("-functions\\'" (repeat function)) | |
456 ("-list\\'" (repeat sexp)) | |
457 ("-alist\\'" (repeat (cons sexp sexp)))) | |
458 "Alist of (MATCH TYPE). | |
459 | |
460 MATCH should be a regexp matching the name of a symbol, and TYPE should | |
461 be a widget suitable for editing the value of that symbol. The TYPE | |
462 of the first entry where MATCH matches the name of the symbol will be | |
463 used. | |
464 | |
465 This is used for guessing the type of variables not declared with | |
466 customize." | |
467 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type"))) | |
468 :group 'customize) | |
469 | |
470 (defcustom custom-guess-doc-alist | |
471 '(("\\`\\*?Non-nil " boolean)) | |
472 "Alist of (MATCH TYPE). | |
473 | |
474 MATCH should be a regexp matching a documentation string, and TYPE | |
475 should be a widget suitable for editing the value of a variable with | |
476 that documentation string. The TYPE of the first entry where MATCH | |
477 matches the name of the symbol will be used. | |
478 | |
479 This is used for guessing the type of variables not declared with | |
480 customize." | |
481 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type"))) | |
482 :group 'customize) | |
483 | |
484 (defun custom-guess-type (symbol) | |
485 "Guess a widget suitable for editing the value of SYMBOL. | |
486 This is done by matching SYMBOL with `custom-guess-name-alist' and | |
487 if that fails, the doc string with `custom-guess-doc-alist'." | |
488 (let ((name (symbol-name symbol)) | |
489 (names custom-guess-name-alist) | |
490 current found) | |
491 (while names | |
492 (setq current (car names) | |
493 names (cdr names)) | |
494 (when (string-match (nth 0 current) name) | |
495 (setq found (nth 1 current) | |
496 names nil))) | |
497 (unless found | |
498 (let ((doc (documentation-property symbol 'variable-documentation)) | |
499 (docs custom-guess-doc-alist)) | |
500 (when doc | |
501 (while docs | |
502 (setq current (car docs) | |
503 docs (cdr docs)) | |
504 (when (string-match (nth 0 current) doc) | |
505 (setq found (nth 1 current) | |
506 docs nil)))))) | |
507 found)) | |
508 | |
509 ;;; Custom Mode Commands. | |
17334 | 510 |
511 (defvar custom-options nil | |
512 "Customization widgets in the current buffer.") | |
513 | |
514 (defun custom-set () | |
515 "Set changes in all modified options." | |
516 (interactive) | |
517 (let ((children custom-options)) | |
518 (mapcar (lambda (child) | |
519 (when (eq (widget-get child :custom-state) 'modified) | |
520 (widget-apply child :custom-set))) | |
521 children))) | |
522 | |
523 (defun custom-save () | |
524 "Set all modified group members and save them." | |
525 (interactive) | |
526 (let ((children custom-options)) | |
527 (mapcar (lambda (child) | |
528 (when (memq (widget-get child :custom-state) '(modified set)) | |
529 (widget-apply child :custom-save))) | |
530 children)) | |
531 (custom-save-all)) | |
532 | |
533 (defvar custom-reset-menu | |
534 '(("Current" . custom-reset-current) | |
535 ("Saved" . custom-reset-saved) | |
536 ("Factory Settings" . custom-reset-factory)) | |
537 "Alist of actions for the `Reset' button. | |
538 The key is a string containing the name of the action, the value is a | |
539 lisp function taking the widget as an element which will be called | |
540 when the action is chosen.") | |
541 | |
542 (defun custom-reset (event) | |
543 "Select item from reset menu." | |
544 (let* ((completion-ignore-case t) | |
545 (answer (widget-choose "Reset to" | |
546 custom-reset-menu | |
547 event))) | |
548 (if answer | |
549 (funcall answer)))) | |
550 | |
551 (defun custom-reset-current () | |
552 "Reset all modified group members to their current value." | |
553 (interactive) | |
554 (let ((children custom-options)) | |
555 (mapcar (lambda (child) | |
556 (when (eq (widget-get child :custom-state) 'modified) | |
557 (widget-apply child :custom-reset-current))) | |
558 children))) | |
559 | |
560 (defun custom-reset-saved () | |
561 "Reset all modified or set group members to their saved value." | |
562 (interactive) | |
563 (let ((children custom-options)) | |
564 (mapcar (lambda (child) | |
565 (when (eq (widget-get child :custom-state) 'modified) | |
566 (widget-apply child :custom-reset-current))) | |
567 children))) | |
568 | |
569 (defun custom-reset-factory () | |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
570 "Reset all modified, set, or saved group members to their standard settings." |
17334 | 571 (interactive) |
572 (let ((children custom-options)) | |
573 (mapcar (lambda (child) | |
574 (when (eq (widget-get child :custom-state) 'modified) | |
575 (widget-apply child :custom-reset-current))) | |
576 children))) | |
577 | |
578 ;;; The Customize Commands | |
579 | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
580 (defun custom-prompt-variable (prompt-var prompt-val) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
581 "Prompt for a variable and a value and return them as a list. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
582 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
583 prompt for the value. The %s escape in PROMPT-VAL is replaced with |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
584 the name of the variable. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
585 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
586 If the variable has a `variable-interactive' property, that is used as if |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
587 it were the arg to `interactive' (which see) to interactively read the value. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
588 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
589 If the variable has a `custom-type' property, it must be a widget and the |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
590 `:prompt-value' property of that widget will be used for reading the value." |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
591 (let* ((var (read-variable prompt-var)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
592 (minibuffer-help-form '(describe-variable var))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
593 (list var |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
594 (let ((prop (get var 'variable-interactive)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
595 (type (get var 'custom-type)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
596 (prompt (format prompt-val var))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
597 (unless (listp type) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
598 (setq type (list type))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
599 (cond (prop |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
600 ;; Use VAR's `variable-interactive' property |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
601 ;; as an interactive spec for prompting. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
602 (call-interactively (list 'lambda '(arg) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
603 (list 'interactive prop) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
604 'arg))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
605 (type |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
606 (widget-prompt-value type |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
607 prompt |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
608 (if (boundp var) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
609 (symbol-value var)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
610 (not (boundp var)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
611 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
612 (eval-minibuffer prompt))))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
613 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
614 ;;;###autoload |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
615 (defun custom-set-value (var val) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
616 "Set VARIABLE to VALUE. VALUE is a Lisp object. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
617 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
618 If VARIABLE has a `variable-interactive' property, that is used as if |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
619 it were the arg to `interactive' (which see) to interactively read the value. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
620 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
621 If VARIABLE has a `custom-type' property, it must be a widget and the |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
622 `:prompt-value' property of that widget will be used for reading the value." |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
623 (interactive (custom-prompt-variable "Set variable: " |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
624 "Set %s to value: ")) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
625 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
626 (set var val)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
627 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
628 ;;;###autoload |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
629 (defun custom-set-variable (var val) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
630 "Set the default for VARIABLE to VALUE. VALUE is a Lisp object. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
631 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
632 If VARIABLE has a `custom-set' property, that is used for setting |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
633 VARIABLE, otherwise `set-default' is used. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
634 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
635 The `customized-value' property of the VARIABLE will be set to a list |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
636 with a quoted VALUE as its sole list member. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
637 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
638 If VARIABLE has a `variable-interactive' property, that is used as if |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
639 it were the arg to `interactive' (which see) to interactively read the value. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
640 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
641 If VARIABLE has a `custom-type' property, it must be a widget and the |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
642 `:prompt-value' property of that widget will be used for reading the value. " |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
643 (interactive (custom-prompt-variable "Set variable: " |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
644 "Set customized value for %s to: ")) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
645 (funcall (or (get var 'custom-set) 'set-default) var val) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
646 (put var 'customized-value (list (custom-quote val)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
647 |
17334 | 648 ;;;###autoload |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
649 (defun customize () |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
650 "Select a customization buffer which you can use to set user options. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
651 User options are structured into \"groups\". |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
652 Initially the top-level group `Emacs' and its immediate subgroups |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
653 are shown; the contents of those subgroups are initially hidden." |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
654 (interactive) |
17703 | 655 (customize-group 'emacs)) |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
656 |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
657 ;;;###autoload |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
658 (defun customize-group (group) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
659 "Customize GROUP, which must be a customization group." |
17334 | 660 (interactive (list (completing-read "Customize group: (default emacs) " |
661 obarray | |
662 (lambda (symbol) | |
663 (get symbol 'custom-group)) | |
664 t))) | |
665 | |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
666 (when (stringp group) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
667 (if (string-equal "" group) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
668 (setq group 'emacs) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
669 (setq group (intern group)))) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
670 (custom-buffer-create (list (list group 'custom-group)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
671 (format "*Customize Group: %s*" |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
672 (custom-unlispify-tag-name group)))) |
17334 | 673 |
674 ;;;###autoload | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
675 (defun customize-other-window (symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
676 "Customize SYMBOL, which must be a customization group." |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
677 (interactive (list (completing-read "Customize group: (default emacs) " |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
678 obarray |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
679 (lambda (symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
680 (get symbol 'custom-group)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
681 t))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
682 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
683 (when (stringp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
684 (if (string-equal "" symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
685 (setq symbol 'emacs) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
686 (setq symbol (intern symbol)))) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
687 (custom-buffer-create-other-window |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
688 (list (list symbol 'custom-group)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
689 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol)))) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
690 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
691 ;;;###autoload |
17334 | 692 (defun customize-variable (symbol) |
693 "Customize SYMBOL, which must be a variable." | |
17415 | 694 (interactive (custom-variable-prompt)) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
695 (custom-buffer-create (list (list symbol 'custom-variable)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
696 (format "*Customize Variable: %s*" |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
697 (custom-unlispify-tag-name symbol)))) |
17334 | 698 |
699 ;;;###autoload | |
17415 | 700 (defun customize-variable-other-window (symbol) |
701 "Customize SYMBOL, which must be a variable. | |
702 Show the buffer in another window, but don't select it." | |
703 (interactive (custom-variable-prompt)) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
704 (custom-buffer-create-other-window |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
705 (list (list symbol 'custom-variable)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
706 (format "*Customize Variable: %s*" (custom-unlispify-tag-name symbol)))) |
17415 | 707 |
708 ;;;###autoload | |
17334 | 709 (defun customize-face (&optional symbol) |
710 "Customize SYMBOL, which should be a face name or nil. | |
711 If SYMBOL is nil, customize all faces." | |
712 (interactive (list (completing-read "Customize face: (default all) " | |
713 obarray 'custom-facep))) | |
714 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol)))) | |
715 (let ((found nil)) | |
716 (message "Looking for faces...") | |
717 (mapcar (lambda (symbol) | |
718 (setq found (cons (list symbol 'custom-face) found))) | |
17415 | 719 (nreverse (mapcar 'intern |
720 (sort (mapcar 'symbol-name (face-list)) | |
721 'string<)))) | |
722 | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
723 (custom-buffer-create found "*Customize Faces*")) |
17334 | 724 (if (stringp symbol) |
725 (setq symbol (intern symbol))) | |
726 (unless (symbolp symbol) | |
727 (error "Should be a symbol %S" symbol)) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
728 (custom-buffer-create (list (list symbol 'custom-face)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
729 (format "*Customize Face: %s*" |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
730 (custom-unlispify-tag-name symbol))))) |
17334 | 731 |
732 ;;;###autoload | |
17415 | 733 (defun customize-face-other-window (&optional symbol) |
734 "Show customization buffer for FACE in other window." | |
735 (interactive (list (completing-read "Customize face: " | |
736 obarray 'custom-facep))) | |
737 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol)))) | |
738 () | |
739 (if (stringp symbol) | |
740 (setq symbol (intern symbol))) | |
741 (unless (symbolp symbol) | |
742 (error "Should be a symbol %S" symbol)) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
743 (custom-buffer-create-other-window |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
744 (list (list symbol 'custom-face)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
745 (format "*Customize Face: %s*" (custom-unlispify-tag-name symbol))))) |
17415 | 746 |
747 ;;;###autoload | |
17334 | 748 (defun customize-customized () |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
749 "Customize all user options set since the last save in this session." |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
750 (interactive) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
751 (let ((found nil)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
752 (mapatoms (lambda (symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
753 (and (get symbol 'customized-face) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
754 (custom-facep symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
755 (setq found (cons (list symbol 'custom-face) found))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
756 (and (get symbol 'customized-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
757 (boundp symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
758 (setq found |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
759 (cons (list symbol 'custom-variable) found))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
760 (if found |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
761 (custom-buffer-create found "*Customize Customized*") |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
762 (error "No customized user options")))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
763 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
764 ;;;###autoload |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
765 (defun customize-saved () |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
766 "Customize all already saved user options." |
17334 | 767 (interactive) |
768 (let ((found nil)) | |
769 (mapatoms (lambda (symbol) | |
770 (and (get symbol 'saved-face) | |
771 (custom-facep symbol) | |
772 (setq found (cons (list symbol 'custom-face) found))) | |
773 (and (get symbol 'saved-value) | |
774 (boundp symbol) | |
775 (setq found | |
776 (cons (list symbol 'custom-variable) found))))) | |
777 (if found | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
778 (custom-buffer-create found "*Customize Saved*") |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
779 (error "No saved user options")))) |
17334 | 780 |
781 ;;;###autoload | |
782 (defun customize-apropos (regexp &optional all) | |
783 "Customize all user options matching REGEXP. | |
784 If ALL (e.g., started with a prefix key), include options which are not | |
785 user-settable." | |
786 (interactive "sCustomize regexp: \nP") | |
787 (let ((found nil)) | |
788 (mapatoms (lambda (symbol) | |
789 (when (string-match regexp (symbol-name symbol)) | |
790 (when (get symbol 'custom-group) | |
791 (setq found (cons (list symbol 'custom-group) found))) | |
792 (when (custom-facep symbol) | |
793 (setq found (cons (list symbol 'custom-face) found))) | |
794 (when (and (boundp symbol) | |
795 (or (get symbol 'saved-value) | |
796 (get symbol 'factory-value) | |
797 (if all | |
798 (get symbol 'variable-documentation) | |
799 (user-variable-p symbol)))) | |
800 (setq found | |
801 (cons (list symbol 'custom-variable) found)))))) | |
802 (if found | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
803 (custom-buffer-create found "*Customize Apropos*") |
17334 | 804 (error "No matches")))) |
805 | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
806 ;;; Buffer. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
807 |
17334 | 808 ;;;###autoload |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
809 (defun custom-buffer-create (options &optional name) |
17334 | 810 "Create a buffer containing OPTIONS. |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
811 Optional NAME is the name of the buffer. |
17334 | 812 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where |
813 SYMBOL is a customization option, and WIDGET is a widget for editing | |
814 that option." | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
815 (unless name (setq name "*Customization*")) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
816 (kill-buffer (get-buffer-create name)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
817 (switch-to-buffer (get-buffer-create name)) |
17415 | 818 (custom-buffer-create-internal options)) |
819 | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
820 ;;;###autoload |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
821 (defun custom-buffer-create-other-window (options &optional name) |
17415 | 822 "Create a buffer containing OPTIONS. |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
823 Optional NAME is the name of the buffer. |
17415 | 824 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where |
825 SYMBOL is a customization option, and WIDGET is a widget for editing | |
826 that option." | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
827 (unless name (setq name "*Customization*")) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
828 (kill-buffer (get-buffer-create name)) |
17415 | 829 (let ((window (selected-window))) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
830 (switch-to-buffer-other-window (get-buffer-create name)) |
17415 | 831 (custom-buffer-create-internal options) |
832 (select-window window))) | |
833 | |
834 | |
835 (defun custom-buffer-create-internal (options) | |
836 (message "Creating customization buffer...") | |
17334 | 837 (custom-mode) |
838 (widget-insert "This is a customization buffer. | |
839 Push RET or click mouse-2 on the word ") | |
840 ;; (put-text-property 1 2 'start-open nil) | |
841 (widget-create 'info-link | |
842 :tag "help" | |
843 :help-echo "Read the online help." | |
844 "(custom)The Customization Buffer") | |
845 (widget-insert " for more information.\n\n") | |
846 (setq custom-options | |
847 (if (= (length options) 1) | |
848 (mapcar (lambda (entry) | |
849 (widget-create (nth 1 entry) | |
850 :custom-state 'unknown | |
851 :tag (custom-unlispify-tag-name | |
852 (nth 0 entry)) | |
853 :value (nth 0 entry))) | |
854 options) | |
855 (let ((count 0) | |
856 (length (length options))) | |
857 (mapcar (lambda (entry) | |
858 (prog2 | |
859 (message "Creating customization items %2d%%..." | |
860 (/ (* 100.0 count) length)) | |
861 (widget-create (nth 1 entry) | |
862 :tag (custom-unlispify-tag-name | |
863 (nth 0 entry)) | |
864 :value (nth 0 entry)) | |
865 (setq count (1+ count)) | |
866 (unless (eq (preceding-char) ?\n) | |
867 (widget-insert "\n")) | |
868 (widget-insert "\n"))) | |
869 options)))) | |
870 (unless (eq (preceding-char) ?\n) | |
871 (widget-insert "\n")) | |
872 (widget-insert "\n") | |
873 (message "Creating customization magic...") | |
874 (mapcar 'custom-magic-reset custom-options) | |
875 (message "Creating customization buttons...") | |
876 (widget-create 'push-button | |
877 :tag "Set" | |
878 :help-echo "Set all modifications for this session." | |
879 :action (lambda (widget &optional event) | |
880 (custom-set))) | |
881 (widget-insert " ") | |
882 (widget-create 'push-button | |
883 :tag "Save" | |
884 :help-echo "\ | |
885 Make the modifications default for future sessions." | |
886 :action (lambda (widget &optional event) | |
887 (custom-save))) | |
888 (widget-insert " ") | |
889 (widget-create 'push-button | |
890 :tag "Reset" | |
891 :help-echo "Undo all modifications." | |
892 :action (lambda (widget &optional event) | |
893 (custom-reset event))) | |
894 (widget-insert " ") | |
895 (widget-create 'push-button | |
896 :tag "Done" | |
897 :help-echo "Bury the buffer." | |
898 :action (lambda (widget &optional event) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
899 (bury-buffer))) |
17334 | 900 (widget-insert "\n") |
901 (message "Creating customization setup...") | |
902 (widget-setup) | |
903 (goto-char (point-min)) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
904 (when (fboundp 'map-extents) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
905 ;; This horrible kludge should make bob and eob read-only in XEmacs. |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
906 (map-extents (lambda (extent &rest junk) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
907 (set-extent-property extent 'start-closed t)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
908 nil (point-min) (1+ (point-min))) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
909 (map-extents (lambda (extent &rest junk) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
910 (set-extent-property extent 'end-closed t)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
911 nil (1- (point-max)) (point-max))) |
17334 | 912 (message "Creating customization buffer...done")) |
913 | |
914 ;;; Modification of Basic Widgets. | |
915 ;; | |
916 ;; We add extra properties to the basic widgets needed here. This is | |
917 ;; fine, as long as we are careful to stay within out own namespace. | |
918 ;; | |
919 ;; We want simple widgets to be displayed by default, but complex | |
920 ;; widgets to be hidden. | |
921 | |
922 (widget-put (get 'item 'widget-type) :custom-show t) | |
923 (widget-put (get 'editable-field 'widget-type) | |
924 :custom-show (lambda (widget value) | |
925 (let ((pp (pp-to-string value))) | |
926 (cond ((string-match "\n" pp) | |
927 nil) | |
928 ((> (length pp) 40) | |
929 nil) | |
930 (t t))))) | |
931 (widget-put (get 'menu-choice 'widget-type) :custom-show t) | |
932 | |
933 ;;; The `custom-manual' Widget. | |
934 | |
935 (define-widget 'custom-manual 'info-link | |
936 "Link to the manual entry for this customization option." | |
937 :help-echo "Read the manual entry for this option." | |
938 :tag "Manual") | |
939 | |
940 ;;; The `custom-magic' Widget. | |
941 | |
942 (defface custom-invalid-face '((((class color)) | |
943 (:foreground "yellow" :background "red")) | |
944 (t | |
945 (:bold t :italic t :underline t))) | |
946 "Face used when the customize item is invalid.") | |
947 | |
948 (defface custom-rogue-face '((((class color)) | |
949 (:foreground "pink" :background "black")) | |
950 (t | |
951 (:underline t))) | |
952 "Face used when the customize item is not defined for customization.") | |
953 | |
954 (defface custom-modified-face '((((class color)) | |
955 (:foreground "white" :background "blue")) | |
956 (t | |
957 (:italic t :bold))) | |
958 "Face used when the customize item has been modified.") | |
959 | |
960 (defface custom-set-face '((((class color)) | |
961 (:foreground "blue" :background "white")) | |
962 (t | |
963 (:italic t))) | |
964 "Face used when the customize item has been set.") | |
965 | |
966 (defface custom-changed-face '((((class color)) | |
967 (:foreground "white" :background "blue")) | |
968 (t | |
969 (:italic t))) | |
970 "Face used when the customize item has been changed.") | |
971 | |
972 (defface custom-saved-face '((t (:underline t))) | |
973 "Face used when the customize item has been saved.") | |
974 | |
975 (defcustom custom-magic-alist '((nil "#" underline "\ | |
976 uninitialized, you should not see this.") | |
977 (unknown "?" italic "\ | |
978 unknown, you should not see this.") | |
979 (hidden "-" default "\ | |
980 hidden, press the state button to show.") | |
981 (invalid "x" custom-invalid-face "\ | |
982 the value displayed for this item is invalid and cannot be set.") | |
983 (modified "*" custom-modified-face "\ | |
984 you have edited the item, and can now set it.") | |
985 (set "+" custom-set-face "\ | |
986 you have set this item, but not saved it.") | |
987 (changed ":" custom-changed-face "\ | |
988 this item has been changed outside customize.") | |
989 (saved "!" custom-saved-face "\ | |
990 this item has been saved.") | |
991 (rogue "@" custom-rogue-face "\ | |
992 this item is not prepared for customization.") | |
993 (factory " " nil "\ | |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
994 this item is unchanged from its standard setting.")) |
17334 | 995 "Alist of customize option states. |
996 Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where | |
997 | |
998 STATE is one of the following symbols: | |
999 | |
1000 `nil' | |
1001 For internal use, should never occur. | |
1002 `unknown' | |
1003 For internal use, should never occur. | |
1004 `hidden' | |
1005 This item is not being displayed. | |
1006 `invalid' | |
1007 This item is modified, but has an invalid form. | |
1008 `modified' | |
1009 This item is modified, and has a valid form. | |
1010 `set' | |
1011 This item has been set but not saved. | |
1012 `changed' | |
1013 The current value of this item has been changed temporarily. | |
1014 `saved' | |
1015 This item is marked for saving. | |
1016 `rogue' | |
1017 This item has no customization information. | |
1018 `factory' | |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1019 This item is unchanged from the standard setting. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1020 |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1021 MAGIC is a string used to present that state. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1022 |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1023 FACE is a face used to present the state. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1024 |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1025 DESCRIPTION is a string describing the state. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1026 |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1027 The list should be sorted most significant first." |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1028 :type '(list (checklist :inline t |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1029 (group (const nil) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1030 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1031 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1032 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1033 (group (const unknown) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1034 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1035 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1036 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1037 (group (const hidden) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1038 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1039 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1040 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1041 (group (const invalid) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1042 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1043 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1044 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1045 (group (const modified) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1046 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1047 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1048 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1049 (group (const set) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1050 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1051 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1052 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1053 (group (const changed) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1054 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1055 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1056 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1057 (group (const saved) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1058 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1059 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1060 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1061 (group (const rogue) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1062 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1063 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1064 (string :tag "Description")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1065 (group (const factory) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1066 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1067 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1068 (string :tag "Description"))) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1069 (editable-list :inline t |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1070 (group symbol |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1071 (string :tag "Magic") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1072 face |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1073 (string :tag "Description")))) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1074 :group 'customize |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1075 :group 'custom-faces) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1076 |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1077 (defcustom custom-group-magic-alist '((nil "#" underline "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1078 uninitialized, you should not see this.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1079 (unknown "?" italic "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1080 unknown, you should not see this.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1081 (hidden "-" default "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1082 group now hidden; click on the asterisks above to show contents.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1083 (invalid "x" custom-invalid-face "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1084 the value displayed for this item is invalid and cannot be set.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1085 (modified "*" custom-modified-face "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1086 you have edited something in this group, and can now set it.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1087 (set "+" custom-set-face "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1088 something in this group has been set, but not yet saved.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1089 (changed ":" custom-changed-face "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1090 this item has been changed outside customize.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1091 (saved "!" custom-saved-face "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1092 something in this group has been set and saved.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1093 (rogue "@" custom-rogue-face "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1094 this item is not prepared for customization.") |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1095 (factory " " nil "\ |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1096 nothing in this group has been changed.")) |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1097 "Alist of customize option states. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1098 Each entry is of the form (STATE MAGIC FACE DESCRIPTION), where |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1099 |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1100 STATE is one of the following symbols: |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1101 |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1102 `nil' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1103 For internal use, should never occur. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1104 `unknown' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1105 For internal use, should never occur. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1106 `hidden' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1107 This item is not being displayed. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1108 `invalid' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1109 This item is modified, but has an invalid form. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1110 `modified' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1111 This item is modified, and has a valid form. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1112 `set' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1113 This item has been set but not saved. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1114 `changed' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1115 The current value of this item has been changed temporarily. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1116 `saved' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1117 This item is marked for saving. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1118 `rogue' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1119 This item has no customization information. |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1120 `factory' |
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1121 This item is unchanged from the standard setting. |
17334 | 1122 |
1123 MAGIC is a string used to present that state. | |
1124 | |
1125 FACE is a face used to present the state. | |
1126 | |
1127 DESCRIPTION is a string describing the state. | |
1128 | |
1129 The list should be sorted most significant first." | |
1130 :type '(list (checklist :inline t | |
1131 (group (const nil) | |
1132 (string :tag "Magic") | |
1133 face | |
1134 (string :tag "Description")) | |
1135 (group (const unknown) | |
1136 (string :tag "Magic") | |
1137 face | |
1138 (string :tag "Description")) | |
1139 (group (const hidden) | |
1140 (string :tag "Magic") | |
1141 face | |
1142 (string :tag "Description")) | |
1143 (group (const invalid) | |
1144 (string :tag "Magic") | |
1145 face | |
1146 (string :tag "Description")) | |
1147 (group (const modified) | |
1148 (string :tag "Magic") | |
1149 face | |
1150 (string :tag "Description")) | |
1151 (group (const set) | |
1152 (string :tag "Magic") | |
1153 face | |
1154 (string :tag "Description")) | |
1155 (group (const changed) | |
1156 (string :tag "Magic") | |
1157 face | |
1158 (string :tag "Description")) | |
1159 (group (const saved) | |
1160 (string :tag "Magic") | |
1161 face | |
1162 (string :tag "Description")) | |
1163 (group (const rogue) | |
1164 (string :tag "Magic") | |
1165 face | |
1166 (string :tag "Description")) | |
1167 (group (const factory) | |
1168 (string :tag "Magic") | |
1169 face | |
1170 (string :tag "Description"))) | |
1171 (editable-list :inline t | |
1172 (group symbol | |
1173 (string :tag "Magic") | |
1174 face | |
1175 (string :tag "Description")))) | |
17415 | 1176 :group 'customize |
1177 :group 'custom-faces) | |
17334 | 1178 |
1179 (defcustom custom-magic-show 'long | |
1180 "Show long description of the state of each customization option." | |
1181 :type '(choice (const :tag "no" nil) | |
1182 (const short) | |
1183 (const long)) | |
1184 :group 'customize) | |
1185 | |
1186 (defcustom custom-magic-show-button t | |
1187 "Show a magic button indicating the state of each customization option." | |
1188 :type 'boolean | |
1189 :group 'customize) | |
1190 | |
1191 (define-widget 'custom-magic 'default | |
1192 "Show and manipulate state for a customization option." | |
1193 :format "%v" | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1194 :action 'widget-parent-action |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1195 :notify 'ignore |
17334 | 1196 :value-get 'ignore |
1197 :value-create 'custom-magic-value-create | |
1198 :value-delete 'widget-children-value-delete) | |
1199 | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1200 (defun widget-magic-mouse-down-action (widget &optional event) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1201 ;; Non-nil unless hidden. |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1202 (not (eq (widget-get (widget-get (widget-get widget :parent) :parent) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1203 :custom-state) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1204 'hidden))) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1205 |
17334 | 1206 (defun custom-magic-value-create (widget) |
1207 ;; Create compact status report for WIDGET. | |
1208 (let* ((parent (widget-get widget :parent)) | |
1209 (state (widget-get parent :custom-state)) | |
17800
ebc3066cd381
Restored code lost in merge.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17798
diff
changeset
|
1210 (entry (assq state (if (eq (car parent) 'custom-group) |
ebc3066cd381
Restored code lost in merge.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17798
diff
changeset
|
1211 custom-group-magic-alist |
ebc3066cd381
Restored code lost in merge.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17798
diff
changeset
|
1212 custom-magic-alist))) |
17334 | 1213 (magic (nth 1 entry)) |
1214 (face (nth 2 entry)) | |
1215 (text (nth 3 entry)) | |
1216 (lisp (eq (widget-get parent :custom-form) 'lisp)) | |
1217 children) | |
1218 (when custom-magic-show | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1219 (push (widget-create-child-and-convert |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1220 widget 'choice-item |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1221 :help-echo "\ |
17334 | 1222 Change the state of this item." |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1223 :format "%[%t%]" |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1224 :mouse-down-action 'widget-magic-mouse-down-action |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1225 :tag "State") |
17334 | 1226 children) |
1227 (insert ": ") | |
1228 (if (eq custom-magic-show 'long) | |
1229 (insert text) | |
1230 (insert (symbol-name state))) | |
1231 (when lisp | |
1232 (insert " (lisp)")) | |
1233 (insert "\n")) | |
1234 (when custom-magic-show-button | |
1235 (when custom-magic-show | |
1236 (let ((indent (widget-get parent :indent))) | |
1237 (when indent | |
1238 (insert-char ? indent)))) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1239 (push (widget-create-child-and-convert |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1240 widget 'choice-item |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1241 :mouse-down-action 'widget-magic-mouse-down-action |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1242 :button-face face |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1243 :help-echo "Change the state." |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1244 :format "%[%t%]" |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1245 :tag (if lisp |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1246 (concat "(" magic ")") |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1247 (concat "[" magic "]"))) |
17334 | 1248 children) |
1249 (insert " ")) | |
1250 (widget-put widget :children children))) | |
1251 | |
1252 (defun custom-magic-reset (widget) | |
1253 "Redraw the :custom-magic property of WIDGET." | |
1254 (let ((magic (widget-get widget :custom-magic))) | |
1255 (widget-value-set magic (widget-value magic)))) | |
1256 | |
1257 ;;; The `custom-level' Widget. | |
1258 | |
1259 (define-widget 'custom-level 'item | |
1260 "The custom level buttons." | |
1261 :format "%[%t%]" | |
1262 :help-echo "Expand or collapse this item." | |
1263 :action 'custom-level-action) | |
1264 | |
1265 (defun custom-level-action (widget &optional event) | |
1266 "Toggle visibility for parent to WIDGET." | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1267 (custom-toggle-hide (widget-get widget :parent))) |
17334 | 1268 |
1269 ;;; The `custom' Widget. | |
1270 | |
1271 (define-widget 'custom 'default | |
1272 "Customize a user option." | |
1273 :convert-widget 'custom-convert-widget | |
1274 :format "%l%[%t%]: %v%m%h%a" | |
1275 :format-handler 'custom-format-handler | |
1276 :notify 'custom-notify | |
1277 :custom-level 1 | |
1278 :custom-state 'hidden | |
1279 :documentation-property 'widget-subclass-responsibility | |
1280 :value-create 'widget-subclass-responsibility | |
1281 :value-delete 'widget-children-value-delete | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1282 :value-get 'widget-value-value-get |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1283 :validate 'widget-children-validate |
17334 | 1284 :match (lambda (widget value) (symbolp value))) |
1285 | |
1286 (defun custom-convert-widget (widget) | |
1287 ;; Initialize :value and :tag from :args in WIDGET. | |
1288 (let ((args (widget-get widget :args))) | |
1289 (when args | |
1290 (widget-put widget :value (widget-apply widget | |
1291 :value-to-internal (car args))) | |
1292 (widget-put widget :tag (custom-unlispify-tag-name (car args))) | |
1293 (widget-put widget :args nil))) | |
1294 widget) | |
1295 | |
1296 (defun custom-format-handler (widget escape) | |
1297 ;; We recognize extra escape sequences. | |
1298 (let* ((buttons (widget-get widget :buttons)) | |
1299 (state (widget-get widget :custom-state)) | |
1300 (level (widget-get widget :custom-level))) | |
1301 (cond ((eq escape ?l) | |
1302 (when level | |
1303 (push (widget-create-child-and-convert | |
1304 widget 'custom-level (make-string level ?*)) | |
1305 buttons) | |
1306 (widget-insert " ") | |
1307 (widget-put widget :buttons buttons))) | |
1308 ((eq escape ?L) | |
1309 (when (eq state 'hidden) | |
1310 (widget-insert " ..."))) | |
1311 ((eq escape ?m) | |
1312 (and (eq (preceding-char) ?\n) | |
1313 (widget-get widget :indent) | |
1314 (insert-char ? (widget-get widget :indent))) | |
1315 (let ((magic (widget-create-child-and-convert | |
1316 widget 'custom-magic nil))) | |
1317 (widget-put widget :custom-magic magic) | |
1318 (push magic buttons) | |
1319 (widget-put widget :buttons buttons))) | |
1320 ((eq escape ?a) | |
1321 (let* ((symbol (widget-get widget :value)) | |
1322 (links (get symbol 'custom-links)) | |
1323 (many (> (length links) 2))) | |
1324 (when links | |
1325 (and (eq (preceding-char) ?\n) | |
1326 (widget-get widget :indent) | |
1327 (insert-char ? (widget-get widget :indent))) | |
1328 (insert "See also ") | |
1329 (while links | |
1330 (push (widget-create-child-and-convert widget (car links)) | |
1331 buttons) | |
1332 (setq links (cdr links)) | |
1333 (cond ((null links) | |
1334 (insert ".\n")) | |
1335 ((null (cdr links)) | |
1336 (if many | |
1337 (insert ", and ") | |
1338 (insert " and "))) | |
1339 (t | |
1340 (insert ", ")))) | |
1341 (widget-put widget :buttons buttons)))) | |
1342 (t | |
1343 (widget-default-format-handler widget escape))))) | |
1344 | |
1345 (defun custom-notify (widget &rest args) | |
1346 "Keep track of changes." | |
1347 (unless (memq (widget-get widget :custom-state) '(nil unknown hidden)) | |
1348 (widget-put widget :custom-state 'modified)) | |
1349 (let ((buffer-undo-list t)) | |
1350 (custom-magic-reset widget)) | |
1351 (apply 'widget-default-notify widget args)) | |
1352 | |
1353 (defun custom-redraw (widget) | |
1354 "Redraw WIDGET with current settings." | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1355 (let ((line (count-lines (point-min) (point))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1356 (column (current-column)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1357 (pos (point)) |
17334 | 1358 (from (marker-position (widget-get widget :from))) |
1359 (to (marker-position (widget-get widget :to)))) | |
1360 (save-excursion | |
1361 (widget-value-set widget (widget-value widget)) | |
1362 (custom-redraw-magic widget)) | |
1363 (when (and (>= pos from) (<= pos to)) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1364 (condition-case nil |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1365 (progn |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1366 (if (> column 0) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1367 (goto-line line) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1368 (goto-line (1+ line))) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1369 (move-to-column column)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1370 (error nil))))) |
17334 | 1371 |
1372 (defun custom-redraw-magic (widget) | |
1373 "Redraw WIDGET state with current settings." | |
1374 (while widget | |
1375 (let ((magic (widget-get widget :custom-magic))) | |
1376 (unless magic | |
1377 (debug)) | |
1378 (widget-value-set magic (widget-value magic)) | |
1379 (when (setq widget (widget-get widget :group)) | |
1380 (custom-group-state-update widget)))) | |
1381 (widget-setup)) | |
1382 | |
1383 (defun custom-show (widget value) | |
1384 "Non-nil if WIDGET should be shown with VALUE by default." | |
1385 (let ((show (widget-get widget :custom-show))) | |
1386 (cond ((null show) | |
1387 nil) | |
1388 ((eq t show) | |
1389 t) | |
1390 (t | |
1391 (funcall show widget value))))) | |
1392 | |
17415 | 1393 (defvar custom-load-recursion nil |
1394 "Hack to avoid recursive dependencies.") | |
1395 | |
17334 | 1396 (defun custom-load-symbol (symbol) |
1397 "Load all dependencies for SYMBOL." | |
17415 | 1398 (unless custom-load-recursion |
1399 (let ((custom-load-recursion t) | |
1400 (loads (get symbol 'custom-loads)) | |
1401 load) | |
1402 (while loads | |
1403 (setq load (car loads) | |
1404 loads (cdr loads)) | |
1405 (cond ((symbolp load) | |
1406 (condition-case nil | |
1407 (require load) | |
1408 (error nil))) | |
1409 ((assoc load load-history)) | |
1410 (t | |
1411 (condition-case nil | |
1412 (load-library load) | |
1413 (error nil)))))))) | |
17334 | 1414 |
1415 (defun custom-load-widget (widget) | |
1416 "Load all dependencies for WIDGET." | |
1417 (custom-load-symbol (widget-value widget))) | |
1418 | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1419 (defun custom-toggle-hide (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1420 "Toggle visibility of WIDGET." |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1421 (let ((state (widget-get widget :custom-state))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1422 (cond ((memq state '(invalid modified)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1423 (error "There are unset changes")) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1424 ((eq state 'hidden) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1425 (widget-put widget :custom-state 'unknown)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1426 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1427 (widget-put widget :custom-state 'hidden))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1428 (custom-redraw widget))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1429 |
17334 | 1430 ;;; The `custom-variable' Widget. |
1431 | |
1432 (defface custom-variable-sample-face '((t (:underline t))) | |
1433 "Face used for unpushable variable tags." | |
17415 | 1434 :group 'custom-faces) |
17334 | 1435 |
1436 (defface custom-variable-button-face '((t (:underline t :bold t))) | |
1437 "Face used for pushable variable tags." | |
17415 | 1438 :group 'custom-faces) |
17334 | 1439 |
1440 (define-widget 'custom-variable 'custom | |
1441 "Customize variable." | |
1442 :format "%l%v%m%h%a" | |
1443 :help-echo "Set or reset this variable." | |
1444 :documentation-property 'variable-documentation | |
1445 :custom-state nil | |
1446 :custom-menu 'custom-variable-menu-create | |
1447 :custom-form 'edit | |
1448 :value-create 'custom-variable-value-create | |
1449 :action 'custom-variable-action | |
1450 :custom-set 'custom-variable-set | |
1451 :custom-save 'custom-variable-save | |
1452 :custom-reset-current 'custom-redraw | |
1453 :custom-reset-saved 'custom-variable-reset-saved | |
1454 :custom-reset-factory 'custom-variable-reset-factory) | |
1455 | |
17415 | 1456 (defun custom-variable-type (symbol) |
1457 "Return a widget suitable for editing the value of SYMBOL. | |
1458 If SYMBOL has a `custom-type' property, use that. | |
1459 Otherwise, look up symbol in `custom-guess-type-alist'." | |
1460 (let* ((type (or (get symbol 'custom-type) | |
1461 (and (not (get symbol 'factory-value)) | |
1462 (custom-guess-type symbol)) | |
1463 'sexp)) | |
1464 (options (get symbol 'custom-options)) | |
1465 (tmp (if (listp type) | |
17534
a5cf59eee84b
(custom-variable-type): Use copy-sequence, not copy-list.
Richard M. Stallman <rms@gnu.org>
parents:
17521
diff
changeset
|
1466 (copy-sequence type) |
17415 | 1467 (list type)))) |
1468 (when options | |
1469 (widget-put tmp :options options)) | |
1470 tmp)) | |
1471 | |
17334 | 1472 (defun custom-variable-value-create (widget) |
1473 "Here is where you edit the variables value." | |
1474 (custom-load-widget widget) | |
1475 (let* ((buttons (widget-get widget :buttons)) | |
1476 (children (widget-get widget :children)) | |
1477 (form (widget-get widget :custom-form)) | |
1478 (state (widget-get widget :custom-state)) | |
1479 (symbol (widget-get widget :value)) | |
1480 (tag (widget-get widget :tag)) | |
17415 | 1481 (type (custom-variable-type symbol)) |
17334 | 1482 (conv (widget-convert type)) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1483 (get (or (get symbol 'custom-get) 'default-value)) |
17334 | 1484 (value (if (default-boundp symbol) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1485 (funcall get symbol) |
17334 | 1486 (widget-get conv :value)))) |
1487 ;; If the widget is new, the child determine whether it is hidden. | |
1488 (cond (state) | |
1489 ((custom-show type value) | |
1490 (setq state 'unknown)) | |
1491 (t | |
1492 (setq state 'hidden))) | |
1493 ;; If we don't know the state, see if we need to edit it in lisp form. | |
1494 (when (eq state 'unknown) | |
1495 (unless (widget-apply conv :match value) | |
1496 ;; (widget-apply (widget-convert type) :match value) | |
1497 (setq form 'lisp))) | |
1498 ;; Now we can create the child widget. | |
1499 (cond ((eq state 'hidden) | |
1500 ;; Indicate hidden value. | |
1501 (push (widget-create-child-and-convert | |
1502 widget 'item | |
1503 :format "%{%t%}: ..." | |
1504 :sample-face 'custom-variable-sample-face | |
1505 :tag tag | |
1506 :parent widget) | |
1507 children)) | |
1508 ((eq form 'lisp) | |
1509 ;; In lisp mode edit the saved value when possible. | |
1510 (let* ((value (cond ((get symbol 'saved-value) | |
1511 (car (get symbol 'saved-value))) | |
1512 ((get symbol 'factory-value) | |
1513 (car (get symbol 'factory-value))) | |
1514 ((default-boundp symbol) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1515 (custom-quote (funcall get symbol))) |
17334 | 1516 (t |
1517 (custom-quote (widget-get conv :value)))))) | |
1518 (push (widget-create-child-and-convert | |
1519 widget 'sexp | |
1520 :button-face 'custom-variable-button-face | |
1521 :tag (symbol-name symbol) | |
1522 :parent widget | |
1523 :value value) | |
1524 children))) | |
1525 (t | |
1526 ;; Edit mode. | |
1527 (push (widget-create-child-and-convert | |
1528 widget type | |
1529 :tag tag | |
1530 :button-face 'custom-variable-button-face | |
1531 :sample-face 'custom-variable-sample-face | |
1532 :value value) | |
1533 children))) | |
1534 ;; Now update the state. | |
1535 (unless (eq (preceding-char) ?\n) | |
1536 (widget-insert "\n")) | |
1537 (if (eq state 'hidden) | |
1538 (widget-put widget :custom-state state) | |
1539 (custom-variable-state-set widget)) | |
1540 (widget-put widget :custom-form form) | |
1541 (widget-put widget :buttons buttons) | |
1542 (widget-put widget :children children))) | |
1543 | |
1544 (defun custom-variable-state-set (widget) | |
1545 "Set the state of WIDGET." | |
1546 (let* ((symbol (widget-value widget)) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1547 (get (or (get symbol 'custom-get) 'default-value)) |
17334 | 1548 (value (if (default-boundp symbol) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1549 (funcall get symbol) |
17334 | 1550 (widget-get widget :value))) |
1551 tmp | |
1552 (state (cond ((setq tmp (get symbol 'customized-value)) | |
1553 (if (condition-case nil | |
1554 (equal value (eval (car tmp))) | |
1555 (error nil)) | |
1556 'set | |
1557 'changed)) | |
1558 ((setq tmp (get symbol 'saved-value)) | |
1559 (if (condition-case nil | |
1560 (equal value (eval (car tmp))) | |
1561 (error nil)) | |
1562 'saved | |
1563 'changed)) | |
1564 ((setq tmp (get symbol 'factory-value)) | |
1565 (if (condition-case nil | |
1566 (equal value (eval (car tmp))) | |
1567 (error nil)) | |
1568 'factory | |
1569 'changed)) | |
1570 (t 'rogue)))) | |
1571 (widget-put widget :custom-state state))) | |
1572 | |
1573 (defvar custom-variable-menu | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1574 '(("Hide" custom-toggle-hide |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1575 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1576 (not (memq (widget-get widget :custom-state) '(modified invalid))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1577 ("Edit" custom-variable-edit |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1578 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1579 (not (eq (widget-get widget :custom-form) 'edit)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1580 ("Edit Lisp" custom-variable-edit-lisp |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1581 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1582 (not (eq (widget-get widget :custom-form) 'lisp)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1583 ("Set" custom-variable-set |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1584 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1585 (eq (widget-get widget :custom-state) 'modified))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1586 ("Save" custom-variable-save |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1587 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1588 (memq (widget-get widget :custom-state) '(modified set changed rogue)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1589 ("Reset to Current" custom-redraw |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1590 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1591 (and (default-boundp (widget-value widget)) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1592 (memq (widget-get widget :custom-state) '(modified changed))))) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1593 ("Reset to Saved" custom-variable-reset-saved |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1594 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1595 (and (get (widget-value widget) 'saved-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1596 (memq (widget-get widget :custom-state) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1597 '(modified set changed rogue))))) |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1598 ("Reset to Standard Settings" custom-variable-reset-factory |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1599 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1600 (and (get (widget-value widget) 'factory-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1601 (memq (widget-get widget :custom-state) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1602 '(modified set changed saved rogue)))))) |
17334 | 1603 "Alist of actions for the `custom-variable' widget. |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1604 Each entry has the form (NAME ACTION FILTER) where NAME is the name of |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1605 the menu entry, ACTION is the function to call on the widget when the |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1606 menu is selected, and FILTER is a predicate which takes a `custom-variable' |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1607 widget as an argument, and returns non-nil if ACTION is valid on that |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1608 widget. If FILTER is nil, ACTION is always valid.") |
17334 | 1609 |
1610 (defun custom-variable-action (widget &optional event) | |
1611 "Show the menu for `custom-variable' WIDGET. | |
1612 Optional EVENT is the location for the menu." | |
1613 (if (eq (widget-get widget :custom-state) 'hidden) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1614 (custom-toggle-hide widget) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1615 (unless (eq (widget-get widget :custom-state) 'modified) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1616 (custom-variable-state-set widget)) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1617 (custom-redraw-magic widget) |
17334 | 1618 (let* ((completion-ignore-case t) |
1619 (answer (widget-choose (custom-unlispify-tag-name | |
1620 (widget-get widget :value)) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1621 (custom-menu-filter custom-variable-menu |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1622 widget) |
17334 | 1623 event))) |
1624 (if answer | |
1625 (funcall answer widget))))) | |
1626 | |
1627 (defun custom-variable-edit (widget) | |
1628 "Edit value of WIDGET." | |
1629 (widget-put widget :custom-state 'unknown) | |
1630 (widget-put widget :custom-form 'edit) | |
1631 (custom-redraw widget)) | |
1632 | |
1633 (defun custom-variable-edit-lisp (widget) | |
1634 "Edit the lisp representation of the value of WIDGET." | |
1635 (widget-put widget :custom-state 'unknown) | |
1636 (widget-put widget :custom-form 'lisp) | |
1637 (custom-redraw widget)) | |
1638 | |
1639 (defun custom-variable-set (widget) | |
1640 "Set the current value for the variable being edited by WIDGET." | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1641 (let* ((form (widget-get widget :custom-form)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1642 (state (widget-get widget :custom-state)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1643 (child (car (widget-get widget :children))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1644 (symbol (widget-value widget)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1645 (set (or (get symbol 'custom-set) 'set-default)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1646 val) |
17334 | 1647 (cond ((eq state 'hidden) |
1648 (error "Cannot set hidden variable.")) | |
1649 ((setq val (widget-apply child :validate)) | |
1650 (goto-char (widget-get val :from)) | |
1651 (error "%s" (widget-get val :error))) | |
1652 ((eq form 'lisp) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1653 (funcall set symbol (eval (setq val (widget-value child)))) |
17334 | 1654 (put symbol 'customized-value (list val))) |
1655 (t | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1656 (funcall set symbol (setq val (widget-value child))) |
17334 | 1657 (put symbol 'customized-value (list (custom-quote val))))) |
1658 (custom-variable-state-set widget) | |
1659 (custom-redraw-magic widget))) | |
1660 | |
1661 (defun custom-variable-save (widget) | |
1662 "Set the default value for the variable being edited by WIDGET." | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1663 (let* ((form (widget-get widget :custom-form)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1664 (state (widget-get widget :custom-state)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1665 (child (car (widget-get widget :children))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1666 (symbol (widget-value widget)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1667 (set (or (get symbol 'custom-set) 'set-default)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1668 val) |
17334 | 1669 (cond ((eq state 'hidden) |
1670 (error "Cannot set hidden variable.")) | |
1671 ((setq val (widget-apply child :validate)) | |
1672 (goto-char (widget-get val :from)) | |
1673 (error "%s" (widget-get val :error))) | |
1674 ((eq form 'lisp) | |
1675 (put symbol 'saved-value (list (widget-value child))) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1676 (funcall set symbol (eval (widget-value child)))) |
17334 | 1677 (t |
1678 (put symbol | |
1679 'saved-value (list (custom-quote (widget-value | |
1680 child)))) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1681 (funcall set symbol (widget-value child)))) |
17334 | 1682 (put symbol 'customized-value nil) |
1683 (custom-save-all) | |
1684 (custom-variable-state-set widget) | |
1685 (custom-redraw-magic widget))) | |
1686 | |
1687 (defun custom-variable-reset-saved (widget) | |
1688 "Restore the saved value for the variable being edited by WIDGET." | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1689 (let* ((symbol (widget-value widget)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1690 (set (or (get symbol 'custom-set) 'set-default))) |
17334 | 1691 (if (get symbol 'saved-value) |
1692 (condition-case nil | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1693 (funcall set symbol (eval (car (get symbol 'saved-value)))) |
17334 | 1694 (error nil)) |
1695 (error "No saved value for %s" symbol)) | |
1696 (put symbol 'customized-value nil) | |
1697 (widget-put widget :custom-state 'unknown) | |
1698 (custom-redraw widget))) | |
1699 | |
1700 (defun custom-variable-reset-factory (widget) | |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1701 "Restore the standard setting for the variable being edited by WIDGET." |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1702 (let* ((symbol (widget-value widget)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1703 (set (or (get symbol 'custom-set) 'set-default))) |
17334 | 1704 (if (get symbol 'factory-value) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1705 (funcall set symbol (eval (car (get symbol 'factory-value)))) |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1706 (error "No standard setting known for %S" symbol)) |
17334 | 1707 (put symbol 'customized-value nil) |
1708 (when (get symbol 'saved-value) | |
1709 (put symbol 'saved-value nil) | |
1710 (custom-save-all)) | |
1711 (widget-put widget :custom-state 'unknown) | |
1712 (custom-redraw widget))) | |
1713 | |
1714 ;;; The `custom-face-edit' Widget. | |
1715 | |
1716 (define-widget 'custom-face-edit 'checklist | |
1717 "Edit face attributes." | |
1718 :format "%t: %v" | |
1719 :tag "Attributes" | |
1720 :extra-offset 12 | |
1721 :button-args '(:help-echo "Control whether this attribute have any effect.") | |
1722 :args (mapcar (lambda (att) | |
1723 (list 'group | |
1724 :inline t | |
1725 :sibling-args (widget-get (nth 1 att) :sibling-args) | |
1726 (list 'const :format "" :value (nth 0 att)) | |
1727 (nth 1 att))) | |
1728 custom-face-attributes)) | |
1729 | |
1730 ;;; The `custom-display' Widget. | |
1731 | |
1732 (define-widget 'custom-display 'menu-choice | |
1733 "Select a display type." | |
1734 :tag "Display" | |
1735 :value t | |
1736 :help-echo "Specify frames where the face attributes should be used." | |
1737 :args '((const :tag "all" t) | |
1738 (checklist | |
1739 :offset 0 | |
1740 :extra-offset 9 | |
1741 :args ((group :sibling-args (:help-echo "\ | |
1742 Only match the specified window systems.") | |
1743 (const :format "Type: " | |
1744 type) | |
1745 (checklist :inline t | |
1746 :offset 0 | |
1747 (const :format "X " | |
1748 :sibling-args (:help-echo "\ | |
1749 The X11 Window System.") | |
1750 x) | |
1751 (const :format "PM " | |
1752 :sibling-args (:help-echo "\ | |
1753 OS/2 Presentation Manager.") | |
1754 pm) | |
1755 (const :format "Win32 " | |
1756 :sibling-args (:help-echo "\ | |
1757 Windows NT/95/97.") | |
1758 win32) | |
1759 (const :format "DOS " | |
1760 :sibling-args (:help-echo "\ | |
1761 Plain MS-DOS.") | |
1762 pc) | |
1763 (const :format "TTY%n" | |
1764 :sibling-args (:help-echo "\ | |
1765 Plain text terminals.") | |
1766 tty))) | |
1767 (group :sibling-args (:help-echo "\ | |
1768 Only match the frames with the specified color support.") | |
1769 (const :format "Class: " | |
1770 class) | |
1771 (checklist :inline t | |
1772 :offset 0 | |
1773 (const :format "Color " | |
1774 :sibling-args (:help-echo "\ | |
1775 Match color frames.") | |
1776 color) | |
1777 (const :format "Grayscale " | |
1778 :sibling-args (:help-echo "\ | |
1779 Match grayscale frames.") | |
1780 grayscale) | |
1781 (const :format "Monochrome%n" | |
1782 :sibling-args (:help-echo "\ | |
1783 Match frames with no color support.") | |
1784 mono))) | |
1785 (group :sibling-args (:help-echo "\ | |
1786 Only match frames with the specified intensity.") | |
1787 (const :format "\ | |
1788 Background brightness: " | |
1789 background) | |
1790 (checklist :inline t | |
1791 :offset 0 | |
1792 (const :format "Light " | |
1793 :sibling-args (:help-echo "\ | |
1794 Match frames with light backgrounds.") | |
1795 light) | |
1796 (const :format "Dark\n" | |
1797 :sibling-args (:help-echo "\ | |
1798 Match frames with dark backgrounds.") | |
1799 dark))))))) | |
1800 | |
1801 ;;; The `custom-face' Widget. | |
1802 | |
1803 (defface custom-face-tag-face '((t (:underline t))) | |
1804 "Face used for face tags." | |
17415 | 1805 :group 'custom-faces) |
17334 | 1806 |
1807 (define-widget 'custom-face 'custom | |
1808 "Customize face." | |
1809 :format "%l%{%t%}: %s%m%h%a%v" | |
1810 :format-handler 'custom-face-format-handler | |
1811 :sample-face 'custom-face-tag-face | |
1812 :help-echo "Set or reset this face." | |
1813 :documentation-property '(lambda (face) | |
1814 (face-doc-string face)) | |
1815 :value-create 'custom-face-value-create | |
1816 :action 'custom-face-action | |
1817 :custom-form 'selected | |
1818 :custom-set 'custom-face-set | |
1819 :custom-save 'custom-face-save | |
1820 :custom-reset-current 'custom-redraw | |
1821 :custom-reset-saved 'custom-face-reset-saved | |
1822 :custom-reset-factory 'custom-face-reset-factory | |
1823 :custom-menu 'custom-face-menu-create) | |
1824 | |
1825 (defun custom-face-format-handler (widget escape) | |
1826 ;; We recognize extra escape sequences. | |
1827 (let (child | |
1828 (symbol (widget-get widget :value))) | |
1829 (cond ((eq escape ?s) | |
1830 (and (string-match "XEmacs" emacs-version) | |
1831 ;; XEmacs cannot display initialized faces. | |
1832 (not (custom-facep symbol)) | |
1833 (copy-face 'custom-face-empty symbol)) | |
1834 (setq child (widget-create-child-and-convert | |
1835 widget 'item | |
1836 :format "(%{%t%})\n" | |
1837 :sample-face symbol | |
1838 :tag "sample"))) | |
1839 (t | |
1840 (custom-format-handler widget escape))) | |
1841 (when child | |
1842 (widget-put widget | |
1843 :buttons (cons child (widget-get widget :buttons)))))) | |
1844 | |
1845 (define-widget 'custom-face-all 'editable-list | |
1846 "An editable list of display specifications and attributes." | |
1847 :entry-format "%i %d %v" | |
1848 :insert-button-args '(:help-echo "Insert new display specification here.") | |
1849 :append-button-args '(:help-echo "Append new display specification here.") | |
1850 :delete-button-args '(:help-echo "Delete this display specification.") | |
1851 :args '((group :format "%v" custom-display custom-face-edit))) | |
1852 | |
1853 (defconst custom-face-all (widget-convert 'custom-face-all) | |
1854 "Converted version of the `custom-face-all' widget.") | |
1855 | |
1856 (define-widget 'custom-display-unselected 'item | |
1857 "A display specification that doesn't match the selected display." | |
1858 :match 'custom-display-unselected-match) | |
1859 | |
1860 (defun custom-display-unselected-match (widget value) | |
1861 "Non-nil if VALUE is an unselected display specification." | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1862 (not (face-spec-set-match-display value (selected-frame)))) |
17334 | 1863 |
1864 (define-widget 'custom-face-selected 'group | |
1865 "Edit the attributes of the selected display in a face specification." | |
1866 :args '((repeat :format "" | |
1867 :inline t | |
1868 (group custom-display-unselected sexp)) | |
1869 (group (sexp :format "") custom-face-edit) | |
1870 (repeat :format "" | |
1871 :inline t | |
1872 sexp))) | |
1873 | |
1874 (defconst custom-face-selected (widget-convert 'custom-face-selected) | |
1875 "Converted version of the `custom-face-selected' widget.") | |
1876 | |
1877 (defun custom-face-value-create (widget) | |
1878 ;; Create a list of the display specifications. | |
1879 (unless (eq (preceding-char) ?\n) | |
1880 (insert "\n")) | |
1881 (when (not (eq (widget-get widget :custom-state) 'hidden)) | |
1882 (message "Creating face editor...") | |
1883 (custom-load-widget widget) | |
1884 (let* ((symbol (widget-value widget)) | |
1885 (spec (or (get symbol 'saved-face) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1886 (get symbol 'face-defface-spec) |
17334 | 1887 ;; Attempt to construct it. |
1888 (list (list t (custom-face-attributes-get | |
1889 symbol (selected-frame)))))) | |
1890 (form (widget-get widget :custom-form)) | |
1891 (indent (widget-get widget :indent)) | |
1892 (edit (widget-create-child-and-convert | |
1893 widget | |
1894 (cond ((and (eq form 'selected) | |
1895 (widget-apply custom-face-selected :match spec)) | |
1896 (when indent (insert-char ?\ indent)) | |
1897 'custom-face-selected) | |
1898 ((and (not (eq form 'lisp)) | |
1899 (widget-apply custom-face-all :match spec)) | |
1900 'custom-face-all) | |
1901 (t | |
1902 (when indent (insert-char ?\ indent)) | |
1903 'sexp)) | |
1904 :value spec))) | |
1905 (custom-face-state-set widget) | |
1906 (widget-put widget :children (list edit))) | |
1907 (message "Creating face editor...done"))) | |
1908 | |
1909 (defvar custom-face-menu | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1910 '(("Hide" custom-toggle-hide |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1911 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1912 (not (memq (widget-get widget :custom-state) '(modified invalid))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1913 ("Edit Selected" custom-face-edit-selected |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1914 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1915 (not (eq (widget-get widget :custom-form) 'selected)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1916 ("Edit All" custom-face-edit-all |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1917 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1918 (not (eq (widget-get widget :custom-form) 'all)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1919 ("Edit Lisp" custom-face-edit-lisp |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1920 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1921 (not (eq (widget-get widget :custom-form) 'lisp)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1922 ("Set" custom-face-set) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1923 ("Save" custom-face-save) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1924 ("Reset to Saved" custom-face-reset-saved |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1925 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1926 (get (widget-value widget) 'saved-face))) |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
1927 ("Reset to Standard Setting" custom-face-reset-factory |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1928 (lambda (widget) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1929 (get (widget-value widget) 'face-defface-spec)))) |
17334 | 1930 "Alist of actions for the `custom-face' widget. |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1931 Each entry has the form (NAME ACTION FILTER) where NAME is the name of |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1932 the menu entry, ACTION is the function to call on the widget when the |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1933 menu is selected, and FILTER is a predicate which takes a `custom-face' |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1934 widget as an argument, and returns non-nil if ACTION is valid on that |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1935 widget. If FILTER is nil, ACTION is always valid.") |
17334 | 1936 |
1937 (defun custom-face-edit-selected (widget) | |
1938 "Edit selected attributes of the value of WIDGET." | |
1939 (widget-put widget :custom-state 'unknown) | |
1940 (widget-put widget :custom-form 'selected) | |
1941 (custom-redraw widget)) | |
1942 | |
1943 (defun custom-face-edit-all (widget) | |
1944 "Edit all attributes of the value of WIDGET." | |
1945 (widget-put widget :custom-state 'unknown) | |
1946 (widget-put widget :custom-form 'all) | |
1947 (custom-redraw widget)) | |
1948 | |
1949 (defun custom-face-edit-lisp (widget) | |
1950 "Edit the lisp representation of the value of WIDGET." | |
1951 (widget-put widget :custom-state 'unknown) | |
1952 (widget-put widget :custom-form 'lisp) | |
1953 (custom-redraw widget)) | |
1954 | |
1955 (defun custom-face-state-set (widget) | |
1956 "Set the state of WIDGET." | |
1957 (let ((symbol (widget-value widget))) | |
1958 (widget-put widget :custom-state (cond ((get symbol 'customized-face) | |
1959 'set) | |
1960 ((get symbol 'saved-face) | |
1961 'saved) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
1962 ((get symbol 'face-defface-spec) |
17334 | 1963 'factory) |
1964 (t | |
1965 'rogue))))) | |
1966 | |
1967 (defun custom-face-action (widget &optional event) | |
1968 "Show the menu for `custom-face' WIDGET. | |
1969 Optional EVENT is the location for the menu." | |
1970 (if (eq (widget-get widget :custom-state) 'hidden) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1971 (custom-toggle-hide widget) |
17334 | 1972 (let* ((completion-ignore-case t) |
1973 (symbol (widget-get widget :value)) | |
1974 (answer (widget-choose (custom-unlispify-tag-name symbol) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1975 (custom-menu-filter custom-face-menu |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1976 widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
1977 event))) |
17334 | 1978 (if answer |
1979 (funcall answer widget))))) | |
1980 | |
1981 (defun custom-face-set (widget) | |
1982 "Make the face attributes in WIDGET take effect." | |
1983 (let* ((symbol (widget-value widget)) | |
1984 (child (car (widget-get widget :children))) | |
1985 (value (widget-value child))) | |
1986 (put symbol 'customized-face value) | |
1987 (custom-face-display-set symbol value) | |
1988 (custom-face-state-set widget) | |
1989 (custom-redraw-magic widget))) | |
1990 | |
1991 (defun custom-face-save (widget) | |
1992 "Make the face attributes in WIDGET default." | |
1993 (let* ((symbol (widget-value widget)) | |
1994 (child (car (widget-get widget :children))) | |
1995 (value (widget-value child))) | |
1996 (custom-face-display-set symbol value) | |
1997 (put symbol 'saved-face value) | |
1998 (put symbol 'customized-face nil) | |
1999 (custom-face-state-set widget) | |
2000 (custom-redraw-magic widget))) | |
2001 | |
2002 (defun custom-face-reset-saved (widget) | |
2003 "Restore WIDGET to the face's default attributes." | |
2004 (let* ((symbol (widget-value widget)) | |
2005 (child (car (widget-get widget :children))) | |
2006 (value (get symbol 'saved-face))) | |
2007 (unless value | |
2008 (error "No saved value for this face")) | |
2009 (put symbol 'customized-face nil) | |
2010 (custom-face-display-set symbol value) | |
2011 (widget-value-set child value) | |
2012 (custom-face-state-set widget) | |
2013 (custom-redraw-magic widget))) | |
2014 | |
2015 (defun custom-face-reset-factory (widget) | |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
2016 "Restore WIDGET to the face's standard settings." |
17334 | 2017 (let* ((symbol (widget-value widget)) |
2018 (child (car (widget-get widget :children))) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2019 (value (get symbol 'face-defface-spec))) |
17334 | 2020 (unless value |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
2021 (error "No standard setting for this face")) |
17334 | 2022 (put symbol 'customized-face nil) |
2023 (when (get symbol 'saved-face) | |
2024 (put symbol 'saved-face nil) | |
2025 (custom-save-all)) | |
2026 (custom-face-display-set symbol value) | |
2027 (widget-value-set child value) | |
2028 (custom-face-state-set widget) | |
2029 (custom-redraw-magic widget))) | |
2030 | |
2031 ;;; The `face' Widget. | |
2032 | |
2033 (define-widget 'face 'default | |
2034 "Select and customize a face." | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2035 :convert-widget 'widget-value-convert-widget |
17334 | 2036 :format "%[%t%]: %v" |
2037 :tag "Face" | |
2038 :value 'default | |
2039 :value-create 'widget-face-value-create | |
2040 :value-delete 'widget-face-value-delete | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2041 :value-get 'widget-value-value-get |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2042 :validate 'widget-children-validate |
17334 | 2043 :action 'widget-face-action |
2044 :match '(lambda (widget value) (symbolp value))) | |
2045 | |
2046 (defun widget-face-value-create (widget) | |
2047 ;; Create a `custom-face' child. | |
2048 (let* ((symbol (widget-value widget)) | |
2049 (child (widget-create-child-and-convert | |
2050 widget 'custom-face | |
2051 :format "%t %s%m%h%v" | |
2052 :custom-level nil | |
2053 :value symbol))) | |
2054 (custom-magic-reset child) | |
2055 (setq custom-options (cons child custom-options)) | |
2056 (widget-put widget :children (list child)))) | |
2057 | |
2058 (defun widget-face-value-delete (widget) | |
2059 ;; Remove the child from the options. | |
2060 (let ((child (car (widget-get widget :children)))) | |
2061 (setq custom-options (delq child custom-options)) | |
2062 (widget-children-value-delete widget))) | |
2063 | |
2064 (defvar face-history nil | |
2065 "History of entered face names.") | |
2066 | |
2067 (defun widget-face-action (widget &optional event) | |
2068 "Prompt for a face." | |
2069 (let ((answer (completing-read "Face: " | |
2070 (mapcar (lambda (face) | |
2071 (list (symbol-name face))) | |
2072 (face-list)) | |
2073 nil nil nil | |
2074 'face-history))) | |
2075 (unless (zerop (length answer)) | |
2076 (widget-value-set widget (intern answer)) | |
2077 (widget-apply widget :notify widget event) | |
2078 (widget-setup)))) | |
2079 | |
2080 ;;; The `hook' Widget. | |
2081 | |
2082 (define-widget 'hook 'list | |
2083 "A emacs lisp hook" | |
2084 :convert-widget 'custom-hook-convert-widget | |
2085 :tag "Hook") | |
2086 | |
2087 (defun custom-hook-convert-widget (widget) | |
2088 ;; Handle `:custom-options'. | |
2089 (let* ((options (widget-get widget :options)) | |
2090 (other `(editable-list :inline t | |
2091 :entry-format "%i %d%v" | |
2092 (function :format " %v"))) | |
2093 (args (if options | |
2094 (list `(checklist :inline t | |
2095 ,@(mapcar (lambda (entry) | |
2096 `(function-item ,entry)) | |
2097 options)) | |
2098 other) | |
2099 (list other)))) | |
2100 (widget-put widget :args args) | |
2101 widget)) | |
2102 | |
2103 ;;; The `custom-group' Widget. | |
2104 | |
2105 (defcustom custom-group-tag-faces '(custom-group-tag-face-1) | |
2106 ;; In XEmacs, this ought to play games with font size. | |
2107 "Face used for group tags. | |
2108 The first member is used for level 1 groups, the second for level 2, | |
2109 and so forth. The remaining group tags are shown with | |
2110 `custom-group-tag-face'." | |
2111 :type '(repeat face) | |
17415 | 2112 :group 'custom-faces) |
17334 | 2113 |
2114 (defface custom-group-tag-face-1 '((((class color) | |
2115 (background dark)) | |
2116 (:foreground "pink" :underline t)) | |
2117 (((class color) | |
2118 (background light)) | |
2119 (:foreground "red" :underline t)) | |
2120 (t (:underline t))) | |
2121 "Face used for group tags.") | |
2122 | |
2123 (defface custom-group-tag-face '((((class color) | |
2124 (background dark)) | |
2125 (:foreground "light blue" :underline t)) | |
2126 (((class color) | |
2127 (background light)) | |
2128 (:foreground "blue" :underline t)) | |
2129 (t (:underline t))) | |
2130 "Face used for low level group tags." | |
17415 | 2131 :group 'custom-faces) |
17334 | 2132 |
2133 (define-widget 'custom-group 'custom | |
2134 "Customize group." | |
2135 :format "%l%{%t%}:%L\n%m%h%a%v" | |
2136 :sample-face-get 'custom-group-sample-face-get | |
2137 :documentation-property 'group-documentation | |
2138 :help-echo "Set or reset all members of this group." | |
2139 :value-create 'custom-group-value-create | |
2140 :action 'custom-group-action | |
2141 :custom-set 'custom-group-set | |
2142 :custom-save 'custom-group-save | |
2143 :custom-reset-current 'custom-group-reset-current | |
2144 :custom-reset-saved 'custom-group-reset-saved | |
2145 :custom-reset-factory 'custom-group-reset-factory | |
2146 :custom-menu 'custom-group-menu-create) | |
2147 | |
2148 (defun custom-group-sample-face-get (widget) | |
2149 ;; Use :sample-face. | |
2150 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces) | |
2151 'custom-group-tag-face)) | |
2152 | |
2153 (defun custom-group-value-create (widget) | |
2154 (let ((state (widget-get widget :custom-state))) | |
2155 (unless (eq state 'hidden) | |
2156 (message "Creating group...") | |
2157 (custom-load-widget widget) | |
2158 (let* ((level (widget-get widget :custom-level)) | |
2159 (symbol (widget-value widget)) | |
2160 (members (get symbol 'custom-group)) | |
2161 (prefixes (widget-get widget :custom-prefixes)) | |
2162 (custom-prefix-list (custom-prefix-add symbol prefixes)) | |
2163 (length (length members)) | |
2164 (count 0) | |
2165 (children (mapcar (lambda (entry) | |
2166 (widget-insert "\n") | |
2167 (message "Creating group members... %2d%%" | |
2168 (/ (* 100.0 count) length)) | |
2169 (setq count (1+ count)) | |
2170 (prog1 | |
2171 (widget-create-child-and-convert | |
2172 widget (nth 1 entry) | |
2173 :group widget | |
2174 :tag (custom-unlispify-tag-name | |
2175 (nth 0 entry)) | |
2176 :custom-prefixes custom-prefix-list | |
2177 :custom-level (1+ level) | |
2178 :value (nth 0 entry)) | |
2179 (unless (eq (preceding-char) ?\n) | |
2180 (widget-insert "\n")))) | |
2181 members))) | |
2182 (message "Creating group magic...") | |
2183 (mapcar 'custom-magic-reset children) | |
2184 (message "Creating group state...") | |
2185 (widget-put widget :children children) | |
2186 (custom-group-state-update widget) | |
2187 (message "Creating group... done"))))) | |
2188 | |
2189 (defvar custom-group-menu | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2190 '(("Hide" custom-toggle-hide |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2191 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2192 (not (memq (widget-get widget :custom-state) '(modified invalid))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2193 ("Set" custom-group-set |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2194 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2195 (eq (widget-get widget :custom-state) 'modified))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2196 ("Save" custom-group-save |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2197 (lambda (widget) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2198 (memq (widget-get widget :custom-state) '(modified set)))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2199 ("Reset to Current" custom-group-reset-current |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2200 (lambda (widget) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2201 (memq (widget-get widget :custom-state) '(modified)))) |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2202 ("Reset to Saved" custom-group-reset-saved |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2203 (lambda (widget) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2204 (memq (widget-get widget :custom-state) '(modified set)))) |
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2205 ("Reset to standard setting" custom-group-reset-factory |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2206 (lambda (widget) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2207 (memq (widget-get widget :custom-state) '(modified set saved))))) |
17334 | 2208 "Alist of actions for the `custom-group' widget. |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2209 Each entry has the form (NAME ACTION FILTER) where NAME is the name of |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2210 the menu entry, ACTION is the function to call on the widget when the |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2211 menu is selected, and FILTER is a predicate which takes a `custom-group' |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2212 widget as an argument, and returns non-nil if ACTION is valid on that |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2213 widget. If FILTER is nil, ACTION is always valid.") |
17334 | 2214 |
2215 (defun custom-group-action (widget &optional event) | |
2216 "Show the menu for `custom-group' WIDGET. | |
2217 Optional EVENT is the location for the menu." | |
2218 (if (eq (widget-get widget :custom-state) 'hidden) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2219 (custom-toggle-hide widget) |
17334 | 2220 (let* ((completion-ignore-case t) |
2221 (answer (widget-choose (custom-unlispify-tag-name | |
2222 (widget-get widget :value)) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2223 (custom-menu-filter custom-group-menu |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2224 widget) |
17334 | 2225 event))) |
2226 (if answer | |
2227 (funcall answer widget))))) | |
2228 | |
2229 (defun custom-group-set (widget) | |
2230 "Set changes in all modified group members." | |
2231 (let ((children (widget-get widget :children))) | |
2232 (mapcar (lambda (child) | |
2233 (when (eq (widget-get child :custom-state) 'modified) | |
2234 (widget-apply child :custom-set))) | |
2235 children ))) | |
2236 | |
2237 (defun custom-group-save (widget) | |
2238 "Save all modified group members." | |
2239 (let ((children (widget-get widget :children))) | |
2240 (mapcar (lambda (child) | |
2241 (when (memq (widget-get child :custom-state) '(modified set)) | |
2242 (widget-apply child :custom-save))) | |
2243 children ))) | |
2244 | |
2245 (defun custom-group-reset-current (widget) | |
2246 "Reset all modified group members." | |
2247 (let ((children (widget-get widget :children))) | |
2248 (mapcar (lambda (child) | |
2249 (when (eq (widget-get child :custom-state) 'modified) | |
2250 (widget-apply child :custom-reset-current))) | |
2251 children ))) | |
2252 | |
2253 (defun custom-group-reset-saved (widget) | |
2254 "Reset all modified or set group members." | |
2255 (let ((children (widget-get widget :children))) | |
2256 (mapcar (lambda (child) | |
2257 (when (memq (widget-get child :custom-state) '(modified set)) | |
2258 (widget-apply child :custom-reset-saved))) | |
2259 children ))) | |
2260 | |
2261 (defun custom-group-reset-factory (widget) | |
2262 "Reset all modified, set, or saved group members." | |
2263 (let ((children (widget-get widget :children))) | |
2264 (mapcar (lambda (child) | |
2265 (when (memq (widget-get child :custom-state) | |
2266 '(modified set saved)) | |
2267 (widget-apply child :custom-reset-factory))) | |
2268 children ))) | |
2269 | |
2270 (defun custom-group-state-update (widget) | |
2271 "Update magic." | |
2272 (unless (eq (widget-get widget :custom-state) 'hidden) | |
2273 (let* ((children (widget-get widget :children)) | |
2274 (states (mapcar (lambda (child) | |
2275 (widget-get child :custom-state)) | |
2276 children)) | |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
2277 (magics custom-group-magic-alist) |
17334 | 2278 (found 'factory)) |
2279 (while magics | |
2280 (let ((magic (car (car magics)))) | |
2281 (if (and (not (eq magic 'hidden)) | |
2282 (memq magic states)) | |
2283 (setq found magic | |
2284 magics nil) | |
2285 (setq magics (cdr magics))))) | |
2286 (widget-put widget :custom-state found))) | |
2287 (custom-magic-reset widget)) | |
2288 | |
2289 ;;; The `custom-save-all' Function. | |
2290 | |
2291 (defcustom custom-file "~/.emacs" | |
2292 "File used for storing customization information. | |
2293 If you change this from the default \"~/.emacs\" you need to | |
2294 explicitly load that file for the settings to take effect." | |
2295 :type 'file | |
2296 :group 'customize) | |
2297 | |
2298 (defun custom-save-delete (symbol) | |
2299 "Delete the call to SYMBOL form `custom-file'. | |
2300 Leave point at the location of the call, or after the last expression." | |
2301 (set-buffer (find-file-noselect custom-file)) | |
2302 (goto-char (point-min)) | |
2303 (catch 'found | |
2304 (while t | |
2305 (let ((sexp (condition-case nil | |
2306 (read (current-buffer)) | |
2307 (end-of-file (throw 'found nil))))) | |
2308 (when (and (listp sexp) | |
2309 (eq (car sexp) symbol)) | |
2310 (delete-region (save-excursion | |
2311 (backward-sexp) | |
2312 (point)) | |
2313 (point)) | |
2314 (throw 'found nil)))))) | |
2315 | |
2316 (defun custom-save-variables () | |
2317 "Save all customized variables in `custom-file'." | |
2318 (save-excursion | |
2319 (custom-save-delete 'custom-set-variables) | |
2320 (let ((standard-output (current-buffer))) | |
2321 (unless (bolp) | |
2322 (princ "\n")) | |
2323 (princ "(custom-set-variables") | |
2324 (mapatoms (lambda (symbol) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2325 (let ((value (get symbol 'saved-value)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2326 (requests (get symbol 'custom-requests)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2327 (now (not (or (get symbol 'factory-value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2328 (and (not (boundp symbol)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2329 (not (get symbol 'force-value))))))) |
17334 | 2330 (when value |
2331 (princ "\n '(") | |
2332 (princ symbol) | |
2333 (princ " ") | |
2334 (prin1 (car value)) | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2335 (cond (requests |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2336 (if now |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2337 (princ " t ") |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2338 (princ " nil ")) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2339 (prin1 requests) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2340 (princ ")")) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2341 (now |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2342 (princ " t)")) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2343 (t |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2344 (princ ")"))))))) |
17334 | 2345 (princ ")") |
2346 (unless (looking-at "\n") | |
2347 (princ "\n"))))) | |
2348 | |
2349 (defun custom-save-faces () | |
2350 "Save all customized faces in `custom-file'." | |
2351 (save-excursion | |
2352 (custom-save-delete 'custom-set-faces) | |
2353 (let ((standard-output (current-buffer))) | |
2354 (unless (bolp) | |
2355 (princ "\n")) | |
2356 (princ "(custom-set-faces") | |
17415 | 2357 (let ((value (get 'default 'saved-face))) |
2358 ;; The default face must be first, since it affects the others. | |
2359 (when value | |
2360 (princ "\n '(default ") | |
2361 (prin1 value) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2362 (if (or (get 'default 'face-defface-spec) |
17415 | 2363 (and (not (custom-facep 'default)) |
2364 (not (get 'default 'force-face)))) | |
2365 (princ ")") | |
2366 (princ " t)")))) | |
17334 | 2367 (mapatoms (lambda (symbol) |
2368 (let ((value (get symbol 'saved-face))) | |
17415 | 2369 (when (and (not (eq symbol 'default)) |
2370 ;; Don't print default face here. | |
2371 value) | |
17334 | 2372 (princ "\n '(") |
2373 (princ symbol) | |
2374 (princ " ") | |
2375 (prin1 value) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2376 (if (or (get symbol 'face-defface-spec) |
17334 | 2377 (and (not (custom-facep symbol)) |
2378 (not (get symbol 'force-face)))) | |
2379 (princ ")") | |
2380 (princ " t)")))))) | |
2381 (princ ")") | |
2382 (unless (looking-at "\n") | |
2383 (princ "\n"))))) | |
2384 | |
2385 ;;;###autoload | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2386 (defun custom-save-customized () |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2387 "Save all user options which have been set in this session." |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2388 (interactive) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2389 (mapatoms (lambda (symbol) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2390 (let ((face (get symbol 'customized-face)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2391 (value (get symbol 'customized-value))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2392 (when face |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2393 (put symbol 'saved-face face) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2394 (put symbol 'customized-face nil)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2395 (when value |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2396 (put symbol 'saved-value value) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2397 (put symbol 'customized-value nil))))) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2398 ;; We really should update all custom buffers here. |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2399 (custom-save-all)) |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2400 |
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2401 ;;;###autoload |
17334 | 2402 (defun custom-save-all () |
2403 "Save all customizations in `custom-file'." | |
2404 (custom-save-variables) | |
2405 (custom-save-faces) | |
2406 (save-excursion | |
2407 (set-buffer (find-file-noselect custom-file)) | |
2408 (save-buffer))) | |
2409 | |
2410 ;;; The Customize Menu. | |
2411 | |
17415 | 2412 ;;; Menu support |
2413 | |
2414 (unless (string-match "XEmacs" emacs-version) | |
2415 (defconst custom-help-menu '("Customize" | |
2416 ["Update menu..." custom-menu-update t] | |
2417 ["Group..." customize t] | |
2418 ["Variable..." customize-variable t] | |
2419 ["Face..." customize-face t] | |
2420 ["Saved..." customize-customized t] | |
2421 ["Apropos..." customize-apropos t]) | |
2422 ;; This menu should be identical to the one defined in `menu-bar.el'. | |
2423 "Customize menu") | |
2424 | |
2425 (defun custom-menu-reset () | |
2426 "Reset customize menu." | |
2427 (remove-hook 'custom-define-hook 'custom-menu-reset) | |
2428 (define-key global-map [menu-bar help-menu customize-menu] | |
2429 (cons (car custom-help-menu) | |
2430 (easy-menu-create-keymaps (car custom-help-menu) | |
2431 (cdr custom-help-menu))))) | |
2432 | |
2433 (defun custom-menu-update (event) | |
2434 "Update customize menu." | |
2435 (interactive "e") | |
2436 (add-hook 'custom-define-hook 'custom-menu-reset) | |
2437 (let* ((emacs (widget-apply '(custom-group) :custom-menu 'emacs)) | |
2438 (menu `(,(car custom-help-menu) | |
2439 ,emacs | |
2440 ,@(cdr (cdr custom-help-menu))))) | |
2441 (let ((map (easy-menu-create-keymaps (car menu) (cdr menu)))) | |
2442 (define-key global-map [menu-bar help-menu customize-menu] | |
2443 (cons (car menu) map))))) | |
2444 | |
2445 (defcustom custom-menu-nesting 2 | |
2446 "Maximum nesting in custom menus." | |
2447 :type 'integer | |
2448 :group 'customize)) | |
17334 | 2449 |
2450 (defun custom-face-menu-create (widget symbol) | |
2451 "Ignoring WIDGET, create a menu entry for customization face SYMBOL." | |
2452 (vector (custom-unlispify-menu-entry symbol) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2453 `(customize-face ',symbol) |
17334 | 2454 t)) |
2455 | |
2456 (defun custom-variable-menu-create (widget symbol) | |
2457 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL." | |
2458 (let ((type (get symbol 'custom-type))) | |
2459 (unless (listp type) | |
2460 (setq type (list type))) | |
2461 (if (and type (widget-get type :custom-menu)) | |
2462 (widget-apply type :custom-menu symbol) | |
2463 (vector (custom-unlispify-menu-entry symbol) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2464 `(customize-variable ',symbol) |
17334 | 2465 t)))) |
2466 | |
17415 | 2467 ;; Add checkboxes to boolean variable entries. |
17334 | 2468 (widget-put (get 'boolean 'widget-type) |
2469 :custom-menu (lambda (widget symbol) | |
2470 (vector (custom-unlispify-menu-entry symbol) | |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2471 `(customize-variable ',symbol) |
17334 | 2472 ':style 'toggle |
2473 ':selected symbol))) | |
2474 | |
2475 (if (string-match "XEmacs" emacs-version) | |
2476 ;; XEmacs can create menus dynamically. | |
2477 (defun custom-group-menu-create (widget symbol) | |
2478 "Ignoring WIDGET, create a menu entry for customization group SYMBOL." | |
2479 `( ,(custom-unlispify-menu-entry symbol t) | |
2480 :filter (lambda (&rest junk) | |
2481 (cdr (custom-menu-create ',symbol))))) | |
2482 ;; But emacs can't. | |
2483 (defun custom-group-menu-create (widget symbol) | |
2484 "Ignoring WIDGET, create a menu entry for customization group SYMBOL." | |
2485 ;; Limit the nesting. | |
2486 (let ((custom-menu-nesting (1- custom-menu-nesting))) | |
2487 (custom-menu-create symbol)))) | |
2488 | |
17415 | 2489 ;;;###autoload |
2490 (defun custom-menu-create (symbol) | |
17334 | 2491 "Create menu for customization group SYMBOL. |
2492 The menu is in a format applicable to `easy-menu-define'." | |
17415 | 2493 (let* ((item (vector (custom-unlispify-menu-entry symbol) |
17798
f59c9a63514b
Synched with version 1.97.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17703
diff
changeset
|
2494 `(customize-group ',symbol) |
17415 | 2495 t))) |
2496 (if (and (or (not (boundp 'custom-menu-nesting)) | |
2497 (>= custom-menu-nesting 0)) | |
17334 | 2498 (< (length (get symbol 'custom-group)) widget-menu-max-size)) |
2499 (let ((custom-prefix-list (custom-prefix-add symbol | |
2500 custom-prefix-list))) | |
2501 (custom-load-symbol symbol) | |
2502 `(,(custom-unlispify-menu-entry symbol t) | |
2503 ,item | |
2504 "--" | |
2505 ,@(mapcar (lambda (entry) | |
2506 (widget-apply (if (listp (nth 1 entry)) | |
2507 (nth 1 entry) | |
2508 (list (nth 1 entry))) | |
2509 :custom-menu (nth 0 entry))) | |
2510 (get symbol 'custom-group)))) | |
2511 item))) | |
2512 | |
2513 ;;;###autoload | |
17415 | 2514 (defun customize-menu-create (symbol &optional name) |
2515 "Return a customize menu for customization group SYMBOL. | |
2516 If optional NAME is given, use that as the name of the menu. | |
2517 Otherwise the menu will be named `Customize'. | |
2518 The format is suitable for use with `easy-menu-define'." | |
2519 (unless name | |
2520 (setq name "Customize")) | |
2521 (if (string-match "XEmacs" emacs-version) | |
2522 ;; We can delay it under XEmacs. | |
2523 `(,name | |
2524 :filter (lambda (&rest junk) | |
2525 (cdr (custom-menu-create ',symbol)))) | |
2526 ;; But we must create it now under Emacs. | |
2527 (cons name (cdr (custom-menu-create symbol))))) | |
17334 | 2528 |
17415 | 2529 ;;; The Custom Mode. |
2530 | |
2531 (defvar custom-mode-map nil | |
2532 "Keymap for `custom-mode'.") | |
2533 | |
2534 (unless custom-mode-map | |
2535 (setq custom-mode-map (make-sparse-keymap)) | |
2536 (set-keymap-parent custom-mode-map widget-keymap) | |
2537 (define-key custom-mode-map "q" 'bury-buffer)) | |
2538 | |
2539 (easy-menu-define custom-mode-customize-menu | |
2540 custom-mode-map | |
17550
d6545cfb6c5a
Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
17534
diff
changeset
|
2541 "Menu used to customize customization buffers." |
17415 | 2542 (customize-menu-create 'customize)) |
17334 | 2543 |
17415 | 2544 (easy-menu-define custom-mode-menu |
2545 custom-mode-map | |
2546 "Menu used in customization buffers." | |
2547 `("Custom" | |
2548 ["Set" custom-set t] | |
2549 ["Save" custom-save t] | |
2550 ["Reset to Current" custom-reset-current t] | |
2551 ["Reset to Saved" custom-reset-saved t] | |
17641
4650d25e48f6
Say "standard settings" instead of "factory settings".
Richard M. Stallman <rms@gnu.org>
parents:
17550
diff
changeset
|
2552 ["Reset to Standard Settings" custom-reset-factory t] |
17415 | 2553 ["Info" (Info-goto-node "(custom)The Customization Buffer") t])) |
2554 | |
2555 (defcustom custom-mode-hook nil | |
2556 "Hook called when entering custom-mode." | |
2557 :type 'hook | |
2558 :group 'customize) | |
2559 | |
2560 (defun custom-mode () | |
2561 "Major mode for editing customization buffers. | |
2562 | |
2563 The following commands are available: | |
2564 | |
2565 Move to next button or editable field. \\[widget-forward] | |
2566 Move to previous button or editable field. \\[widget-backward] | |
2567 Activate button under the mouse pointer. \\[widget-button-click] | |
2568 Activate button under point. \\[widget-button-press] | |
2569 Set all modifications. \\[custom-set] | |
2570 Make all modifications default. \\[custom-save] | |
2571 Reset all modified options. \\[custom-reset-current] | |
2572 Reset all modified or set options. \\[custom-reset-saved] | |
2573 Reset all options. \\[custom-reset-factory] | |
2574 | |
2575 Entry to this mode calls the value of `custom-mode-hook' | |
2576 if that value is non-nil." | |
2577 (kill-all-local-variables) | |
2578 (setq major-mode 'custom-mode | |
2579 mode-name "Custom") | |
2580 (use-local-map custom-mode-map) | |
2581 (easy-menu-add custom-mode-customize-menu) | |
2582 (easy-menu-add custom-mode-menu) | |
2583 (make-local-variable 'custom-options) | |
2584 (run-hooks 'custom-mode-hook)) | |
17334 | 2585 |
2586 ;;; The End. | |
2587 | |
2588 (provide 'cus-edit) | |
2589 | |
2590 ;; cus-edit.el ends here |