annotate lisp/custom.el @ 112410:744ddded8b6a

* allout.el (allout-prefixed-keybindings): Bind (prefixed) '#' to allout-number-siblings, in keeping with what obtained due to (now-defunct) allout-keybindings-list. Ditch repeat binding to (prefixed) ?i. (allout-before-change-handler): Better expose spots affected by undo.
author Ken Manheimer <ken.manheimer@gmail.com>
date Fri, 21 Jan 2011 23:41:57 -0500
parents ef719132ddfa
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 36902
diff changeset
1 ;;; custom.el --- tools for declaring and initializing options
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
2 ;;
64762
41bb365f41c4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64441
diff changeset
3 ;; Copyright (C) 1996, 1997, 1999, 2001, 2002, 2003, 2004,
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 107234
diff changeset
4 ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
5 ;;
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
6 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
7 ;; Maintainer: FSF
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
8 ;; Keywords: help, faces
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 109490
diff changeset
9 ;; Package: emacs
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
10
17520
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
11 ;; This file is part of GNU Emacs.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
12
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92148
diff changeset
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
17520
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92148
diff changeset
15 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92148
diff changeset
16 ;; (at your option) any later version.
17520
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
17
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
21 ;; GNU General Public License for more details.
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
22
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
23 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92148
diff changeset
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
17520
f33d7729b6a1 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17442
diff changeset
25
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
26 ;;; Commentary:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
27 ;;
48238
b6f8e90bc592 Fix typos in Commentary section.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47822
diff changeset
28 ;; This file only contains the code needed to declare and initialize
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
29 ;; user options. The code to customize options is autoloaded from
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
30 ;; `cus-edit.el' and is documented in the Emacs Lisp Reference manual.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
31
48238
b6f8e90bc592 Fix typos in Commentary section.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 47822
diff changeset
32 ;; The code implementing face declarations is in `cus-face.el'.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
33
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
34 ;;; Code:
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
35
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
36 (require 'widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
37
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
38 (defvar custom-define-hook nil
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
39 ;; Customize information for this option is in `cus-edit.el'.
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
40 "Hook called after defining each customize option.")
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
41
47570
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
42 (defvar custom-dont-initialize nil
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
43 "Non-nil means `defcustom' should not initialize the variable.
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
44 That is used for the sake of `custom-make-dependencies'.
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
45 Users should not set it.")
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
46
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
47 (defvar custom-current-group-alist nil
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
48 "Alist of (FILE . GROUP) indicating the current group to use for FILE.")
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
49
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
50 ;;; The `defcustom' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
51
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
52 (defun custom-initialize-default (symbol value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
53 "Initialize SYMBOL with VALUE.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
54 This will do nothing if symbol already has a default binding.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
55 Otherwise, if symbol has a `saved-value' property, it will evaluate
55518
10cd0e6bfb73 (custom-initialize-default, defcustom): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 54161
diff changeset
56 the car of that and use it as the default binding for symbol.
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
57 Otherwise, VALUE will be evaluated and used as the default binding for
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
58 symbol."
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
59 (unless (default-boundp symbol)
18033
bccd356a3b7c Synched with version 1.9900.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17949
diff changeset
60 ;; Use the saved value if it exists, otherwise the standard setting.
105032
57aeab3faaa9 (custom-initialize-default, custom-initialize-set): CSE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104990
diff changeset
61 (set-default symbol (eval (if (get symbol 'saved-value)
57aeab3faaa9 (custom-initialize-default, custom-initialize-set): CSE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104990
diff changeset
62 (car (get symbol 'saved-value))
57aeab3faaa9 (custom-initialize-default, custom-initialize-set): CSE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104990
diff changeset
63 value)))))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
64
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
65 (defun custom-initialize-set (symbol value)
19535
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
66 "Initialize SYMBOL based on VALUE.
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
67 If the symbol doesn't have a default binding already,
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
68 then set it using its `:set' function (or `set-default' if it has none).
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
69 The value is either the value in the symbol's `saved-value' property,
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
70 if any, or VALUE."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
71 (unless (default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
72 (funcall (or (get symbol 'custom-set) 'set-default)
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
73 symbol
105032
57aeab3faaa9 (custom-initialize-default, custom-initialize-set): CSE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104990
diff changeset
74 (eval (if (get symbol 'saved-value)
57aeab3faaa9 (custom-initialize-default, custom-initialize-set): CSE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104990
diff changeset
75 (car (get symbol 'saved-value))
57aeab3faaa9 (custom-initialize-default, custom-initialize-set): CSE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104990
diff changeset
76 value)))))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
77
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
78 (defun custom-initialize-reset (symbol value)
19535
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
79 "Initialize SYMBOL based on VALUE.
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
80 Set the symbol, using its `:set' function (or `set-default' if it has none).
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
81 The value is either the symbol's current value
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
82 \(as obtained using the `:get' function), if any,
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
83 or the value in the symbol's `saved-value' property if any,
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
84 or (last of all) VALUE."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
85 (funcall (or (get symbol 'custom-set) 'set-default)
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
86 symbol
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
87 (cond ((default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
88 (funcall (or (get symbol 'custom-get) 'default-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
89 symbol))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
90 ((get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
91 (eval (car (get symbol 'saved-value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
92 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
93 (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
94
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
95 (defun custom-initialize-changed (symbol value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
96 "Initialize SYMBOL with VALUE.
36269
9a470a7db563 (custom-initialize-changed, defcustom): Doc fix.
Dave Love <fx@gnu.org>
parents: 33027
diff changeset
97 Like `custom-initialize-reset', but only use the `:set' function if
19535
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
98 not using the standard setting.
36269
9a470a7db563 (custom-initialize-changed, defcustom): Doc fix.
Dave Love <fx@gnu.org>
parents: 33027
diff changeset
99 For the standard setting, use `set-default'."
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
100 (cond ((default-boundp symbol)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
101 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
102 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
103 (funcall (or (get symbol 'custom-get) 'default-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
104 symbol)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
105 ((get symbol 'saved-value)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
106 (funcall (or (get symbol 'custom-set) 'set-default)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
107 symbol
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
108 (eval (car (get symbol 'saved-value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
109 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
110 (set-default symbol (eval value)))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
111
104961
0ea87b098bb0 * custom.el (custom-delayed-init-variables): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
112 (defvar custom-delayed-init-variables nil
0ea87b098bb0 * custom.el (custom-delayed-init-variables): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
113 "List of variables whose initialization is pending.")
0ea87b098bb0 * custom.el (custom-delayed-init-variables): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
114
0ea87b098bb0 * custom.el (custom-delayed-init-variables): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
115 (defun custom-initialize-delay (symbol value)
0ea87b098bb0 * custom.el (custom-delayed-init-variables): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
116 "Delay initialization of SYMBOL to the next Emacs start.
107234
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
117 This is used in files that are preloaded (or for autoloaded
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
118 variables), so that the initialization is done in the run-time
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
119 context rather than the build-time context. This also has the
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
120 side-effect that the (delayed) initialization is performed with
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
121 the :set function.
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
122
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
123 For variables in preloaded files, you can simply use this
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
124 function for the :initialize property. For autoloaded variables,
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
125 you will also need to add an autoload stanza calling this
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
126 function, and another one setting the standard-value property.
78f7c3c01214 * custom.el (custom-initialize-delay): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
127 See `send-mail-function' in sendmail.el for an example."
104990
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104961
diff changeset
128 ;; Until the var is actually initialized, it is kept unbound.
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104961
diff changeset
129 ;; This seemed to be at least as good as setting it to an arbitrary
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104961
diff changeset
130 ;; value like nil (evaluating `value' is not an option because it
f0794252d960 * mail/sendmail.el (send-mail-function):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 104961
diff changeset
131 ;; may have undesirable side-effects).
104961
0ea87b098bb0 * custom.el (custom-delayed-init-variables): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
132 (push symbol custom-delayed-init-variables))
0ea87b098bb0 * custom.el (custom-delayed-init-variables): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 100908
diff changeset
133
19516
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
134 (defun custom-declare-variable (symbol default doc &rest args)
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
135 "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments.
6591f294b265 (custom-declare-variable): Rename 2nd arg to DEFAULT.
Richard M. Stallman <rms@gnu.org>
parents: 18882
diff changeset
136 DEFAULT should be an expression to evaluate to compute the default value,
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
137 not the default value itself.
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
138
64226
278c7e4c078a (custom-declare-variable): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 64221
diff changeset
139 DEFAULT is stored as SYMBOL's standard value, in SYMBOL's property
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
140 `standard-value'. At the same time, SYMBOL's property `force-value' is
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
141 set to nil, as the value is no longer rogue."
105855
f9569789f83f (custom-declare-group): Purecopy standard-value.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105032
diff changeset
142 (put symbol 'standard-value (purecopy (list default)))
17415
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
143 ;; Maybe this option was rogue in an earlier version. It no longer is.
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
144 (when (get symbol 'force-value)
30a567b89fb6 Sync with 1.84.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17374
diff changeset
145 (put symbol 'force-value nil))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
146 (when doc
109490
715d5a9df4aa * custom.el (custom-declare-variable): Give clearer error message (bug#6476).
Juanma Barranquero <lekktu@gmail.com>
parents: 107898
diff changeset
147 (if (keywordp doc)
715d5a9df4aa * custom.el (custom-declare-variable): Give clearer error message (bug#6476).
Juanma Barranquero <lekktu@gmail.com>
parents: 107898
diff changeset
148 (error "Doc string is missing")
715d5a9df4aa * custom.el (custom-declare-variable): Give clearer error message (bug#6476).
Juanma Barranquero <lekktu@gmail.com>
parents: 107898
diff changeset
149 (put symbol 'variable-documentation doc)))
19535
e9d8fcec9843 (custom-declare-variable): Use custom-initialize-reset
Richard M. Stallman <rms@gnu.org>
parents: 19516
diff changeset
150 (let ((initialize 'custom-initialize-reset)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
151 (requests nil))
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
152 (unless (memq :group args)
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
153 (custom-add-to-group (custom-current-group) symbol 'custom-variable))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
154 (while args
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
155 (let ((arg (car args)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
156 (setq args (cdr args))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
157 (unless (symbolp arg)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
158 (error "Junk in args %S" args))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
159 (let ((keyword arg)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
160 (value (car args)))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
161 (unless args
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
162 (error "Keyword %s is missing an argument" keyword))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
163 (setq args (cdr args))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
164 (cond ((eq keyword :initialize)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
165 (setq initialize value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
166 ((eq keyword :set)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
167 (put symbol 'custom-set value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
168 ((eq keyword :get)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
169 (put symbol 'custom-get value))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
170 ((eq keyword :require)
48476
29e63846608d (custom-declare-variable): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48334
diff changeset
171 (push value requests))
85618
e2b55f3f0f2b (custom-declare-variable): Add :risky and :safe keywords.
Glenn Morris <rgm@gnu.org>
parents: 82365
diff changeset
172 ((eq keyword :risky)
e2b55f3f0f2b (custom-declare-variable): Add :risky and :safe keywords.
Glenn Morris <rgm@gnu.org>
parents: 82365
diff changeset
173 (put symbol 'risky-local-variable value))
e2b55f3f0f2b (custom-declare-variable): Add :risky and :safe keywords.
Glenn Morris <rgm@gnu.org>
parents: 82365
diff changeset
174 ((eq keyword :safe)
e2b55f3f0f2b (custom-declare-variable): Add :risky and :safe keywords.
Glenn Morris <rgm@gnu.org>
parents: 82365
diff changeset
175 (put symbol 'safe-local-variable value))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
176 ((eq keyword :type)
26928
755f54893c1f (custom-declare-variable): Purecopy value.
Dave Love <fx@gnu.org>
parents: 26831
diff changeset
177 (put symbol 'custom-type (purecopy value)))
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
178 ((eq keyword :options)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
179 (if (get symbol 'custom-options)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
180 ;; Slow safe code to avoid duplicates.
32225
15a7324321bb (custom-declare-variable, custom-set-variables): Use mapc.
Dave Love <fx@gnu.org>
parents: 31362
diff changeset
181 (mapc (lambda (option)
15a7324321bb (custom-declare-variable, custom-set-variables): Use mapc.
Dave Love <fx@gnu.org>
parents: 31362
diff changeset
182 (custom-add-option symbol option))
48476
29e63846608d (custom-declare-variable): Use push.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 48334
diff changeset
183 value)
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
184 ;; Fast code for the common case.
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
185 (put symbol 'custom-options (copy-sequence value))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
186 (t
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
187 (custom-handle-keyword symbol keyword value
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
188 'custom-variable))))))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
189 (put symbol 'custom-requests requests)
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
190 ;; Do the actual initialization.
47570
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
191 (unless custom-dont-initialize
b65cc673fb00 (custom-dont-initialize): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 45366
diff changeset
192 (funcall initialize symbol default)))
59507
359397c57b70 (custom-declare-variable): Just put symbol instead of (defvar . symbol)
John Paul Wallington <jpw@pobox.com>
parents: 59385
diff changeset
193 (push symbol current-load-list)
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
194 (run-hooks 'custom-define-hook)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
195 symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
196
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
197 (defmacro defcustom (symbol value doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
198 "Declare SYMBOL as a customizable variable that defaults to VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
199 DOC is the variable documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
200
55518
10cd0e6bfb73 (custom-initialize-default, defcustom): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 54161
diff changeset
201 Neither SYMBOL nor VALUE need to be quoted.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
202 If SYMBOL is not already bound, initialize it to VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
203 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
204
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
205 [KEYWORD VALUE]...
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
206
22141
8ddb49eb4814 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 21703
diff changeset
207 The following keywords are meaningful:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
208
47677
8ed8d9b28086 (defcustom): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 47570
diff changeset
209 :type VALUE should be a widget type for editing the symbol's value.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
210 :options VALUE should be a list of valid members of the widget type.
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
211 :initialize
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
212 VALUE should be a function used to initialize the
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
213 variable. It takes two arguments, the symbol and value
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
214 given in the `defcustom' call. The default is
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
215 `custom-initialize-reset'.
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
216 :set VALUE should be a function to set the value of the symbol.
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
217 It takes two arguments, the symbol to set and the value to
73180
16edffa03262 (defcustom): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 72580
diff changeset
218 give it. The default choice of function is `set-default'.
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
219 :get VALUE should be a function to extract the value of symbol.
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
220 The function takes one argument, a symbol, and should return
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
221 the current value for that symbol. The default choice of function
73180
16edffa03262 (defcustom): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 72580
diff changeset
222 is `default-value'.
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
223 :require
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
224 VALUE should be a feature symbol. If you save a value
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
225 for this option, then when your `.emacs' file loads the value,
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
226 it does (require VALUE) first.
85618
e2b55f3f0f2b (custom-declare-variable): Add :risky and :safe keywords.
Glenn Morris <rgm@gnu.org>
parents: 82365
diff changeset
227 :risky Set SYMBOL's `risky-local-variable' property to VALUE.
e2b55f3f0f2b (custom-declare-variable): Add :risky and :safe keywords.
Glenn Morris <rgm@gnu.org>
parents: 82365
diff changeset
228 :safe Set SYMBOL's `safe-local-variable' property to VALUE.
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
229
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
230 The following common keywords are also meaningful.
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
231
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
232 :group VALUE should be a customization group.
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
233 Add SYMBOL (or FACE with `defface') to that group.
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
234 :link LINK-DATA
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
235 Include an external link after the documentation string for this
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
236 item. This is a sentence containing an active field which
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
237 references some other documentation.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49522
diff changeset
238
67064
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
239 There are several alternatives you can use for LINK-DATA:
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49522
diff changeset
240
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
241 (custom-manual INFO-NODE)
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
242 Link to an Info node; INFO-NODE is a string which specifies
67064
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
243 the node name, as in \"(emacs)Top\".
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49522
diff changeset
244
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
245 (info-link INFO-NODE)
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
246 Like `custom-manual' except that the link appears in the
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
247 customization buffer with the Info node name.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49522
diff changeset
248
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
249 (url-link URL)
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
250 Link to a web page; URL is a string which specifies the URL.
67064
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
251
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
252 (emacs-commentary-link LIBRARY)
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
253 Link to the commentary section of LIBRARY.
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
254
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
255 (emacs-library-link LIBRARY)
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
256 Link to an Emacs Lisp LIBRARY file.
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
257
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
258 (file-link FILE)
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
259 Link to FILE.
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
260
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
261 (function-link FUNCTION)
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
262 Link to the documentation of FUNCTION.
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
263
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
264 (variable-link VARIABLE)
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
265 Link to the documentation of VARIABLE.
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
266
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
267 (custom-group-link GROUP)
e541df85ad86 (defcustom): Update link types in docstring.
Juri Linkov <juri@jurta.org>
parents: 67058
diff changeset
268 Link to another customization GROUP.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49522
diff changeset
269
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
270 You can specify the text to use in the customization buffer by
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
271 adding `:tag NAME' after the first element of the LINK-DATA; for
42508
37d771fc6685 (defcustom): Fix syntax of previous change.
Richard M. Stallman <rms@gnu.org>
parents: 42503
diff changeset
272 example, (info-link :tag \"foo\" \"(emacs)Top\") makes a link to the
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
273 Emacs manual which appears in the buffer as `foo'.
49588
37645a051842 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49522
diff changeset
274
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
275 An item can have more than one external link; however, most items
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
276 have none at all.
29761
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
277 :version
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
278 VALUE should be a string specifying that the variable was
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
279 first introduced, or its default value was changed, in Emacs
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
280 version VERSION.
69922
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
281 :package-version
70021
8991a6461375 * cus-edit.el (customize-package-emacs-version-alist): Update
Bill Wohler <wohler@newt.com>
parents: 69925
diff changeset
282 VALUE should be a list with the form (PACKAGE . VERSION)
69922
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
283 specifying that the variable was first introduced, or its
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
284 default value was changed, in PACKAGE version VERSION. This
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
285 keyword takes priority over :version. The PACKAGE and VERSION
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
286 must appear in the alist `customize-package-emacs-version-alist'.
70021
8991a6461375 * cus-edit.el (customize-package-emacs-version-alist): Update
Bill Wohler <wohler@newt.com>
parents: 69925
diff changeset
287 Since PACKAGE must be unique and the user might see it in an
8991a6461375 * cus-edit.el (customize-package-emacs-version-alist): Update
Bill Wohler <wohler@newt.com>
parents: 69925
diff changeset
288 error message, a good choice is the official name of the
8991a6461375 * cus-edit.el (customize-package-emacs-version-alist): Update
Bill Wohler <wohler@newt.com>
parents: 69925
diff changeset
289 package, such as MH-E or Gnus.
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
290 :tag LABEL
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
291 Use LABEL, a string, instead of the item's name, to label the item
42556
fc69700db2a3 Fix typo.
Pavel Janík <Pavel@Janik.cz>
parents: 42508
diff changeset
292 in customization menus and buffers.
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
293 :load FILE
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
294 Load file FILE (a string) before displaying this customization
47822
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
295 item. Loading is done with `load', and only if the file is
42503
e95910976840 (defcustom): Documented :tag, :link and :load.
Eli Zaretskii <eliz@gnu.org>
parents: 41821
diff changeset
296 not already loaded.
48821
d886606b4f3a (defcustom, custom-set-variables): Doc fix.
Dave Love <fx@gnu.org>
parents: 48476
diff changeset
297 :set-after VARIABLES
d886606b4f3a (defcustom, custom-set-variables): Doc fix.
Dave Love <fx@gnu.org>
parents: 48476
diff changeset
298 Specifies that SYMBOL should be set after the list of variables
d886606b4f3a (defcustom, custom-set-variables): Doc fix.
Dave Love <fx@gnu.org>
parents: 48476
diff changeset
299 VARIABLES when both have been customized.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
300
56558
e897db553e21 (defcustom): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55945
diff changeset
301 If SYMBOL has a local binding, then this form affects the local
e897db553e21 (defcustom): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55945
diff changeset
302 binding. This is normally not what you want. Thus, if you need
e897db553e21 (defcustom): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55945
diff changeset
303 to load a file defining variables with this form, or with
e897db553e21 (defcustom): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55945
diff changeset
304 `defvar' or `defconst', you should always load that file
e897db553e21 (defcustom): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55945
diff changeset
305 _outside_ any bindings for these variables. \(`defvar' and
e897db553e21 (defcustom): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55945
diff changeset
306 `defconst' behave similarly in this respect.)
e897db553e21 (defcustom): Doc fix.
Luc Teirlinck <teirllm@auburn.edu>
parents: 55945
diff changeset
307
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
308 See Info node `(elisp) Customization' in the Emacs Lisp manual
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
309 for more information."
107898
6eae3bc10330 * custom.el (defcustom): Add edebug spec.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 107234
diff changeset
310 (declare (doc-string 3) (debug (name body)))
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
311 ;; It is better not to use backquote in this file,
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
312 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
313 ;; if you need to recompile all the Lisp files using interpreted code.
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
314 (nconc (list 'custom-declare-variable
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
315 (list 'quote symbol)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
316 (list 'quote value)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
317 doc)
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
318 args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
319
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
320 ;;; The `defface' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
321
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
322 (defmacro defface (face spec doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
323 "Declare FACE as a customizable face that defaults to SPEC.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
324 FACE does not need to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
325
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
326 Third argument DOC is the face documentation.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
327
53040
5c1c3b292fe3 doc typo fix
Sam Steingold <sds@gnu.org>
parents: 52401
diff changeset
328 If FACE has been set with `custom-set-faces', set the face attributes
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
329 as specified by that function, otherwise set the face attributes
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
330 according to SPEC.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
331
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
332 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
333
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
334 [KEYWORD VALUE]...
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
335
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
336 For a list of valid keywords, see the common keywords listed in
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
337 `defcustom'.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
338
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
339 SPEC should be an alist of the form ((DISPLAY ATTS)...).
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
340
77487
cd48f6284818 Johan Bockg? <bojohan at dd.chalmers.se>:
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
341 In the first element, DISPLAY can be `default'. The ATTS in that
61530
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
342 element then act as defaults for all the following elements.
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
343
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
344 Aside from that, DISPLAY specifies conditions to match some or
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
345 all frames. For each frame, the first element of SPEC where the
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
346 DISPLAY conditions are satisfied is the one that applies to that
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
347 frame. The ATTRs in this element take effect, and the following
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
348 elements are ignored, on that frame.
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
349
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
350 In the last element, DISPLAY can be t. That element applies to a
77487
cd48f6284818 Johan Bockg? <bojohan at dd.chalmers.se>:
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
351 frame if none of the previous elements (except the `default' if
61530
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
352 any) did.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
353
17949
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
354 ATTS is a list of face attributes followed by their values:
3b0f71e1661d (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17921
diff changeset
355 (ATTR VALUE ATTR VALUE...)
24986
cf6d86af7374 (defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents: 24872
diff changeset
356
cf6d86af7374 (defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents: 24872
diff changeset
357 The possible attributes are `:family', `:width', `:height', `:weight',
cf6d86af7374 (defface): Extend documentation to include new
Gerd Moellmann <gerd@gnu.org>
parents: 24872
diff changeset
358 `:slant', `:underline', `:overline', `:strike-through', `:box',
39981
c576f3427825 (defface): Mention `:inherit' in doc-string.
Miles Bader <miles@gnu.org>
parents: 38857
diff changeset
359 `:foreground', `:background', `:stipple', `:inverse-video', and `:inherit'.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
360
77487
cd48f6284818 Johan Bockg? <bojohan at dd.chalmers.se>:
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
361 DISPLAY can be `default' (only in the first element), the symbol
61530
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
362 t (only in the last element) to match all frames, or an alist of
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
363 conditions of the form \(REQ ITEM...). For such an alist to
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
364 match a frame, each of the conditions must be satisfied, meaning
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
365 that the REQ property of the frame must match one of the
a4f9ea538274 (defface): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 61432
diff changeset
366 corresponding ITEMs. These are the defined REQ values:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
367
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
368 `type' (the value of `window-system')
25888
7144668076c7 (defface): Extend documentation for new values of `type'.
Gerd Moellmann <gerd@gnu.org>
parents: 25683
diff changeset
369 Under X, in addition to the values `window-system' can take,
55545
70c4138d3b8d * custom.el (defface): Document that type can have value gtk.
Jan Djärv <jan.h.d@swipnet.se>
parents: 55518
diff changeset
370 `motif', `lucid', `gtk' and `x-toolkit' are allowed, and match when
70c4138d3b8d * custom.el (defface): Document that type can have value gtk.
Jan Djärv <jan.h.d@swipnet.se>
parents: 55518
diff changeset
371 the Motif toolkit, Lucid toolkit, GTK toolkit or any X toolkit is in use.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
372
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
373 `class' (the frame's color support)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
374 Should be one of `color', `grayscale', or `mono'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
375
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
376 `background' (what color is used for the background text)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
377 Should be one of `light' or `dark'.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
378
54152
42286a8d371c (defface): Add documentation for `min-colors'.
Eli Zaretskii <eliz@gnu.org>
parents: 53371
diff changeset
379 `min-colors' (the minimum number of colors the frame should support)
42286a8d371c (defface): Add documentation for `min-colors'.
Eli Zaretskii <eliz@gnu.org>
parents: 53371
diff changeset
380 Should be an integer, it is compared with the result of
42286a8d371c (defface): Add documentation for `min-colors'.
Eli Zaretskii <eliz@gnu.org>
parents: 53371
diff changeset
381 `display-color-cells'.
42286a8d371c (defface): Add documentation for `min-colors'.
Eli Zaretskii <eliz@gnu.org>
parents: 53371
diff changeset
382
55945
4ecb534c2d20 (defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents: 55545
diff changeset
383 `supports' (only match frames that support the specified face attributes)
4ecb534c2d20 (defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents: 55545
diff changeset
384 Should be a list of face attributes. See the documentation for
4ecb534c2d20 (defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents: 55545
diff changeset
385 the function `display-supports-face-attributes-p' for more
4ecb534c2d20 (defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents: 55545
diff changeset
386 information on exactly how testing is done.
4ecb534c2d20 (defface): Add `supports' to docstring.
Juri Linkov <juri@jurta.org>
parents: 55545
diff changeset
387
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
388 See Info node `(elisp) Customization' in the Emacs Lisp manual
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
389 for more information."
66399
65d160cfd8f2 (defface, defcustom): Add `doc-string' declaration.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 65480
diff changeset
390 (declare (doc-string 3))
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
391 ;; It is better not to use backquote in this file,
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
392 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
393 ;; if you need to recompile all the Lisp files using interpreted code.
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
394 (nconc (list 'custom-declare-face (list 'quote face) spec doc) args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
395
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
396 ;;; The `defgroup' Macro.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
397
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
398 (defun custom-current-group ()
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
399 (cdr (assoc load-file-name custom-current-group-alist)))
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
400
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
401 (defun custom-declare-group (symbol members doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
402 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
403 (while members
17550
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
404 (apply 'custom-add-to-group symbol (car members))
d6545cfb6c5a Synched with custom 1.90.
Per Abrahamsen <abraham@dina.kvl.dk>
parents: 17529
diff changeset
405 (setq members (cdr members)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
406 (when doc
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
407 ;; This text doesn't get into DOC.
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
408 (put symbol 'group-documentation (purecopy doc)))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
409 (while args
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
410 (let ((arg (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
411 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
412 (unless (symbolp arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
413 (error "Junk in args %S" args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
414 (let ((keyword arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
415 (value (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
416 (unless args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
417 (error "Keyword %s is missing an argument" keyword))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
418 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
419 (cond ((eq keyword :prefix)
105855
f9569789f83f (custom-declare-group): Purecopy standard-value.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105032
diff changeset
420 (put symbol 'custom-prefix (purecopy value)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
421 (t
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
422 (custom-handle-keyword symbol keyword value
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
423 'custom-group))))))
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
424 ;; Record the group on the `current' list.
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
425 (let ((elt (assoc load-file-name custom-current-group-alist)))
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
426 (if elt (setcdr elt symbol)
105943
39e6ad203eb0 (custom-declare-group): Purecopy load-file-name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105855
diff changeset
427 (push (cons (purecopy load-file-name) symbol)
39e6ad203eb0 (custom-declare-group): Purecopy load-file-name.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 105855
diff changeset
428 custom-current-group-alist)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
429 (run-hooks 'custom-define-hook)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
430 symbol)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
431
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
432 (defmacro defgroup (symbol members doc &rest args)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
433 "Declare SYMBOL as a customization group containing MEMBERS.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
434 SYMBOL does not need to be quoted.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
435
106001
02d1ed432817 (defgroup): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 105943
diff changeset
436 Third argument DOC is the group documentation. This should be a short
02d1ed432817 (defgroup): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 105943
diff changeset
437 description of the group, beginning with a capital and ending with
02d1ed432817 (defgroup): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 105943
diff changeset
438 a period. Words other than the first should not be capitalized, if they
02d1ed432817 (defgroup): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 105943
diff changeset
439 are not usually written so.
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
440
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
441 MEMBERS should be an alist of the form ((NAME WIDGET)...) where
20599
a529e09b1fe2 (defgroup): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 20445
diff changeset
442 NAME is a symbol and WIDGET is a widget for editing that symbol.
a529e09b1fe2 (defgroup): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 20445
diff changeset
443 Useful widgets are `custom-variable' for editing variables,
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
444 `custom-face' for edit faces, and `custom-group' for editing groups.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
445
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
446 The remaining arguments should have the form
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
447
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
448 [KEYWORD VALUE]...
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
449
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
450 For a list of valid keywords, see the common keywords listed in
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
451 `defcustom'.
29761
00dcb25bfffd (defcustom, defgroup): Doc fix.
Dave Love <fx@gnu.org>
parents: 28171
diff changeset
452
69925
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
453 See Info node `(elisp) Customization' in the Emacs Lisp manual
9319f873855b (defcustom): Create Common Keywords section in docstring.
Bill Wohler <wohler@newt.com>
parents: 69922
diff changeset
454 for more information."
67058
65266d675973 (defgroup): Add doc-string-elt info.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 66399
diff changeset
455 (declare (doc-string 3))
21703
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
456 ;; It is better not to use backquote in this file,
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
457 ;; because that makes a bootstrapping problem
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
458 ;; if you need to recompile all the Lisp files using interpreted code.
aea35bf72489 (defcustom, defgroup, defface): Don't use backquote.
Richard M. Stallman <rms@gnu.org>
parents: 20599
diff changeset
459 (nconc (list 'custom-declare-group (list 'quote symbol) members doc) args))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
460
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
461 (defun custom-add-to-group (group option widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
462 "To existing GROUP add a new OPTION of type WIDGET.
33025
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
463 If there already is an entry for OPTION and WIDGET, nothing is done."
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
464 (let ((members (get group 'custom-group))
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
465 (entry (list option widget)))
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
466 (unless (member entry members)
9559a9aeff3c (custom-add-to-group): Allow multiple entries for a given value OPTION,
Miles Bader <miles@gnu.org>
parents: 32225
diff changeset
467 (put group 'custom-group (nconc members (list entry))))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
468
47822
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
469 (defun custom-group-of-mode (mode)
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
470 "Return the custom group corresponding to the major or minor MODE.
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
471 If no such group is found, return nil."
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
472 (or (get mode 'custom-mode-group)
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
473 (if (or (get mode 'custom-group)
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
474 (and (string-match "-mode\\'" (symbol-name mode))
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
475 (get (setq mode (intern (substring (symbol-name mode)
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
476 0 (match-beginning 0))))
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
477 'custom-group)))
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
478 mode)))
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
479
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
480 ;;; Properties.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
481
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
482 (defun custom-handle-all-keywords (symbol args type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
483 "For customization option SYMBOL, handle keyword arguments ARGS.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
484 Third argument TYPE is the custom option type."
41224
fc0e6d3f905d (custom-current-group-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39981
diff changeset
485 (unless (memq :group args)
48272
8555178ad8a0 (custom-handle-all-keywords): Fix arg passed to custom-add-to-group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48238
diff changeset
486 (custom-add-to-group (custom-current-group) symbol type))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
487 (while args
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
488 (let ((arg (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
489 (setq args (cdr args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
490 (unless (symbolp arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
491 (error "Junk in args %S" args))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
492 (let ((keyword arg)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
493 (value (car args)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
494 (unless args
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
495 (error "Keyword %s is missing an argument" keyword))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
496 (setq args (cdr args))
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
497 (custom-handle-keyword symbol keyword value type)))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
498
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
499 (defun custom-handle-keyword (symbol keyword value type)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
500 "For customization option SYMBOL, handle KEYWORD with VALUE.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
501 Fourth argument TYPE is the custom option type."
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
502 (if purify-flag
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
503 (setq value (purecopy value)))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
504 (cond ((eq keyword :group)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
505 (custom-add-to-group value symbol type))
20445
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
506 ((eq keyword :version)
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
507 (custom-add-version symbol value))
69922
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
508 ((eq keyword :package-version)
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
509 (custom-add-package-version symbol value))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
510 ((eq keyword :link)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
511 (custom-add-link symbol value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
512 ((eq keyword :load)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
513 (custom-add-load symbol value))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
514 ((eq keyword :tag)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
515 (put symbol 'custom-tag value))
26831
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
516 ((eq keyword :set-after)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
517 (custom-add-dependencies symbol value))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
518 (t
24872
9db8a7ed814e (custom-handle-keyword): Fix error message.
Karl Heuer <kwzh@gnu.org>
parents: 24438
diff changeset
519 (error "Unknown keyword %s" keyword))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
520
26831
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
521 (defun custom-add-dependencies (symbol value)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
522 "To the custom option SYMBOL, add dependencies specified by VALUE.
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
523 VALUE should be a list of symbols. For each symbol in that list,
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
524 this specifies that SYMBOL should be set after the specified symbol, if
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
525 both appear in constructs like `custom-set-variables'."
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
526 (unless (listp value)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
527 (error "Invalid custom dependency `%s'" value))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
528 (let* ((deps (get symbol 'custom-dependencies))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
529 (new-deps deps))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
530 (while value
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
531 (let ((dep (car value)))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
532 (unless (symbolp dep)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
533 (error "Invalid custom dependency `%s'" dep))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
534 (unless (memq dep new-deps)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
535 (setq new-deps (cons dep new-deps)))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
536 (setq value (cdr value))))
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
537 (unless (eq deps new-deps)
ddaafb816c3e (custom-handle-keyword): Add :set-after.
Gerd Moellmann <gerd@gnu.org>
parents: 26582
diff changeset
538 (put symbol 'custom-dependencies new-deps))))
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
539
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
540 (defun custom-add-option (symbol option)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
541 "To the variable SYMBOL add OPTION.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
542
63932
bbf23e50d797 (custom-add-option): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 63927
diff changeset
543 If SYMBOL's custom type is a hook, OPTION should be a hook member.
bbf23e50d797 (custom-add-option): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 63927
diff changeset
544 If SYMBOL's custom type is an alist, OPTION specifies a symbol
bbf23e50d797 (custom-add-option): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 63927
diff changeset
545 to offer to the user as a possible key in the alist.
bbf23e50d797 (custom-add-option): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 63927
diff changeset
546 For other custom types, this has no effect."
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
547 (let ((options (get symbol 'custom-options)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
548 (unless (member option options)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
549 (put symbol 'custom-options (cons option options)))))
74861
7054ae4948fb (custom-add-frequent-value): Alias for custom-add-option.
Chong Yidong <cyd@stupidchicken.com>
parents: 73180
diff changeset
550 (defalias 'custom-add-frequent-value 'custom-add-option)
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
551
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
552 (defun custom-add-link (symbol widget)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
553 "To the custom option SYMBOL add the link WIDGET."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
554 (let ((links (get symbol 'custom-links)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
555 (unless (member widget links)
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
556 (put symbol 'custom-links (cons (purecopy widget) links)))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
557
20445
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
558 (defun custom-add-version (symbol version)
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
559 "To the custom option SYMBOL add the version VERSION."
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
560 (put symbol 'custom-version (purecopy version)))
20445
20ff88ac8cc2 (custom-add-version): New function.
Karl Heuer <kwzh@gnu.org>
parents: 19535
diff changeset
561
69922
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
562 (defun custom-add-package-version (symbol version)
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
563 "To the custom option SYMBOL add the package version VERSION."
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
564 (put symbol 'custom-package-version (purecopy version)))
dc1f0ab7e276 * custom.el (defcustom, custom-handle-keyword): Add :package-version
Bill Wohler <wohler@newt.com>
parents: 69624
diff changeset
565
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
566 (defun custom-add-load (symbol load)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
567 "To the custom option SYMBOL add the dependency LOAD.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
568 LOAD should be either a library file name, or a feature name."
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
569 (let ((loads (get symbol 'custom-loads)))
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
570 (unless (member load loads)
26582
fbd1f4d3000d (custom-declare-group): Purecopy DOC.
Dave Love <fx@gnu.org>
parents: 25888
diff changeset
571 (put symbol 'custom-loads (cons (purecopy load) loads)))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
572
71954
628aeba24139 (custom-autoload): Add `noset' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70646
diff changeset
573 (defun custom-autoload (symbol load &optional noset)
628aeba24139 (custom-autoload): Add `noset' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70646
diff changeset
574 "Mark SYMBOL as autoloaded custom variable and add dependency LOAD.
628aeba24139 (custom-autoload): Add `noset' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70646
diff changeset
575 If NOSET is non-nil, don't bother autoloading LOAD when setting the variable."
628aeba24139 (custom-autoload): Add `noset' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70646
diff changeset
576 (put symbol 'custom-autoload (if noset 'noset t))
49099
04672e32e3b0 (custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48951
diff changeset
577 (custom-add-load symbol load))
04672e32e3b0 (custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48951
diff changeset
578
04672e32e3b0 (custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48951
diff changeset
579 ;; This test is also in the C code of `user-variable-p'.
04672e32e3b0 (custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48951
diff changeset
580 (defun custom-variable-p (variable)
64149
8633ed45b13c (custom-variable-p): Make it recursively follow aliases. Mention that
Luc Teirlinck <teirllm@auburn.edu>
parents: 64091
diff changeset
581 "Return non-nil if VARIABLE is a custom variable.
8633ed45b13c (custom-variable-p): Make it recursively follow aliases. Mention that
Luc Teirlinck <teirllm@auburn.edu>
parents: 64091
diff changeset
582 This recursively follows aliases."
8633ed45b13c (custom-variable-p): Make it recursively follow aliases. Mention that
Luc Teirlinck <teirllm@auburn.edu>
parents: 64091
diff changeset
583 (setq variable (indirect-variable variable))
49099
04672e32e3b0 (custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48951
diff changeset
584 (or (get variable 'standard-value)
04672e32e3b0 (custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48951
diff changeset
585 (get variable 'custom-autoload)))
04672e32e3b0 (custom-autoload, custom-variable-p): New functions.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48951
diff changeset
586
85653
58abbc936e8f (custom-note-var-changed): New function.
Richard M. Stallman <rms@gnu.org>
parents: 85618
diff changeset
587 (defun custom-note-var-changed (variable)
58abbc936e8f (custom-note-var-changed): New function.
Richard M. Stallman <rms@gnu.org>
parents: 85618
diff changeset
588 "Inform Custom that VARIABLE has been set (changed).
58abbc936e8f (custom-note-var-changed): New function.
Richard M. Stallman <rms@gnu.org>
parents: 85618
diff changeset
589 VARIABLE is a symbol that names a user option.
58abbc936e8f (custom-note-var-changed): New function.
Richard M. Stallman <rms@gnu.org>
parents: 85618
diff changeset
590 The result is that the change is treated as having been made through Custom."
58abbc936e8f (custom-note-var-changed): New function.
Richard M. Stallman <rms@gnu.org>
parents: 85618
diff changeset
591 (put variable 'customized-value (list (custom-quote (eval variable)))))
86028
cdd09d6acfdc (custom-note-var-changed): Remove the `interactive'
Juri Linkov <juri@jurta.org>
parents: 85653
diff changeset
592
cdd09d6acfdc (custom-note-var-changed): Remove the `interactive'
Juri Linkov <juri@jurta.org>
parents: 85653
diff changeset
593
cdd09d6acfdc (custom-note-var-changed): Remove the `interactive'
Juri Linkov <juri@jurta.org>
parents: 85653
diff changeset
594 ;;; Custom Themes
85653
58abbc936e8f (custom-note-var-changed): New function.
Richard M. Stallman <rms@gnu.org>
parents: 85618
diff changeset
595
44911
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
596 ;;; Loading files needed to customize a symbol.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
597 ;;; This is in custom.el because menu-bar.el needs it for toggle cmds.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
598
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
599 (defvar custom-load-recursion nil
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
600 "Hack to avoid recursive dependencies.")
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
601
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
602 (defun custom-load-symbol (symbol)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
603 "Load all dependencies for SYMBOL."
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
604 (unless custom-load-recursion
47822
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
605 (let ((custom-load-recursion t))
52207
c26f56efcd5d (custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents: 50123
diff changeset
606 ;; Load these files if not already done,
c26f56efcd5d (custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents: 50123
diff changeset
607 ;; to make sure we know all the dependencies of SYMBOL.
c26f56efcd5d (custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents: 50123
diff changeset
608 (condition-case nil
c26f56efcd5d (custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents: 50123
diff changeset
609 (require 'cus-load)
c26f56efcd5d (custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents: 50123
diff changeset
610 (error nil))
c26f56efcd5d (custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents: 50123
diff changeset
611 (condition-case nil
c26f56efcd5d (custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents: 50123
diff changeset
612 (require 'cus-start)
c26f56efcd5d (custom-load-symbol): Load cus-load and cus-start first.
Richard M. Stallman <rms@gnu.org>
parents: 50123
diff changeset
613 (error nil))
47822
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
614 (dolist (load (get symbol 'custom-loads))
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
615 (cond ((symbolp load) (condition-case nil (require load) (error nil)))
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
616 ;; This is subsumed by the test below, but it's much faster.
44911
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
617 ((assoc load load-history))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
618 ;; This was just (assoc (locate-library load) load-history)
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
619 ;; but has been optimized not to load locate-library
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
620 ;; if not necessary.
47822
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
621 ((let ((regexp (concat "\\(\\`\\|/\\)" (regexp-quote load)
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
622 "\\(\\'\\|\\.\\)"))
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
623 (found nil))
44911
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
624 (dolist (loaded load-history)
45366
c9338efa3fd9 (custom-load-symbol): Verify that LOADED is a string.
Richard M. Stallman <rms@gnu.org>
parents: 44911
diff changeset
625 (and (stringp (car loaded))
c9338efa3fd9 (custom-load-symbol): Verify that LOADED is a string.
Richard M. Stallman <rms@gnu.org>
parents: 44911
diff changeset
626 (string-match regexp (car loaded))
44911
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
627 (setq found t)))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
628 found))
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
629 ;; Without this, we would load cus-edit recursively.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
630 ;; We are still loading it when we call this,
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
631 ;; and it is not in load-history yet.
0edc2b27187b (custom-load-symbol): Moved from cus-edit.el.
Richard M. Stallman <rms@gnu.org>
parents: 44683
diff changeset
632 ((equal load "cus-edit"))
47822
46f8bf0fc7b4 (custom-group-of-mode): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 47677
diff changeset
633 (t (condition-case nil (load load) (error nil))))))))
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
634
67978
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
635 (defvar custom-local-buffer nil
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
636 "Non-nil, in a Customization buffer, means customize a specific buffer.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
637 If this variable is non-nil, it should be a buffer,
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
638 and it means customize the local bindings of that buffer.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
639 This variable is a permanent local, and it normally has a local binding
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
640 in every Customization buffer.")
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
641 (put 'custom-local-buffer 'permanent-local t)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
642
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
643 (defun custom-set-default (variable value)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
644 "Default :set function for a customizable variable.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
645 Normally, this sets the default value of VARIABLE to VALUE,
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
646 but if `custom-local-buffer' is non-nil,
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
647 this sets the local binding in that buffer instead."
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
648 (if custom-local-buffer
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
649 (with-current-buffer custom-local-buffer
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
650 (set variable value))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
651 (set-default variable value)))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
652
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
653 (defun custom-set-minor-mode (variable value)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
654 ":set function for minor mode variables.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
655 Normally, this sets the default value of VARIABLE to nil if VALUE
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
656 is nil and to t otherwise,
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
657 but if `custom-local-buffer' is non-nil,
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
658 this sets the local binding in that buffer instead."
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
659 (if custom-local-buffer
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
660 (with-current-buffer custom-local-buffer
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
661 (funcall variable (if value 1 0)))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
662 (funcall variable (if value 1 0))))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
663
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
664 (defun custom-quote (sexp)
78492
7c8949dbfa0d Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
665 "Quote SEXP if it is not self quoting."
67978
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
666 (if (or (memq sexp '(t nil))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
667 (keywordp sexp)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
668 (and (listp sexp)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
669 (memq (car sexp) '(lambda)))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
670 (stringp sexp)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
671 (numberp sexp)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
672 (vectorp sexp)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
673 ;;; (and (fboundp 'characterp)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
674 ;;; (characterp sexp))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
675 )
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
676 sexp
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
677 (list 'quote sexp)))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
678
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
679 (defun customize-mark-to-save (symbol)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
680 "Mark SYMBOL for later saving.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
681
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
682 If the default value of SYMBOL is different from the standard value,
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
683 set the `saved-value' property to a list whose car evaluates to the
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
684 default value. Otherwise, set it to nil.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
685
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
686 To actually save the value, call `custom-save-all'.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
687
78492
7c8949dbfa0d Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
688 Return non-nil if the `saved-value' property actually changed."
69037
2e60323be52d * custom.el (customize-mark-to-save, customize-mark-as-set): Load
Chong Yidong <cyd@stupidchicken.com>
parents: 69006
diff changeset
689 (custom-load-symbol symbol)
67978
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
690 (let* ((get (or (get symbol 'custom-get) 'default-value))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
691 (value (funcall get symbol))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
692 (saved (get symbol 'saved-value))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
693 (standard (get symbol 'standard-value))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
694 (comment (get symbol 'customized-variable-comment)))
78492
7c8949dbfa0d Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
695 ;; Save default value if different from standard value.
67978
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
696 (if (or (null standard)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
697 (not (equal value (condition-case nil
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
698 (eval (car standard))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
699 (error nil)))))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
700 (put symbol 'saved-value (list (custom-quote value)))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
701 (put symbol 'saved-value nil))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
702 ;; Clear customized information (set, but not saved).
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
703 (put symbol 'customized-value nil)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
704 ;; Save any comment that might have been set.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
705 (when comment
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
706 (put symbol 'saved-variable-comment comment))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
707 (not (equal saved (get symbol 'saved-value)))))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
708
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
709 (defun customize-mark-as-set (symbol)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
710 "Mark current value of SYMBOL as being set from customize.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
711
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
712 If the default value of SYMBOL is different from the saved value if any,
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
713 or else if it is different from the standard value, set the
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
714 `customized-value' property to a list whose car evaluates to the
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
715 default value. Otherwise, set it to nil.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
716
78492
7c8949dbfa0d Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
717 Return non-nil if the `customized-value' property actually changed."
69037
2e60323be52d * custom.el (customize-mark-to-save, customize-mark-as-set): Load
Chong Yidong <cyd@stupidchicken.com>
parents: 69006
diff changeset
718 (custom-load-symbol symbol)
67978
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
719 (let* ((get (or (get symbol 'custom-get) 'default-value))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
720 (value (funcall get symbol))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
721 (customized (get symbol 'customized-value))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
722 (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
78492
7c8949dbfa0d Replace `iff' in doc-strings and comments.
Glenn Morris <rgm@gnu.org>
parents: 78236
diff changeset
723 ;; Mark default value as set if different from old value.
71954
628aeba24139 (custom-autoload): Add `noset' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70646
diff changeset
724 (if (not (and old
628aeba24139 (custom-autoload): Add `noset' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70646
diff changeset
725 (equal value (condition-case nil
628aeba24139 (custom-autoload): Add `noset' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70646
diff changeset
726 (eval (car old))
628aeba24139 (custom-autoload): Add `noset' argument.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 70646
diff changeset
727 (error nil)))))
69006
e4d97c1f1377 * custom.el (customize-mark-as-set): Push to `user' theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 69005
diff changeset
728 (progn (put symbol 'customized-value (list (custom-quote value)))
e4d97c1f1377 * custom.el (customize-mark-as-set): Push to `user' theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 69005
diff changeset
729 (custom-push-theme 'theme-value symbol 'user 'set
e4d97c1f1377 * custom.el (customize-mark-as-set): Push to `user' theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 69005
diff changeset
730 (custom-quote value)))
67978
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
731 (put symbol 'customized-value nil))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
732 ;; Changed?
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
733 (not (equal customized (get symbol 'customized-value)))))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
734
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
735 (defun custom-reevaluate-setting (symbol)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
736 "Reset the value of SYMBOL by re-evaluating its saved or standard value.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
737 Use the :set function to do so. This is useful for customizable options
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
738 that are defined before their standard value can really be computed.
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
739 E.g. dumped variables whose default depends on run-time information."
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
740 (funcall (or (get symbol 'custom-set) 'set-default)
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
741 symbol
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
742 (eval (car (or (get symbol 'saved-value) (get symbol 'standard-value))))))
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
743
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
744
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
745 ;;; Custom Themes
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
746
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
747 ;; Custom themes are collections of settings that can be enabled or
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
748 ;; disabled as a unit.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
749
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
750 ;; Each Custom theme is defined by a symbol, called the theme name.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
751 ;; The `theme-settings' property of the theme name records the
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
752 ;; variable and face settings of the theme. This property is a list
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
753 ;; of elements, each of the form
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
754 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
755 ;; (PROP SYMBOL THEME VALUE)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
756 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
757 ;; - PROP is either `theme-value' or `theme-face'
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
758 ;; - SYMBOL is the face or variable name
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
759 ;; - THEME is the theme name (redundant, but simplifies the code)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
760 ;; - VALUE is an expression that gives the theme's setting for SYMBOL.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
761 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
762 ;; The theme name also has a `theme-feature' property, whose value is
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
763 ;; specified when the theme is defined (see `custom-declare-theme').
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
764 ;; Usually, this is just a symbol named THEME-theme. This lets
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
765 ;; external libraries call (require 'foo-theme).
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
766
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
767 ;; In addition, each symbol (either a variable or a face) affected by
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
768 ;; an *enabled* theme has a `theme-value' or `theme-face' property,
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
769 ;; which is a list of elements each of the form
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
770 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
771 ;; (THEME VALUE)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
772 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
773 ;; which have the same meanings as in `theme-settings'.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
774 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
775 ;; The `theme-value' and `theme-face' lists are ordered by decreasing
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
776 ;; theme precedence. Thus, the first element is always the one that
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
777 ;; is in effect.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
778
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
779 ;; Each theme is stored in a theme file, with filename THEME-theme.el.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
780 ;; Loading a theme basically involves calling (load "THEME-theme")
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
781 ;; This is done by the function `load-theme'. Loading a theme
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
782 ;; automatically enables it.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
783 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
784 ;; When a theme is enabled, the `theme-value' and `theme-face'
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
785 ;; properties for the affected symbols are set. When a theme is
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
786 ;; disabled, its settings are removed from the `theme-value' and
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
787 ;; `theme-face' properties, but the theme's own `theme-settings'
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
788 ;; property remains unchanged.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
789
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
790 (defvar custom-known-themes '(user changed)
63927
7f7d0de05845 (custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61530
diff changeset
791 "Themes that have been defined with `deftheme'.
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
792 The default value is the list (user changed). The theme `changed'
65341
6990826a916f Custom Theme bugfixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 65334
diff changeset
793 contains the settings before custom themes are applied. The
64441
d0cd5eb4d042 (custom-known-themes): Delete duplicate words.
Juri Linkov <juri@jurta.org>
parents: 64303
diff changeset
794 theme `user' contains all the settings the user customized and saved.
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
795 Additional themes declared with the `deftheme' macro will be added to
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
796 the front of this list.")
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
797
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
798 (defsubst custom-theme-p (theme)
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
799 "Non-nil when THEME has been defined."
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
800 (memq theme custom-known-themes))
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
801
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
802 (defsubst custom-check-theme (theme)
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
803 "Check whether THEME is valid, and signal an error if it is not."
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
804 (unless (custom-theme-p theme)
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
805 (error "Unknown theme `%s'" theme)))
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
806
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
807 (defun custom-push-theme (prop symbol theme mode &optional value)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
808 "Record VALUE for face or variable SYMBOL in custom theme THEME.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
809 PROP is `theme-face' for a face, `theme-value' for a variable.
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
810
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
811 MODE can be either the symbol `set' or the symbol `reset'. If it is the
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
812 symbol `set', then VALUE is the value to use. If it is the symbol
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
813 `reset', then SYMBOL will be removed from THEME (VALUE is ignored).
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
814
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
815 See `custom-known-themes' for a list of known themes."
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
816 (unless (memq prop '(theme-value theme-face))
67783
118df638c3ff 2005-12-23 Chong Yidong <cyd@stupidchicken.com>
Chong Yidong <cyd@stupidchicken.com>
parents: 67123
diff changeset
817 (error "Unknown theme property"))
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
818 (let* ((old (get symbol prop))
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
819 (setting (assq theme old)) ; '(theme value)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
820 (theme-settings ; '(prop symbol theme value)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
821 (get theme 'theme-settings)))
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
822 (cond
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
823 ;; Remove a setting:
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
824 ((eq mode 'reset)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
825 (when setting
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
826 (let (res)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
827 (dolist (theme-setting theme-settings)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
828 (if (and (eq (car theme-setting) prop)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
829 (eq (cadr theme-setting) symbol))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
830 (setq res theme-setting)))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
831 (put theme 'theme-settings (delq res theme-settings)))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
832 (put symbol prop (delq setting old))))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
833 ;; Alter an existing setting:
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
834 (setting
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
835 (let (res)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
836 (dolist (theme-setting theme-settings)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
837 (if (and (eq (car theme-setting) prop)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
838 (eq (cadr theme-setting) symbol))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
839 (setq res theme-setting)))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
840 (put theme 'theme-settings
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
841 (cons (list prop symbol theme value)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
842 (delq res theme-settings)))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
843 (setcar (cdr setting) value)))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
844 ;; Add a new setting:
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
845 (t
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
846 (unless old
67783
118df638c3ff 2005-12-23 Chong Yidong <cyd@stupidchicken.com>
Chong Yidong <cyd@stupidchicken.com>
parents: 67123
diff changeset
847 ;; If the user changed the value outside of Customize, we
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
848 ;; first save the current value to a fake theme, `changed'.
67783
118df638c3ff 2005-12-23 Chong Yidong <cyd@stupidchicken.com>
Chong Yidong <cyd@stupidchicken.com>
parents: 67123
diff changeset
849 ;; This ensures that the user-set value comes back if the
118df638c3ff 2005-12-23 Chong Yidong <cyd@stupidchicken.com>
Chong Yidong <cyd@stupidchicken.com>
parents: 67123
diff changeset
850 ;; theme is later disabled.
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
851 (cond ((and (eq prop 'theme-value)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
852 (boundp symbol))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
853 (let ((sv (get symbol 'standard-value)))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
854 (unless (and sv
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
855 (equal (eval (car sv)) (symbol-value symbol)))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
856 (setq old (list (list 'changed (symbol-value symbol)))))))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
857 ((and (facep symbol)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
858 (not (face-attr-match-p
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
859 symbol
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
860 (custom-fix-face-spec
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
861 (face-spec-choose
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
862 (get symbol 'face-defface-spec))))))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
863 (setq old `((changed
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
864 (,(append '(t) (custom-face-attributes-get
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
865 symbol nil)))))))))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
866 (put symbol prop (cons (list theme value) old))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
867 (put theme 'theme-settings
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
868 (cons (list prop symbol theme value) theme-settings))))))
67978
f313a5c7323b Change ordering so all the Custom Themes code is in one place.
Chong Yidong <cyd@stupidchicken.com>
parents: 67977
diff changeset
869
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
870 (defun custom-fix-face-spec (spec)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
871 "Convert face SPEC, replacing obsolete :bold and :italic attributes.
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
872 Also change :reverse-video to :inverse-video."
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
873 (when (listp spec)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
874 (if (or (memq :bold spec)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
875 (memq :italic spec)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
876 (memq :inverse-video spec))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
877 (let (result)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
878 (while spec
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
879 (let ((key (car spec))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
880 (val (car (cdr spec))))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
881 (cond ((eq key :italic)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
882 (push :slant result)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
883 (push (if val 'italic 'normal) result))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
884 ((eq key :bold)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
885 (push :weight result)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
886 (push (if val 'bold 'normal) result))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
887 ((eq key :reverse-video)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
888 (push :inverse-video result)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
889 (push val result))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
890 (t
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
891 (push key result)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
892 (push val result))))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
893 (setq spec (cddr spec)))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
894 (nreverse result))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
895 spec)))
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
896
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
897 (defun custom-set-variables (&rest args)
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
898 "Install user customizations of variable values specified in ARGS.
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
899 These settings are registered as theme `user'.
48821
d886606b4f3a (defcustom, custom-set-variables): Doc fix.
Dave Love <fx@gnu.org>
parents: 48476
diff changeset
900 The arguments should each be a list of the form:
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
901
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
902 (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
903
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
904 This stores EXP (without evaluating it) as the saved value for SYMBOL.
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
905 If NOW is present and non-nil, then also evaluate EXP and set
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
906 the default value for the SYMBOL to the value of EXP.
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
907
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
908 REQUEST is a list of features we must require in order to
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
909 handle SYMBOL properly.
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
910 COMMENT is a comment string about SYMBOL."
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
911 (apply 'custom-theme-set-variables 'user args))
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
912
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
913 (defun custom-theme-set-variables (theme &rest args)
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
914 "Initialize variables for theme THEME according to settings in ARGS.
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
915 Each of the arguments in ARGS should be a list of this form:
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
916
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
917 (SYMBOL EXP [NOW [REQUEST [COMMENT]]])
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
918
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
919 This stores EXP (without evaluating it) as the saved value for SYMBOL.
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
920 If NOW is present and non-nil, then also evaluate EXP and set
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
921 the default value for the SYMBOL to the value of EXP.
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
922
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
923 REQUEST is a list of features we must require in order to
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
924 handle SYMBOL properly.
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
925 COMMENT is a comment string about SYMBOL.
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
926
59385
24b54016dd51 (custom-set-variables, custom-theme-set-variables): Clarify documentation.
Richard M. Stallman <rms@gnu.org>
parents: 56558
diff changeset
927 EXP itself is saved unevaluated as SYMBOL property `saved-value' and
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
928 in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
929 (custom-check-theme theme)
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
930
72580
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
931 ;; Process all the needed autoloads before anything else, so that the
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
932 ;; subsequent code has all the info it needs (e.g. which var corresponds
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
933 ;; to a minor mode), regardless of the ordering of the variables.
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
934 (dolist (entry args)
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
935 (let* ((symbol (indirect-variable (nth 0 entry))))
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
936 (unless (or (get symbol 'standard-value)
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
937 (memq (get symbol 'custom-autoload) '(nil noset)))
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
938 ;; This symbol needs to be autoloaded, even just for a `set'.
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
939 (custom-load-symbol symbol))))
80075
23de7844a977 (custom-theme-set-variables): Sort symbols that are
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
940
72580
2da08bd76792 (custom-theme-set-variables): Autoload packages before sorting the variables.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 71954
diff changeset
941 ;; Move minor modes and variables with explicit requires to the end.
60413
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
942 (setq args
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
943 (sort args
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
944 (lambda (a1 a2)
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
945 (let* ((sym1 (car a1))
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
946 (sym2 (car a2))
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
947 (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
948 (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
949 (cond ((and 1-then-2 2-then-1)
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
950 (error "Circular custom dependency between `%s' and `%s'"
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
951 sym1 sym2))
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
952 (2-then-1 nil)
80075
23de7844a977 (custom-theme-set-variables): Sort symbols that are
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
953 ;; 1 is a dependency of 2, so needs to be set first.
23de7844a977 (custom-theme-set-variables): Sort symbols that are
Glenn Morris <rgm@gnu.org>
parents: 79721
diff changeset
954 (1-then-2)
65093
1aae62fd4a80 (custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
955 ;; Put minor modes and symbols with :require last.
1aae62fd4a80 (custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
956 ;; Putting minor modes last ensures that the mode
1aae62fd4a80 (custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
957 ;; function will see other customized values rather
1aae62fd4a80 (custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
958 ;; than default values.
1aae62fd4a80 (custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
959 (t (or (nth 3 a2)
1aae62fd4a80 (custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
960 (eq (get sym2 'custom-set)
1aae62fd4a80 (custom-theme-set-variables): Sort minor modes last.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 64762
diff changeset
961 'custom-set-minor-mode))))))))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
962
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
963 (dolist (entry args)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
964 (unless (listp entry)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
965 (error "Incompatible Custom theme spec"))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
966 (let* ((symbol (indirect-variable (nth 0 entry)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
967 (value (nth 1 entry)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
968 (custom-push-theme 'theme-value symbol theme 'set value)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
969 (unless custom--inhibit-theme-enable
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
970 ;; Now set the variable.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
971 (let* ((now (nth 2 entry))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
972 (requests (nth 3 entry))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
973 (comment (nth 4 entry))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
974 set)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
975 (when requests
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
976 (put symbol 'custom-requests requests)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
977 (mapc 'require requests))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
978 (setq set (or (get symbol 'custom-set) 'custom-set-default))
60413
28b5c27160e8 (custom-reevaluate-setting): Simple function to handle variables
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 60020
diff changeset
979 (put symbol 'saved-value (list value))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
980 (put symbol 'saved-variable-comment comment)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
981 ;; Allow for errors in the case where the setter has
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
982 ;; changed between versions, say, but let the user know.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
983 (condition-case data
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
984 (cond (now
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
985 ;; Rogue variable, set it now.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
986 (put symbol 'force-value t)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
987 (funcall set symbol (eval value)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
988 ((default-boundp symbol)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
989 ;; Something already set this, overwrite it.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
990 (funcall set symbol (eval value))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
991 (error
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
992 (message "Error setting %s: %s" symbol data)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
993 (and (or now (default-boundp symbol))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
994 (put symbol 'variable-comment comment)))))))
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
995
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
996
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
997 ;;; Defining themes.
44683
17031c88f781 (customize-mark-to-save, customize-mark-as-set)
Miles Bader <miles@gnu.org>
parents: 42556
diff changeset
998
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
999 ;; A theme file is named `THEME-theme.el' (where THEME is the theme
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1000 ;; name) found in `custom-theme-load-path'. It has this format:
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1001 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1002 ;; (deftheme THEME
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1003 ;; DOCSTRING)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1004 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1005 ;; (custom-theme-set-variables
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1006 ;; 'THEME
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1007 ;; [THEME-VARIABLES])
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1008 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1009 ;; (custom-theme-set-faces
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1010 ;; 'THEME
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1011 ;; [THEME-FACES])
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1012 ;;
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1013 ;; (provide-theme 'THEME)
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1014
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1015
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1016 ;; The IGNORED arguments to deftheme come from the XEmacs theme code, where
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1017 ;; they were used to supply keyword-value pairs like `:immediate',
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1018 ;; `:variable-reset-string', etc. We don't use any of these, so ignore them.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1019
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1020 (defmacro deftheme (theme &optional doc &rest ignored)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1021 "Declare THEME to be a Custom theme.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1022 The optional argument DOC is a doc string describing the theme.
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1023
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1024 Any theme `foo' should be defined in a file called `foo-theme.el';
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1025 see `custom-make-theme-feature' for more information."
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1026 (let ((feature (custom-make-theme-feature theme)))
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1027 ;; It is better not to use backquote in this file,
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1028 ;; because that makes a bootstrapping problem
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1029 ;; if you need to recompile all the Lisp files using interpreted code.
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1030 (list 'custom-declare-theme (list 'quote theme) (list 'quote feature) doc)))
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1031
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1032 (defun custom-declare-theme (theme feature &optional doc &rest ignored)
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1033 "Like `deftheme', but THEME is evaluated as a normal argument.
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1034 FEATURE is the feature this theme provides. Normally, this is a symbol
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1035 created from THEME by `custom-make-theme-feature'."
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1036 (unless (custom-theme-name-valid-p theme)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1037 (error "Custom theme cannot be named %S" theme))
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1038 (add-to-list 'custom-known-themes theme)
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1039 (put theme 'theme-feature feature)
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1040 (when doc (put theme 'theme-documentation doc)))
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1041
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1042 (defun custom-make-theme-feature (theme)
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1043 "Given a symbol THEME, create a new symbol by appending \"-theme\".
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1044 Store this symbol in the `theme-feature' property of THEME.
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1045 Calling `provide-theme' to provide THEME actually puts `THEME-theme'
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1046 into `features'.
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1047
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1048 This allows for a file-name convention for autoloading themes:
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1049 Every theme X has a property `provide-theme' whose value is \"X-theme\".
65334
2c6c9fd9d86b *** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents: 65093
diff changeset
1050 \(load-theme X) then attempts to load the file `X-theme.el'."
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1051 (intern (concat (symbol-name theme) "-theme")))
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1052
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1053 ;;; Loading themes.
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1054
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1055 (defcustom custom-theme-directory user-emacs-directory
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1056 "Default user directory for storing custom theme files.
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1057 The command `customize-create-theme' writes theme files into this
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1058 directory. By default, Emacs searches for custom themes in this
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1059 directory first---see `custom-theme-load-path'."
63927
7f7d0de05845 (custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61530
diff changeset
1060 :type 'string
7f7d0de05845 (custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61530
diff changeset
1061 :group 'customize
7f7d0de05845 (custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61530
diff changeset
1062 :version "22.1")
7f7d0de05845 (custom-declare-variable): Fix typos in comment.
Luc Teirlinck <teirllm@auburn.edu>
parents: 61530
diff changeset
1063
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1064 (defcustom custom-theme-load-path (list 'custom-theme-directory t)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1065 "List of directories to search for custom theme files.
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1066 When loading custom themes (e.g. in `customize-themes' and
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1067 `load-theme'), Emacs searches for theme files in the specified
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1068 order. Each element in the list should be one of the following:
111017
9506df1b7b65 Allow hiding of modified custom widgets.
Chong Yidong <cyd@stupidchicken.com>
parents: 111016
diff changeset
1069 - the symbol `custom-theme-directory', meaning the value of
9506df1b7b65 Allow hiding of modified custom widgets.
Chong Yidong <cyd@stupidchicken.com>
parents: 111016
diff changeset
1070 `custom-theme-directory'.
9506df1b7b65 Allow hiding of modified custom widgets.
Chong Yidong <cyd@stupidchicken.com>
parents: 111016
diff changeset
1071 - the symbol t, meaning the built-in theme directory (a directory
9506df1b7b65 Allow hiding of modified custom widgets.
Chong Yidong <cyd@stupidchicken.com>
parents: 111016
diff changeset
1072 named \"themes\" in `data-directory').
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1073 - a directory name (a string).
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1074
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1075 Each theme file is named NAME-theme.el, where THEME is the theme
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1076 name."
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1077 :type '(repeat (choice (const :tag "custom-theme-directory"
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1078 custom-theme-directory)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1079 (const :tag "Built-in theme directory" t)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1080 directory))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1081 :group 'customize
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1082 :version "24.1")
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1083
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1084 (defvar custom--inhibit-theme-enable nil
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1085 "If non-nil, loading a theme does not enable it.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1086 This internal variable is set by `load-theme' when its NO-ENABLE
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1087 argument is non-nil, and it affects `custom-theme-set-variables',
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1088 `custom-theme-set-faces', and `provide-theme'." )
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1089
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1090 (defun provide-theme (theme)
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1091 "Indicate that this file provides THEME.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1092 This calls `provide' to provide the feature name stored in THEME's
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1093 property `theme-feature' (which is usually a symbol created by
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1094 `custom-make-theme-feature')."
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1095 (unless (custom-theme-name-valid-p theme)
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1096 (error "Custom theme cannot be named %S" theme))
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1097 (custom-check-theme theme)
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1098 (provide (get theme 'theme-feature))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1099 (unless custom--inhibit-theme-enable
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1100 ;; By default, loading a theme also enables it.
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1101 (push theme custom-enabled-themes)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1102 ;; `user' must always be the highest-precedence enabled theme.
111018
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1103 ;; Make that remain true. (This has the effect of making user
de901820e0bc Allow Custom settings to be migrated into a custom theme.
Chong Yidong <cyd@stupidchicken.com>
parents: 111017
diff changeset
1104 ;; settings override the ones just loaded, too.)
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1105 (let ((custom-enabling-themes t))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1106 (enable-theme 'user))))
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1107
112170
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1108 (defcustom custom-safe-themes '(default)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1109 "List of themes that are considered safe to load.
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1110 Each list element should be the `sha1' hash of a theme file, or
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1111 the symbol `default', which stands for any theme in the built-in
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1112 Emacs theme directory (a directory named \"themes\" in
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1113 `data-directory')."
112164
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1114 :type '(repeat
112170
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1115 (choice string (const :tag "Built-in themes" default)))
112164
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1116 :group 'customize
112170
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1117 :risky t
112164
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1118 :version "24.1")
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1119
111050
b23826c3d7a1 Revert 2010-10-18 change; use safe-functions instead.
Chong Yidong <cyd@stupidchicken.com>
parents: 111024
diff changeset
1120 (defvar safe-functions) ; From unsafep.el
b23826c3d7a1 Revert 2010-10-18 change; use safe-functions instead.
Chong Yidong <cyd@stupidchicken.com>
parents: 111024
diff changeset
1121
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1122 (defun load-theme (theme &optional no-enable)
68020
d8acae190ef7 * cus-edit.el (custom-reset-menu, custom-reset, Custom-mode-menu)
Chong Yidong <cyd@stupidchicken.com>
parents: 67980
diff changeset
1123 "Load a theme's settings from its file.
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1124 Normally, this also enables the theme; use `disable-theme' to
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1125 disable it. If optional arg NO-ENABLE is non-nil, don't enable
112164
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1126 the theme.
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1127
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1128 A theme file is named THEME-theme.el, where THEME is the theme name,
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1129 in one of the directories specified by `custom-theme-load-path'."
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1130 (interactive
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1131 (list
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1132 (intern (completing-read "Load custom theme: "
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1133 (mapcar 'symbol-name
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1134 (custom-available-themes))))))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1135 (unless (custom-theme-name-valid-p theme)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1136 (error "Invalid theme name `%s'" theme))
68020
d8acae190ef7 * cus-edit.el (custom-reset-menu, custom-reset, Custom-mode-menu)
Chong Yidong <cyd@stupidchicken.com>
parents: 67980
diff changeset
1137 ;; If reloading, clear out the old theme settings.
d8acae190ef7 * cus-edit.el (custom-reset-menu, custom-reset, Custom-mode-menu)
Chong Yidong <cyd@stupidchicken.com>
parents: 67980
diff changeset
1138 (when (custom-theme-p theme)
d8acae190ef7 * cus-edit.el (custom-reset-menu, custom-reset, Custom-mode-menu)
Chong Yidong <cyd@stupidchicken.com>
parents: 67980
diff changeset
1139 (disable-theme theme)
d8acae190ef7 * cus-edit.el (custom-reset-menu, custom-reset, Custom-mode-menu)
Chong Yidong <cyd@stupidchicken.com>
parents: 67980
diff changeset
1140 (put theme 'theme-settings nil)
d8acae190ef7 * cus-edit.el (custom-reset-menu, custom-reset, Custom-mode-menu)
Chong Yidong <cyd@stupidchicken.com>
parents: 67980
diff changeset
1141 (put theme 'theme-feature nil)
d8acae190ef7 * cus-edit.el (custom-reset-menu, custom-reset, Custom-mode-menu)
Chong Yidong <cyd@stupidchicken.com>
parents: 67980
diff changeset
1142 (put theme 'theme-documentation nil))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1143 (let ((fn (locate-file (concat (symbol-name theme) "-theme.el")
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1144 (custom-theme--load-path)
112170
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1145 '("" "c")))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1146 hash)
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1147 (unless fn
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1148 (error "Unable to find theme file for `%s'." theme))
112170
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1149 (with-temp-buffer
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1150 (insert-file-contents fn)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1151 (setq hash (sha1 (current-buffer)))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1152 ;; Check file safety.
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1153 (when (or (and (memq 'default custom-safe-themes)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1154 (equal (file-name-directory fn)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1155 (expand-file-name "themes/" data-directory)))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1156 (member hash custom-safe-themes)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1157 ;; If the theme is not in `custom-safe-themes', check
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1158 ;; it with unsafep.
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1159 (progn
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1160 (require 'unsafep)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1161 (let ((safe-functions
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1162 (append '(provide-theme deftheme
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1163 custom-theme-set-variables
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1164 custom-theme-set-faces)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1165 safe-functions))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1166 unsafep form)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1167 (while (and (setq form (condition-case nil
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1168 (let ((read-circle nil))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1169 (read (current-buffer)))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1170 (end-of-file nil)))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1171 (null (setq unsafep (unsafep form)))))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1172 (or (null unsafep)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1173 (custom-theme-load-confirm hash)))))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1174 (let ((custom--inhibit-theme-enable no-enable))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1175 (eval-buffer))))))
112164
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1176
112170
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1177 (defun custom-theme-load-confirm (hash)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1178 "Query the user about loading a Custom theme that may not be safe.
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1179 The theme should be in the current buffer. If the user agrees,
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1180 query also about adding HASH to `custom-safe-themes'."
112164
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1181 (if noninteractive
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1182 nil
112170
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1183 (let ((exit-chars '(?y ?n ?\s))
112164
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1184 prompt char)
afa244de82cd Load themes using `load', querying if theme file not known safe.
Chong Yidong <cyd@stupidchicken.com>
parents: 111050
diff changeset
1185 (save-window-excursion
112170
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1186 (rename-buffer "*Custom Theme*" t)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1187 (emacs-lisp-mode)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1188 (display-buffer (current-buffer))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1189 (setq prompt
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1190 (format "This theme is not guaranteed to be safe. Really load? %s"
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1191 (if (< (line-number-at-pos (point-max))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1192 (window-body-height))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1193 "(y or n) "
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1194 (push ?\C-v exit-chars)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1195 "Type y or n, or C-v to scroll: ")))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1196 (goto-char (point-min))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1197 (while (null char)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1198 (setq char (read-char-choice prompt exit-chars))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1199 (when (eq char ?\C-v)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1200 (condition-case nil
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1201 (scroll-up)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1202 (error (goto-char (point-min))))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1203 (setq char nil)))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1204 (when (memq char '(?\s ?y))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1205 (push hash custom-safe-themes)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1206 ;; Offer to save to `custom-safe-themes'.
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1207 (and (or custom-file user-init-file)
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1208 (y-or-n-p "Treat this theme as safe for future loads? ")
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1209 (let ((coding-system-for-read nil))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1210 (customize-save-variable 'custom-safe-themes
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1211 custom-safe-themes)))
2b3091d14255 Record "safe themes" as sha1 hashes, as suggested by Stefan Monnier.
Chong Yidong <cyd@stupidchicken.com>
parents: 112164
diff changeset
1212 t)))))
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1213
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1214 (defun custom-theme-name-valid-p (name)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1215 "Return t if NAME is a valid name for a Custom theme, nil otherwise.
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1216 NAME should be a symbol."
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1217 (and (symbolp name)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1218 name
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1219 (not (or (zerop (length (symbol-name name)))
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1220 (eq name 'user)
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1221 (eq name 'changed)))))
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1222
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1223 (defun custom-available-themes ()
110938
17bbe431e616 New interface for choosing Custom themes.
Chong Yidong <cyd@stupidchicken.com>
parents: 110914
diff changeset
1224 "Return a list of available Custom themes (symbols)."
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1225 (let* (sym themes)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1226 (dolist (dir (custom-theme--load-path))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1227 (when (file-directory-p dir)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1228 (dolist (file (file-expand-wildcards
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1229 (expand-file-name "*-theme.el" dir) t))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1230 (setq file (file-name-nondirectory file))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1231 (and (string-match "\\`\\(.+\\)-theme.el\\'" file)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1232 (setq sym (intern (match-string 1 file)))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1233 (custom-theme-name-valid-p sym)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1234 (push sym themes)))))
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1235 (delete-dups themes)))
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1236
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1237 (defun custom-theme--load-path ()
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1238 (let (lpath)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1239 (dolist (f custom-theme-load-path)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1240 (cond ((eq f 'custom-theme-directory)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1241 (setq f custom-theme-directory))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1242 ((eq f t)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1243 (setq f (expand-file-name "themes" data-directory))))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1244 (if (file-directory-p f)
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1245 (push f lpath)))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1246 (nreverse lpath)))
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1247
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1248
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1249 ;;; Enabling and disabling loaded themes.
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1250
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1251 (defvar custom-enabling-themes nil)
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1252
65334
2c6c9fd9d86b *** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents: 65093
diff changeset
1253 (defun enable-theme (theme)
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1254 "Reenable all variable and face settings defined by THEME.
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1255 The newly enabled theme gets the highest precedence (after `user').
67123
6e41569f62c8 * custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents: 67064
diff changeset
1256 If it is already enabled, just give it highest precedence (after `user').
6e41569f62c8 * custom.el (enable-theme): Signal error if argument is not a
Chong Yidong <cyd@stupidchicken.com>
parents: 67064
diff changeset
1257
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1258 If THEME does not specify any theme settings, this tries to load
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1259 the theme from its theme file, by calling `load-theme'."
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1260 (interactive (list (intern
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1261 (completing-read
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1262 "Enable custom theme: "
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1263 obarray (lambda (sym) (get sym 'theme-settings))))))
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1264 (if (not (custom-theme-p theme))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1265 (load-theme theme)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1266 ;; This could use a bit of optimization -- cyd
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1267 (let ((settings (get theme 'theme-settings)))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1268 (dolist (s settings)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1269 (let* ((prop (car s))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1270 (symbol (cadr s))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1271 (spec-list (get symbol prop)))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1272 (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1273 (if (eq prop 'theme-value)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1274 (custom-theme-recalc-variable symbol)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1275 (custom-theme-recalc-face symbol)))))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1276 (unless (eq theme 'user)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1277 (setq custom-enabled-themes
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1278 (cons theme (delq theme custom-enabled-themes)))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1279 (unless custom-enabling-themes
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1280 (enable-theme 'user)))))
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1281
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1282 (defcustom custom-enabled-themes nil
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1283 "List of enabled Custom Themes, highest precedence first.
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1284
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1285 This does not include the `user' theme, which is set by Customize,
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1286 and always takes precedence over other Custom Themes."
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1287 :group 'customize
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1288 :type '(repeat symbol)
111016
fedd4f6fa7e5 Move built-in theme directory to etc/.
Chong Yidong <cyd@stupidchicken.com>
parents: 110977
diff changeset
1289 :set-after '(custom-theme-directory custom-theme-load-path)
111050
b23826c3d7a1 Revert 2010-10-18 change; use safe-functions instead.
Chong Yidong <cyd@stupidchicken.com>
parents: 111024
diff changeset
1290 :risky t
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1291 :set (lambda (symbol themes)
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1292 ;; Avoid an infinite loop when custom-enabled-themes is
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1293 ;; defined in a theme (e.g. `user'). Enabling the theme sets
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1294 ;; custom-enabled-themes, which enables the theme...
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1295 (unless custom-enabling-themes
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1296 (let ((custom-enabling-themes t) failures)
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1297 (setq themes (delq 'user (delete-dups themes)))
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1298 (if (boundp symbol)
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1299 (dolist (theme (symbol-value symbol))
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1300 (if (not (memq theme themes))
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1301 (disable-theme theme))))
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1302 (dolist (theme (reverse themes))
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1303 (condition-case nil
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1304 (enable-theme theme)
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1305 (error (progn (push theme failures)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1306 (setq themes (delq theme themes))))))
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1307 (enable-theme 'user)
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1308 (custom-set-default symbol themes)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1309 (if failures
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1310 (message "Failed to enable themes: %s"
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1311 (mapconcat 'symbol-name failures " ")))))))
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1312
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1313 (defsubst custom-theme-enabled-p (theme)
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1314 "Return non-nil if THEME is enabled."
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1315 (memq theme custom-enabled-themes))
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1316
65334
2c6c9fd9d86b *** empty log message ***
Chong Yidong <cyd@stupidchicken.com>
parents: 65093
diff changeset
1317 (defun disable-theme (theme)
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1318 "Disable all variable and face settings defined by THEME.
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1319 See `custom-enabled-themes' for a list of enabled themes."
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1320 (interactive (list (intern
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1321 (completing-read
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1322 "Disable custom theme: "
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1323 (mapcar 'symbol-name custom-enabled-themes)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1324 nil t))))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1325 (when (custom-theme-enabled-p theme)
67943
6130ad6751ca (custom-load-themes): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents: 67798
diff changeset
1326 (let ((settings (get theme 'theme-settings)))
6130ad6751ca (custom-load-themes): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents: 67798
diff changeset
1327 (dolist (s settings)
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1328 (let* ((prop (car s))
67943
6130ad6751ca (custom-load-themes): Function deleted.
Richard M. Stallman <rms@gnu.org>
parents: 67798
diff changeset
1329 (symbol (cadr s))
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1330 (val (assq-delete-all theme (get symbol prop))))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1331 (put symbol prop val)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1332 (cond
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1333 ((eq prop 'theme-value)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1334 (custom-theme-recalc-variable symbol))
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1335 ((eq prop 'theme-face)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1336 ;; If the face spec specified by this theme is in the
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1337 ;; saved-face property, reset that property.
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1338 (when (equal (nth 3 s) (get symbol 'saved-face))
110977
a5cd85a6290e Define a cursor defface; minor face optimizations.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
1339 (put symbol 'saved-face (and val (cadr (car val)))))
67962
48d2cc2834b4 * custom.el (provide-theme): Ban `user' theme name.
Chong Yidong <cyd@stupidchicken.com>
parents: 67944
diff changeset
1340 (custom-theme-recalc-face symbol)))))
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1341 (setq custom-enabled-themes
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1342 (delq theme custom-enabled-themes)))))
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1343
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1344 (defun custom-variable-theme-value (variable)
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1345 "Return (list VALUE) indicating the custom theme value of VARIABLE.
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1346 That is to say, it specifies what the value should be according to
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1347 currently enabled custom themes.
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1348
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1349 This function returns nil if no custom theme specifies a value for VARIABLE."
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1350 (let* ((theme-value (get variable 'theme-value)))
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1351 (if theme-value
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1352 (cdr (car theme-value)))))
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1353
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1354 (defun custom-theme-recalc-variable (variable)
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1355 "Set VARIABLE according to currently enabled custom themes."
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1356 (let ((valspec (custom-variable-theme-value variable)))
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1357 (if valspec
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1358 (put variable 'saved-value valspec)
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1359 (setq valspec (get variable 'standard-value)))
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1360 (if (and valspec
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1361 (or (get variable 'force-value)
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1362 (default-boundp variable)))
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1363 (funcall (or (get variable 'custom-set) 'set-default) variable
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1364 (eval (car valspec))))))
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1365
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1366 (defun custom-theme-recalc-face (face)
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1367 "Set FACE according to currently enabled custom themes."
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1368 (if (get face 'face-alias)
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1369 (setq face (get face 'face-alias)))
110977
a5cd85a6290e Define a cursor defface; minor face optimizations.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
1370 ;; Reset the faces for each frame.
a5cd85a6290e Define a cursor defface; minor face optimizations.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
1371 (dolist (frame (frame-list))
a5cd85a6290e Define a cursor defface; minor face optimizations.
Chong Yidong <cyd@stupidchicken.com>
parents: 110955
diff changeset
1372 (face-spec-recalc face frame)))
110914
ccdc694ce7bd More cleanups and minor fixes for Customize.
Chong Yidong <cyd@stupidchicken.com>
parents: 110015
diff changeset
1373
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1374
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1375 ;;; XEmacs compability functions
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1376
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1377 ;; In XEmacs, when you reset a Custom Theme, you have to specify the
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1378 ;; theme to reset it to. We just apply the next available theme, so
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1379 ;; just ignore the IGNORED arguments.
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1380
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1381 (defun custom-theme-reset-variables (theme &rest args)
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1382 "Reset some variable settings in THEME to their values in other themes.
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1383 Each of the arguments ARGS has this form:
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1384
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1385 (VARIABLE IGNORED)
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1386
67980
6ddcdaaf3992 Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 67979
diff changeset
1387 This means reset VARIABLE. (The argument IGNORED is ignored)."
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1388 (custom-check-theme theme)
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1389 (dolist (arg args)
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1390 (custom-push-theme 'theme-value (car arg) theme 'reset)))
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1391
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1392 (defun custom-reset-variables (&rest args)
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1393 "Reset the specs of some variables to their values in other themes.
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1394 This creates settings in the `user' theme.
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1395
64220
38b6647b9ed4 (custom-push-theme): Maintain list of the settings
Richard M. Stallman <rms@gnu.org>
parents: 64200
diff changeset
1396 Each of the arguments ARGS has this form:
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1397
67977
03ee9bccbfeb * custom.el: Move Custom Themes commentary to start of theme code.
Chong Yidong <cyd@stupidchicken.com>
parents: 67962
diff changeset
1398 (VARIABLE IGNORED)
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1399
67980
6ddcdaaf3992 Doc fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 67979
diff changeset
1400 This means reset VARIABLE. (The argument IGNORED is ignored)."
48951
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1401 (apply 'custom-theme-reset-variables 'user args))
d77bc55dd27b (custom-known-themes): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 48821
diff changeset
1402
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
1403 ;;; The End.
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
1404
18882
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
1405 ;; Process the defcustoms for variables loaded before this file.
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
1406 (while custom-declare-variable-list
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
1407 (apply 'custom-declare-variable (car custom-declare-variable-list))
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
1408 (setq custom-declare-variable-list (cdr custom-declare-variable-list)))
539611251037 (custom-declare-variable-list): Process already-declared
Richard M. Stallman <rms@gnu.org>
parents: 18033
diff changeset
1409
17334
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
1410 (provide 'custom)
1effe507ea85 Initial revision
Per Abrahamsen <abraham@dina.kvl.dk>
parents:
diff changeset
1411
25683
d1179efb4e87 Don't define-widget-keywords.
Dave Love <fx@gnu.org>
parents: 24986
diff changeset
1412 ;;; custom.el ends here