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