annotate lisp/custom.el @ 4570:e6a7054a9c30

Add check-coding-systems-region, test it and others, fix some bugs. tests/ChangeLog addition: 2008-12-28 Aidan Kehoe <kehoea@parhasard.net> * automated/query-coding-tests.el: Add tests for #'unencodable-char-position, #'check-coding-systems-region, #'encode-coding-char. Remove some debugging statements. lisp/ChangeLog addition: 2008-12-28 Aidan Kehoe <kehoea@parhasard.net> * coding.el (query-coding-region): (query-coding-string): Make these defsubsts, they're short enough and they're called explicitly rarely enough that it make some sense. The alternative would be compiler macros that avoid the binding of the arguments. (unencodable-char-position): Document where the docstring and API are from. Correct a special case for zero--check-argument-type returns nil when it succeeds, we can't usefully chain its result in an and here. (check-coding-systems-region): New. API taken from GNU; docstring and implementation are independent. (encode-coding-char): Add an optional third argument, as used by recent GNU. Document the origen of the docstring. (default-query-coding-region): Add a short docstring to the non-Mule implementation of this function. * unicode.el: Don't set the query-coding-function property for unicode coding systems if we're on non-mule. Unintern unicode-query-coding-region, unicode-query-coding-skip-chars-arg in the same context.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 28 Dec 2008 22:51:14 +0000
parents 8748a3f7ceb4
children 061e030e3270
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1 ;;; custom.el --- tools for declaring and initializing options
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
2 ;;
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
3 ;; Copyright (C) 1996, 1997, 1999, 2001, 2002 Free Software Foundation, Inc.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
4 ;;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
6 ;; Maintainer: XEmacs Development Group
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: help, faces, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; GNU General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
26 ;;; Synched with: FSF 21.3.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
27
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
32 ;;
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
33 ;; This file only contains the code needed to declare and initialize
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;; user options. The code to customize options is autoloaded from
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
35 ;; `cus-edit.el' and is documented in the XEmacs Lisp Reference manual.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
36
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
37 ;; The code implementing face declarations is in `cus-face.el'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
41 ;; it is now safe to put the `provide' anywhere. if an error occurs while
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
42 ;; loading, all provides (and fsets) will be undone. put it first to
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
43 ;; prevent require/provide loop with custom and cus-face.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
44 (provide 'custom)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
45
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (eval-when-compile
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
47 (load "cl-macs" nil t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
48 ;; To elude warnings.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
49 (require 'cus-face))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
51 (autoload 'custom-declare-face "cus-face")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
52 (autoload 'defun* "cl-macs")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (require 'widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 (defvar custom-define-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 ;; Customize information for this option is in `cus-edit.el'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 "Hook called after defining each customize option.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
60 (defvar custom-dont-initialize nil
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
61 "Non-nil means `defcustom' should not initialize the variable.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
62 That is used for the sake of `custom-make-dependencies'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
63 Users should not set it.")
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
64
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
65 (defvar custom-current-group-alist nil
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
66 "Alist of (FILE . GROUP) indicating the current group to use for FILE.")
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
67
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 ;;; The `defcustom' Macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 (defun custom-initialize-default (symbol value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 "Initialize SYMBOL with VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 This will do nothing if symbol already has a default binding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 Otherwise, if symbol has a `saved-value' property, it will evaluate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 the car of that and used as the default binding for symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 Otherwise, VALUE will be evaluated and used as the default binding for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 (unless (default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 ;; Use the saved value if it exists, otherwise the standard setting.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 (set-default symbol (if (get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 (eval (car (get symbol 'saved-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 (eval value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 (defun custom-initialize-set (symbol value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 "Initialize SYMBOL with VALUE.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
85 If the symbol doesn't have a default binding already,
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
86 then set it using its `:set' function (or `set-default' if it has none).
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
87 The value is either the value in the symbol's `saved-value' property,
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
88 if any, or VALUE.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
89
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
90 This is like `custom-initialize-default', but uses the function specified by
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 `:set' to initialize SYMBOL."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (unless (default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (funcall (or (get symbol 'custom-set) 'set-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 (if (get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (eval (car (get symbol 'saved-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (eval value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (defun custom-initialize-reset (symbol value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 "Initialize SYMBOL with VALUE.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
101 Set the symbol, using its `:set' function (or `set-default' if it has none).
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
102 The value is either the symbol's current value
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
103 \(as obtained using the `:get' function), if any,
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
104 or the value in the symbol's `saved-value' property if any,
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
105 or (last of all) VALUE.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
106
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 Like `custom-initialize-set', but use the function specified by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 `:get' to reinitialize SYMBOL if it is already bound."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 (funcall (or (get symbol 'custom-set) 'set-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (cond ((default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (funcall (or (get symbol 'custom-get) 'default-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 ((get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 (eval (car (get symbol 'saved-value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 (eval value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
119 ;; XEmacs change; move to defsubst, since this is only called in one place
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
120 ;; and usage of it clusters.
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
121 (defsubst custom-initialize-changed (symbol value)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 "Initialize SYMBOL with VALUE.
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
123 Like `custom-initialize-reset', but only use the `:set' function if
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
124 not using the standard setting.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
125 For the standard setting, use `set-default'."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 (cond ((default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (funcall (or (get symbol 'custom-set) 'set-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (funcall (or (get symbol 'custom-get) 'default-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 symbol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 ((get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 (funcall (or (get symbol 'custom-set) 'set-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 (eval (car (get symbol 'saved-value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 (set-default symbol (eval value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
138 (defun custom-declare-variable (symbol default doc &rest args)
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
139 "Like `defcustom', but SYMBOL and DEFAULT are evaluated as normal arguments.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
140 DEFAULT should be an expression to evaluate to compute the default value,
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
141 not the default value itself.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
142
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
143 DEFAULT is stored as SYMBOL's value in the standard theme. See
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
144 `custom-known-themes' for a list of known themes. For backwards
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
145 compatibility, DEFAULT is also stored in SYMBOL's property
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
146 `standard-value'. At the same time, SYMBOL's property `force-value' is
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
147 set to nil, as the value is no longer rogue.
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
148
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
149 The byte compiler adds an XEmacs-specific :default keyword and value to
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
150 `custom-declare-variable' calls when it byte-compiles the DEFAULT argument.
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
151 These describe what the custom UI shows when editing a customizable
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
152 variable's associated Lisp expression. We don't encourage use of this
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
153 keyword in your own programs. "
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
154 ;; Remember the standard setting. The value should be in the standard
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
155 ;; theme, not in this property. However, this would require changing
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
156 ;; the C source of defvar and others as well...
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
157 (put symbol 'standard-value (list default))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 ;; Maybe this option was rogue in an earlier version. It no longer is.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (when (eq (get symbol 'force-value) 'rogue)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 ;; It no longer is.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (put symbol 'force-value nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 (when doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (put symbol 'variable-documentation doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 (let ((initialize 'custom-initialize-reset)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
165 (requests nil))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
166 (unless (memq :group args)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
167 (custom-add-to-group (custom-current-group) symbol 'custom-variable))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (while args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (let ((arg (car args)))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
170 (setq args (cdr args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (check-argument-type 'keywordp arg)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
172 (let ((keyword arg)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
173 (value (car args)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
174 (unless args
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (signal 'error (list "Keyword is missing an argument" keyword)))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
176 (setq args (cdr args))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
177 (cond ((eq keyword :initialize)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
178 (setq initialize value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
179 ((eq keyword :set)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
180 (put symbol 'custom-set value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
181 ((eq keyword :get)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
182 (put symbol 'custom-get value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
183 ((eq keyword :require)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
184 (push value requests))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
185 ((eq keyword :type)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
186 (put symbol 'custom-type (purecopy value)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
187 ((eq keyword :options)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
188 (if (get symbol 'custom-options)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
189 ;; Slow safe code to avoid duplicates.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
190 (mapc (lambda (option)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
191 (custom-add-option symbol option))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
192 value)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
193 ;; Fast code for the common case.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
194 (put symbol 'custom-options (copy-sequence value))))
4289
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
195 ;; In the event that the byte compile has compiled the init
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
196 ;; value, we want the value the UI sees to be uncompiled.
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
197 ((eq keyword :default)
20accccbebd6 [xemacs-hg @ 2007-11-27 22:15:32 by aidan]
aidan
parents: 4021
diff changeset
198 (put symbol 'standard-value (list value)))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
199 (t
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
200 (custom-handle-keyword symbol keyword value
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
201 'custom-variable))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (put symbol 'custom-requests requests)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 ;; Do the actual initialization.
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
204 (unless custom-dont-initialize
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
205 (funcall initialize symbol default)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 ;; #### This is a rough equivalent of LOADHIST_ATTACH. However,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 ;; LOADHIST_ATTACH also checks for `initialized'.
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
208 (push (cons 'defvar symbol) current-load-list)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (run-hooks 'custom-define-hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (defmacro defcustom (symbol value doc &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 "Declare SYMBOL as a customizable variable that defaults to VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 DOC is the variable documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 Neither SYMBOL nor VALUE needs to be quoted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 If SYMBOL is not already bound, initialize it to VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 The remaining arguments should have the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 [KEYWORD VALUE]...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
222 The following keywords are meaningful:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
224 :type VALUE should be a widget type for editing the symbol's value.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 The default is `sexp'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 :options VALUE should be a list of valid members of the widget type.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 :group VALUE should be a customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 Add SYMBOL to that group.
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
229 :link LINK-DATA
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
230 Include an external link after the documentation string for this
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
231 item. This is a sentence containing an active field which
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
232 references some other documentation.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
233
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
234 There are three alternatives you can use for LINK-DATA:
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
235
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
236 (custom-manual INFO-NODE)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
237 Link to an Info node; INFO-NODE is a string which specifies
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
238 the node name, as in \"(emacs)Top\". The link appears as
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
239 `[manual]' in the customization buffer.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
240
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
241 (info-link INFO-NODE)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
242 Like `custom-manual' except that the link appears in the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
243 customization buffer with the Info node name.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
244
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
245 (url-link URL)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
246 Link to a web page; URL is a string which specifies the URL.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
247 The link appears in the customization buffer as URL.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
248
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
249 You can specify the text to use in the customization buffer by
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
250 adding `:tag NAME' after the first element of the LINK-DATA; for
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
251 example, (info-link :tag \"foo\" \"(emacs)Top\") makes a link to the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
252 Emacs manual which appears in the buffer as `foo'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
253
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
254 An item can have more than one external link; however, most items
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
255 have none at all.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
256 :initialize
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
257 VALUE should be a function used to initialize the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
258 variable. It takes two arguments, the symbol and value
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
259 given in the `defcustom' call. The default is
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
260 `custom-initialize-reset'.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
261 :set VALUE should be a function to set the value of the symbol.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
262 It takes two arguments, the symbol to set and the value to
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
263 give it. The default choice of function is `custom-set-default'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 :get VALUE should be a function to extract the value of symbol.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
265 The function takes one argument, a symbol, and should return
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
266 the current value for that symbol. The default choice of function
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
267 is `custom-default-value'. #### XEmacs used to say `default-value';
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
268 is that right?
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
269 :require
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
270 VALUE should be a feature symbol. If you save a value
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
271 for this option, then when your custom init file loads the value,
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
272 it does (require VALUE) first.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
273 :version
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
274 VALUE should be a string specifying that the variable was
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
275 first introduced, or its default value was changed, in Emacs
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
276 version VERSION.
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
277 :tag LABEL
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
278 Use LABEL, a string, instead of the item's name, to label the item
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
279 in customization menus and buffers.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
280 :load FILE
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
281 Load file FILE (a string) before displaying this customization
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
282 item. Loading is done with `load', and only if the file is
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
283 not already loaded.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
284 :set-after VARIABLES
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
285 Specifies that SYMBOL should be set after the list of variables
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
286 VARIABLES when both have been customized.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 Read the section about customization in the Emacs Lisp manual for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 ;;; The `defface' Macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (defmacro defface (face spec doc &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 "Declare FACE as a customizable face that defaults to SPEC.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 FACE does not need to be quoted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 Third argument DOC is the face documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 If FACE has been set with `custom-set-face', set the face attributes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 as specified by that function, otherwise set the face attributes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 according to SPEC.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 The remaining arguments should have the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 [KEYWORD VALUE]...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 The following KEYWORDs are defined:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 :group VALUE should be a customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 Add FACE to that group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 SPEC should be an alist of the form ((DISPLAY ATTS)...).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 ATTS is a list of face attributes and their values. The possible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 attributes are defined in the variable `custom-face-attributes'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 The ATTS of the first entry in SPEC where the DISPLAY matches the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 frame should take effect in that frame. DISPLAY can either be the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 symbol t, which will match all frames, or an alist of the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 \((REQ ITEM...)...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 For the DISPLAY to match a FRAME, the REQ property of the frame must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 match one of the ITEM. The following REQ are defined:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 `type' (the value of `window-system')
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
327 Should be one of `x', `mswindows', or `tty'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 `class' (the frame's color support)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 Should be one of `color', `grayscale', or `mono'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 `background' (what color is used for the background text)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 Should be one of `light' or `dark'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 Read the section about customization in the Emacs Lisp manual for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 `(custom-declare-face (quote ,face) ,spec ,doc ,@args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 ;;; The `defgroup' Macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
341 (defun custom-current-group ()
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
342 (cdr (assoc load-file-name custom-current-group-alist)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
343
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 (defun custom-declare-group (symbol members doc &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 (while members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 (apply 'custom-add-to-group symbol (car members))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (pop members))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (when doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (put symbol 'group-documentation doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 (while args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 (let ((arg (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 (check-argument-type 'keywordp arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (let ((keyword arg)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
356 (value (car args)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (unless args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 (signal 'error (list "Keyword is missing an argument" keyword)))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
359 (setq args (cdr args))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
360 (cond ((eq keyword :prefix)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
361 (put symbol 'custom-prefix value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
362 (t
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
363 (custom-handle-keyword symbol keyword value
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
364 'custom-group))))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
365 ;; Record the group on the `current' list.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
366 (let ((elt (assoc load-file-name custom-current-group-alist)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
367 (if elt (setcdr elt symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
368 (push (cons load-file-name symbol) custom-current-group-alist)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 (run-hooks 'custom-define-hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 (defmacro defgroup (symbol members doc &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 "Declare SYMBOL as a customization group containing MEMBERS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 SYMBOL does not need to be quoted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 Third arg DOC is the group documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 MEMBERS should be an alist of the form ((NAME WIDGET)...) where NAME
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 is a symbol and WIDGET is a widget for editing that symbol. Useful
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 widgets are `custom-variable' for editing variables, `custom-face' for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 edit faces, and `custom-group' for editing groups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 The remaining arguments should have the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 [KEYWORD VALUE]...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
387 The following KEYWORDs are defined:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 :group VALUE should be a customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 Add SYMBOL to that group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 Read the section about customization in the Emacs Lisp manual for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 information."
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
394
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
395 ;; XEmacs: Evidently a purposeful omission from the docs:
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
396 ;:version VALUE should be a string specifying that the group was introduced
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
397 ; in Emacs version VERSION.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
398 ;
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
399
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
400 ;; FSF: (not a problem for XEmacs)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
401 ;; It is better not to use backquote in this file,
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
402 ;; because that makes a bootstrapping problem
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
403 ;; if you need to recompile all the Lisp files using interpreted code.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
404 ; (nconc (list 'custom-declare-group (list 'quote symbol) members doc) args))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 `(custom-declare-group (quote ,symbol) ,members ,doc ,@args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 (defvar custom-group-hash-table (make-hash-table :size 300 :test 'eq)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 "Hash-table of non-empty groups.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 (defun custom-add-to-group (group option widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 "To existing GROUP add a new OPTION of type WIDGET.
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
412 If there already is an entry for OPTION and WIDGET, nothing is done."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
413 (let ((members (get group 'custom-group))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
414 (entry (list option widget)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
415 (unless (member entry members)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
416 (put group 'custom-group (nconc members (list entry)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (puthash group t custom-group-hash-table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
419 (defun custom-group-of-mode (mode)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
420 "Return the custom group corresponding to the major or minor MODE.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
421 If no such group is found, return nil."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
422 (or (get mode 'custom-mode-group)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
423 (if (or (get mode 'custom-group)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
424 (and (string-match "-mode\\'" (symbol-name mode))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
425 (get (setq mode (intern (substring (symbol-name mode)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
426 0 (match-beginning 0))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
427 'custom-group)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
428 mode)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
429
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 ;;; Properties.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 (defun custom-handle-all-keywords (symbol args type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 "For customization option SYMBOL, handle keyword arguments ARGS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 Third argument TYPE is the custom option type."
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
435 (unless (memq :group args)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
436 (custom-add-to-group (custom-current-group) symbol type))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (while args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (let ((arg (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (check-argument-type 'keywordp arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (let ((keyword arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 (value (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (unless args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (signal 'error (list "Keyword is missing an argument" keyword)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 (custom-handle-keyword symbol keyword value type)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 (defun custom-handle-keyword (symbol keyword value type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 "For customization option SYMBOL, handle KEYWORD with VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 Fourth argument TYPE is the custom option type."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 (cond ((eq keyword :group)
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
452 (custom-add-to-group value symbol type))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
453 ((eq keyword :version)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
454 (custom-add-version symbol value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
455 ((eq keyword :link)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
456 (custom-add-link symbol value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
457 ((eq keyword :load)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
458 (custom-add-load symbol value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
459 ((eq keyword :tag)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
460 (put symbol 'custom-tag value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
461 ((eq keyword :set-after)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
462 (custom-add-dependencies symbol value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
463 (t
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
464 (signal 'error (list "Unknown keyword" keyword)))))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
465
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
466 (defun custom-add-dependencies (symbol value)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
467 "To the custom option SYMBOL, add dependencies specified by VALUE.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
468 VALUE should be a list of symbols. For each symbol in that list,
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
469 this specifies that SYMBOL should be set after the specified symbol, if
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
470 both appear in constructs like `custom-set-variables'."
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
471 (unless (listp value)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
472 (error "Invalid custom dependency `%s'" value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
473 (let* ((deps (get symbol 'custom-dependencies))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
474 (new-deps deps))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
475 (while value
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
476 (let ((dep (car value)))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
477 (unless (symbolp dep)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
478 (error "Invalid custom dependency `%s'" dep))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
479 (unless (memq dep new-deps)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
480 (setq new-deps (cons dep new-deps)))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
481 (setq value (cdr value))))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
482 (unless (eq deps new-deps)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
483 (put symbol 'custom-dependencies new-deps))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (defun custom-add-option (symbol option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 "To the variable SYMBOL add OPTION.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 If SYMBOL is a hook variable, OPTION should be a hook member.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 For other types variables, the effect is undefined."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 (let ((options (get symbol 'custom-options)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 (unless (member option options)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 (put symbol 'custom-options (cons option options)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 (defun custom-add-link (symbol widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 "To the custom option SYMBOL add the link WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (let ((links (get symbol 'custom-links)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (unless (member widget links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (put symbol 'custom-links (cons widget links)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 (defun custom-add-version (symbol version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 "To the custom option SYMBOL add the version VERSION."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 (put symbol 'custom-version version))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 (defun custom-add-load (symbol load)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 "To the custom option SYMBOL add the dependency LOAD.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 LOAD should be either a library file name, or a feature name."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 (puthash symbol t custom-group-hash-table)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (let ((loads (get symbol 'custom-loads)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 (unless (member load loads)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (put symbol 'custom-loads (cons load loads)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
512 (defun custom-autoload (symbol load)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
513 "Mark SYMBOL as autoloaded custom variable and add dependency LOAD."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
514 (put symbol 'custom-autoload t)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
515 (custom-add-load symbol load))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
516
4502
8748a3f7ceb4 Handle varalias chains, custom variables in #'user-variable-p.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4441
diff changeset
517 ;; XEmacs;
8748a3f7ceb4 Handle varalias chains, custom variables in #'user-variable-p.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4441
diff changeset
518 ;; #'custom-variable-p is in symbols.c, since it's called from
8748a3f7ceb4 Handle varalias chains, custom variables in #'user-variable-p.
Aidan Kehoe <kehoea@parhasard.net>
parents: 4441
diff changeset
519 ;; #'user-variable-p.
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
520
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
521 ;;; Loading files needed to customize a symbol.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
522 ;;; This is in custom.el because menu-bar.el needs it for toggle cmds.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
523
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
524 (defvar custom-load-recursion nil
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
525 "Hack to avoid recursive dependencies.")
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
526
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
527 (defun custom-load-symbol (symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
528 "Load all dependencies for SYMBOL."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
529 (unless custom-load-recursion
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
530 (let ((custom-load-recursion t))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
531 (dolist (load (get symbol 'custom-loads))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
532 (cond ((symbolp load) (condition-case nil (require load) (error nil)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
533 ;; This is subsumed by the test below, but it's much faster.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
534 ((assoc load load-history))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
535 ;; This was just (assoc (locate-library load) load-history)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
536 ;; but has been optimized not to load locate-library
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
537 ;; if not necessary.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
538 ((let ((regexp (concat "\\(\\`\\|/\\)" (regexp-quote load)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
539 "\\(\\'\\|\\.\\)"))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
540 (found nil))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
541 (dolist (loaded load-history)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
542 (and (stringp (car loaded))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
543 (string-match regexp (car loaded))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
544 (setq found t)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
545 found))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
546 ;; Without this, we would load cus-edit recursively.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
547 ;; We are still loading it when we call this,
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
548 ;; and it is not in load-history yet.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
549 ((equal load "cus-edit"))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
550 (t (condition-case nil (load load) (error nil))))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (defvar custom-known-themes '(user standard)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
553 "Themes that have been define with `deftheme'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
554 The default value is the list (user standard). The theme `standard'
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
555 contains the Emacs standard settings from the original Lisp files. The
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
556 theme `user' contains all the the settings the user customized and saved.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
557 Additional themes declared with the `deftheme' macro will be added to
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
558 the front of this list.")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
560 (defun custom-declare-theme (theme feature &optional doc &rest args)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
561 "Like `deftheme', but THEME is evaluated as a normal argument.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
562 FEATURE is the feature this theme provides. This symbol is created
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
563 from THEME by `custom-make-theme-feature'."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
564 (add-to-list 'custom-known-themes theme)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 (put theme 'theme-feature feature)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
566 (when doc
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
567 (put theme 'theme-documentation doc))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
568 (while args
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
569 (let ((arg (car args)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
570 (setq args (cdr args))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
571 (check-argument-type 'keywordp arg)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
572 (let ((keyword arg)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
573 (value (car args)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
574 (unless args
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
575 (signal 'error (list "Keyword is missing an argument" keyword)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
576 (setq args (cdr args))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
577 (cond ((eq keyword :short-description)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
578 (put theme 'theme-short-description value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
579 ((eq keyword :immediate)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
580 (put theme 'theme-immediate value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
581 ((eq keyword :variable-set-string)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
582 (put theme 'theme-variable-set-string value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
583 ((eq keyword :variable-reset-string)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
584 (put theme 'theme-variable-reset-string value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
585 ((eq keyword :face-set-string)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
586 (put theme 'theme-face-set-string value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
587 ((eq keyword :face-reset-string)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
588 (put theme 'theme-face-reset-string value)))))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
589
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
590 (defmacro deftheme (theme &optional doc &rest args)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
591 "Declare custom theme THEME.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
592 The optional argument DOC is a doc string describing the theme.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
593 The remaining arguments should have the form
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
594
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
595 [KEYWORD VALUE]...
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
596
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
597 The following KEYWORD's are defined:
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
598
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
599 :short-description
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
600 VALUE is a short (one line) description of the theme. If not
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
601 given, DOC is used.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
602 :immediate
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
603 If VALUE is non-nil, variables specified in this theme are set
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
604 immediately when loading the theme.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
605 :variable-set-string
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
606 VALUE is a string used to indicate that a variable takes its
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
607 setting from this theme. It is passed to FORMAT with the name
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
608 of the theme as an additional argument. If not given, a
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
609 generic description is used.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
610 :variable-reset-string
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
611 VALUE is a string used in the case a variable has been forced
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
612 to its value in this theme. It is passed to FORMAT with the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
613 name of the theme as an additional argument. If not given, a
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
614 generic description is used.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
615 :face-set-string
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
616 VALUE is a string used to indicate that a face takes its
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
617 setting from this theme. It is passed to FORMAT with the name
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
618 of the theme as an additional argument. If not given, a
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
619 generic description is used.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
620 :face-reset-string
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
621 VALUE is a string used in the case a face has been forced to
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
622 its value in this theme. It is passed to FORMAT with the name
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
623 of the theme as an additional argument. If not given, a
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
624 generic description is used.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
625
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
626 Any theme `foo' should be defined in a file called `foo-theme.el';
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
627 see `custom-make-theme-feature' for more information."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
628 (let ((feature (custom-make-theme-feature theme)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
629 ;; It is better not to use backquote in this file,
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
630 ;; because that makes a bootstrapping problem
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
631 ;; if you need to recompile all the Lisp files using interpreted code.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
632 (nconc (list 'custom-declare-theme
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
633 (list 'quote theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
634 (list 'quote feature)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
635 doc) args)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 (defun custom-make-theme-feature (theme)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
638 "Given a symbol THEME, create a new symbol by appending \"-theme\".
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
639 Store this symbol in the `theme-feature' property of THEME.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
640 Calling `provide-theme' to provide THEME actually puts `THEME-theme'
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
641 into `features'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
643 This allows for a file-name convention for autoloading themes:
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
644 Every theme X has a property `provide-theme' whose value is \"X-theme\".
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
645 \(require-theme X) then attempts to load the file `X-theme.el'."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
646 (intern (concat (symbol-name theme) "-theme")))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 (defsubst custom-theme-p (theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 "Non-nil when THEME has been defined."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 (memq theme custom-known-themes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 (defsubst custom-check-theme (theme)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
653 "Check whether THEME is valid, and signal an error if it is not."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 (unless (custom-theme-p theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 (error "Unknown theme `%s'" theme)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 ;;; Initializing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 (defun custom-push-theme (prop symbol theme mode value)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
660 "Add (THEME MODE VALUE) to the list in property PROP of SYMBOL.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
661 If the first element in that list is already (THEME ...),
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
662 discard it first.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
663
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
664 MODE can be either the symbol `set' or the symbol `reset'. If it is the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
665 symbol `set', then VALUE is the value to use. If it is the symbol
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
666 `reset', then VALUE is the mode to query instead.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
667
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
668 In the following example for the variable `goto-address-url-face', the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
669 theme `subtle-hacker' uses the same value for the variable as the theme
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
670 `gnome2':
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
671
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
672 \((standard set bold)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
673 \(gnome2 set info-xref)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
674 \(jonadab set underline)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
675 \(subtle-hacker reset gnome2))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
676
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
677
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
678 If a value has been stored for themes A B and C, and a new value
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
679 is to be stored for theme C, then the old value of C is discarded.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
680 If a new value is to be stored for theme B, however, the old value
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
681 of B is not discarded because B is not the car of the list.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
682
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
683 For variables, list property PROP is `theme-value'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
684 For faces, list property PROP is `theme-face'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
685 This is used in `custom-do-theme-reset', for example.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
686
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
687 The list looks the same in any case; the examples shows a possible
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
688 value of the `theme-face' property for the face `region':
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
689
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
690 \((gnome2 set ((t (:foreground \"cyan\" :background \"dark cyan\"))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
691 \(standard set ((((class color) (background dark))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
692 \(:background \"blue\"))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
693 \(t (:background \"gray\")))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
694
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
695 This records values for the `standard' and the `gnome2' themes.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
696 The user has not customized the face; had he done that,
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
697 the list would contain an entry for the `user' theme, too.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
698 See `custom-known-themes' for a list of known themes."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 (let ((old (get symbol prop)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 (if (eq (car-safe (car-safe old)) theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 (setq old (cdr old)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 (put symbol prop (cons (list theme mode value) old))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
704 (defvar custom-local-buffer nil
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
705 "Non-nil, in a Customization buffer, means customize a specific buffer.
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
706 If this variable is non-nil, it should be a buffer,
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
707 and it means customize the local bindings of that buffer.
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
708 This variable is a permanent local, and it normally has a local binding
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
709 in every Customization buffer.")
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
710 (put 'custom-local-buffer 'permanent-local t)
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
711
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 (defun custom-set-variables (&rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 "Initialize variables according to user preferences.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 The settings are registered as theme `user'.
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
715 The arguments should each be a list of the form:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 The unevaluated VALUE is stored as the saved value for SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 If NOW is present and non-nil, VALUE is also evaluated and bound as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 the default value for the SYMBOL.
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
722
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 REQUEST is a list of features we must 'require for SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 COMMENT is a comment string about SYMBOL."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 (apply 'custom-theme-set-variables 'user args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 (defun custom-theme-set-variables (theme &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 "Initialize variables according to settings specified by args.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 Records the settings as belonging to THEME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
731 The arguments should be a list where each entry has the form:
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
732
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
733 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]])
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
734
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
735 The unevaluated VALUE is stored as the saved value for SYMBOL.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
736 If NOW is present and non-nil, VALUE is also evaluated and bound as
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
737 the default value for the SYMBOL.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
738 REQUEST is a list of features we must 'require for SYMBOL.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
739 COMMENT is a comment string about SYMBOL.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
740
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
741 Several properties of THEME and SYMBOL are used in the process:
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
742
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
743 If THEME property `theme-immediate' is non-nil, this is equivalent of
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
744 providing the NOW argument to all symbols in the argument list: SYMBOL
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
745 is bound to the evaluated VALUE. The only difference is SYMBOL property
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
746 `force-value': if NOW is non-nil, SYMBOL's property `force-value' is set to
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
747 the symbol `rogue', else if THEME's property `theme-immediate' is non-nil,
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
748 FACE's property `force-face' is set to the symbol `immediate'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
749
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
750 VALUE itself is saved unevaluated as SYMBOL property `saved-value' and
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
751 in SYMBOL's list property `theme-value' \(using `custom-push-theme')."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 (custom-check-theme theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 (let ((immediate (get theme 'theme-immediate)))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
754 (setq args
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
755 (sort args
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
756 (lambda (a1 a2)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
757 (let* ((sym1 (car a1))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
758 (sym2 (car a2))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
759 (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
760 (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
761 (cond ((and 1-then-2 2-then-1)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
762 (error "Circular custom dependency between `%s' and `%s'"
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
763 sym1 sym2))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
764 (2-then-1 nil)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
765 ;; Put symbols with :require last. The macro
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
766 ;; define-minor-mode generates a defcustom
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
767 ;; with a :require and a :set, where the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
768 ;; setter function calls the mode function.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
769 ;; Putting symbols with :require last ensures
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
770 ;; that the mode function will see other
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
771 ;; customized values rather than default
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
772 ;; values.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
773 (t (nth 3 a2)))))))
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
774 (while args
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 (let ((entry (car args)))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
776 (if (listp entry)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
777 (let* ((symbol (nth 0 entry))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
778 (value (nth 1 entry))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
779 (now (nth 2 entry))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
780 (requests (nth 3 entry))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
781 (comment (nth 4 entry))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
782 set)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
783 (when requests
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
784 (put symbol 'custom-requests requests)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
785 (mapc 'require requests))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
786 (setq set (or (get symbol 'custom-set) 'custom-set-default))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
787 (put symbol 'saved-value (list value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
788 (put symbol 'saved-variable-comment comment)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 (custom-push-theme 'theme-value symbol theme 'set value)
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
790 ;; Allow for errors in the case where the setter has
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
791 ;; changed between versions, say, but let the user know.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
792 (condition-case data
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
793 (cond ((or now immediate)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
794 ;; Rogue variable, set it now.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
795 (put symbol 'force-value (if now 'rogue 'immediate))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
796 (funcall set symbol (eval value)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
797 ((default-boundp symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
798 ;; Something already set this, overwrite it.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
799 (funcall set symbol (eval value))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
800 (error
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
801 (message "Error setting %s: %s" symbol data)))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
802 (setq args (cdr args))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
803 (and (or now (default-boundp symbol))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
804 (put symbol 'variable-comment comment)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
805 ;; Old format, a plist of SYMBOL VALUE pairs.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
806 (message "Warning: old format `custom-set-variables'")
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
807 (ding)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
808 (sit-for 2)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
809 (let ((symbol (nth 0 args))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
810 (value (nth 1 args)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
811 (put symbol 'saved-value (list value))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 (custom-push-theme 'theme-value symbol theme 'set value))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
813 (setq args (cdr (cdr args))))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
815 (defun custom-set-default (variable value)
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
816 "Default :set function for a customizable variable.
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
817 Normally, this sets the default value of VARIABLE to VALUE,
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
818 but if `custom-local-buffer' is non-nil,
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
819 this sets the local binding in that buffer instead."
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
820 (if custom-local-buffer
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
821 (with-current-buffer custom-local-buffer
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
822 (set variable value))
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
823 (set-default variable value)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
825 (defun custom-quote (sexp)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
826 "Quote SEXP iff it is not self quoting."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
827 (if (or (memq sexp '(t nil))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
828 (keywordp sexp)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
829 (and (listp sexp)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
830 (memq (car sexp) '(lambda)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
831 (stringp sexp)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
832 (numberp sexp)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
833 (vectorp sexp)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
834 ;;; (and (fboundp 'characterp)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
835 ;;; (characterp sexp))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
836 )
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
837 sexp
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
838 (list 'quote sexp)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
839
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
840 (defun customize-mark-to-save (symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
841 "Mark SYMBOL for later saving.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
842
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
843 If the default value of SYMBOL is different from the standard value,
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
844 set the `saved-value' property to a list whose car evaluates to the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
845 default value. Otherwise, set it to nil.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
846
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
847 To actually save the value, call `custom-save-all'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
848
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
849 Return non-nil iff the `saved-value' property actually changed."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
850 (let* ((get (or (get symbol 'custom-get) 'default-value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
851 (value (funcall get symbol))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
852 (saved (get symbol 'saved-value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
853 (standard (get symbol 'standard-value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
854 (comment (get symbol 'customized-variable-comment)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
855 ;; Save default value iff different from standard value.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
856 (if (or (null standard)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
857 (not (equal value (condition-case nil
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
858 (eval (car standard))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
859 (error nil)))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
860 (put symbol 'saved-value (list (custom-quote value)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
861 (put symbol 'saved-value nil))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
862 ;; Clear customized information (set, but not saved).
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
863 (put symbol 'customized-value nil)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
864 ;; Save any comment that might have been set.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
865 (when comment
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
866 (put symbol 'saved-variable-comment comment))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
867 (not (equal saved (get symbol 'saved-value)))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
868
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
869 (defun customize-mark-as-set (symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
870 "Mark current value of SYMBOL as being set from customize.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
871
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
872 If the default value of SYMBOL is different from the saved value if any,
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
873 or else if it is different from the standard value, set the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
874 `customized-value' property to a list whose car evaluates to the
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
875 default value. Otherwise, set it to nil.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
876
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
877 Return non-nil iff the `customized-value' property actually changed."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
878 (let* ((get (or (get symbol 'custom-get) 'default-value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
879 (value (funcall get symbol))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
880 (customized (get symbol 'customized-value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
881 (old (or (get symbol 'saved-value) (get symbol 'standard-value))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
882 ;; Mark default value as set iff different from old value.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
883 (if (or (null old)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
884 (not (equal value (condition-case nil
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
885 (eval (car old))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
886 (error nil)))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
887 (put symbol 'customized-value (list (custom-quote value)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
888 (put symbol 'customized-value nil))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
889 ;; Changed?
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
890 (not (equal customized (get symbol 'customized-value)))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
891
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
892 ;;; Theme Manipulation
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
893
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
894 (defvar custom-loaded-themes nil
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
895 "Themes in the order they are loaded.")
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
896
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
897 (defun custom-theme-loaded-p (theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
898 "Return non-nil when THEME has been loaded."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
899 (memq theme custom-loaded-themes))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
900
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
901 (defun provide-theme (theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
902 "Indicate that this file provides THEME.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
903 Add THEME to `custom-loaded-themes' and `provide' whatever
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
904 is stored in THEME's property `theme-feature'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
905
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
906 Usually the theme-feature property contains a symbol created
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
907 by `custom-make-theme-feature'."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
908 (custom-check-theme theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
909 (provide (get theme 'theme-feature))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
910 (setq custom-loaded-themes (nconc (list theme) custom-loaded-themes)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
911
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
912 (defun require-theme (theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
913 "Try to load a theme by requiring its feature.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
914 THEME's feature is stored in THEME's `theme-feature' property.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
915
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
916 Usually the `theme-feature' property contains a symbol created
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
917 by `custom-make-theme-feature'."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
918 ;; Note we do no check for validity of the theme here.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
919 ;; This allows to pull in themes by a file-name convention
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
920 (require (or (get theme 'theme-feature)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
921 (custom-make-theme-feature theme))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
922
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
923 (defun custom-remove-theme (spec-alist theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
924 "Delete all elements from SPEC-ALIST whose car is THEME."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
925 (let ((elt (assoc theme spec-alist)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
926 (while elt
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
927 (setq spec-alist (delete elt spec-alist)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
928 elt (assoc theme spec-alist))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
929 spec-alist)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
930
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
931 (defun custom-do-theme-reset (theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
932 "Undo all settings defined by THEME.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
933
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
934 A variable remains unchanged if its property `theme-value' does not
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
935 contain a value for THEME. A face remains unchanged if its property
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
936 `theme-face' does not contain a value for THEME. In either case, all
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
937 settings for THEME are removed from the property and the variable or
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
938 face is set to the `user' theme.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
940 See `custom-known-themes' for a list of known themes."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
941 (let (spec-list)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
942 (mapatoms (lambda (symbol)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
943 ;; This works even if symbol is both a variable and a
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
944 ;; face.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
945 (setq spec-list (get symbol 'theme-value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
946 (when spec-list
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
947 (put symbol 'theme-value (custom-remove-theme spec-list theme))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
948 (custom-theme-reset-internal symbol 'user))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
949 (setq spec-list (get symbol 'theme-face))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
950 (when spec-list
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
951 (put symbol 'theme-face (custom-remove-theme spec-list theme))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
952 (custom-theme-reset-internal-face symbol 'user))))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
953
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
954 (defun custom-theme-load-themes (by-theme &rest body)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
955 "Load the themes specified by BODY.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
956 Record them as required by theme BY-THEME. BODY is a sequence of either
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
957
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
958 THEME
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
959 BY-THEME requires THEME
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
960 \(reset THEME)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
961 Undo all the settings made by THEME
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
962 \(hidden THEME)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
963 Require THEME but hide it from the user
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
964
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
965 All the themes loaded for BY-THEME are recorded in BY-THEME's property
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
966 `theme-loads-themes'. Any theme loaded with the hidden predicate will
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
967 be given the property `theme-hidden' unless it has been loaded before.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
968 Whether a theme has been loaded before is determined by the function
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
969 `custom-theme-loaded-p'."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
970 (custom-check-theme by-theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
971 (let ((theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
972 (themes-loaded (get by-theme 'theme-loads-themes)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
973 (while theme
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
974 (setq theme (car body)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
975 body (cdr body))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
976 (cond ((and (consp theme) (eq (car theme) 'reset))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
977 (custom-do-theme-reset (cadr theme)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
978 ((and (consp theme) (eq (car theme) 'hidden))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
979 (require-theme (cadr theme))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
980 (unless (custom-theme-loaded-p (cadr theme))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
981 (put (cadr theme) 'theme-hidden t)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
982 (t
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
983 (require-theme theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
984 (put theme 'theme-hidden nil)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
985 (setq themes-loaded (nconc (list theme) themes-loaded)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
986 (put by-theme 'theme-loads-themes themes-loaded)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
987
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
988 (defun custom-load-themes (&rest body)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
989 "Load themes for the USER theme as specified by BODY.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
990
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
991 See `custom-theme-load-themes' for more information on BODY."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
992 (apply 'custom-theme-load-themes 'user body))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
993
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
994 ; (defsubst copy-upto-last (elt list)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
995 ; "Copy all the elements of the list upto the last occurrence of elt"
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
996 ; ;; Is it faster to do more work in C than to do less in elisp?
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
997 ; (nreverse (cdr (member elt (reverse list)))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
998
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
999 (defun custom-theme-value (theme theme-spec-list)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1000 "Determine the value for THEME defined by THEME-SPEC-LIST.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1001 Returns a list with the original value if found; nil otherwise.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1002
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1003 THEME-SPEC-LIST is an alist with themes as its key. As new themes are
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1004 installed, these are added to the front of THEME-SPEC-LIST.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1005 Each element has the form
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1006
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1007 \(THEME MODE VALUE)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1008
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1009 MODE is either the symbol `set' or the symbol `reset'. See
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1010 `custom-push-theme' for more information on the format of
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1011 THEME-SPEC-LIST."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1012 ;; Note we do _NOT_ signal an error if the theme is unknown
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1013 ;; it might have gone away without the user knowing.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1014 (let ((value (cdr (assoc theme theme-spec-list))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1015 (if value
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1016 (if (eq (car value) 'set)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1017 (cdr value)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1018 (custom-theme-value (cadr value) theme-spec-list)))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1019
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1020 (defun custom-theme-variable-value (variable theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1021 "Return (list value) indicating value of VARIABLE in THEME.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1022 If THEME does not define a value for VARIABLE, return nil. The value
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1023 definitions per theme are stored in VARIABLE's property `theme-value'.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1024 The actual work is done by function `custom-theme-value', which see.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1025 See `custom-push-theme' for more information on how these definitions
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1026 are stored."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1027 (custom-theme-value theme (get variable 'theme-value)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1028
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1029 (defun custom-theme-reset-internal (symbol to-theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1030 "Reset SYMBOL to the value defined by TO-THEME.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1031 If SYMBOL is not defined in TO-THEME, reset SYMBOL to the standard
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1032 value. See `custom-theme-variable-value'. The standard value is
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1033 stored in SYMBOL's property `standard-value'."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1034 (let ((value (custom-theme-variable-value symbol to-theme))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1035 was-in-theme)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1036 (setq was-in-theme value)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1037 (setq value (or value (get symbol 'standard-value)))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1038 (when value
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1039 (put symbol 'saved-value was-in-theme)
4441
1d7faae1080c Fix call to get in custom-theme-reset-internal.
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4289
diff changeset
1040 (if (or (get symbol 'force-value) (default-boundp symbol))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1041 (funcall (or (get symbol 'custom-set) 'set-default) symbol
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1042 (eval (car value)))))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1043 value))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1044
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1045 (defun custom-theme-reset-variables (theme &rest args)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1046 "Reset the value of the variables to values previously defined.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1047 Associate this setting with THEME.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1048
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1049 ARGS is a list of lists of the form
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1050
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1051 (VARIABLE TO-THEME)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1052
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1053 This means reset VARIABLE to its value in TO-THEME."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1054 (custom-check-theme theme)
4021
cef5f57bb9e2 [xemacs-hg @ 2007-06-21 13:39:08 by aidan]
aidan
parents: 2544
diff changeset
1055 (mapcar #'(lambda (arg)
cef5f57bb9e2 [xemacs-hg @ 2007-06-21 13:39:08 by aidan]
aidan
parents: 2544
diff changeset
1056 (apply 'custom-theme-reset-internal arg)
cef5f57bb9e2 [xemacs-hg @ 2007-06-21 13:39:08 by aidan]
aidan
parents: 2544
diff changeset
1057 (custom-push-theme 'theme-value (car arg) theme 'reset (cadr arg)))
2544
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1058 args))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1059
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1060 (defun custom-reset-variables (&rest args)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1061 "Reset the value of the variables to values previously saved.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1062 This is the setting associated the `user' theme.
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1063
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1064 ARGS is a list of lists of the form
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1065
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1066 (VARIABLE TO-THEME)
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1067
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1068 This means reset VARIABLE to its value in TO-THEME."
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1069 (apply 'custom-theme-reset-variables 'user args))
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1070
b4a8cd0dd8df [xemacs-hg @ 2005-02-03 04:29:32 by ben]
ben
parents: 1336
diff changeset
1071 ;;; The End.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
1072
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
1073 ;; Process the defcustoms for variables loaded before this file.
1336
c9b6a2fec10d [xemacs-hg @ 2003-03-03 10:17:39 by stephent]
stephent
parents: 1333
diff changeset
1074 ;; `custom-declare-variable-list' is defvar'd in subr.el. Utility programs
c9b6a2fec10d [xemacs-hg @ 2003-03-03 10:17:39 by stephent]
stephent
parents: 1333
diff changeset
1075 ;; run from temacs that do not load subr.el should defvar it themselves.
c9b6a2fec10d [xemacs-hg @ 2003-03-03 10:17:39 by stephent]
stephent
parents: 1333
diff changeset
1076 ;; (As of 21.5.11, make-docfile.el.)
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
1077 (while custom-declare-variable-list
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
1078 (apply 'custom-declare-variable (car custom-declare-variable-list))
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
1079 (setq custom-declare-variable-list (cdr custom-declare-variable-list)))
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
1080
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 ;; custom.el ends here