209
|
1 ;;; cus-edit.el --- Tools for customizating Emacs and Lisp packages.
|
|
2 ;;
|
|
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
|
|
4 ;;
|
|
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
|
|
6 ;; Maintainer: Hrvoje Niksic <hniksic@srce.hr>
|
|
7 ;; Keywords: help, faces
|
|
8 ;; Version: 1.9960-x
|
|
9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
|
|
10
|
|
11 ;; This file is part of XEmacs.
|
|
12
|
|
13 ;; XEmacs is free software; you can redistribute it and/or modify
|
|
14 ;; it under the terms of the GNU General Public License as published by
|
|
15 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
16 ;; any later version.
|
|
17
|
|
18 ;; XEmacs is distributed in the hope that it will be useful,
|
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 ;; GNU General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
|
24 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
26 ;; Boston, MA 02111-1307, USA.
|
|
27
|
|
28 ;;; Commentary:
|
|
29 ;;
|
|
30 ;; This file implements the code to create and edit customize buffers.
|
|
31 ;;
|
|
32 ;; See `custom.el'.
|
|
33
|
|
34 ;; No commands should have names starting with `custom-' because
|
|
35 ;; that interferes with completion. Use `customize-' for commands
|
|
36 ;; that the user will run with M-x, and `Custom-' for interactive commands.
|
|
37
|
|
38
|
|
39 ;;; Code:
|
|
40
|
|
41 (require 'cus-face)
|
|
42 (require 'wid-edit)
|
|
43 (require 'easymenu)
|
|
44
|
|
45 (require 'cus-load)
|
|
46 (require 'cus-start)
|
|
47
|
|
48 ;; Huh? This looks dirty!
|
|
49 (put 'custom-define-hook 'custom-type 'hook)
|
|
50 (put 'custom-define-hook 'standard-value '(nil))
|
|
51 (custom-add-to-group 'customize 'custom-define-hook 'custom-variable)
|
|
52
|
|
53 ;;; Customization Groups.
|
|
54
|
|
55 (defgroup emacs nil
|
|
56 "Customization of the One True Editor."
|
|
57 :link '(custom-manual "(XEmacs)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
|
|
195 (defgroup x nil
|
|
196 "The X Window system."
|
|
197 :group 'environment)
|
|
198
|
|
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 files nil
|
|
208 "Support editing files."
|
|
209 :group 'emacs)
|
|
210
|
|
211 (defgroup wp nil
|
|
212 "Word processing."
|
|
213 :group 'emacs)
|
|
214
|
|
215 (defgroup tex nil
|
|
216 "Code related to the TeX formatter."
|
|
217 :group 'wp)
|
|
218
|
|
219 (defgroup faces nil
|
|
220 "Support for multiple fonts."
|
|
221 :group 'emacs)
|
|
222
|
|
223 (defgroup hypermedia nil
|
|
224 "Support for links between text or other media types."
|
|
225 :group 'emacs)
|
|
226
|
|
227 (defgroup help nil
|
|
228 "Support for on-line help systems."
|
|
229 :group 'emacs)
|
|
230
|
|
231 (defgroup local nil
|
|
232 "Code local to your site."
|
|
233 :group 'emacs)
|
|
234
|
|
235 (defgroup customize '((widgets custom-group))
|
|
236 "Customization of the Customization support."
|
|
237 :link '(custom-manual "(custom)Top")
|
|
238 :link '(url-link :tag "Development Page"
|
|
239 "http://www.dina.kvl.dk/~abraham/custom/")
|
|
240 :prefix "custom-"
|
|
241 :group 'help)
|
|
242
|
|
243 (defgroup custom-faces nil
|
|
244 "Faces used by customize."
|
|
245 :group 'customize
|
|
246 :group 'faces)
|
|
247
|
|
248 (defgroup custom-browse nil
|
|
249 "Control customize browser."
|
|
250 :prefix "custom-"
|
|
251 :group 'customize)
|
|
252
|
|
253 (defgroup custom-buffer nil
|
|
254 "Control customize buffers."
|
|
255 :prefix "custom-"
|
|
256 :group 'customize)
|
|
257
|
|
258 (defgroup custom-menu nil
|
|
259 "Control customize menus."
|
|
260 :prefix "custom-"
|
|
261 :group 'customize)
|
|
262
|
|
263 (defgroup abbrev-mode nil
|
|
264 "Word abbreviations mode."
|
|
265 :group 'abbrev)
|
|
266
|
|
267 (defgroup alloc nil
|
|
268 "Storage allocation and gc for GNU Emacs Lisp interpreter."
|
|
269 :tag "Storage Allocation"
|
|
270 :group 'internal)
|
|
271
|
|
272 (defgroup undo nil
|
|
273 "Undoing changes in buffers."
|
|
274 :group 'editing)
|
|
275
|
|
276 (defgroup modeline nil
|
|
277 "Content of the modeline."
|
|
278 :group 'environment)
|
|
279
|
|
280 (defgroup fill nil
|
|
281 "Indenting and filling text."
|
|
282 :group 'editing)
|
|
283
|
|
284 (defgroup editing-basics nil
|
|
285 "Most basic editing facilities."
|
|
286 :group 'editing)
|
|
287
|
|
288 (defgroup display nil
|
|
289 "How characters are displayed in buffers."
|
|
290 :group 'environment)
|
|
291
|
|
292 (defgroup execute nil
|
|
293 "Executing external commands."
|
|
294 :group 'processes)
|
|
295
|
|
296 (defgroup installation nil
|
|
297 "The Emacs installation."
|
|
298 :group 'environment)
|
|
299
|
|
300 (defgroup dired nil
|
|
301 "Directory editing."
|
|
302 :group 'environment)
|
|
303
|
|
304 (defgroup limits nil
|
|
305 "Internal Emacs limits."
|
|
306 :group 'internal)
|
|
307
|
|
308 (defgroup debug nil
|
|
309 "Debugging Emacs itself."
|
|
310 :group 'development)
|
|
311
|
|
312 (defgroup minibuffer nil
|
|
313 "Controling the behaviour of the minibuffer."
|
|
314 :group 'environment)
|
|
315
|
|
316 (defgroup keyboard nil
|
|
317 "Input from the keyboard."
|
|
318 :group 'environment)
|
|
319
|
|
320 (defgroup mouse nil
|
|
321 "Input from the mouse."
|
|
322 :group 'environment)
|
|
323
|
|
324 (defgroup menu nil
|
|
325 "Input from the menus."
|
|
326 :group 'environment)
|
|
327
|
|
328 (defgroup auto-save nil
|
|
329 "Preventing accidential loss of data."
|
|
330 :group 'files)
|
|
331
|
|
332 (defgroup processes-basics nil
|
|
333 "Basic stuff dealing with processes."
|
|
334 :group 'processes)
|
|
335
|
|
336 (defgroup mule nil
|
|
337 "MULE Emacs internationalization."
|
|
338 :group 'i18n)
|
|
339
|
|
340 (defgroup windows nil
|
|
341 "Windows within a frame."
|
|
342 :group 'environment)
|
|
343
|
|
344
|
|
345 ;;; Utilities.
|
|
346
|
|
347 (defun custom-quote (sexp)
|
|
348 "Quote SEXP iff it is not self quoting."
|
|
349 (if (or (memq sexp '(t nil))
|
|
350 (keywordp sexp)
|
|
351 (eq (car-safe sexp) 'lambda)
|
|
352 (stringp sexp)
|
|
353 (numberp sexp)
|
|
354 (characterp sexp))
|
|
355 sexp
|
|
356 (list 'quote sexp)))
|
|
357
|
|
358 (defun custom-split-regexp-maybe (regexp)
|
|
359 "If REGEXP is a string, split it to a list at `\\|'.
|
|
360 You can get the original back with from the result with:
|
|
361 (mapconcat 'identity result \"\\|\")
|
|
362
|
|
363 IF REGEXP is not a string, return it unchanged."
|
|
364 (if (stringp regexp)
|
|
365 (split-string regexp "\\\\|")
|
|
366 regexp))
|
|
367
|
|
368 (defun custom-variable-prompt ()
|
|
369 ;; Code stolen from `help.el'.
|
|
370 "Prompt for a variable, defaulting to the variable at point.
|
|
371 Return a list suitable for use in `interactive'."
|
|
372 (let ((v (variable-at-point))
|
|
373 (enable-recursive-minibuffers t)
|
|
374 val)
|
|
375 (setq val (completing-read
|
|
376 (if (symbolp v)
|
|
377 (format "Customize variable: (default %s) " v)
|
|
378 "Customize variable: ")
|
|
379 obarray (lambda (symbol)
|
|
380 (and (boundp symbol)
|
|
381 (or (get symbol 'custom-type)
|
|
382 (user-variable-p symbol))))))
|
|
383 (list (if (equal val "")
|
|
384 (if (symbolp v) v nil)
|
|
385 (intern val)))))
|
|
386
|
|
387 ;; Here we take not only the actual groups, but the loads, too.
|
|
388 (defun custom-group-prompt (prompt)
|
|
389 "Read group from minibuffer."
|
|
390 (let ((completion-ignore-case t))
|
|
391 (list (completing-read
|
|
392 prompt obarray
|
|
393 (lambda (symbol)
|
|
394 (or (get symbol 'custom-group)
|
|
395 (get symbol 'custom-loads)))
|
|
396 t))))
|
|
397
|
|
398 (defun custom-menu-filter (menu widget)
|
|
399 "Convert MENU to the form used by `widget-choose'.
|
|
400 MENU should be in the same format as `custom-variable-menu'.
|
|
401 WIDGET is the widget to apply the filter entries of MENU on."
|
|
402 (let ((result nil)
|
|
403 current name action filter)
|
|
404 (while menu
|
|
405 (setq current (car menu)
|
|
406 name (nth 0 current)
|
|
407 action (nth 1 current)
|
|
408 filter (nth 2 current)
|
|
409 menu (cdr menu))
|
|
410 (if (or (null filter) (funcall filter widget))
|
|
411 (push (cons name action) result)
|
|
412 (push name result)))
|
|
413 (nreverse result)))
|
|
414
|
|
415
|
|
416 ;;; Unlispify.
|
|
417
|
|
418 (defvar custom-prefix-list nil
|
|
419 "List of prefixes that should be ignored by `custom-unlispify'")
|
|
420
|
|
421 (defcustom custom-unlispify-menu-entries t
|
|
422 "Display menu entries as words instead of symbols if non nil."
|
|
423 :group 'custom-menu
|
|
424 :type 'boolean)
|
|
425
|
|
426 (defcustom custom-unlispify-remove-prefixes t
|
|
427 "Non-nil means remove group prefixes from option names in buffers and menus."
|
|
428 :group 'custom-menu
|
|
429 :type 'boolean)
|
|
430
|
|
431 (defun custom-unlispify-menu-entry (symbol &optional no-suffix)
|
|
432 "Convert symbol into a menu entry."
|
|
433 (cond ((not custom-unlispify-menu-entries)
|
|
434 (symbol-name symbol))
|
|
435 ((get symbol 'custom-tag)
|
|
436 (if no-suffix
|
|
437 (get symbol 'custom-tag)
|
|
438 (concat (get symbol 'custom-tag) "...")))
|
|
439 (t
|
|
440 (with-current-buffer (get-buffer-create " *Custom-Work*")
|
|
441 (erase-buffer)
|
|
442 (princ symbol (current-buffer))
|
|
443 (goto-char (point-min))
|
|
444 (when (and (eq (get symbol 'custom-type) 'boolean)
|
|
445 (re-search-forward "-p\\'" nil t))
|
|
446 (replace-match "" t t)
|
|
447 (goto-char (point-min)))
|
|
448 (when custom-unlispify-remove-prefixes
|
|
449 (let ((prefixes custom-prefix-list)
|
|
450 prefix)
|
|
451 (while prefixes
|
|
452 (setq prefix (car prefixes))
|
|
453 (if (search-forward prefix (+ (point) (length prefix)) t)
|
|
454 (progn
|
|
455 (setq prefixes nil)
|
|
456 (delete-region (point-min) (point)))
|
|
457 (setq prefixes (cdr prefixes))))))
|
|
458 (subst-char-in-region (point-min) (point-max) ?- ?\ t)
|
|
459 (capitalize-region (point-min) (point-max))
|
|
460 (unless no-suffix
|
|
461 (goto-char (point-max))
|
|
462 (insert "..."))
|
|
463 (buffer-string)))))
|
|
464
|
|
465 (defcustom custom-unlispify-tag-names t
|
|
466 "Display tag names as words instead of symbols if non nil."
|
|
467 :group 'custom-buffer
|
|
468 :type 'boolean)
|
|
469
|
|
470 (defun custom-unlispify-tag-name (symbol)
|
|
471 "Convert symbol into a menu entry."
|
|
472 (let ((custom-unlispify-menu-entries custom-unlispify-tag-names))
|
|
473 (custom-unlispify-menu-entry symbol t)))
|
|
474
|
|
475 (defun custom-prefix-add (symbol prefixes)
|
|
476 ;; Addd SYMBOL to list of ignored PREFIXES.
|
|
477 (cons (or (get symbol 'custom-prefix)
|
|
478 (concat (symbol-name symbol) "-"))
|
|
479 prefixes))
|
|
480
|
|
481
|
|
482 ;;; Guess.
|
|
483
|
|
484 (defcustom custom-guess-name-alist
|
|
485 '(("-p\\'" boolean)
|
|
486 ("-hooks?\\'" hook)
|
|
487 ("-face\\'" face)
|
|
488 ("-file\\'" file)
|
|
489 ("-function\\'" function)
|
|
490 ("-functions\\'" (repeat function))
|
|
491 ("-list\\'" (repeat sexp))
|
|
492 ("-alist\\'" (repeat (cons sexp sexp))))
|
|
493 "Alist of (MATCH TYPE).
|
|
494
|
|
495 MATCH should be a regexp matching the name of a symbol, and TYPE should
|
|
496 be a widget suitable for editing the value of that symbol. The TYPE
|
|
497 of the first entry where MATCH matches the name of the symbol will be
|
|
498 used.
|
|
499
|
|
500 This is used for guessing the type of variables not declared with
|
|
501 customize."
|
|
502 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
|
|
503 :group 'customize)
|
|
504
|
|
505 (defcustom custom-guess-doc-alist
|
|
506 '(("\\`\\*?Non-nil " boolean))
|
|
507 "Alist of (MATCH TYPE).
|
|
508
|
|
509 MATCH should be a regexp matching a documentation string, and TYPE
|
|
510 should be a widget suitable for editing the value of a variable with
|
|
511 that documentation string. The TYPE of the first entry where MATCH
|
|
512 matches the name of the symbol will be used.
|
|
513
|
|
514 This is used for guessing the type of variables not declared with
|
|
515 customize."
|
|
516 :type '(repeat (group (regexp :tag "Match") (sexp :tag "Type")))
|
|
517 :group 'customize)
|
|
518
|
|
519 (defun custom-guess-type (symbol)
|
|
520 "Guess a widget suitable for editing the value of SYMBOL.
|
|
521 This is done by matching SYMBOL with `custom-guess-name-alist' and
|
|
522 if that fails, the doc string with `custom-guess-doc-alist'."
|
|
523 (let ((name (symbol-name symbol))
|
|
524 (names custom-guess-name-alist)
|
|
525 current found)
|
|
526 (while names
|
|
527 (setq current (car names)
|
|
528 names (cdr names))
|
|
529 (when (string-match (nth 0 current) name)
|
|
530 (setq found (nth 1 current)
|
|
531 names nil)))
|
|
532 (unless found
|
|
533 (let ((doc (documentation-property symbol 'variable-documentation))
|
|
534 (docs custom-guess-doc-alist))
|
|
535 (when doc
|
|
536 (while docs
|
|
537 (setq current (car docs)
|
|
538 docs (cdr docs))
|
|
539 (when (string-match (nth 0 current) doc)
|
|
540 (setq found (nth 1 current)
|
|
541 docs nil))))))
|
|
542 found))
|
|
543
|
|
544
|
|
545 ;;; Sorting.
|
|
546
|
|
547 (defcustom custom-browse-sort-alphabetically nil
|
|
548 "If non-nil, sort members of each customization group alphabetically."
|
|
549 :type 'boolean
|
|
550 :group 'custom-browse)
|
|
551
|
|
552 (defcustom custom-browse-order-groups nil
|
|
553 "If non-nil, order group members within each customization group.
|
|
554 If `first', order groups before non-groups.
|
|
555 If `last', order groups after non-groups."
|
|
556 :type '(choice (const first)
|
|
557 (const last)
|
|
558 (const :tag "none" nil))
|
|
559 :group 'custom-browse)
|
|
560
|
|
561 (defcustom custom-browse-only-groups nil
|
|
562 "If non-nil, show group members only within each customization group."
|
|
563 :type 'boolean
|
|
564 :group 'custom-browse)
|
|
565
|
|
566 (defcustom custom-buffer-sort-alphabetically nil
|
|
567 "If non-nil, sort members of each customization group alphabetically."
|
|
568 :type 'boolean
|
|
569 :group 'custom-buffer)
|
|
570
|
|
571 (defcustom custom-buffer-order-groups 'last
|
|
572 "If non-nil, order group members within each customization group.
|
|
573 If `first', order groups before non-groups.
|
|
574 If `last', order groups after non-groups."
|
|
575 :type '(choice (const first)
|
|
576 (const last)
|
|
577 (const :tag "none" nil))
|
|
578 :group 'custom-buffer)
|
|
579
|
|
580 (defcustom custom-menu-sort-alphabetically nil
|
|
581 "If non-nil, sort members of each customization group alphabetically."
|
|
582 :type 'boolean
|
|
583 :group 'custom-menu)
|
|
584
|
|
585 (defcustom custom-menu-order-groups 'first
|
|
586 "If non-nil, order group members within each customization group.
|
|
587 If `first', order groups before non-groups.
|
|
588 If `last', order groups after non-groups."
|
|
589 :type '(choice (const first)
|
|
590 (const last)
|
|
591 (const :tag "none" nil))
|
|
592 :group 'custom-menu)
|
|
593
|
|
594 (defun custom-sort-items (items sort-alphabetically order-groups)
|
|
595 "Return a sorted copy of ITEMS.
|
|
596 ITEMS should be a `custom-group' property.
|
|
597 If SORT-ALPHABETICALLY non-nil, sort alphabetically.
|
|
598 If ORDER-GROUPS is `first' order groups before non-groups, if `last' order
|
|
599 groups after non-groups, if nil do not order groups at all."
|
|
600 (sort (copy-sequence items)
|
|
601 (lambda (a b)
|
|
602 (let ((typea (nth 1 a)) (typeb (nth 1 b))
|
|
603 (namea (symbol-name (nth 0 a))) (nameb (symbol-name (nth 0 b))))
|
|
604 (cond ((not order-groups)
|
|
605 ;; Since we don't care about A and B order, maybe sort.
|
|
606 (when sort-alphabetically
|
|
607 (string-lessp namea nameb)))
|
|
608 ((eq typea 'custom-group)
|
|
609 ;; If B is also a group, maybe sort. Otherwise, order A and B.
|
|
610 (if (eq typeb 'custom-group)
|
|
611 (when sort-alphabetically
|
|
612 (string-lessp namea nameb))
|
|
613 (eq order-groups 'first)))
|
|
614 ((eq typeb 'custom-group)
|
|
615 ;; Since A cannot be a group, order A and B.
|
|
616 (eq order-groups 'last))
|
|
617 (sort-alphabetically
|
|
618 ;; Since A and B cannot be groups, sort.
|
|
619 (string-lessp namea nameb)))))))
|
|
620
|
|
621
|
|
622 ;;; Custom Mode Commands.
|
|
623
|
|
624 (defvar custom-options nil
|
|
625 "Customization widgets in the current buffer.")
|
|
626
|
|
627 (defun Custom-set ()
|
|
628 "Set changes in all modified options."
|
|
629 (interactive)
|
|
630 (let ((children custom-options))
|
|
631 (mapc (lambda (child)
|
|
632 (when (eq (widget-get child :custom-state) 'modified)
|
|
633 (widget-apply child :custom-set)))
|
|
634 children)))
|
|
635
|
|
636 (defun Custom-save ()
|
|
637 "Set all modified group members and save them."
|
|
638 (interactive)
|
|
639 (let ((children custom-options))
|
|
640 (mapc (lambda (child)
|
|
641 (when (memq (widget-get child :custom-state) '(modified set))
|
|
642 (widget-apply child :custom-save)))
|
|
643 children))
|
|
644 (custom-save-all))
|
|
645
|
|
646 (defvar custom-reset-menu
|
|
647 '(("Current" . Custom-reset-current)
|
|
648 ("Saved" . Custom-reset-saved)
|
|
649 ("Standard Settings" . Custom-reset-standard))
|
|
650 "Alist of actions for the `Reset' button.
|
|
651 The key is a string containing the name of the action, the value is a
|
|
652 lisp function taking the widget as an element which will be called
|
|
653 when the action is chosen.")
|
|
654
|
|
655 (defun custom-reset (event)
|
|
656 "Select item from reset menu."
|
|
657 (let* ((completion-ignore-case t)
|
|
658 (answer (widget-choose "Reset to"
|
|
659 custom-reset-menu
|
|
660 event)))
|
|
661 (if answer
|
|
662 (funcall answer))))
|
|
663
|
|
664 (defun Custom-reset-current (&rest ignore)
|
|
665 "Reset all modified group members to their current value."
|
|
666 (interactive)
|
|
667 (let ((children custom-options))
|
|
668 (mapc (lambda (child)
|
|
669 (when (eq (widget-get child :custom-state) 'modified)
|
|
670 (widget-apply child :custom-reset-current)))
|
|
671 children)))
|
|
672
|
|
673 (defun Custom-reset-saved (&rest ignore)
|
|
674 "Reset all modified or set group members to their saved value."
|
|
675 (interactive)
|
|
676 (let ((children custom-options))
|
|
677 (mapc (lambda (child)
|
|
678 (when (eq (widget-get child :custom-state) 'modified)
|
|
679 (widget-apply child :custom-reset-saved)))
|
|
680 children)))
|
|
681
|
|
682 (defun Custom-reset-standard (&rest ignore)
|
|
683 "Reset all modified, set, or saved group members to their standard settings."
|
|
684 (interactive)
|
|
685 (let ((children custom-options))
|
|
686 (mapc (lambda (child)
|
|
687 (when (eq (widget-get child :custom-state) 'modified)
|
|
688 (widget-apply child :custom-reset-standard)))
|
|
689 children)))
|
|
690
|
|
691
|
|
692 ;;; The Customize Commands
|
|
693
|
|
694 (defun custom-prompt-variable (prompt-var prompt-val)
|
|
695 "Prompt for a variable and a value and return them as a list.
|
|
696 PROMPT-VAR is the prompt for the variable, and PROMPT-VAL is the
|
|
697 prompt for the value. The %s escape in PROMPT-VAL is replaced with
|
|
698 the name of the variable.
|
|
699
|
|
700 If the variable has a `variable-interactive' property, that is used as if
|
|
701 it were the arg to `interactive' (which see) to interactively read the value.
|
|
702
|
|
703 If the variable has a `custom-type' property, it must be a widget and the
|
|
704 `:prompt-value' property of that widget will be used for reading the value."
|
|
705 (let* ((var (read-variable prompt-var))
|
|
706 (minibuffer-help-form '(describe-variable var)))
|
|
707 (list var
|
|
708 (let ((prop (get var 'variable-interactive))
|
|
709 (type (get var 'custom-type))
|
|
710 (prompt (format prompt-val var)))
|
|
711 (unless (listp type)
|
|
712 (setq type (list type)))
|
|
713 (cond (prop
|
|
714 ;; Use VAR's `variable-interactive' property
|
|
715 ;; as an interactive spec for prompting.
|
|
716 (call-interactively (list 'lambda '(arg)
|
|
717 (list 'interactive prop)
|
|
718 'arg)))
|
|
719 (type
|
|
720 (widget-prompt-value type
|
|
721 prompt
|
|
722 (if (boundp var)
|
|
723 (symbol-value var))
|
|
724 (not (boundp var))))
|
|
725 (t
|
|
726 (eval-minibuffer prompt)))))))
|
|
727
|
|
728 ;;;###autoload
|
|
729 (defun customize-set-value (var val)
|
|
730 "Set VARIABLE to VALUE. VALUE is a Lisp object.
|
|
731
|
|
732 If VARIABLE has a `variable-interactive' property, that is used as if
|
|
733 it were the arg to `interactive' (which see) to interactively read the value.
|
|
734
|
|
735 If VARIABLE has a `custom-type' property, it must be a widget and the
|
|
736 `:prompt-value' property of that widget will be used for reading the value."
|
|
737 (interactive (custom-prompt-variable "Set variable: "
|
|
738 "Set %s to value: "))
|
|
739
|
|
740 (set var val))
|
|
741
|
|
742 ;;;###autoload
|
|
743 (defun customize-set-variable (var val)
|
|
744 "Set the default for VARIABLE to VALUE. VALUE is a Lisp object.
|
|
745
|
|
746 If VARIABLE has a `custom-set' property, that is used for setting
|
|
747 VARIABLE, otherwise `set-default' is used.
|
|
748
|
|
749 The `customized-value' property of the VARIABLE will be set to a list
|
|
750 with a quoted VALUE as its sole list member.
|
|
751
|
|
752 If VARIABLE has a `variable-interactive' property, that is used as if
|
|
753 it were the arg to `interactive' (which see) to interactively read the value.
|
|
754
|
|
755 If VARIABLE has a `custom-type' property, it must be a widget and the
|
|
756 `:prompt-value' property of that widget will be used for reading the value. "
|
|
757 (interactive (custom-prompt-variable "Set variable: "
|
|
758 "Set customized value for %s to: "))
|
|
759 (funcall (or (get var 'custom-set) 'set-default) var val)
|
|
760 (put var 'customized-value (list (custom-quote val))))
|
|
761
|
|
762 ;;;###autoload
|
|
763 (defun customize-save-variable (var val)
|
|
764 "Set the default for VARIABLE to VALUE, and save it for future sessions.
|
|
765 If VARIABLE has a `custom-set' property, that is used for setting
|
|
766 VARIABLE, otherwise `set-default' is used.
|
|
767
|
|
768 The `customized-value' property of the VARIABLE will be set to a list
|
|
769 with a quoted VALUE as its sole list member.
|
|
770
|
|
771 If VARIABLE has a `variable-interactive' property, that is used as if
|
|
772 it were the arg to `interactive' (which see) to interactively read the value.
|
|
773
|
|
774 If VARIABLE has a `custom-type' property, it must be a widget and the
|
|
775 `:prompt-value' property of that widget will be used for reading the value. "
|
|
776 (interactive (custom-prompt-variable "Set and ave variable: "
|
|
777 "Set and save value for %s as: "))
|
|
778 (funcall (or (get var 'custom-set) 'set-default) var val)
|
|
779 (put var 'saved-value (list (custom-quote val)))
|
|
780 (custom-save-all))
|
|
781
|
|
782 ;;;###autoload
|
|
783 (defun customize (group)
|
|
784 "Select a customization buffer which you can use to set user options.
|
|
785 User options are structured into \"groups\".
|
|
786 The default group is `Emacs'."
|
|
787 (interactive (custom-group-prompt
|
|
788 "Customize group: (default emacs) "))
|
|
789 (when (stringp group)
|
|
790 (if (string-equal "" group)
|
|
791 (setq group 'emacs)
|
|
792 (setq group (intern group))))
|
|
793 (let ((name (format "*Customize Group: %s*"
|
|
794 (custom-unlispify-tag-name group))))
|
|
795 (if (get-buffer name)
|
|
796 (switch-to-buffer name)
|
|
797 (custom-buffer-create (list (list group 'custom-group))
|
|
798 name
|
|
799 (concat " for group "
|
|
800 (custom-unlispify-tag-name group))))))
|
|
801
|
|
802 ;;;###autoload
|
|
803 (defalias 'customize-group 'customize)
|
|
804
|
|
805 ;;;###autoload
|
|
806 (defun customize-other-window (symbol)
|
|
807 "Customize SYMBOL, which must be a customization group."
|
|
808 (interactive (custom-group-prompt
|
|
809 "Customize group: (default emacs) "))
|
|
810 (when (stringp symbol)
|
|
811 (if (string-equal "" symbol)
|
|
812 (setq symbol 'emacs)
|
|
813 (setq symbol (intern symbol))))
|
|
814 (custom-buffer-create-other-window
|
|
815 (list (list symbol 'custom-group))
|
|
816 (format "*Customize Group: %s*" (custom-unlispify-tag-name symbol))))
|
|
817
|
|
818 ;;;###autoload
|
|
819 (defalias 'customize-group-other-window 'customize-other-window)
|
|
820
|
|
821 ;;;###autoload
|
|
822 (defalias 'customize-option 'customize-variable)
|
|
823
|
|
824 ;;;###autoload
|
|
825 (defun customize-variable (symbol)
|
|
826 "Customize SYMBOL, which must be a user option variable."
|
|
827 (interactive (custom-variable-prompt))
|
|
828 (custom-buffer-create (list (list symbol 'custom-variable))
|
|
829 (format "*Customize Variable: %s*"
|
|
830 (custom-unlispify-tag-name symbol))))
|
|
831
|
|
832 ;;;###autoload
|
|
833 (defalias 'customize-variable-other-window 'customize-option-other-window)
|
|
834
|
|
835 ;;;###autoload
|
|
836 (defun customize-option-other-window (symbol)
|
|
837 "Customize SYMBOL, which must be a user option variable.
|
|
838 Show the buffer in another window, but don't select it."
|
|
839 (interactive (custom-variable-prompt))
|
|
840 (custom-buffer-create-other-window
|
|
841 (list (list symbol 'custom-variable))
|
|
842 (format "*Customize Option: %s*" (custom-unlispify-tag-name symbol))))
|
|
843
|
|
844 ;;;###autoload
|
|
845 (defun customize-face (&optional symbol)
|
|
846 "Customize SYMBOL, which should be a face name or nil.
|
|
847 If SYMBOL is nil, customize all faces."
|
|
848 (interactive (list (completing-read "Customize face: (default all) "
|
|
849 obarray 'find-face)))
|
|
850 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
|
|
851 (custom-buffer-create (custom-sort-items
|
|
852 (mapcar (lambda (symbol)
|
|
853 (list symbol 'custom-face))
|
|
854 (face-list))
|
|
855 t nil)
|
|
856 "*Customize Faces*")
|
|
857 (when (stringp symbol)
|
|
858 (setq symbol (intern symbol)))
|
|
859 (unless (symbolp symbol)
|
|
860 (error "Should be a symbol %S" symbol))
|
|
861 (custom-buffer-create (list (list symbol 'custom-face))
|
|
862 (format "*Customize Face: %s*"
|
|
863 (custom-unlispify-tag-name symbol)))))
|
|
864
|
|
865 ;;;###autoload
|
|
866 (defun customize-face-other-window (&optional symbol)
|
|
867 "Show customization buffer for FACE in other window."
|
|
868 (interactive (list (completing-read "Customize face: "
|
|
869 obarray 'find-face)))
|
|
870 (if (or (null symbol) (and (stringp symbol) (zerop (length symbol))))
|
|
871 ()
|
|
872 (if (stringp symbol)
|
|
873 (setq symbol (intern symbol)))
|
|
874 (unless (symbolp symbol)
|
|
875 (error "Should be a symbol %S" symbol))
|
|
876 (custom-buffer-create-other-window
|
|
877 (list (list symbol 'custom-face))
|
|
878 (format "*Customize Face: %s*" (custom-unlispify-tag-name symbol)))))
|
|
879
|
|
880 ;;;###autoload
|
|
881 (defun customize-customized ()
|
|
882 "Customize all user options set since the last save in this session."
|
|
883 (interactive)
|
|
884 (let ((found nil))
|
|
885 (mapatoms (lambda (symbol)
|
|
886 (and (get symbol 'customized-face)
|
|
887 (find-face symbol)
|
|
888 (push (list symbol 'custom-face) found))
|
|
889 (and (get symbol 'customized-value)
|
|
890 (boundp symbol)
|
|
891 (push (list symbol 'custom-variable) found))))
|
|
892 (if (not found)
|
|
893 (error "No customized user options")
|
|
894 (custom-buffer-create (custom-sort-items found t nil)
|
|
895 "*Customize Customized*"))))
|
|
896
|
|
897 ;;;###autoload
|
|
898 (defun customize-saved ()
|
|
899 "Customize all already saved user options."
|
|
900 (interactive)
|
|
901 (let ((found nil))
|
|
902 (mapatoms (lambda (symbol)
|
|
903 (and (get symbol 'saved-face)
|
|
904 (find-face symbol)
|
|
905 (push (list symbol 'custom-face) found))
|
|
906 (and (get symbol 'saved-value)
|
|
907 (boundp symbol)
|
|
908 (push (list symbol 'custom-variable) found))))
|
|
909 (if (not found )
|
|
910 (error "No saved user options")
|
|
911 (custom-buffer-create (custom-sort-items found t nil)
|
|
912 "*Customize Saved*"))))
|
|
913
|
|
914 ;;;###autoload
|
|
915 (defun customize-apropos (regexp &optional all)
|
|
916 "Customize all user options matching REGEXP.
|
|
917 If ALL is `options', include only options.
|
|
918 If ALL is `faces', include only faces.
|
|
919 If ALL is `groups', include only groups.
|
|
920 If ALL is t (interactively, with prefix arg), include options which are not
|
|
921 user-settable, as well as faces and groups."
|
|
922 (interactive "sCustomize regexp: \nP")
|
|
923 (let ((found nil))
|
|
924 (mapatoms (lambda (symbol)
|
|
925 (when (string-match regexp (symbol-name symbol))
|
|
926 (when (and (not (memq all '(faces options)))
|
|
927 (get symbol 'custom-group))
|
|
928 (push (list symbol 'custom-group) found))
|
|
929 (when (and (not (memq all '(options groups)))
|
|
930 (find-face symbol))
|
|
931 (push (list symbol 'custom-face) found))
|
|
932 (when (and (not (memq all '(groups faces)))
|
|
933 (boundp symbol)
|
|
934 (or (get symbol 'saved-value)
|
|
935 (get symbol 'standard-value)
|
|
936 (if (memq all '(nil options))
|
|
937 (user-variable-p symbol)
|
|
938 (get symbol 'variable-documentation))))
|
|
939 (push (list symbol 'custom-variable) found)))))
|
|
940 (if (not found)
|
|
941 (error "No matches")
|
|
942 (custom-buffer-create (custom-sort-items found t
|
|
943 custom-buffer-order-groups)
|
|
944 "*Customize Apropos*"))))
|
|
945
|
|
946 ;;;###autoload
|
|
947 (defun customize-apropos-options (regexp &optional arg)
|
|
948 "Customize all user options matching REGEXP.
|
|
949 With prefix arg, include options which are not user-settable."
|
|
950 (interactive "sCustomize regexp: \nP")
|
|
951 (customize-apropos regexp (or arg 'options)))
|
|
952
|
|
953 ;;;###autoload
|
|
954 (defun customize-apropos-faces (regexp)
|
|
955 "Customize all user faces matching REGEXP."
|
|
956 (interactive "sCustomize regexp: \n")
|
|
957 (customize-apropos regexp 'faces))
|
|
958
|
|
959 ;;;###autoload
|
|
960 (defun customize-apropos-groups (regexp)
|
|
961 "Customize all user groups matching REGEXP."
|
|
962 (interactive "sCustomize regexp: \n")
|
|
963 (customize-apropos regexp 'groups))
|
|
964
|
|
965
|
|
966 ;;; Buffer.
|
|
967
|
|
968 (defcustom custom-buffer-style 'links
|
|
969 "Control the presentation style for customization buffers.
|
|
970 The value should be a symbol, one of:
|
|
971
|
|
972 brackets: groups nest within each other with big horizontal brackets.
|
|
973 links: groups have links to subgroups."
|
|
974 :type '(radio (const :tag "brackets: Groups nest within each others" brackets)
|
|
975 (const :tag "links: Group have links to subgroups" links))
|
|
976 :group 'custom-buffer)
|
|
977
|
|
978 (defcustom custom-buffer-indent 3
|
|
979 "Number of spaces to indent nested groups."
|
|
980 :type 'integer
|
|
981 :group 'custom-buffer)
|
|
982
|
|
983 ;;;###autoload
|
|
984 (defun custom-buffer-create (options &optional name description)
|
|
985 "Create a buffer containing OPTIONS.
|
|
986 Optional NAME is the name of the buffer.
|
|
987 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
|
|
988 SYMBOL is a customization option, and WIDGET is a widget for editing
|
|
989 that option."
|
|
990 (unless name (setq name "*Customization*"))
|
|
991 (kill-buffer (get-buffer-create name))
|
|
992 (switch-to-buffer (get-buffer-create name))
|
|
993 (custom-buffer-create-internal options description))
|
|
994
|
|
995 ;;;###autoload
|
|
996 (defun custom-buffer-create-other-window (options &optional name description)
|
|
997 "Create a buffer containing OPTIONS.
|
|
998 Optional NAME is the name of the buffer.
|
|
999 OPTIONS should be an alist of the form ((SYMBOL WIDGET)...), where
|
|
1000 SYMBOL is a customization option, and WIDGET is a widget for editing
|
|
1001 that option."
|
|
1002 (unless name (setq name "*Customization*"))
|
|
1003 (kill-buffer (get-buffer-create name))
|
|
1004 (let ((window (selected-window)))
|
|
1005 (switch-to-buffer-other-window (get-buffer-create name))
|
|
1006 (custom-buffer-create-internal options description)
|
|
1007 (select-window window)))
|
|
1008
|
|
1009 (defcustom custom-reset-button-menu t
|
|
1010 "If non-nil, only show a single reset button in customize buffers.
|
|
1011 This button will have a menu with all three reset operations."
|
|
1012 :type 'boolean
|
|
1013 :group 'custom-buffer)
|
|
1014
|
|
1015 (defconst custom-skip-messages 5)
|
|
1016
|
|
1017 (defun custom-buffer-create-internal (options &optional description)
|
|
1018 (message "Creating customization buffer...")
|
|
1019 (custom-mode)
|
|
1020 (widget-insert "This is a customization buffer")
|
|
1021 (if description
|
|
1022 (widget-insert description))
|
|
1023 (widget-insert ".\n\
|
|
1024 Type RET or click button2 on an active field to invoke its action.
|
|
1025 Invoke ")
|
|
1026 (widget-create 'info-link
|
|
1027 :tag "Help"
|
|
1028 :help-echo "Read the online help"
|
|
1029 "(XEmacs)Easy Customization")
|
|
1030 (widget-insert " for more information.\n\n")
|
|
1031 (message "Creating customization buttons...")
|
|
1032 (widget-insert "Operate on everything in this buffer:\n ")
|
|
1033 (widget-create 'push-button
|
|
1034 :tag "Set"
|
|
1035 :tag-glyph '("set-up" "set-down")
|
|
1036 :help-echo "\
|
|
1037 Make your editing in this buffer take effect for this session"
|
|
1038 :action (lambda (widget &optional event)
|
|
1039 (Custom-set)))
|
|
1040 (widget-insert " ")
|
|
1041 (widget-create 'push-button
|
|
1042 :tag "Save"
|
|
1043 :tag-glyph '("save-up" "save-down")
|
|
1044 :help-echo "\
|
|
1045 Make your editing in this buffer take effect for future Emacs sessions"
|
|
1046 :action (lambda (widget &optional event)
|
|
1047 (Custom-save)))
|
|
1048 (if custom-reset-button-menu
|
|
1049 (progn
|
|
1050 (widget-insert " ")
|
|
1051 (widget-create 'push-button
|
|
1052 :tag "Reset"
|
|
1053 :tag-glyph '("reset-up" "reset-down")
|
|
1054 :help-echo "Show a menu with reset operations"
|
|
1055 :mouse-down-action (lambda (&rest junk) t)
|
|
1056 :action (lambda (widget &optional event)
|
|
1057 (custom-reset event))))
|
|
1058 (widget-insert " ")
|
|
1059 (widget-create 'push-button
|
|
1060 :tag "Reset"
|
|
1061 :help-echo "\
|
|
1062 Reset all edited text in this buffer to reflect current values"
|
|
1063 :action 'Custom-reset-current)
|
|
1064 (widget-insert " ")
|
|
1065 (widget-create 'push-button
|
|
1066 :tag "Reset to Saved"
|
|
1067 :help-echo "\
|
|
1068 Reset all values in this buffer to their saved settings"
|
|
1069 :action 'Custom-reset-saved)
|
|
1070 (widget-insert " ")
|
|
1071 (widget-create 'push-button
|
|
1072 :tag "Reset to Standard"
|
|
1073 :help-echo "\
|
|
1074 Reset all values in this buffer to their standard settings"
|
|
1075 :action 'Custom-reset-standard))
|
|
1076 (widget-insert " ")
|
|
1077 (widget-create 'push-button
|
|
1078 :tag "Done"
|
|
1079 :tag-glyph '("done-up" "done-down")
|
|
1080 :help-echo "Bury the buffer"
|
|
1081 :action (lambda (widget &optional event)
|
|
1082 (bury-buffer)))
|
|
1083 (widget-insert "\n\n")
|
|
1084 (message "Creating customization items...")
|
|
1085 (setq custom-options
|
|
1086 (if (= (length options) 1)
|
|
1087 (mapcar (lambda (entry)
|
|
1088 (widget-create (nth 1 entry)
|
|
1089 :documentation-shown t
|
|
1090 :custom-state 'unknown
|
|
1091 :tag (custom-unlispify-tag-name
|
|
1092 (nth 0 entry))
|
|
1093 :value (nth 0 entry)))
|
|
1094 options)
|
|
1095 (let ((count 0)
|
|
1096 (length (length options)))
|
|
1097 (mapcar (lambda (entry)
|
|
1098 (prog2
|
|
1099 (display-message
|
|
1100 'progress
|
|
1101 (format "Creating customization items %2d%%..."
|
|
1102 (/ (* 100.0 count) length)))
|
|
1103 (widget-create (nth 1 entry)
|
|
1104 :tag (custom-unlispify-tag-name
|
|
1105 (nth 0 entry))
|
|
1106 :value (nth 0 entry))
|
|
1107 (incf count)
|
|
1108 (unless (eq (preceding-char) ?\n)
|
|
1109 (widget-insert "\n"))
|
|
1110 (widget-insert "\n")))
|
|
1111 options))))
|
|
1112 (unless (eq (preceding-char) ?\n)
|
|
1113 (widget-insert "\n"))
|
|
1114 (display-message 'progress
|
|
1115 (format
|
|
1116 "Creating customization items %2d%%...done" 100))
|
|
1117 (unless (eq custom-buffer-style 'tree)
|
|
1118 (mapc 'custom-magic-reset custom-options))
|
|
1119 (message "Creating customization setup...")
|
|
1120 (widget-setup)
|
|
1121 (goto-char (point-min))
|
|
1122 (message "Creating customization buffer...done"))
|
|
1123
|
|
1124
|
|
1125 ;;; The Tree Browser.
|
|
1126
|
|
1127 ;;;###autoload
|
|
1128 (defun customize-browse (&optional group)
|
|
1129 "Create a tree browser for the customize hierarchy."
|
|
1130 (interactive)
|
|
1131 (unless group
|
|
1132 (setq group 'emacs))
|
|
1133 (let ((name "*Customize Browser*"))
|
|
1134 (kill-buffer (get-buffer-create name))
|
|
1135 (switch-to-buffer (get-buffer-create name)))
|
|
1136 (custom-mode)
|
|
1137 (widget-insert "\
|
|
1138 Square brackets show active fields; type RET or click button2
|
|
1139 on an active field to invoke its action.
|
|
1140 Invoke [+] below to expand a group, and [-] to collapse an expanded group.\n")
|
|
1141 (if custom-browse-only-groups
|
|
1142 (widget-insert "\
|
|
1143 Invoke the [Group] button below to edit that item in another window.\n\n")
|
|
1144 (widget-insert "Invoke the ")
|
|
1145 (widget-create 'item
|
|
1146 :format "%t"
|
|
1147 :tag "[Group]"
|
|
1148 :tag-glyph "folder")
|
|
1149 (widget-insert ", ")
|
|
1150 (widget-create 'item
|
|
1151 :format "%t"
|
|
1152 :tag "[Face]"
|
|
1153 :tag-glyph "face")
|
|
1154 (widget-insert ", and ")
|
|
1155 (widget-create 'item
|
|
1156 :format "%t"
|
|
1157 :tag "[Option]"
|
|
1158 :tag-glyph "option")
|
|
1159 (widget-insert " buttons below to edit that
|
|
1160 item in another window.\n\n"))
|
|
1161 (let ((custom-buffer-style 'tree))
|
|
1162 (widget-create 'custom-group
|
|
1163 :custom-last t
|
|
1164 :custom-state 'unknown
|
|
1165 :tag (custom-unlispify-tag-name group)
|
|
1166 :value group))
|
215
|
1167 (widget-add-change)
|
209
|
1168 (goto-char (point-min)))
|
|
1169
|
|
1170 (define-widget 'custom-browse-visibility 'item
|
|
1171 "Control visibility of of items in the customize tree browser."
|
|
1172 :format "%[[%t]%]"
|
|
1173 :action 'custom-browse-visibility-action)
|
|
1174
|
|
1175 (defun custom-browse-visibility-action (widget &rest ignore)
|
|
1176 (let ((custom-buffer-style 'tree))
|
|
1177 (custom-toggle-parent widget)))
|
|
1178
|
|
1179 (define-widget 'custom-browse-group-tag 'push-button
|
|
1180 "Show parent in other window when activated."
|
|
1181 :tag "Group"
|
|
1182 :tag-glyph "folder"
|
|
1183 :action 'custom-browse-group-tag-action)
|
|
1184
|
|
1185 (defun custom-browse-group-tag-action (widget &rest ignore)
|
|
1186 (let ((parent (widget-get widget :parent)))
|
|
1187 (customize-group-other-window (widget-value parent))))
|
|
1188
|
|
1189 (define-widget 'custom-browse-variable-tag 'push-button
|
|
1190 "Show parent in other window when activated."
|
|
1191 :tag "Option"
|
|
1192 :tag-glyph "option"
|
|
1193 :action 'custom-browse-variable-tag-action)
|
|
1194
|
|
1195 (defun custom-browse-variable-tag-action (widget &rest ignore)
|
|
1196 (let ((parent (widget-get widget :parent)))
|
|
1197 (customize-variable-other-window (widget-value parent))))
|
|
1198
|
|
1199 (define-widget 'custom-browse-face-tag 'push-button
|
|
1200 "Show parent in other window when activated."
|
|
1201 :tag "Face"
|
|
1202 :tag-glyph "face"
|
|
1203 :action 'custom-browse-face-tag-action)
|
|
1204
|
|
1205 (defun custom-browse-face-tag-action (widget &rest ignore)
|
|
1206 (let ((parent (widget-get widget :parent)))
|
|
1207 (customize-face-other-window (widget-value parent))))
|
|
1208
|
|
1209 (defconst custom-browse-alist '((" " "space")
|
|
1210 (" | " "vertical")
|
|
1211 ("-\\ " "top")
|
|
1212 (" |-" "middle")
|
|
1213 (" `-" "bottom")))
|
|
1214
|
|
1215 (defun custom-browse-insert-prefix (prefix)
|
|
1216 "Insert PREFIX. On XEmacs convert it to line graphics."
|
|
1217 ;; ### Unfinished.
|
|
1218 (if nil ; (string-match "XEmacs" emacs-version)
|
|
1219 (progn
|
|
1220 (insert "*")
|
|
1221 (while (not (string-equal prefix ""))
|
|
1222 (let ((entry (substring prefix 0 3)))
|
|
1223 (setq prefix (substring prefix 3))
|
|
1224 (let ((overlay (make-overlay (1- (point)) (point) nil t nil))
|
|
1225 (name (nth 1 (assoc entry custom-browse-alist))))
|
|
1226 (overlay-put overlay 'end-glyph (widget-glyph-find name entry))
|
|
1227 (overlay-put overlay 'start-open t)
|
|
1228 (overlay-put overlay 'end-open t)))))
|
|
1229 (insert prefix)))
|
|
1230
|
|
1231
|
|
1232 ;;; Modification of Basic Widgets.
|
|
1233 ;;
|
|
1234 ;; We add extra properties to the basic widgets needed here. This is
|
|
1235 ;; fine, as long as we are careful to stay within out own namespace.
|
|
1236 ;;
|
|
1237 ;; We want simple widgets to be displayed by default, but complex
|
|
1238 ;; widgets to be hidden.
|
|
1239
|
|
1240 (widget-put (get 'item 'widget-type) :custom-show t)
|
|
1241 (widget-put (get 'editable-field 'widget-type)
|
|
1242 :custom-show (lambda (widget value)
|
|
1243 (let ((pp (pp-to-string value)))
|
|
1244 (cond ((string-match "\n" pp)
|
|
1245 nil)
|
|
1246 ((> (length pp) 40)
|
|
1247 nil)
|
|
1248 (t t)))))
|
|
1249 (widget-put (get 'menu-choice 'widget-type) :custom-show t)
|
|
1250
|
|
1251 ;;; The `custom-manual' Widget.
|
|
1252
|
|
1253 (define-widget 'custom-manual 'info-link
|
|
1254 "Link to the manual entry for this customization option."
|
|
1255 :tag "Manual")
|
|
1256
|
|
1257 ;;; The `custom-magic' Widget.
|
|
1258
|
|
1259 (defgroup custom-magic-faces nil
|
|
1260 "Faces used by the magic button."
|
|
1261 :group 'custom-faces
|
|
1262 :group 'custom-buffer)
|
|
1263
|
|
1264 (defface custom-invalid-face '((((class color))
|
|
1265 (:foreground "yellow" :background "red"))
|
|
1266 (t
|
|
1267 (:bold t :italic t :underline t)))
|
|
1268 "Face used when the customize item is invalid."
|
|
1269 :group 'custom-magic-faces)
|
|
1270
|
|
1271 (defface custom-rogue-face '((((class color))
|
|
1272 (:foreground "pink" :background "black"))
|
|
1273 (t
|
|
1274 (:underline t)))
|
|
1275 "Face used when the customize item is not defined for customization."
|
|
1276 :group 'custom-magic-faces)
|
|
1277
|
|
1278 (defface custom-modified-face '((((class color))
|
|
1279 (:foreground "white" :background "blue"))
|
|
1280 (t
|
|
1281 (:italic t :bold)))
|
|
1282 "Face used when the customize item has been modified."
|
|
1283 :group 'custom-magic-faces)
|
|
1284
|
|
1285 (defface custom-set-face '((((class color))
|
|
1286 (:foreground "blue" :background "white"))
|
|
1287 (t
|
|
1288 (:italic t)))
|
|
1289 "Face used when the customize item has been set."
|
|
1290 :group 'custom-magic-faces)
|
|
1291
|
|
1292 (defface custom-changed-face '((((class color))
|
|
1293 (:foreground "white" :background "blue"))
|
|
1294 (t
|
|
1295 (:italic t)))
|
|
1296 "Face used when the customize item has been changed."
|
|
1297 :group 'custom-magic-faces)
|
|
1298
|
|
1299 (defface custom-saved-face '((t (:underline t)))
|
|
1300 "Face used when the customize item has been saved."
|
|
1301 :group 'custom-magic-faces)
|
|
1302
|
|
1303 (defconst custom-magic-alist '((nil "#" underline "\
|
|
1304 uninitialized, you should not see this.")
|
|
1305 (unknown "?" italic "\
|
|
1306 unknown, you should not see this.")
|
|
1307 (hidden "-" default "\
|
|
1308 hidden, invoke \"Show\" button in the previous line to show." "\
|
|
1309 group now hidden, invoke the above \"Show\" button to show contents.")
|
|
1310 (invalid "x" custom-invalid-face "\
|
|
1311 the value displayed for this %c is invalid and cannot be set.")
|
|
1312 (modified "*" custom-modified-face "\
|
|
1313 you have edited the value as text, but you have not set the %c." "\
|
|
1314 you have edited something in this group, but not set it.")
|
|
1315 (set "+" custom-set-face "\
|
|
1316 you have set this %c, but not saved it for future sessions." "\
|
|
1317 something in this group has been set, but not saved.")
|
|
1318 (changed ":" custom-changed-face "\
|
|
1319 this %c has been changed outside the customize buffer." "\
|
|
1320 something in this group has been changed outside customize.")
|
|
1321 (saved "!" custom-saved-face "\
|
|
1322 this %c has been set and saved." "\
|
|
1323 something in this group has been set and saved.")
|
|
1324 (rogue "@" custom-rogue-face "\
|
|
1325 this %c has not been changed with customize." "\
|
|
1326 something in this group is not prepared for customization.")
|
|
1327 (standard " " nil "\
|
|
1328 this %c is unchanged from its standard setting." "\
|
|
1329 visible group members are all at standard settings."))
|
|
1330 "Alist of customize option states.
|
|
1331 Each entry is of the form (STATE MAGIC FACE ITEM-DESC [ GROUP-DESC ]), where
|
|
1332
|
|
1333 STATE is one of the following symbols:
|
|
1334
|
|
1335 `nil'
|
|
1336 For internal use, should never occur.
|
|
1337 `unknown'
|
|
1338 For internal use, should never occur.
|
|
1339 `hidden'
|
|
1340 This item is not being displayed.
|
|
1341 `invalid'
|
|
1342 This item is modified, but has an invalid form.
|
|
1343 `modified'
|
|
1344 This item is modified, and has a valid form.
|
|
1345 `set'
|
|
1346 This item has been set but not saved.
|
|
1347 `changed'
|
|
1348 The current value of this item has been changed temporarily.
|
|
1349 `saved'
|
|
1350 This item is marked for saving.
|
|
1351 `rogue'
|
|
1352 This item has no customization information.
|
|
1353 `standard'
|
|
1354 This item is unchanged from the standard setting.
|
|
1355
|
|
1356 MAGIC is a string used to present that state.
|
|
1357
|
|
1358 FACE is a face used to present the state.
|
|
1359
|
|
1360 ITEM-DESC is a string describing the state for options.
|
|
1361
|
|
1362 GROUP-DESC is a string describing the state for groups. If this is
|
|
1363 left out, ITEM-DESC will be used.
|
|
1364
|
|
1365 The string %c in either description will be replaced with the
|
|
1366 category of the item. These are `group'. `option', and `face'.
|
|
1367
|
|
1368 The list should be sorted most significant first.")
|
|
1369
|
|
1370 (defcustom custom-magic-show 'long
|
|
1371 "If non-nil, show textual description of the state.
|
|
1372 If `long', show a full-line description, not just one word."
|
|
1373 :type '(choice (const :tag "no" nil)
|
|
1374 (const short)
|
|
1375 (const long))
|
|
1376 :group 'custom-buffer)
|
|
1377
|
|
1378 (defcustom custom-magic-show-hidden '(option face)
|
|
1379 "Control whether the State button is shown for hidden items.
|
|
1380 The value should be a list with the custom categories where the State
|
|
1381 button should be visible. Possible categories are `group', `option',
|
|
1382 and `face'."
|
|
1383 :type '(set (const group) (const option) (const face))
|
|
1384 :group 'custom-buffer)
|
|
1385
|
|
1386 (defcustom custom-magic-show-button nil
|
|
1387 "Show a \"magic\" button indicating the state of each customization option."
|
|
1388 :type 'boolean
|
|
1389 :group 'custom-buffer)
|
|
1390
|
|
1391 (define-widget 'custom-magic 'default
|
|
1392 "Show and manipulate state for a customization option."
|
|
1393 :format "%v"
|
|
1394 :action 'widget-parent-action
|
|
1395 :notify 'ignore
|
|
1396 :value-get 'ignore
|
|
1397 :value-create 'custom-magic-value-create
|
|
1398 :value-delete 'widget-children-value-delete)
|
|
1399
|
|
1400 (defun widget-magic-mouse-down-action (widget &optional event)
|
|
1401 ;; Non-nil unless hidden.
|
|
1402 (not (eq (widget-get (widget-get (widget-get widget :parent) :parent)
|
|
1403 :custom-state)
|
|
1404 'hidden)))
|
|
1405
|
|
1406 (defun custom-magic-value-create (widget)
|
|
1407 ;; Create compact status report for WIDGET.
|
|
1408 (let* ((parent (widget-get widget :parent))
|
|
1409 (state (widget-get parent :custom-state))
|
|
1410 (hidden (eq state 'hidden))
|
|
1411 (entry (assq state custom-magic-alist))
|
|
1412 (magic (nth 1 entry))
|
|
1413 (face (nth 2 entry))
|
|
1414 (category (widget-get parent :custom-category))
|
|
1415 (text (or (and (eq category 'group)
|
|
1416 (nth 4 entry))
|
|
1417 (nth 3 entry)))
|
|
1418 (form (widget-get parent :custom-form))
|
|
1419 children)
|
|
1420 (while (string-match "\\`\\(.*\\)%c\\(.*\\)\\'" text)
|
|
1421 (setq text (concat (match-string 1 text)
|
|
1422 (symbol-name category)
|
|
1423 (match-string 2 text))))
|
|
1424 (when (and custom-magic-show
|
|
1425 (or (not hidden)
|
|
1426 (memq category custom-magic-show-hidden)))
|
|
1427 (insert " ")
|
|
1428 (when (and (eq category 'group)
|
|
1429 (not (and (eq custom-buffer-style 'links)
|
|
1430 (> (widget-get parent :custom-level) 1))))
|
|
1431 (insert-char ?\ (* custom-buffer-indent
|
|
1432 (widget-get parent :custom-level))))
|
|
1433 (push (widget-create-child-and-convert
|
|
1434 widget 'choice-item
|
|
1435 :help-echo "Change the state of this item"
|
|
1436 :format (if hidden "%t" "%[%t%]")
|
|
1437 :button-prefix 'widget-push-button-prefix
|
|
1438 :button-suffix 'widget-push-button-suffix
|
|
1439 :mouse-down-action 'widget-magic-mouse-down-action
|
|
1440 :tag "State"
|
|
1441 ;;:tag-glyph (or hidden '("state-up" "state-down"))
|
|
1442 )
|
|
1443 children)
|
|
1444 (insert ": ")
|
|
1445 (let ((start (point)))
|
|
1446 (if (eq custom-magic-show 'long)
|
|
1447 (insert text)
|
|
1448 (insert (symbol-name state)))
|
|
1449 (cond ((eq form 'lisp)
|
|
1450 (insert " (lisp)"))
|
|
1451 ((eq form 'mismatch)
|
|
1452 (insert " (mismatch)")))
|
|
1453 (put-text-property start (point) 'face 'custom-state-face))
|
|
1454 (insert "\n"))
|
|
1455 (when (and (eq category 'group)
|
|
1456 (not (and (eq custom-buffer-style 'links)
|
|
1457 (> (widget-get parent :custom-level) 1))))
|
|
1458 (insert-char ?\ (* custom-buffer-indent
|
|
1459 (widget-get parent :custom-level))))
|
|
1460 (when custom-magic-show-button
|
|
1461 (when custom-magic-show
|
|
1462 (let ((indent (widget-get parent :indent)))
|
|
1463 (when indent
|
|
1464 (insert-char ?\ indent))))
|
|
1465 (push (widget-create-child-and-convert
|
|
1466 widget 'choice-item
|
|
1467 :mouse-down-action 'widget-magic-mouse-down-action
|
|
1468 :button-face face
|
|
1469 :button-prefix ""
|
|
1470 :button-suffix ""
|
|
1471 :help-echo "Change the state"
|
|
1472 :format (if hidden "%t" "%[%t%]")
|
|
1473 :tag (if (memq form '(lisp mismatch))
|
|
1474 (concat "(" magic ")")
|
|
1475 (concat "[" magic "]")))
|
|
1476 children)
|
|
1477 (insert " "))
|
|
1478 (widget-put widget :children children)))
|
|
1479
|
|
1480 (defun custom-magic-reset (widget)
|
|
1481 "Redraw the :custom-magic property of WIDGET."
|
|
1482 (let ((magic (widget-get widget :custom-magic)))
|
|
1483 (widget-value-set magic (widget-value magic))))
|
|
1484
|
|
1485 ;;; The `custom' Widget.
|
|
1486
|
|
1487 (defface custom-button-face '((t (:bold t)))
|
|
1488 "Face used for buttons in customization buffers."
|
|
1489 :group 'custom-faces)
|
|
1490
|
|
1491 (defface custom-documentation-face nil
|
|
1492 "Face used for documentation strings in customization buffers."
|
|
1493 :group 'custom-faces)
|
|
1494
|
|
1495 (defface custom-state-face '((((class color)
|
|
1496 (background dark))
|
|
1497 (:foreground "lime green"))
|
|
1498 (((class color)
|
|
1499 (background light))
|
|
1500 (:foreground "dark green"))
|
|
1501 (t nil))
|
|
1502 "Face used for State descriptions in the customize buffer."
|
|
1503 :group 'custom-faces)
|
|
1504
|
|
1505 (define-widget 'custom 'default
|
|
1506 "Customize a user option."
|
|
1507 :format "%v"
|
|
1508 :convert-widget 'custom-convert-widget
|
|
1509 :notify 'custom-notify
|
|
1510 :custom-prefix ""
|
|
1511 :custom-level 1
|
|
1512 :custom-state 'hidden
|
|
1513 :documentation-property 'widget-subclass-responsibility
|
|
1514 :value-create 'widget-subclass-responsibility
|
|
1515 :value-delete 'widget-children-value-delete
|
|
1516 :value-get 'widget-value-value-get
|
|
1517 :validate 'widget-children-validate
|
|
1518 :match (lambda (widget value) (symbolp value)))
|
|
1519
|
|
1520 (defun custom-convert-widget (widget)
|
|
1521 ;; Initialize :value and :tag from :args in WIDGET.
|
|
1522 (let ((args (widget-get widget :args)))
|
|
1523 (when args
|
|
1524 (widget-put widget :value (widget-apply widget
|
|
1525 :value-to-internal (car args)))
|
|
1526 (widget-put widget :tag (custom-unlispify-tag-name (car args)))
|
|
1527 (widget-put widget :args nil)))
|
|
1528 widget)
|
|
1529
|
|
1530 (defun custom-notify (widget &rest args)
|
|
1531 "Keep track of changes."
|
|
1532 (let ((state (widget-get widget :custom-state)))
|
|
1533 (unless (eq state 'modified)
|
|
1534 (unless (memq state '(nil unknown hidden))
|
|
1535 (widget-put widget :custom-state 'modified))
|
|
1536 (custom-magic-reset widget)
|
|
1537 (apply 'widget-default-notify widget args))))
|
|
1538
|
|
1539 (defun custom-redraw (widget)
|
|
1540 "Redraw WIDGET with current settings."
|
|
1541 (let ((line (count-lines (point-min) (point)))
|
|
1542 (column (current-column))
|
|
1543 (pos (point))
|
|
1544 (from (marker-position (widget-get widget :from)))
|
|
1545 (to (marker-position (widget-get widget :to))))
|
|
1546 (save-excursion
|
|
1547 (widget-value-set widget (widget-value widget))
|
|
1548 (custom-redraw-magic widget))
|
|
1549 (when (and (>= pos from) (<= pos to))
|
|
1550 (condition-case nil
|
|
1551 (progn
|
|
1552 (if (> column 0)
|
|
1553 (goto-line line)
|
|
1554 (goto-line (1+ line)))
|
|
1555 (move-to-column column))
|
|
1556 (error nil)))))
|
|
1557
|
|
1558 (defun custom-redraw-magic (widget)
|
|
1559 "Redraw WIDGET state with current settings."
|
|
1560 (while widget
|
|
1561 (let ((magic (widget-get widget :custom-magic)))
|
|
1562 (cond (magic
|
|
1563 (widget-value-set magic (widget-value magic))
|
|
1564 (when (setq widget (widget-get widget :group))
|
|
1565 (custom-group-state-update widget)))
|
|
1566 (t
|
|
1567 (setq widget nil)))))
|
|
1568 (widget-setup))
|
|
1569
|
|
1570 (defun custom-show (widget value)
|
|
1571 "Non-nil if WIDGET should be shown with VALUE by default."
|
|
1572 (let ((show (widget-get widget :custom-show)))
|
|
1573 (cond ((null show)
|
|
1574 nil)
|
|
1575 ((eq t show)
|
|
1576 t)
|
|
1577 (t
|
|
1578 (funcall show widget value)))))
|
|
1579
|
|
1580 (defvar custom-load-recursion nil
|
|
1581 "Hack to avoid recursive dependencies.")
|
|
1582
|
|
1583 (defun custom-load-symbol (symbol)
|
|
1584 "Load all dependencies for SYMBOL."
|
|
1585 (unless custom-load-recursion
|
|
1586 (let ((custom-load-recursion t)
|
|
1587 (loads (get symbol 'custom-loads))
|
|
1588 load)
|
|
1589 (while loads
|
|
1590 (setq load (car loads)
|
|
1591 loads (cdr loads))
|
|
1592 (cond ((symbolp load)
|
|
1593 (condition-case nil
|
|
1594 (require load)
|
|
1595 (error nil)))
|
|
1596 ;; Don't reload a file already loaded.
|
|
1597 ((and (boundp 'preloaded-file-list)
|
|
1598 (member load preloaded-file-list)))
|
|
1599 ((assoc load load-history))
|
|
1600 ((assoc (locate-library load) load-history))
|
|
1601 (t
|
|
1602 (condition-case nil
|
|
1603 ;; Without this, we would load cus-edit recursively.
|
|
1604 ;; We are still loading it when we call this,
|
|
1605 ;; and it is not in load-history yet.
|
|
1606 (or (equal load "cus-edit")
|
|
1607 (load-library load))
|
|
1608 (error nil))))))))
|
|
1609
|
|
1610 (defun custom-load-widget (widget)
|
|
1611 "Load all dependencies for WIDGET."
|
|
1612 (custom-load-symbol (widget-value widget)))
|
|
1613
|
|
1614 (defun custom-unloaded-symbol-p (symbol)
|
|
1615 "Return non-nil if the dependencies of SYMBOL has not yet been loaded."
|
|
1616 (let ((found nil)
|
|
1617 (loads (get symbol 'custom-loads))
|
|
1618 load)
|
|
1619 (while loads
|
|
1620 (setq load (car loads)
|
|
1621 loads (cdr loads))
|
|
1622 (cond ((symbolp load)
|
|
1623 (unless (featurep load)
|
|
1624 (setq found t)))
|
|
1625 ((assoc load load-history))
|
|
1626 ((assoc (locate-library load) load-history)
|
|
1627 ;; #### WTF???
|
|
1628 (message nil))
|
|
1629 (t
|
|
1630 (setq found t))))
|
|
1631 found))
|
|
1632
|
|
1633 (defun custom-unloaded-widget-p (widget)
|
|
1634 "Return non-nil if the dependencies of WIDGET has not yet been loaded."
|
|
1635 (custom-unloaded-symbol-p (widget-value widget)))
|
|
1636
|
|
1637 (defun custom-toggle-hide (widget)
|
|
1638 "Toggle visibility of WIDGET."
|
|
1639 (custom-load-widget widget)
|
|
1640 (let ((state (widget-get widget :custom-state)))
|
|
1641 (cond ((memq state '(invalid modified))
|
|
1642 (error "There are unset changes"))
|
|
1643 ((eq state 'hidden)
|
|
1644 (widget-put widget :custom-state 'unknown))
|
|
1645 (t
|
|
1646 (widget-put widget :documentation-shown nil)
|
|
1647 (widget-put widget :custom-state 'hidden)))
|
|
1648 (custom-redraw widget)
|
|
1649 (widget-setup)))
|
|
1650
|
|
1651 (defun custom-toggle-parent (widget &rest ignore)
|
|
1652 "Toggle visibility of parent of WIDGET."
|
|
1653 (custom-toggle-hide (widget-get widget :parent)))
|
|
1654
|
|
1655 (defun custom-add-see-also (widget &optional prefix)
|
|
1656 "Add `See also ...' to WIDGET if there are any links.
|
|
1657 Insert PREFIX first if non-nil."
|
|
1658 (let* ((symbol (widget-get widget :value))
|
|
1659 (links (get symbol 'custom-links))
|
|
1660 (many (> (length links) 2))
|
|
1661 (buttons (widget-get widget :buttons))
|
|
1662 (indent (widget-get widget :indent)))
|
|
1663 (when links
|
|
1664 (when indent
|
|
1665 (insert-char ?\ indent))
|
|
1666 (when prefix
|
|
1667 (insert prefix))
|
|
1668 (insert "See also ")
|
|
1669 (while links
|
|
1670 (push (widget-create-child-and-convert widget (car links))
|
|
1671 buttons)
|
|
1672 (setq links (cdr links))
|
|
1673 (cond ((null links)
|
|
1674 (insert ".\n"))
|
|
1675 ((null (cdr links))
|
|
1676 (if many
|
|
1677 (insert ", and ")
|
|
1678 (insert " and ")))
|
|
1679 (t
|
|
1680 (insert ", "))))
|
|
1681 (widget-put widget :buttons buttons))))
|
|
1682
|
|
1683 (defun custom-add-parent-links (widget &optional initial-string)
|
|
1684 "Add \"Parent groups: ...\" to WIDGET if the group has parents.
|
|
1685 The value if non-nil if any parents were found.
|
|
1686 If INITIAL-STRING is non-nil, use that rather than \"Parent groups:\"."
|
|
1687 (let ((name (widget-value widget))
|
|
1688 (type (widget-type widget))
|
|
1689 (buttons (widget-get widget :buttons))
|
|
1690 (start (point))
|
|
1691 found)
|
|
1692 (insert (or initial-string "Parent groups:"))
|
|
1693 (maphash (lambda (group ignore)
|
|
1694 (let ((entry (assq name (get group 'custom-group))))
|
|
1695 (when (eq (nth 1 entry) type)
|
|
1696 (insert " ")
|
|
1697 (push (widget-create-child-and-convert
|
|
1698 widget 'custom-group-link
|
|
1699 :tag (custom-unlispify-tag-name group)
|
|
1700 group)
|
|
1701 buttons)
|
|
1702 (setq found t))))
|
|
1703 custom-group-hash-table)
|
|
1704 (widget-put widget :buttons buttons)
|
|
1705 (if found
|
|
1706 (insert "\n")
|
|
1707 (delete-region start (point)))
|
|
1708 found))
|
|
1709
|
|
1710 ;;; The `custom-variable' Widget.
|
|
1711
|
|
1712 (defface custom-variable-tag-face '((((class color)
|
|
1713 (background dark))
|
|
1714 (:foreground "light blue" :underline t))
|
|
1715 (((class color)
|
|
1716 (background light))
|
|
1717 (:foreground "blue" :underline t))
|
|
1718 (t (:underline t)))
|
|
1719 "Face used for unpushable variable tags."
|
|
1720 :group 'custom-faces)
|
|
1721
|
|
1722 (defface custom-variable-button-face '((t (:underline t :bold t)))
|
|
1723 "Face used for pushable variable tags."
|
|
1724 :group 'custom-faces)
|
|
1725
|
|
1726 (define-widget 'custom-variable 'custom
|
|
1727 "Customize variable."
|
|
1728 :format "%v"
|
|
1729 :help-echo "Set or reset this variable"
|
|
1730 :documentation-property 'variable-documentation
|
|
1731 :custom-category 'option
|
|
1732 :custom-state nil
|
|
1733 :custom-menu 'custom-variable-menu-create
|
|
1734 :custom-form 'edit
|
|
1735 :value-create 'custom-variable-value-create
|
|
1736 :action 'custom-variable-action
|
|
1737 :custom-set 'custom-variable-set
|
|
1738 :custom-save 'custom-variable-save
|
|
1739 :custom-reset-current 'custom-redraw
|
|
1740 :custom-reset-saved 'custom-variable-reset-saved
|
|
1741 :custom-reset-standard 'custom-variable-reset-standard)
|
|
1742
|
|
1743 (defun custom-variable-type (symbol)
|
|
1744 "Return a widget suitable for editing the value of SYMBOL.
|
|
1745 If SYMBOL has a `custom-type' property, use that.
|
|
1746 Otherwise, look up symbol in `custom-guess-type-alist'."
|
|
1747 (let* ((type (or (get symbol 'custom-type)
|
|
1748 (and (not (get symbol 'standard-value))
|
|
1749 (custom-guess-type symbol))
|
|
1750 'sexp))
|
|
1751 (options (get symbol 'custom-options))
|
|
1752 (tmp (if (listp type)
|
|
1753 (copy-sequence type)
|
|
1754 (list type))))
|
|
1755 (when options
|
|
1756 (widget-put tmp :options options))
|
|
1757 tmp))
|
|
1758
|
|
1759 (defun custom-variable-value-create (widget)
|
|
1760 "Here is where you edit the variables value."
|
|
1761 (custom-load-widget widget)
|
|
1762 (let* ((buttons (widget-get widget :buttons))
|
|
1763 (children (widget-get widget :children))
|
|
1764 (form (widget-get widget :custom-form))
|
|
1765 (state (widget-get widget :custom-state))
|
|
1766 (symbol (widget-get widget :value))
|
|
1767 (tag (widget-get widget :tag))
|
|
1768 (type (custom-variable-type symbol))
|
|
1769 (conv (widget-convert type))
|
|
1770 (get (or (get symbol 'custom-get) 'default-value))
|
|
1771 (prefix (widget-get widget :custom-prefix))
|
|
1772 (last (widget-get widget :custom-last))
|
|
1773 (value (if (default-boundp symbol)
|
|
1774 (funcall get symbol)
|
|
1775 (widget-get conv :value))))
|
|
1776 ;; If the widget is new, the child determine whether it is hidden.
|
|
1777 (cond (state)
|
|
1778 ((custom-show type value)
|
|
1779 (setq state 'unknown))
|
|
1780 (t
|
|
1781 (setq state 'hidden)))
|
|
1782 ;; If we don't know the state, see if we need to edit it in lisp form.
|
|
1783 (when (eq state 'unknown)
|
|
1784 (unless (widget-apply conv :match value)
|
|
1785 ;; (widget-apply (widget-convert type) :match value)
|
|
1786 (setq form 'mismatch)))
|
|
1787 ;; Now we can create the child widget.
|
|
1788 (cond ((eq custom-buffer-style 'tree)
|
|
1789 (insert prefix (if last " `--- " " |--- "))
|
|
1790 (push (widget-create-child-and-convert
|
|
1791 widget 'custom-browse-variable-tag)
|
|
1792 buttons)
|
|
1793 (insert " " tag "\n")
|
|
1794 (widget-put widget :buttons buttons))
|
|
1795 ((eq state 'hidden)
|
|
1796 ;; Indicate hidden value.
|
|
1797 (push (widget-create-child-and-convert
|
|
1798 widget 'item
|
|
1799 :format "%{%t%}: "
|
|
1800 :sample-face 'custom-variable-tag-face
|
|
1801 :tag tag
|
|
1802 :parent widget)
|
|
1803 buttons)
|
|
1804 (push (widget-create-child-and-convert
|
|
1805 widget 'visibility
|
|
1806 :help-echo "Show the value of this option"
|
|
1807 :action 'custom-toggle-parent
|
|
1808 nil)
|
|
1809 buttons))
|
|
1810 ((memq form '(lisp mismatch))
|
|
1811 ;; In lisp mode edit the saved value when possible.
|
|
1812 (let* ((value (cond ((get symbol 'saved-value)
|
|
1813 (car (get symbol 'saved-value)))
|
|
1814 ((get symbol 'standard-value)
|
|
1815 (car (get symbol 'standard-value)))
|
|
1816 ((default-boundp symbol)
|
|
1817 (custom-quote (funcall get symbol)))
|
|
1818 (t
|
|
1819 (custom-quote (widget-get conv :value))))))
|
|
1820 (insert (symbol-name symbol) ": ")
|
|
1821 (push (widget-create-child-and-convert
|
|
1822 widget 'visibility
|
|
1823 :help-echo "Hide the value of this option"
|
|
1824 :action 'custom-toggle-parent
|
|
1825 t)
|
|
1826 buttons)
|
|
1827 (insert " ")
|
|
1828 (push (widget-create-child-and-convert
|
|
1829 widget 'sexp
|
|
1830 :button-face 'custom-variable-button-face
|
|
1831 :format "%v"
|
|
1832 :tag (symbol-name symbol)
|
|
1833 :parent widget
|
|
1834 :value value)
|
|
1835 children)))
|
|
1836 (t
|
|
1837 ;; Edit mode.
|
|
1838 (let* ((format (widget-get type :format))
|
|
1839 tag-format value-format)
|
|
1840 (unless (string-match ":" format)
|
|
1841 (error "Bad format."))
|
|
1842 (setq tag-format (substring format 0 (match-end 0)))
|
|
1843 (setq value-format (substring format (match-end 0)))
|
|
1844 (push (widget-create-child-and-convert
|
|
1845 widget 'item
|
|
1846 :format tag-format
|
|
1847 :action 'custom-tag-action
|
|
1848 :help-echo "Change value of this option"
|
|
1849 :mouse-down-action 'custom-tag-mouse-down-action
|
|
1850 :button-face 'custom-variable-button-face
|
|
1851 :sample-face 'custom-variable-tag-face
|
|
1852 tag)
|
|
1853 buttons)
|
|
1854 (insert " ")
|
|
1855 (push (widget-create-child-and-convert
|
|
1856 widget 'visibility
|
|
1857 :help-echo "Hide the value of this option"
|
|
1858 :action 'custom-toggle-parent
|
|
1859 t)
|
|
1860 buttons)
|
|
1861 (push (widget-create-child-and-convert
|
|
1862 widget type
|
|
1863 :format value-format
|
|
1864 :value value)
|
|
1865 children))))
|
|
1866 (unless (eq custom-buffer-style 'tree)
|
|
1867 ;; Now update the state.
|
|
1868 (unless (eq (preceding-char) ?\n)
|
|
1869 (widget-insert "\n"))
|
|
1870 (if (eq state 'hidden)
|
|
1871 (widget-put widget :custom-state state)
|
|
1872 (custom-variable-state-set widget))
|
|
1873 ;; Create the magic button.
|
|
1874 (let ((magic (widget-create-child-and-convert
|
|
1875 widget 'custom-magic nil)))
|
|
1876 (widget-put widget :custom-magic magic)
|
|
1877 (push magic buttons))
|
|
1878 ;; Update properties.
|
|
1879 (widget-put widget :custom-form form)
|
|
1880 (widget-put widget :buttons buttons)
|
|
1881 (widget-put widget :children children)
|
|
1882 ;; Insert documentation.
|
|
1883 (widget-default-format-handler widget ?h)
|
|
1884 ;; See also.
|
|
1885 (unless (eq state 'hidden)
|
|
1886 (when (eq (widget-get widget :custom-level) 1)
|
|
1887 (custom-add-parent-links widget))
|
|
1888 (custom-add-see-also widget)))))
|
|
1889
|
|
1890 (defun custom-tag-action (widget &rest args)
|
|
1891 "Pass :action to first child of WIDGET's parent."
|
|
1892 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
|
|
1893 :action args))
|
|
1894
|
|
1895 (defun custom-tag-mouse-down-action (widget &rest args)
|
|
1896 "Pass :mouse-down-action to first child of WIDGET's parent."
|
|
1897 (apply 'widget-apply (car (widget-get (widget-get widget :parent) :children))
|
|
1898 :mouse-down-action args))
|
|
1899
|
|
1900 (defun custom-variable-state-set (widget)
|
|
1901 "Set the state of WIDGET."
|
|
1902 (let* ((symbol (widget-value widget))
|
|
1903 (get (or (get symbol 'custom-get) 'default-value))
|
|
1904 (value (if (default-boundp symbol)
|
|
1905 (funcall get symbol)
|
|
1906 (widget-get widget :value)))
|
|
1907 tmp
|
|
1908 (state (cond ((setq tmp (get symbol 'customized-value))
|
|
1909 (if (condition-case nil
|
|
1910 (equal value (eval (car tmp)))
|
|
1911 (error nil))
|
|
1912 'set
|
|
1913 'changed))
|
|
1914 ((setq tmp (get symbol 'saved-value))
|
|
1915 (if (condition-case nil
|
|
1916 (equal value (eval (car tmp)))
|
|
1917 (error nil))
|
|
1918 'saved
|
|
1919 'changed))
|
|
1920 ((setq tmp (get symbol 'standard-value))
|
|
1921 (if (condition-case nil
|
|
1922 (equal value (eval (car tmp)))
|
|
1923 (error nil))
|
|
1924 'standard
|
|
1925 'changed))
|
|
1926 (t 'rogue))))
|
|
1927 (widget-put widget :custom-state state)))
|
|
1928
|
|
1929 (defvar custom-variable-menu
|
|
1930 '(("Set for Current Session" custom-variable-set
|
|
1931 (lambda (widget)
|
|
1932 (eq (widget-get widget :custom-state) 'modified)))
|
|
1933 ("Save for Future Sessions" custom-variable-save
|
|
1934 (lambda (widget)
|
|
1935 (memq (widget-get widget :custom-state) '(modified set changed rogue))))
|
|
1936 ("Reset to Current" custom-redraw
|
|
1937 (lambda (widget)
|
|
1938 (and (default-boundp (widget-value widget))
|
|
1939 (memq (widget-get widget :custom-state) '(modified changed)))))
|
|
1940 ("Reset to Saved" custom-variable-reset-saved
|
|
1941 (lambda (widget)
|
|
1942 (and (get (widget-value widget) 'saved-value)
|
|
1943 (memq (widget-get widget :custom-state)
|
|
1944 '(modified set changed rogue)))))
|
|
1945 ("Reset to Standard Settings" custom-variable-reset-standard
|
|
1946 (lambda (widget)
|
|
1947 (and (get (widget-value widget) 'standard-value)
|
|
1948 (memq (widget-get widget :custom-state)
|
|
1949 '(modified set changed saved rogue)))))
|
|
1950 ("---" ignore ignore)
|
|
1951 ("Don't show as Lisp expression" custom-variable-edit
|
|
1952 (lambda (widget)
|
|
1953 (eq (widget-get widget :custom-form) 'lisp)))
|
|
1954 ("Show as Lisp expression" custom-variable-edit-lisp
|
|
1955 (lambda (widget)
|
|
1956 (eq (widget-get widget :custom-form) 'edit))))
|
|
1957 "Alist of actions for the `custom-variable' widget.
|
|
1958 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
|
|
1959 the menu entry, ACTION is the function to call on the widget when the
|
|
1960 menu is selected, and FILTER is a predicate which takes a `custom-variable'
|
|
1961 widget as an argument, and returns non-nil if ACTION is valid on that
|
|
1962 widget. If FILTER is nil, ACTION is always valid.")
|
|
1963
|
|
1964 (defun custom-variable-action (widget &optional event)
|
|
1965 "Show the menu for `custom-variable' WIDGET.
|
|
1966 Optional EVENT is the location for the menu."
|
|
1967 (if (eq (widget-get widget :custom-state) 'hidden)
|
|
1968 (custom-toggle-hide widget)
|
|
1969 (unless (eq (widget-get widget :custom-state) 'modified)
|
|
1970 (custom-variable-state-set widget))
|
|
1971 ;; Redrawing magic also depresses the state glyph.
|
|
1972 ;(custom-redraw-magic widget)
|
|
1973 (let* ((completion-ignore-case t)
|
|
1974 (answer (widget-choose (concat "Operation on "
|
|
1975 (custom-unlispify-tag-name
|
|
1976 (widget-get widget :value)))
|
|
1977 (custom-menu-filter custom-variable-menu
|
|
1978 widget)
|
|
1979 event)))
|
|
1980 (if answer
|
|
1981 (funcall answer widget)))))
|
|
1982
|
|
1983 (defun custom-variable-edit (widget)
|
|
1984 "Edit value of WIDGET."
|
|
1985 (widget-put widget :custom-state 'unknown)
|
|
1986 (widget-put widget :custom-form 'edit)
|
|
1987 (custom-redraw widget))
|
|
1988
|
|
1989 (defun custom-variable-edit-lisp (widget)
|
|
1990 "Edit the lisp representation of the value of WIDGET."
|
|
1991 (widget-put widget :custom-state 'unknown)
|
|
1992 (widget-put widget :custom-form 'lisp)
|
|
1993 (custom-redraw widget))
|
|
1994
|
|
1995 (defun custom-variable-set (widget)
|
|
1996 "Set the current value for the variable being edited by WIDGET."
|
|
1997 (let* ((form (widget-get widget :custom-form))
|
|
1998 (state (widget-get widget :custom-state))
|
|
1999 (child (car (widget-get widget :children)))
|
|
2000 (symbol (widget-value widget))
|
|
2001 (set (or (get symbol 'custom-set) 'set-default))
|
|
2002 val)
|
|
2003 (cond ((eq state 'hidden)
|
|
2004 (error "Cannot set hidden variable."))
|
|
2005 ((setq val (widget-apply child :validate))
|
|
2006 (goto-char (widget-get val :from))
|
|
2007 (error "%s" (widget-get val :error)))
|
|
2008 ((memq form '(lisp mismatch))
|
|
2009 (funcall set symbol (eval (setq val (widget-value child))))
|
|
2010 (put symbol 'customized-value (list val)))
|
|
2011 (t
|
|
2012 (funcall set symbol (setq val (widget-value child)))
|
|
2013 (put symbol 'customized-value (list (custom-quote val)))))
|
|
2014 (custom-variable-state-set widget)
|
|
2015 (custom-redraw-magic widget)))
|
|
2016
|
|
2017 (defun custom-variable-save (widget)
|
|
2018 "Set and save the value for the variable being edited by WIDGET."
|
|
2019 (let* ((form (widget-get widget :custom-form))
|
|
2020 (state (widget-get widget :custom-state))
|
|
2021 (child (car (widget-get widget :children)))
|
|
2022 (symbol (widget-value widget))
|
|
2023 (set (or (get symbol 'custom-set) 'set-default))
|
|
2024 val)
|
|
2025 (cond ((eq state 'hidden)
|
|
2026 (error "Cannot set hidden variable."))
|
|
2027 ((setq val (widget-apply child :validate))
|
|
2028 (goto-char (widget-get val :from))
|
|
2029 (error "%s" (widget-get val :error)))
|
|
2030 ((memq form '(lisp mismatch))
|
|
2031 (put symbol 'saved-value (list (widget-value child)))
|
|
2032 (funcall set symbol (eval (widget-value child))))
|
|
2033 (t
|
|
2034 (put symbol
|
|
2035 'saved-value (list (custom-quote (widget-value
|
|
2036 child))))
|
|
2037 (funcall set symbol (widget-value child))))
|
|
2038 (put symbol 'customized-value nil)
|
|
2039 (custom-save-all)
|
|
2040 (custom-variable-state-set widget)
|
|
2041 (custom-redraw-magic widget)))
|
|
2042
|
|
2043 (defun custom-variable-reset-saved (widget)
|
|
2044 "Restore the saved value for the variable being edited by WIDGET."
|
|
2045 (let* ((symbol (widget-value widget))
|
|
2046 (set (or (get symbol 'custom-set) 'set-default)))
|
|
2047 (if (get symbol 'saved-value)
|
|
2048 (condition-case nil
|
|
2049 (funcall set symbol (eval (car (get symbol 'saved-value))))
|
|
2050 (error nil))
|
|
2051 (error "No saved value for %s" symbol))
|
|
2052 (put symbol 'customized-value nil)
|
|
2053 (widget-put widget :custom-state 'unknown)
|
|
2054 (custom-redraw widget)))
|
|
2055
|
|
2056 (defun custom-variable-reset-standard (widget)
|
|
2057 "Restore the standard setting for the variable being edited by WIDGET."
|
|
2058 (let* ((symbol (widget-value widget))
|
|
2059 (set (or (get symbol 'custom-set) 'set-default)))
|
|
2060 (if (get symbol 'standard-value)
|
|
2061 (funcall set symbol (eval (car (get symbol 'standard-value))))
|
|
2062 (error "No standard setting known for %S" symbol))
|
|
2063 (put symbol 'customized-value nil)
|
|
2064 (when (get symbol 'saved-value)
|
|
2065 (put symbol 'saved-value nil)
|
|
2066 (custom-save-all))
|
|
2067 (widget-put widget :custom-state 'unknown)
|
|
2068 (custom-redraw widget)))
|
|
2069
|
|
2070 ;;; The `custom-face-edit' Widget.
|
|
2071
|
|
2072 (define-widget 'custom-face-edit 'checklist
|
|
2073 "Edit face attributes."
|
|
2074 :format "%t: %v"
|
|
2075 :tag "Attributes"
|
|
2076 :extra-offset 12
|
|
2077 :button-args '(:help-echo "Control whether this attribute have any effect")
|
|
2078 :args (mapcar (lambda (att)
|
|
2079 (list 'group
|
|
2080 :inline t
|
|
2081 :sibling-args (widget-get (nth 1 att) :sibling-args)
|
|
2082 (list 'const :format "" :value (nth 0 att))
|
|
2083 (nth 1 att)))
|
|
2084 custom-face-attributes))
|
|
2085
|
|
2086 ;;; The `custom-display' Widget.
|
|
2087
|
|
2088 (define-widget 'custom-display 'menu-choice
|
|
2089 "Select a display type."
|
|
2090 :tag "Display"
|
|
2091 :value t
|
|
2092 :help-echo "Specify frames where the face attributes should be used"
|
|
2093 :args '((const :tag "all" t)
|
|
2094 (checklist
|
|
2095 :offset 0
|
|
2096 :extra-offset 9
|
|
2097 :args ((group :sibling-args (:help-echo "\
|
|
2098 Only match the specified window systems")
|
|
2099 (const :format "Type: "
|
|
2100 type)
|
|
2101 (checklist :inline t
|
|
2102 :offset 0
|
|
2103 (const :format "X "
|
|
2104 :sibling-args (:help-echo "\
|
|
2105 The X11 Window System")
|
|
2106 x)
|
|
2107 (const :format "PM "
|
|
2108 :sibling-args (:help-echo "\
|
|
2109 OS/2 Presentation Manager")
|
|
2110 pm)
|
213
|
2111 (const :format "MSWindows "
|
209
|
2112 :sibling-args (:help-echo "\
|
|
2113 Windows NT/95/97")
|
213
|
2114 mswindows)
|
209
|
2115 (const :format "DOS "
|
|
2116 :sibling-args (:help-echo "\
|
|
2117 Plain MS-DOS")
|
|
2118 pc)
|
|
2119 (const :format "TTY%n"
|
|
2120 :sibling-args (:help-echo "\
|
|
2121 Plain text terminals")
|
|
2122 tty)))
|
|
2123 (group :sibling-args (:help-echo "\
|
|
2124 Only match the frames with the specified color support")
|
|
2125 (const :format "Class: "
|
|
2126 class)
|
|
2127 (checklist :inline t
|
|
2128 :offset 0
|
|
2129 (const :format "Color "
|
|
2130 :sibling-args (:help-echo "\
|
|
2131 Match color frames")
|
|
2132 color)
|
|
2133 (const :format "Grayscale "
|
|
2134 :sibling-args (:help-echo "\
|
|
2135 Match grayscale frames")
|
|
2136 grayscale)
|
|
2137 (const :format "Monochrome%n"
|
|
2138 :sibling-args (:help-echo "\
|
|
2139 Match frames with no color support")
|
|
2140 mono)))
|
|
2141 (group :sibling-args (:help-echo "\
|
|
2142 Only match frames with the specified intensity")
|
|
2143 (const :format "\
|
|
2144 Background brightness: "
|
|
2145 background)
|
|
2146 (checklist :inline t
|
|
2147 :offset 0
|
|
2148 (const :format "Light "
|
|
2149 :sibling-args (:help-echo "\
|
|
2150 Match frames with light backgrounds")
|
|
2151 light)
|
|
2152 (const :format "Dark\n"
|
|
2153 :sibling-args (:help-echo "\
|
|
2154 Match frames with dark backgrounds")
|
|
2155 dark)))))))
|
|
2156
|
|
2157 ;;; The `custom-face' Widget.
|
|
2158
|
|
2159 (defface custom-face-tag-face '((t (:underline t)))
|
|
2160 "Face used for face tags."
|
|
2161 :group 'custom-faces)
|
|
2162
|
|
2163 (define-widget 'custom-face 'custom
|
|
2164 "Customize face."
|
|
2165 :sample-face 'custom-face-tag-face
|
|
2166 :help-echo "Set or reset this face"
|
|
2167 :documentation-property '(lambda (face)
|
|
2168 (face-doc-string face))
|
|
2169 :value-create 'custom-face-value-create
|
|
2170 :action 'custom-face-action
|
|
2171 :custom-category 'face
|
|
2172 :custom-form 'selected
|
|
2173 :custom-set 'custom-face-set
|
|
2174 :custom-save 'custom-face-save
|
|
2175 :custom-reset-current 'custom-redraw
|
|
2176 :custom-reset-saved 'custom-face-reset-saved
|
|
2177 :custom-reset-standard 'custom-face-reset-standard
|
|
2178 :custom-menu 'custom-face-menu-create)
|
|
2179
|
|
2180 (define-widget 'custom-face-all 'editable-list
|
|
2181 "An editable list of display specifications and attributes."
|
|
2182 :entry-format "%i %d %v"
|
|
2183 :insert-button-args '(:help-echo "Insert new display specification here")
|
|
2184 :append-button-args '(:help-echo "Append new display specification here")
|
|
2185 :delete-button-args '(:help-echo "Delete this display specification")
|
|
2186 :args '((group :format "%v" custom-display custom-face-edit)))
|
|
2187
|
|
2188 (defconst custom-face-all (widget-convert 'custom-face-all)
|
|
2189 "Converted version of the `custom-face-all' widget.")
|
|
2190
|
|
2191 (define-widget 'custom-display-unselected 'item
|
|
2192 "A display specification that doesn't match the selected display."
|
|
2193 :match 'custom-display-unselected-match)
|
|
2194
|
|
2195 (defun custom-display-unselected-match (widget value)
|
|
2196 "Non-nil if VALUE is an unselected display specification."
|
|
2197 (not (face-spec-set-match-display value (selected-frame))))
|
|
2198
|
|
2199 (define-widget 'custom-face-selected 'group
|
|
2200 "Edit the attributes of the selected display in a face specification."
|
|
2201 :args '((repeat :format ""
|
|
2202 :inline t
|
|
2203 (group custom-display-unselected sexp))
|
|
2204 (group (sexp :format "") custom-face-edit)
|
|
2205 (repeat :format ""
|
|
2206 :inline t
|
|
2207 sexp)))
|
|
2208
|
|
2209 (defconst custom-face-selected (widget-convert 'custom-face-selected)
|
|
2210 "Converted version of the `custom-face-selected' widget.")
|
|
2211
|
|
2212 (defun custom-face-value-create (widget)
|
|
2213 "Create a list of the display specifications for WIDGET."
|
|
2214 (let ((buttons (widget-get widget :buttons))
|
|
2215 (symbol (widget-get widget :value))
|
|
2216 (tag (widget-get widget :tag))
|
|
2217 (state (widget-get widget :custom-state))
|
|
2218 (begin (point))
|
|
2219 (is-last (widget-get widget :custom-last))
|
|
2220 (prefix (widget-get widget :custom-prefix)))
|
|
2221 (unless tag
|
|
2222 (setq tag (prin1-to-string symbol)))
|
|
2223 (cond ((eq custom-buffer-style 'tree)
|
|
2224 (insert prefix (if is-last " `--- " " |--- "))
|
|
2225 (push (widget-create-child-and-convert
|
|
2226 widget 'custom-browse-face-tag)
|
|
2227 buttons)
|
|
2228 (insert " " tag "\n")
|
|
2229 (widget-put widget :buttons buttons))
|
|
2230 (t
|
|
2231 ;; Create tag.
|
|
2232 (insert tag)
|
|
2233 (if (eq custom-buffer-style 'face)
|
|
2234 (insert " ")
|
|
2235 (widget-specify-sample widget begin (point))
|
|
2236 (insert ": "))
|
|
2237 ;; Sample.
|
|
2238 (and (not (find-face symbol))
|
|
2239 ;; XEmacs cannot display uninitialized faces.
|
|
2240 (make-face symbol))
|
|
2241 (push (widget-create-child-and-convert widget 'item
|
|
2242 :format "(%{%t%})"
|
|
2243 :sample-face symbol
|
|
2244 :tag "sample")
|
|
2245 buttons)
|
|
2246 ;; Visibility.
|
|
2247 (insert " ")
|
|
2248 (push (widget-create-child-and-convert
|
|
2249 widget 'visibility
|
|
2250 :help-echo "Hide or show this face"
|
|
2251 :action 'custom-toggle-parent
|
|
2252 (not (eq state 'hidden)))
|
|
2253 buttons)
|
|
2254 ;; Magic.
|
|
2255 (insert "\n")
|
|
2256 (let ((magic (widget-create-child-and-convert
|
|
2257 widget 'custom-magic nil)))
|
|
2258 (widget-put widget :custom-magic magic)
|
|
2259 (push magic buttons))
|
|
2260 ;; Update buttons.
|
|
2261 (widget-put widget :buttons buttons)
|
|
2262 ;; Insert documentation.
|
|
2263 (widget-default-format-handler widget ?h)
|
|
2264 ;; See also.
|
|
2265 (unless (eq state 'hidden)
|
|
2266 (when (eq (widget-get widget :custom-level) 1)
|
|
2267 (custom-add-parent-links widget))
|
|
2268 (custom-add-see-also widget))
|
|
2269 ;; Editor.
|
|
2270 (unless (eq (preceding-char) ?\n)
|
|
2271 (insert "\n"))
|
|
2272 (unless (eq state 'hidden)
|
|
2273 (message "Creating face editor...")
|
|
2274 (custom-load-widget widget)
|
|
2275 (let* ((symbol (widget-value widget))
|
|
2276 (spec (or (get symbol 'saved-face)
|
|
2277 (get symbol 'face-defface-spec)
|
|
2278 ;; Attempt to construct it.
|
|
2279 (list (list t (face-custom-attributes-get
|
|
2280 symbol (selected-frame))))))
|
|
2281 (form (widget-get widget :custom-form))
|
|
2282 (indent (widget-get widget :indent))
|
|
2283 (edit (widget-create-child-and-convert
|
|
2284 widget
|
|
2285 (cond ((and (eq form 'selected)
|
|
2286 (widget-apply custom-face-selected
|
|
2287 :match spec))
|
|
2288 (when indent (insert-char ?\ indent))
|
|
2289 'custom-face-selected)
|
|
2290 ((and (not (eq form 'lisp))
|
|
2291 (widget-apply custom-face-all
|
|
2292 :match spec))
|
|
2293 'custom-face-all)
|
|
2294 (t
|
|
2295 (when indent (insert-char ?\ indent))
|
|
2296 'sexp))
|
|
2297 :value spec)))
|
|
2298 (custom-face-state-set widget)
|
|
2299 (widget-put widget :children (list edit)))
|
|
2300 (message "Creating face editor...done"))))))
|
|
2301
|
|
2302 (defvar custom-face-menu
|
|
2303 '(("Set for Current Session" custom-face-set)
|
|
2304 ("Save for Future Sessions" custom-face-save)
|
|
2305 ("Reset to Saved" custom-face-reset-saved
|
|
2306 (lambda (widget)
|
|
2307 (get (widget-value widget) 'saved-face)))
|
|
2308 ("Reset to Standard Setting" custom-face-reset-standard
|
|
2309 (lambda (widget)
|
|
2310 (get (widget-value widget) 'face-defface-spec)))
|
|
2311 ("---" ignore ignore)
|
|
2312 ("Show all display specs" custom-face-edit-all
|
|
2313 (lambda (widget)
|
|
2314 (not (eq (widget-get widget :custom-form) 'all))))
|
|
2315 ("Just current attributes" custom-face-edit-selected
|
|
2316 (lambda (widget)
|
|
2317 (not (eq (widget-get widget :custom-form) 'selected))))
|
|
2318 ("Show as Lisp expression" custom-face-edit-lisp
|
|
2319 (lambda (widget)
|
|
2320 (not (eq (widget-get widget :custom-form) 'lisp)))))
|
|
2321 "Alist of actions for the `custom-face' widget.
|
|
2322 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
|
|
2323 the menu entry, ACTION is the function to call on the widget when the
|
|
2324 menu is selected, and FILTER is a predicate which takes a `custom-face'
|
|
2325 widget as an argument, and returns non-nil if ACTION is valid on that
|
|
2326 widget. If FILTER is nil, ACTION is always valid.")
|
|
2327
|
|
2328 (defun custom-face-edit-selected (widget)
|
|
2329 "Edit selected attributes of the value of WIDGET."
|
|
2330 (widget-put widget :custom-state 'unknown)
|
|
2331 (widget-put widget :custom-form 'selected)
|
|
2332 (custom-redraw widget))
|
|
2333
|
|
2334 (defun custom-face-edit-all (widget)
|
|
2335 "Edit all attributes of the value of WIDGET."
|
|
2336 (widget-put widget :custom-state 'unknown)
|
|
2337 (widget-put widget :custom-form 'all)
|
|
2338 (custom-redraw widget))
|
|
2339
|
|
2340 (defun custom-face-edit-lisp (widget)
|
|
2341 "Edit the lisp representation of the value of WIDGET."
|
|
2342 (widget-put widget :custom-state 'unknown)
|
|
2343 (widget-put widget :custom-form 'lisp)
|
|
2344 (custom-redraw widget))
|
|
2345
|
|
2346 (defun custom-face-state-set (widget)
|
|
2347 "Set the state of WIDGET."
|
|
2348 (let ((symbol (widget-value widget)))
|
|
2349 (widget-put widget :custom-state (cond ((get symbol 'customized-face)
|
|
2350 'set)
|
|
2351 ((get symbol 'saved-face)
|
|
2352 'saved)
|
|
2353 ((get symbol 'face-defface-spec)
|
|
2354 'standard)
|
|
2355 (t
|
|
2356 'rogue)))))
|
|
2357
|
|
2358 (defun custom-face-action (widget &optional event)
|
|
2359 "Show the menu for `custom-face' WIDGET.
|
|
2360 Optional EVENT is the location for the menu."
|
|
2361 (if (eq (widget-get widget :custom-state) 'hidden)
|
|
2362 (custom-toggle-hide widget)
|
|
2363 (let* ((completion-ignore-case t)
|
|
2364 (symbol (widget-get widget :value))
|
|
2365 (answer (widget-choose (concat "Operation on "
|
|
2366 (custom-unlispify-tag-name symbol))
|
|
2367 (custom-menu-filter custom-face-menu
|
|
2368 widget)
|
|
2369 event)))
|
|
2370 (if answer
|
|
2371 (funcall answer widget)))))
|
|
2372
|
|
2373 (defun custom-face-set (widget)
|
|
2374 "Make the face attributes in WIDGET take effect."
|
|
2375 (let* ((symbol (widget-value widget))
|
|
2376 (child (car (widget-get widget :children)))
|
|
2377 (value (widget-value child)))
|
|
2378 (put symbol 'customized-face value)
|
|
2379 (face-spec-set symbol value)
|
|
2380 (custom-face-state-set widget)
|
|
2381 (custom-redraw-magic widget)))
|
|
2382
|
|
2383 (defun custom-face-save (widget)
|
|
2384 "Make the face attributes in WIDGET default."
|
|
2385 (let* ((symbol (widget-value widget))
|
|
2386 (child (car (widget-get widget :children)))
|
|
2387 (value (widget-value child)))
|
|
2388 (face-spec-set symbol value)
|
|
2389 (put symbol 'saved-face value)
|
|
2390 (put symbol 'customized-face nil)
|
213
|
2391 (custom-save-all)
|
209
|
2392 (custom-face-state-set widget)
|
|
2393 (custom-redraw-magic widget)))
|
|
2394
|
|
2395 (defun custom-face-reset-saved (widget)
|
|
2396 "Restore WIDGET to the face's default attributes."
|
|
2397 (let* ((symbol (widget-value widget))
|
|
2398 (child (car (widget-get widget :children)))
|
|
2399 (value (get symbol 'saved-face)))
|
|
2400 (unless value
|
|
2401 (error "No saved value for this face"))
|
|
2402 (put symbol 'customized-face nil)
|
|
2403 (face-spec-set symbol value)
|
|
2404 (widget-value-set child value)
|
|
2405 (custom-face-state-set widget)
|
|
2406 (custom-redraw-magic widget)))
|
|
2407
|
|
2408 (defun custom-face-reset-standard (widget)
|
|
2409 "Restore WIDGET to the face's standard settings."
|
|
2410 (let* ((symbol (widget-value widget))
|
|
2411 (child (car (widget-get widget :children)))
|
|
2412 (value (get symbol 'face-defface-spec)))
|
|
2413 (unless value
|
|
2414 (error "No standard setting for this face"))
|
|
2415 (put symbol 'customized-face nil)
|
|
2416 (when (get symbol 'saved-face)
|
|
2417 (put symbol 'saved-face nil)
|
|
2418 (custom-save-all))
|
|
2419 (face-spec-set symbol value)
|
|
2420 (widget-value-set child value)
|
|
2421 (custom-face-state-set widget)
|
|
2422 (custom-redraw-magic widget)))
|
|
2423
|
|
2424 ;;; The `face' Widget.
|
|
2425
|
|
2426 (define-widget 'face 'default
|
|
2427 "Select and customize a face."
|
|
2428 :convert-widget 'widget-value-convert-widget
|
|
2429 :button-prefix 'widget-push-button-prefix
|
|
2430 :button-suffix 'widget-push-button-suffix
|
|
2431 :format "%t: %[select face%] %v"
|
|
2432 :tag "Face"
|
|
2433 :value 'default
|
|
2434 :value-create 'widget-face-value-create
|
|
2435 :value-delete 'widget-face-value-delete
|
|
2436 :value-get 'widget-value-value-get
|
|
2437 :validate 'widget-children-validate
|
|
2438 :action 'widget-face-action
|
|
2439 :match (lambda (widget value) (symbolp value)))
|
|
2440
|
|
2441 (defun widget-face-value-create (widget)
|
|
2442 ;; Create a `custom-face' child.
|
|
2443 (let* ((symbol (widget-value widget))
|
|
2444 (custom-buffer-style 'face)
|
|
2445 (child (widget-create-child-and-convert
|
|
2446 widget 'custom-face
|
|
2447 :custom-level nil
|
|
2448 :value symbol)))
|
|
2449 (custom-magic-reset child)
|
|
2450 (setq custom-options (cons child custom-options))
|
|
2451 (widget-put widget :children (list child))))
|
|
2452
|
|
2453 (defun widget-face-value-delete (widget)
|
|
2454 ;; Remove the child from the options.
|
|
2455 (let ((child (car (widget-get widget :children))))
|
|
2456 (setq custom-options (delq child custom-options))
|
|
2457 (widget-children-value-delete widget)))
|
|
2458
|
|
2459 (defvar face-history nil
|
|
2460 "History of entered face names.")
|
|
2461
|
|
2462 (defun widget-face-action (widget &optional event)
|
|
2463 "Prompt for a face."
|
|
2464 (let ((answer (completing-read "Face: "
|
|
2465 (mapcar (lambda (face)
|
|
2466 (list (symbol-name face)))
|
|
2467 (face-list))
|
|
2468 nil nil nil
|
|
2469 'face-history)))
|
|
2470 (unless (zerop (length answer))
|
|
2471 (widget-value-set widget (intern answer))
|
|
2472 (widget-apply widget :notify widget event)
|
|
2473 (widget-setup))))
|
|
2474
|
|
2475 ;;; The `hook' Widget.
|
|
2476
|
|
2477 (define-widget 'hook 'list
|
|
2478 "A emacs lisp hook"
|
|
2479 :value-to-internal (lambda (widget value)
|
|
2480 (if (symbolp value)
|
|
2481 (list value)
|
|
2482 value))
|
|
2483 :match (lambda (widget value)
|
|
2484 (or (symbolp value)
|
|
2485 (widget-group-match widget value)))
|
|
2486 :convert-widget 'custom-hook-convert-widget
|
|
2487 :tag "Hook")
|
|
2488
|
|
2489 (defun custom-hook-convert-widget (widget)
|
|
2490 ;; Handle `:custom-options'.
|
|
2491 (let* ((options (widget-get widget :options))
|
|
2492 (other `(editable-list :inline t
|
|
2493 :entry-format "%i %d%v"
|
|
2494 (function :format " %v")))
|
|
2495 (args (if options
|
|
2496 (list `(checklist :inline t
|
|
2497 ,@(mapcar (lambda (entry)
|
|
2498 `(function-item ,entry))
|
|
2499 options))
|
|
2500 other)
|
|
2501 (list other))))
|
|
2502 (widget-put widget :args args)
|
|
2503 widget))
|
|
2504
|
|
2505 ;;; The `custom-group-link' Widget.
|
|
2506
|
|
2507 (define-widget 'custom-group-link 'link
|
|
2508 "Show parent in other window when activated."
|
|
2509 :help-echo 'custom-group-link-help-echo
|
|
2510 :action 'custom-group-link-action)
|
|
2511
|
|
2512 (defun custom-group-link-help-echo (widget)
|
|
2513 (concat "Create customization buffer for the `"
|
|
2514 (custom-unlispify-tag-name (widget-value widget))
|
|
2515 "' group"))
|
|
2516
|
|
2517 (defun custom-group-link-action (widget &rest ignore)
|
|
2518 (customize-group (widget-value widget)))
|
|
2519
|
|
2520 ;;; The `custom-group' Widget.
|
|
2521
|
|
2522 (defcustom custom-group-tag-faces nil
|
|
2523 ;; In XEmacs, this ought to play games with font size.
|
|
2524 "Face used for group tags.
|
|
2525 The first member is used for level 1 groups, the second for level 2,
|
|
2526 and so forth. The remaining group tags are shown with
|
|
2527 `custom-group-tag-face'."
|
|
2528 :type '(repeat face)
|
|
2529 :group 'custom-faces)
|
|
2530
|
|
2531 (defface custom-group-tag-face-1 '((((class color)
|
|
2532 (background dark))
|
|
2533 (:foreground "pink" :underline t))
|
|
2534 (((class color)
|
|
2535 (background light))
|
|
2536 (:foreground "red" :underline t))
|
|
2537 (t (:underline t)))
|
|
2538 "Face used for group tags.")
|
|
2539
|
|
2540 (defface custom-group-tag-face '((((class color)
|
|
2541 (background dark))
|
|
2542 (:foreground "light blue" :underline t))
|
|
2543 (((class color)
|
|
2544 (background light))
|
|
2545 (:foreground "blue" :underline t))
|
|
2546 (t (:underline t)))
|
|
2547 "Face used for low level group tags."
|
|
2548 :group 'custom-faces)
|
|
2549
|
|
2550 (define-widget 'custom-group 'custom
|
|
2551 "Customize group."
|
|
2552 :format "%v"
|
|
2553 :sample-face-get 'custom-group-sample-face-get
|
|
2554 :documentation-property 'group-documentation
|
|
2555 :help-echo "Set or reset all members of this group"
|
|
2556 :value-create 'custom-group-value-create
|
|
2557 :action 'custom-group-action
|
|
2558 :custom-category 'group
|
|
2559 :custom-set 'custom-group-set
|
|
2560 :custom-save 'custom-group-save
|
|
2561 :custom-reset-current 'custom-group-reset-current
|
|
2562 :custom-reset-saved 'custom-group-reset-saved
|
|
2563 :custom-reset-standard 'custom-group-reset-standard
|
|
2564 :custom-menu 'custom-group-menu-create)
|
|
2565
|
|
2566 (defun custom-group-sample-face-get (widget)
|
|
2567 ;; Use :sample-face.
|
|
2568 (or (nth (1- (widget-get widget :custom-level)) custom-group-tag-faces)
|
|
2569 'custom-group-tag-face))
|
|
2570
|
|
2571 (define-widget 'custom-group-visibility 'visibility
|
|
2572 "An indicator and manipulator for hidden group contents."
|
|
2573 :create 'custom-group-visibility-create)
|
|
2574
|
|
2575 (defun custom-group-visibility-create (widget)
|
|
2576 (let ((visible (widget-value widget)))
|
|
2577 (if visible
|
|
2578 (insert "--------")))
|
|
2579 (widget-default-create widget))
|
|
2580
|
|
2581 (defun custom-group-members (symbol groups-only)
|
|
2582 "Return SYMBOL's custom group members.
|
|
2583 If GROUPS-ONLY non-nil, return only those members that are groups."
|
|
2584 (if (not groups-only)
|
|
2585 (get symbol 'custom-group)
|
|
2586 (let (members)
|
|
2587 (dolist (entry (get symbol 'custom-group) (nreverse members))
|
|
2588 (when (eq (nth 1 entry) 'custom-group)
|
|
2589 (push entry members))))))
|
|
2590
|
|
2591 (defun custom-group-value-create (widget)
|
|
2592 "Insert a customize group for WIDGET in the current buffer."
|
|
2593 (let* ((state (widget-get widget :custom-state))
|
|
2594 (level (widget-get widget :custom-level))
|
|
2595 ;; (indent (widget-get widget :indent))
|
|
2596 (prefix (widget-get widget :custom-prefix))
|
|
2597 (buttons (widget-get widget :buttons))
|
|
2598 (tag (widget-get widget :tag))
|
|
2599 (symbol (widget-value widget))
|
|
2600 (members (custom-group-members symbol
|
|
2601 (and (eq custom-buffer-style 'tree)
|
|
2602 custom-browse-only-groups))))
|
|
2603 (cond ((and (eq custom-buffer-style 'tree)
|
|
2604 (eq state 'hidden)
|
|
2605 (or members (custom-unloaded-widget-p widget)))
|
|
2606 (custom-browse-insert-prefix prefix)
|
|
2607 (push (widget-create-child-and-convert
|
|
2608 widget 'custom-browse-visibility
|
|
2609 ;; :tag-glyph "plus"
|
|
2610 :tag "+")
|
|
2611 buttons)
|
|
2612 (insert "-- ")
|
|
2613 ;; (widget-glyph-insert nil "-- " "horizontal")
|
|
2614 (push (widget-create-child-and-convert
|
|
2615 widget 'custom-browse-group-tag)
|
|
2616 buttons)
|
|
2617 (insert " " tag "\n")
|
|
2618 (widget-put widget :buttons buttons))
|
|
2619 ((and (eq custom-buffer-style 'tree)
|
|
2620 (zerop (length members)))
|
|
2621 (custom-browse-insert-prefix prefix)
|
|
2622 (insert "[ ]-- ")
|
|
2623 ;; (widget-glyph-insert nil "[ ]" "empty")
|
|
2624 ;; (widget-glyph-insert nil "-- " "horizontal")
|
|
2625 (push (widget-create-child-and-convert
|
|
2626 widget 'custom-browse-group-tag)
|
|
2627 buttons)
|
|
2628 (insert " " tag "\n")
|
|
2629 (widget-put widget :buttons buttons))
|
|
2630 ((eq custom-buffer-style 'tree)
|
|
2631 (custom-browse-insert-prefix prefix)
|
|
2632 (custom-load-widget widget)
|
|
2633 (if (zerop (length members))
|
|
2634 (progn
|
|
2635 (custom-browse-insert-prefix prefix)
|
|
2636 (insert "[ ]-- ")
|
|
2637 ;; (widget-glyph-insert nil "[ ]" "empty")
|
|
2638 ;; (widget-glyph-insert nil "-- " "horizontal")
|
|
2639 (push (widget-create-child-and-convert
|
|
2640 widget 'custom-browse-group-tag)
|
|
2641 buttons)
|
|
2642 (insert " " tag "\n")
|
|
2643 (widget-put widget :buttons buttons))
|
|
2644 (push (widget-create-child-and-convert
|
|
2645 widget 'custom-browse-visibility
|
|
2646 ;; :tag-glyph "minus"
|
|
2647 :tag "-")
|
|
2648 buttons)
|
|
2649 (insert "-\\ ")
|
|
2650 ;; (widget-glyph-insert nil "-\\ " "top")
|
|
2651 (push (widget-create-child-and-convert
|
|
2652 widget 'custom-browse-group-tag)
|
|
2653 buttons)
|
|
2654 (insert " " tag "\n")
|
|
2655 (widget-put widget :buttons buttons)
|
|
2656 (message "Creating group...")
|
|
2657 (let* ((members (custom-sort-items members
|
|
2658 custom-browse-sort-alphabetically
|
|
2659 custom-browse-order-groups))
|
|
2660 (prefixes (widget-get widget :custom-prefixes))
|
|
2661 (custom-prefix-list (custom-prefix-add symbol prefixes))
|
|
2662 (extra-prefix (if (widget-get widget :custom-last)
|
|
2663 " "
|
|
2664 " | "))
|
|
2665 (prefix (concat prefix extra-prefix))
|
|
2666 children entry)
|
|
2667 (while members
|
|
2668 (setq entry (car members)
|
|
2669 members (cdr members))
|
|
2670 (push (widget-create-child-and-convert
|
|
2671 widget (nth 1 entry)
|
|
2672 :group widget
|
|
2673 :tag (custom-unlispify-tag-name (nth 0 entry))
|
|
2674 :custom-prefixes custom-prefix-list
|
|
2675 :custom-level (1+ level)
|
|
2676 :custom-last (null members)
|
|
2677 :value (nth 0 entry)
|
|
2678 :custom-prefix prefix)
|
|
2679 children))
|
|
2680 (widget-put widget :children (reverse children)))
|
|
2681 (message "Creating group...done")))
|
|
2682 ;; Nested style.
|
|
2683 ((eq state 'hidden)
|
|
2684 ;; Create level indicator.
|
|
2685 (unless (eq custom-buffer-style 'links)
|
|
2686 (insert-char ?\ (* custom-buffer-indent (1- level)))
|
|
2687 (insert "-- "))
|
|
2688 ;; Create link indicator.
|
|
2689 (when (eq custom-buffer-style 'links)
|
|
2690 (insert " ")
|
|
2691 (push (widget-create-child-and-convert
|
|
2692 widget 'custom-group-link
|
|
2693 :tag "Open"
|
|
2694 :tag-glyph '("open-up" "open-down")
|
|
2695 symbol)
|
|
2696 buttons)
|
|
2697 (insert " "))
|
|
2698 ;; Create tag.
|
|
2699 (let ((begin (point)))
|
|
2700 (insert tag)
|
|
2701 (widget-specify-sample widget begin (point)))
|
|
2702 (insert " group")
|
|
2703 ;; Create visibility indicator.
|
|
2704 (unless (eq custom-buffer-style 'links)
|
|
2705 (insert ": ")
|
|
2706 (push (widget-create-child-and-convert
|
|
2707 widget 'custom-group-visibility
|
|
2708 :help-echo "Show members of this group"
|
|
2709 :action 'custom-toggle-parent
|
|
2710 (not (eq state 'hidden)))
|
|
2711 buttons))
|
|
2712 (insert " \n")
|
|
2713 ;; Create magic button.
|
|
2714 (let ((magic (widget-create-child-and-convert
|
|
2715 widget 'custom-magic nil)))
|
|
2716 (widget-put widget :custom-magic magic)
|
|
2717 (push magic buttons))
|
|
2718 ;; Update buttons.
|
|
2719 (widget-put widget :buttons buttons)
|
|
2720 ;; Insert documentation.
|
|
2721 (if (and (eq custom-buffer-style 'links) (> level 1))
|
|
2722 (widget-put widget :documentation-indent 0))
|
|
2723 (widget-default-format-handler widget ?h))
|
|
2724 ;; Nested style.
|
|
2725 (t ;Visible.
|
|
2726 (custom-load-widget widget)
|
|
2727 ;; Update members
|
|
2728 (setq members (custom-group-members
|
|
2729 symbol (and (eq custom-buffer-style 'tree)
|
|
2730 custom-browse-only-groups)))
|
|
2731 ;; Add parent groups references above the group.
|
|
2732 (if t ;;; This should test that the buffer
|
|
2733 ;;; was made to display a group.
|
|
2734 (when (eq level 1)
|
|
2735 (if (custom-add-parent-links widget
|
|
2736 "Go to parent group:")
|
|
2737 (insert "\n"))))
|
|
2738 ;; Create level indicator.
|
|
2739 (insert-char ?\ (* custom-buffer-indent (1- level)))
|
|
2740 (insert "/- ")
|
|
2741 ;; Create tag.
|
|
2742 (let ((start (point)))
|
|
2743 (insert tag)
|
|
2744 (widget-specify-sample widget start (point)))
|
|
2745 (insert " group: ")
|
|
2746 ;; Create visibility indicator.
|
|
2747 (unless (eq custom-buffer-style 'links)
|
|
2748 (insert "--------")
|
|
2749 (push (widget-create-child-and-convert
|
|
2750 widget 'visibility
|
|
2751 :help-echo "Hide members of this group"
|
|
2752 :action 'custom-toggle-parent
|
|
2753 (not (eq state 'hidden)))
|
|
2754 buttons)
|
|
2755 (insert " "))
|
|
2756 ;; Create more dashes.
|
|
2757 ;; Use 76 instead of 75 to compensate for the temporary "<"
|
|
2758 ;; added by `widget-insert'.
|
|
2759 (insert-char ?- (- 76 (current-column)
|
|
2760 (* custom-buffer-indent level)))
|
|
2761 (insert "\\\n")
|
|
2762 ;; Create magic button.
|
|
2763 (let ((magic (widget-create-child-and-convert
|
|
2764 widget 'custom-magic
|
|
2765 :indent 0
|
|
2766 nil)))
|
|
2767 (widget-put widget :custom-magic magic)
|
|
2768 (push magic buttons))
|
|
2769 ;; Update buttons.
|
|
2770 (widget-put widget :buttons buttons)
|
|
2771 ;; Insert documentation.
|
|
2772 (widget-default-format-handler widget ?h)
|
|
2773 ;; Parent groups.
|
|
2774 (if nil ;;; This should test that the buffer
|
|
2775 ;;; was not made to display a group.
|
|
2776 (when (eq level 1)
|
|
2777 (insert-char ?\ custom-buffer-indent)
|
|
2778 (custom-add-parent-links widget)))
|
|
2779 (custom-add-see-also widget
|
|
2780 (make-string (* custom-buffer-indent level)
|
|
2781 ?\ ))
|
|
2782 ;; Members.
|
|
2783 (message "Creating group...")
|
|
2784 (let* ((members (custom-sort-items members
|
|
2785 custom-buffer-sort-alphabetically
|
|
2786 custom-buffer-order-groups))
|
|
2787 (prefixes (widget-get widget :custom-prefixes))
|
|
2788 (custom-prefix-list (custom-prefix-add symbol prefixes))
|
|
2789 (length (length members))
|
|
2790 (count 0)
|
|
2791 (children (mapcar
|
|
2792 (lambda (entry)
|
|
2793 (widget-insert "\n")
|
|
2794 (when (zerop (% count custom-skip-messages))
|
|
2795 (display-message
|
|
2796 'progress
|
|
2797 (format "\
|
|
2798 Creating group members... %2d%%"
|
|
2799 (/ (* 100.0 count) length))))
|
|
2800 (incf count)
|
|
2801 (prog1
|
|
2802 (widget-create-child-and-convert
|
|
2803 widget (nth 1 entry)
|
|
2804 :group widget
|
|
2805 :tag (custom-unlispify-tag-name
|
|
2806 (nth 0 entry))
|
|
2807 :custom-prefixes custom-prefix-list
|
|
2808 :custom-level (1+ level)
|
|
2809 :value (nth 0 entry))
|
|
2810 (unless (eq (preceding-char) ?\n)
|
|
2811 (widget-insert "\n"))))
|
|
2812 members)))
|
|
2813 (message "Creating group magic...")
|
|
2814 (mapc 'custom-magic-reset children)
|
|
2815 (message "Creating group state...")
|
|
2816 (widget-put widget :children children)
|
|
2817 (custom-group-state-update widget)
|
|
2818 (message "Creating group... done"))
|
|
2819 ;; End line
|
|
2820 (insert "\n")
|
|
2821 (insert-char ?\ (* custom-buffer-indent (1- level)))
|
|
2822 (insert "\\- " (widget-get widget :tag) " group end ")
|
|
2823 (insert-char ?- (- 75 (current-column) (* custom-buffer-indent level)))
|
|
2824 (insert "/\n")))))
|
|
2825
|
|
2826 (defvar custom-group-menu
|
|
2827 '(("Set for Current Session" custom-group-set
|
|
2828 (lambda (widget)
|
|
2829 (eq (widget-get widget :custom-state) 'modified)))
|
|
2830 ("Save for Future Sessions" custom-group-save
|
|
2831 (lambda (widget)
|
|
2832 (memq (widget-get widget :custom-state) '(modified set))))
|
|
2833 ("Reset to Current" custom-group-reset-current
|
|
2834 (lambda (widget)
|
|
2835 (memq (widget-get widget :custom-state) '(modified))))
|
|
2836 ("Reset to Saved" custom-group-reset-saved
|
|
2837 (lambda (widget)
|
|
2838 (memq (widget-get widget :custom-state) '(modified set))))
|
|
2839 ("Reset to standard setting" custom-group-reset-standard
|
|
2840 (lambda (widget)
|
|
2841 (memq (widget-get widget :custom-state) '(modified set saved)))))
|
|
2842 "Alist of actions for the `custom-group' widget.
|
|
2843 Each entry has the form (NAME ACTION FILTER) where NAME is the name of
|
|
2844 the menu entry, ACTION is the function to call on the widget when the
|
|
2845 menu is selected, and FILTER is a predicate which takes a `custom-group'
|
|
2846 widget as an argument, and returns non-nil if ACTION is valid on that
|
|
2847 widget. If FILTER is nil, ACTION is always valid.")
|
|
2848
|
|
2849 (defun custom-group-action (widget &optional event)
|
|
2850 "Show the menu for `custom-group' WIDGET.
|
|
2851 Optional EVENT is the location for the menu."
|
|
2852 (if (eq (widget-get widget :custom-state) 'hidden)
|
|
2853 (custom-toggle-hide widget)
|
|
2854 (let* ((completion-ignore-case t)
|
|
2855 (answer (widget-choose (concat "Operation on "
|
|
2856 (custom-unlispify-tag-name
|
|
2857 (widget-get widget :value)))
|
|
2858 (custom-menu-filter custom-group-menu
|
|
2859 widget)
|
|
2860 event)))
|
|
2861 (if answer
|
|
2862 (funcall answer widget)))))
|
|
2863
|
|
2864 (defun custom-group-set (widget)
|
|
2865 "Set changes in all modified group members."
|
|
2866 (let ((children (widget-get widget :children)))
|
|
2867 (mapc (lambda (child)
|
|
2868 (when (eq (widget-get child :custom-state) 'modified)
|
|
2869 (widget-apply child :custom-set)))
|
|
2870 children)))
|
|
2871
|
|
2872 (defun custom-group-save (widget)
|
|
2873 "Save all modified group members."
|
|
2874 (let ((children (widget-get widget :children)))
|
|
2875 (mapc (lambda (child)
|
|
2876 (when (memq (widget-get child :custom-state) '(modified set))
|
|
2877 (widget-apply child :custom-save)))
|
|
2878 children)))
|
|
2879
|
|
2880 (defun custom-group-reset-current (widget)
|
|
2881 "Reset all modified group members."
|
|
2882 (let ((children (widget-get widget :children)))
|
|
2883 (mapc (lambda (child)
|
|
2884 (when (eq (widget-get child :custom-state) 'modified)
|
|
2885 (widget-apply child :custom-reset-current)))
|
|
2886 children)))
|
|
2887
|
|
2888 (defun custom-group-reset-saved (widget)
|
|
2889 "Reset all modified or set group members."
|
|
2890 (let ((children (widget-get widget :children)))
|
|
2891 (mapc (lambda (child)
|
|
2892 (when (memq (widget-get child :custom-state) '(modified set))
|
|
2893 (widget-apply child :custom-reset-saved)))
|
|
2894 children)))
|
|
2895
|
|
2896 (defun custom-group-reset-standard (widget)
|
|
2897 "Reset all modified, set, or saved group members."
|
|
2898 (let ((children (widget-get widget :children)))
|
|
2899 (mapc (lambda (child)
|
|
2900 (when (memq (widget-get child :custom-state)
|
|
2901 '(modified set saved))
|
|
2902 (widget-apply child :custom-reset-standard)))
|
|
2903 children)))
|
|
2904
|
|
2905 (defun custom-group-state-update (widget)
|
|
2906 "Update magic."
|
|
2907 (unless (eq (widget-get widget :custom-state) 'hidden)
|
|
2908 (let* ((children (widget-get widget :children))
|
|
2909 (states (mapcar (lambda (child)
|
|
2910 (widget-get child :custom-state))
|
|
2911 children))
|
|
2912 (magics custom-magic-alist)
|
|
2913 (found 'standard))
|
|
2914 (while magics
|
|
2915 (let ((magic (car (car magics))))
|
|
2916 (if (and (not (eq magic 'hidden))
|
|
2917 (memq magic states))
|
|
2918 (setq found magic
|
|
2919 magics nil)
|
|
2920 (setq magics (cdr magics)))))
|
|
2921 (widget-put widget :custom-state found)))
|
|
2922 (custom-magic-reset widget))
|
|
2923
|
|
2924 ;;; The `custom-save-all' Function.
|
|
2925 ;;;###autoload
|
213
|
2926 (defcustom custom-file (if (boundp 'user-init-directory)
|
209
|
2927 (concat "~"
|
|
2928 init-file-user
|
213
|
2929 user-init-directory
|
209
|
2930 "options.el")
|
|
2931 "~/.emacs")
|
|
2932 "File used for storing customization information.
|
|
2933 If you change this from the default \"~/.emacs\" you need to
|
|
2934 explicitly load that file for the settings to take effect."
|
|
2935 :type 'file
|
|
2936 :group 'customize)
|
|
2937
|
|
2938 (defun custom-save-delete (symbol)
|
|
2939 "Delete the call to SYMBOL form `custom-file'.
|
|
2940 Leave point at the location of the call, or after the last expression."
|
|
2941 (let ((find-file-hooks nil)
|
|
2942 (auto-mode-alist nil))
|
|
2943 (set-buffer (find-file-noselect custom-file)))
|
|
2944 (goto-char (point-min))
|
|
2945 (catch 'found
|
|
2946 (while t
|
|
2947 (let ((sexp (condition-case nil
|
|
2948 (read (current-buffer))
|
|
2949 (end-of-file (throw 'found nil)))))
|
|
2950 (when (and (listp sexp)
|
|
2951 (eq (car sexp) symbol))
|
|
2952 (delete-region (save-excursion
|
|
2953 (backward-sexp)
|
|
2954 (point))
|
|
2955 (point))
|
|
2956 (throw 'found nil))))))
|
|
2957
|
|
2958 (defun custom-save-variables ()
|
|
2959 "Save all customized variables in `custom-file'."
|
|
2960 (save-excursion
|
|
2961 (custom-save-delete 'custom-set-variables)
|
|
2962 (let ((standard-output (current-buffer)))
|
|
2963 (unless (bolp)
|
|
2964 (princ "\n"))
|
|
2965 (princ "(custom-set-variables")
|
|
2966 (mapatoms (lambda (symbol)
|
|
2967 (let ((value (get symbol 'saved-value))
|
|
2968 (requests (get symbol 'custom-requests))
|
|
2969 (now (not (or (get symbol 'standard-value)
|
|
2970 (and (not (boundp symbol))
|
|
2971 (not (get symbol 'force-value)))))))
|
|
2972 (when value
|
|
2973 (princ "\n '(")
|
|
2974 (princ symbol)
|
|
2975 (princ " ")
|
|
2976 (prin1 (car value))
|
|
2977 (cond (requests
|
|
2978 (if now
|
|
2979 (princ " t ")
|
|
2980 (princ " nil "))
|
|
2981 (prin1 requests)
|
|
2982 (princ ")"))
|
|
2983 (now
|
|
2984 (princ " t)"))
|
|
2985 (t
|
|
2986 (princ ")")))))))
|
|
2987 (princ ")")
|
|
2988 (unless (looking-at "\n")
|
|
2989 (princ "\n")))))
|
|
2990
|
|
2991 (defun custom-save-faces ()
|
|
2992 "Save all customized faces in `custom-file'."
|
|
2993 (save-excursion
|
|
2994 (custom-save-delete 'custom-set-faces)
|
|
2995 (let ((standard-output (current-buffer)))
|
|
2996 (unless (bolp)
|
|
2997 (princ "\n"))
|
|
2998 (princ "(custom-set-faces")
|
|
2999 (let ((value (get 'default 'saved-face)))
|
|
3000 ;; The default face must be first, since it affects the others.
|
|
3001 (when value
|
|
3002 (princ "\n '(default ")
|
|
3003 (prin1 value)
|
|
3004 (if (or (get 'default 'face-defface-spec)
|
|
3005 (and (not (find-face 'default))
|
|
3006 (not (get 'default 'force-face))))
|
|
3007 (princ ")")
|
|
3008 (princ " t)"))))
|
|
3009 (mapatoms (lambda (symbol)
|
|
3010 (let ((value (get symbol 'saved-face)))
|
|
3011 (when (and (not (eq symbol 'default))
|
|
3012 ;; Don't print default face here.
|
|
3013 value)
|
|
3014 (princ "\n '(")
|
|
3015 (princ symbol)
|
|
3016 (princ " ")
|
|
3017 (prin1 value)
|
|
3018 (if (or (get symbol 'face-defface-spec)
|
|
3019 (and (not (find-face symbol))
|
|
3020 (not (get symbol 'force-face))))
|
|
3021 (princ ")")
|
|
3022 (princ " t)"))))))
|
|
3023 (princ ")")
|
|
3024 (unless (looking-at "\n")
|
|
3025 (princ "\n")))))
|
|
3026
|
|
3027 ;;;###autoload
|
|
3028 (defun customize-save-customized ()
|
|
3029 "Save all user options which have been set in this session."
|
|
3030 (interactive)
|
|
3031 (mapatoms (lambda (symbol)
|
|
3032 (let ((face (get symbol 'customized-face))
|
|
3033 (value (get symbol 'customized-value)))
|
|
3034 (when face
|
|
3035 (put symbol 'saved-face face)
|
|
3036 (put symbol 'customized-face nil))
|
|
3037 (when value
|
|
3038 (put symbol 'saved-value value)
|
|
3039 (put symbol 'customized-value nil)))))
|
|
3040 ;; We really should update all custom buffers here.
|
|
3041 (custom-save-all))
|
|
3042
|
|
3043 ;;;###autoload
|
|
3044 (defun custom-save-all ()
|
|
3045 "Save all customizations in `custom-file'."
|
|
3046 (let ((inhibit-read-only t))
|
|
3047 (custom-save-variables)
|
|
3048 (custom-save-faces)
|
|
3049 (let ((find-file-hooks nil)
|
|
3050 (auto-mode-alist))
|
|
3051 (with-current-buffer (find-file-noselect custom-file)
|
|
3052 (save-buffer)))))
|
|
3053
|
|
3054
|
|
3055 ;;; The Customize Menu.
|
|
3056
|
|
3057 ;;; Menu support
|
|
3058
|
|
3059 (defun custom-face-menu-create (widget symbol)
|
|
3060 "Ignoring WIDGET, create a menu entry for customization face SYMBOL."
|
|
3061 (vector (custom-unlispify-menu-entry symbol)
|
|
3062 `(customize-face ',symbol)
|
|
3063 t))
|
|
3064
|
|
3065 (defun custom-variable-menu-create (widget symbol)
|
|
3066 "Ignoring WIDGET, create a menu entry for customization variable SYMBOL."
|
|
3067 (let ((type (get symbol 'custom-type)))
|
|
3068 (unless (listp type)
|
|
3069 (setq type (list type)))
|
|
3070 (if (and type (widget-get type :custom-menu))
|
|
3071 (widget-apply type :custom-menu symbol)
|
|
3072 (vector (custom-unlispify-menu-entry symbol)
|
|
3073 `(customize-variable ',symbol)
|
|
3074 t))))
|
|
3075
|
|
3076 ;; Add checkboxes to boolean variable entries.
|
|
3077 (widget-put (get 'boolean 'widget-type)
|
|
3078 :custom-menu (lambda (widget symbol)
|
|
3079 `[,(custom-unlispify-menu-entry symbol)
|
|
3080 (customize-variable ',symbol)
|
|
3081 :style toggle
|
|
3082 :selected ,symbol]))
|
|
3083
|
|
3084 ;; XEmacs can create menus dynamically.
|
|
3085 (defun custom-group-menu-create (widget symbol)
|
|
3086 "Ignoring WIDGET, create a menu entry for customization group SYMBOL."
|
|
3087 `( ,(custom-unlispify-menu-entry symbol t)
|
|
3088 :filter (lambda (&rest junk)
|
|
3089 (let ((item (custom-menu-create ',symbol)))
|
|
3090 (if (listp item)
|
|
3091 (cdr item)
|
|
3092 (list item))))))
|
|
3093
|
|
3094 ;;;###autoload
|
|
3095 (defun custom-menu-create (symbol)
|
|
3096 "Create menu for customization group SYMBOL.
|
|
3097 The menu is in a format applicable to `easy-menu-define'."
|
|
3098 (let* ((item (vector (custom-unlispify-menu-entry symbol)
|
|
3099 `(customize-group ',symbol)
|
|
3100 t)))
|
|
3101 ;; Item is the entry for creating a menu buffer for SYMBOL.
|
|
3102 ;; We may nest, if the menu is not too big.
|
|
3103 (custom-load-symbol symbol)
|
|
3104 (if (< (length (get symbol 'custom-group)) widget-menu-max-size)
|
|
3105 ;; The menu is not too big.
|
|
3106 (let ((custom-prefix-list (custom-prefix-add symbol
|
|
3107 custom-prefix-list))
|
|
3108 (members (custom-sort-items (get symbol 'custom-group)
|
|
3109 custom-menu-sort-alphabetically
|
|
3110 custom-menu-order-groups)))
|
|
3111 ;; Create the menu.
|
|
3112 `(,(custom-unlispify-menu-entry symbol t)
|
|
3113 ,item
|
|
3114 "--"
|
|
3115 ,@(mapcar (lambda (entry)
|
|
3116 (widget-apply (if (listp (nth 1 entry))
|
|
3117 (nth 1 entry)
|
|
3118 (list (nth 1 entry)))
|
|
3119 :custom-menu (nth 0 entry)))
|
|
3120 members)))
|
|
3121 ;; The menu was too big.
|
|
3122 item)))
|
|
3123
|
|
3124 ;;;###autoload
|
|
3125 (defun customize-menu-create (symbol &optional name)
|
|
3126 "Return a customize menu for customization group SYMBOL.
|
|
3127 If optional NAME is given, use that as the name of the menu.
|
|
3128 Otherwise the menu will be named `Customize'.
|
|
3129 The format is suitable for use with `easy-menu-define'."
|
|
3130 (unless name
|
|
3131 (setq name "Customize"))
|
|
3132 `(,name
|
|
3133 :filter (lambda (&rest junk)
|
|
3134 (cdr (custom-menu-create ',symbol)))))
|
|
3135
|
|
3136 ;;; The Custom Mode.
|
|
3137
|
|
3138 (defvar custom-mode-map nil
|
|
3139 "Keymap for `custom-mode'.")
|
|
3140
|
|
3141 (unless custom-mode-map
|
|
3142 (setq custom-mode-map (make-sparse-keymap))
|
|
3143 (set-keymap-parents custom-mode-map widget-keymap)
|
|
3144 (suppress-keymap custom-mode-map)
|
|
3145 (define-key custom-mode-map " " 'scroll-up)
|
|
3146 (define-key custom-mode-map "\177" 'scroll-down)
|
|
3147 (define-key custom-mode-map "q" 'bury-buffer)
|
|
3148 (define-key custom-mode-map "u" 'Custom-goto-parent)
|
|
3149 (define-key custom-mode-map "n" 'widget-forward)
|
|
3150 (define-key custom-mode-map "p" 'widget-backward)
|
|
3151 ;; (define-key custom-mode-map [mouse-1] 'Custom-move-and-invoke)
|
|
3152 )
|
|
3153
|
|
3154 (defun Custom-move-and-invoke (event)
|
|
3155 "Move to where you click, and if it is an active field, invoke it."
|
|
3156 (interactive "e")
|
|
3157 (mouse-set-point event)
|
|
3158 (if (widget-event-point event)
|
|
3159 (let* ((pos (widget-event-point event))
|
|
3160 (button (get-char-property pos 'button)))
|
|
3161 (if button
|
|
3162 (widget-button-click event)))))
|
|
3163
|
|
3164 (easy-menu-define Custom-mode-menu
|
|
3165 custom-mode-map
|
|
3166 "Menu used in customization buffers."
|
|
3167 `("Custom"
|
|
3168 ,(customize-menu-create 'customize)
|
|
3169 ["Set" Custom-set t]
|
|
3170 ["Save" Custom-save t]
|
|
3171 ["Reset to Current" Custom-reset-current t]
|
|
3172 ["Reset to Saved" Custom-reset-saved t]
|
|
3173 ["Reset to Standard Settings" Custom-reset-standard t]
|
|
3174 ["Info" (Info-goto-node "(xemacs)Easy Customization") t]))
|
|
3175
|
|
3176 (defun Custom-goto-parent ()
|
|
3177 "Go to the parent group listed at the top of this buffer.
|
|
3178 If several parents are listed, go to the first of them."
|
|
3179 (interactive)
|
|
3180 (save-excursion
|
|
3181 (goto-char (point-min))
|
|
3182 (if (search-forward "\nGo to parent group: " nil t)
|
|
3183 (let* ((button (get-char-property (point) 'button))
|
|
3184 (parent (downcase (widget-get button :tag))))
|
|
3185 (customize-group parent)))))
|
|
3186
|
|
3187 (defcustom custom-mode-hook nil
|
|
3188 "Hook called when entering custom-mode."
|
|
3189 :type 'hook
|
|
3190 :group 'custom-buffer )
|
|
3191
|
|
3192 (defun custom-state-buffer-message (widget)
|
|
3193 (if (eq (widget-get (widget-get widget :parent) :custom-state) 'modified)
|
|
3194 (message
|
|
3195 "To install your edits, invoke [State] and choose the Set operation")))
|
|
3196
|
|
3197 (defun custom-mode ()
|
|
3198 "Major mode for editing customization buffers.
|
|
3199
|
|
3200 The following commands are available:
|
|
3201
|
|
3202 Move to next button or editable field. \\[widget-forward]
|
|
3203 Move to previous button or editable field. \\[widget-backward]
|
|
3204 \\<widget-field-keymap>\
|
|
3205 Complete content of editable text field. \\[widget-complete]
|
|
3206 \\<custom-mode-map>\
|
|
3207 Invoke button under the mouse pointer. \\[Custom-move-and-invoke]
|
|
3208 Invoke button under point. \\[widget-button-press]
|
|
3209 Set all modifications. \\[Custom-set]
|
|
3210 Make all modifications default. \\[Custom-save]
|
|
3211 Reset all modified options. \\[Custom-reset-current]
|
|
3212 Reset all modified or set options. \\[Custom-reset-saved]
|
|
3213 Reset all options. \\[Custom-reset-standard]
|
|
3214
|
|
3215 Entry to this mode calls the value of `custom-mode-hook'
|
|
3216 if that value is non-nil."
|
|
3217 (kill-all-local-variables)
|
|
3218 (setq major-mode 'custom-mode
|
|
3219 mode-name "Custom")
|
|
3220 (use-local-map custom-mode-map)
|
|
3221 (easy-menu-add Custom-mode-menu)
|
|
3222 (make-local-variable 'custom-options)
|
|
3223 (make-local-variable 'widget-documentation-face)
|
|
3224 (setq widget-documentation-face 'custom-documentation-face)
|
|
3225 (make-local-variable 'widget-button-face)
|
|
3226 (setq widget-button-face 'custom-button-face)
|
|
3227 (make-local-hook 'widget-edit-functions)
|
|
3228 (add-hook 'widget-edit-functions 'custom-state-buffer-message nil t)
|
|
3229 (run-hooks 'custom-mode-hook))
|
|
3230
|
|
3231
|
|
3232 ;;; The End.
|
|
3233
|
|
3234 (provide 'cus-edit)
|
|
3235
|
|
3236 ;; cus-edit.el ends here
|