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