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