annotate lisp/custom.el @ 2340:91a83e231f92

[xemacs-hg @ 2004-10-19 17:18:59 by james] Mark more unused parameters.
author james
date Tue, 19 Oct 2004 17:19:07 +0000
parents c9b6a2fec10d
children b4a8cd0dd8df
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; custom.el -- Tools for declaring and initializing options.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: Hrvoje Niksic <hniksic@xemacs.org>
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 ;; Version: 1.9960-x
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
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 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; 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
15 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; GNU General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
28 ;;; Synched with: ??? Partially synched to 21.2 by Ben Wing.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
29
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;; This file is dumped with XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 ;; This file only contain the code needed to declare and initialize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 ;; user options. The code to customize options is autoloaded from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 ;; `cus-edit.el'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 ;; The code implementing face declarations is in `cus-face.el'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
42 ;; 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
43 ;; 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
44 ;; 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
45 (provide 'custom)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
46
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
47 ;; BEGIN SYNC WITH FSF 21.2
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
48
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 (eval-when-compile
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
50 (load "cl-macs" nil t)
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
51 ;; To elude warnings.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 444
diff changeset
52 (require 'cus-face))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
54 (autoload 'custom-declare-face "cus-face")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
55 (autoload 'defun* "cl-macs")
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 (require 'widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (defvar custom-define-hook nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 ;; Customize information for this option is in `cus-edit.el'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 "Hook called after defining each customize option.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 ;;; The `defcustom' Macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 (defun custom-initialize-default (symbol value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 "Initialize SYMBOL with VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 This will do nothing if symbol already has a default binding.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 Otherwise, if symbol has a `saved-value' property, it will evaluate
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 the car of that and used as the default binding for symbol.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 Otherwise, VALUE will be evaluated and used as the default binding for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 symbol."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 (unless (default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 ;; Use the saved value if it exists, otherwise the standard setting.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 (set-default symbol (if (get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 (eval (car (get symbol 'saved-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 (eval value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 (defun custom-initialize-set (symbol value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 "Initialize SYMBOL with VALUE.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
80 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
81 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
82 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
83 if any, or VALUE.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
84
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
85 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
86 `:set' to initialize SYMBOL."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 (unless (default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (funcall (or (get symbol 'custom-set) 'set-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (if (get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 (eval (car (get symbol 'saved-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (eval value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (defun custom-initialize-reset (symbol value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 "Initialize SYMBOL with VALUE.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
96 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
97 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
98 \(as obtained using the `:get' function), if any,
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
99 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
100 or (last of all) VALUE.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
101
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 Like `custom-initialize-set', but use the function specified by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 `:get' to reinitialize SYMBOL if it is already bound."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (funcall (or (get symbol 'custom-set) 'set-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (cond ((default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 (funcall (or (get symbol 'custom-get) 'default-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 ((get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (eval (car (get symbol 'saved-value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (eval value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 (defun custom-initialize-changed (symbol value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 "Initialize SYMBOL with VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 Like `custom-initialize-reset', but only use the `:set' function if the
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
117 not using the standard setting.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
118 For the standard setting, use `set-default'."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 (cond ((default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 (funcall (or (get symbol 'custom-set) 'set-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 (funcall (or (get symbol 'custom-get) 'default-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 symbol)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 ((get symbol 'saved-value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 (funcall (or (get symbol 'custom-set) 'set-default)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (eval (car (get symbol 'saved-value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (set-default symbol (eval value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
131 (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
132 "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
133 DEFAULT should be an expression to evaluate to compute the default value,
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
134 not the default value itself."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 ;; Remember the standard setting.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
136 (put symbol 'standard-value (list default))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 ;; 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
138 (when (eq (get symbol 'force-value) 'rogue)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 ;; It no longer is.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 (put symbol 'force-value nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 (when doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 (put symbol 'variable-documentation doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 (let ((initialize 'custom-initialize-reset)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 (requests nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 (while args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 (let ((arg (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 (check-argument-type 'keywordp arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 (let ((keyword arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (value (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (unless args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (signal 'error (list "Keyword is missing an argument" keyword)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 (cond ((eq keyword :initialize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (setq initialize value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 ((eq keyword :set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (put symbol 'custom-set value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 ((eq keyword :get)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (put symbol 'custom-get value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 ((eq keyword :require)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 (setq requests (cons value requests)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 ((eq keyword :type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 (put symbol 'custom-type value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 ((eq keyword :options)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (if (get symbol 'custom-options)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 ;; Slow safe code to avoid duplicates.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 (mapc (lambda (option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 (custom-add-option symbol option))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 ;; Fast code for the common case.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (put symbol 'custom-options (copy-sequence value))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (custom-handle-keyword symbol keyword value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 'custom-variable))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (put symbol 'custom-requests requests)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 ;; Do the actual initialization.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
177 (funcall initialize symbol default))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 ;; #### This is a rough equivalent of LOADHIST_ATTACH. However,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 ;; LOADHIST_ATTACH also checks for `initialized'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (push symbol current-load-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (run-hooks 'custom-define-hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (defmacro defcustom (symbol value doc &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 "Declare SYMBOL as a customizable variable that defaults to VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 DOC is the variable documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 Neither SYMBOL nor VALUE needs to be quoted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 If SYMBOL is not already bound, initialize it to VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 The remaining arguments should have the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 [KEYWORD VALUE]...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
194 The following keywords are meaningful:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 :type VALUE should be a widget type for editing the symbols value.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 The default is `sexp'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 :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
199 :group VALUE should be a customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 Add SYMBOL to that group.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
201 :initialize
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
202 VALUE should be a function used to initialize the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 variable. It takes two arguments, the symbol and value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 given in the `defcustom' call. The default is
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
205 `custom-initialize-reset'
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
206 :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
207 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
208 give it. The default choice of function is `custom-set-default'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 :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
210 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
211 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
212 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
213 is that right?
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
214 :require
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
215 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
216 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
217 it does (require VALUE) first.
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
218 :version
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
219 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
220 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
221 version VERSION.
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
222 :set-after VARIABLE
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
223 Specifies that SYMBOL should be set after VARIABLE when
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
224 both have been customized.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 Read the section about customization in the Emacs Lisp manual for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
230 ;; END SYNC WITH FSF 21.2
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
231
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 ;;; The `defface' Macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 (defmacro defface (face spec doc &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 "Declare FACE as a customizable face that defaults to SPEC.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 FACE does not need to be quoted.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 Third argument DOC is the face documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 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
241 as specified by that function, otherwise set the face attributes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 according to SPEC.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 The remaining arguments should have the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 [KEYWORD VALUE]...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 The following KEYWORDs are defined:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 :group VALUE should be a customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 Add FACE to that group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 SPEC should be an alist of the form ((DISPLAY ATTS)...).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 ATTS is a list of face attributes and their values. The possible
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 attributes are defined in the variable `custom-face-attributes'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 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
259 frame should take effect in that frame. DISPLAY can either be the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 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
261 \((REQ ITEM...)...)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 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
264 match one of the ITEM. The following REQ are defined:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 `type' (the value of `window-system')
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
267 Should be one of `x', `mswindows', or `tty'.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 `class' (the frame's color support)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 Should be one of `color', `grayscale', or `mono'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 `background' (what color is used for the background text)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 Should be one of `light' or `dark'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 Read the section about customization in the Emacs Lisp manual for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 `(custom-declare-face (quote ,face) ,spec ,doc ,@args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 ;;; The `defgroup' Macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 (defun custom-declare-group (symbol members doc &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 (while members
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 (apply 'custom-add-to-group symbol (car members))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 (pop members))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 (put symbol 'custom-group (nconc members (get symbol 'custom-group)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 (when doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 (put symbol 'group-documentation doc))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 (while args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 (let ((arg (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 (check-argument-type 'keywordp arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 (let ((keyword arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 (value (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 (unless args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 (signal 'error (list "Keyword is missing an argument" keyword)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (cond ((eq keyword :prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 (put symbol 'custom-prefix value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 (custom-handle-keyword symbol keyword value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 'custom-group))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 (run-hooks 'custom-define-hook)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 symbol)
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 (defmacro defgroup (symbol members doc &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 "Declare SYMBOL as a customization group containing MEMBERS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 SYMBOL does not need to be quoted.
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 Third arg DOC is the group documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 MEMBERS should be an alist of the form ((NAME WIDGET)...) where NAME
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 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
314 widgets are `custom-variable' for editing variables, `custom-face' for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 edit faces, and `custom-group' for editing groups.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 The remaining arguments should have the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 [KEYWORD VALUE]...
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 The following KEYWORD's are defined:
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 :group VALUE should be a customization group.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 Add SYMBOL to that group.
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 Read the section about customization in the Emacs Lisp manual for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 information."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 `(custom-declare-group (quote ,symbol) ,members ,doc ,@args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 (defvar custom-group-hash-table (make-hash-table :size 300 :test 'eq)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 "Hash-table of non-empty groups.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (defun custom-add-to-group (group option widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 "To existing GROUP add a new OPTION of type WIDGET.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 If there already is an entry for that option, overwrite it."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 (let* ((members (get group 'custom-group))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 (old (assq option members)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 (if old
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 (setcar (cdr old) widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (put group 'custom-group (nconc members (list (list option widget))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 (puthash group t custom-group-hash-table))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 ;;; Properties.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 (defun custom-handle-all-keywords (symbol args type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 "For customization option SYMBOL, handle keyword arguments ARGS.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 Third argument TYPE is the custom option type."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 (while args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 (let ((arg (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 (check-argument-type 'keywordp arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 (let ((keyword arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 (value (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 (unless args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 (signal 'error (list "Keyword is missing an argument" keyword)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 (setq args (cdr args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 (custom-handle-keyword symbol keyword value type)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 (defun custom-handle-keyword (symbol keyword value type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 "For customization option SYMBOL, handle KEYWORD with VALUE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 Fourth argument TYPE is the custom option type."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 (cond ((eq keyword :group)
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
363 (custom-add-to-group value symbol type))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
364 ((eq keyword :version)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
365 (custom-add-version symbol value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
366 ((eq keyword :link)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
367 (custom-add-link symbol value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
368 ((eq keyword :load)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
369 (custom-add-load symbol value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
370 ((eq keyword :tag)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
371 (put symbol 'custom-tag value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
372 ((eq keyword :set-after)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
373 (custom-add-dependencies symbol value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
374 (t
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
375 (signal 'error (list "Unknown keyword" keyword)))))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
376
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
377 (defun custom-add-dependencies (symbol value)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
378 "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
379 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
380 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
381 both appear in constructs like `custom-set-variables'."
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
382 (unless (listp value)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
383 (error "Invalid custom dependency `%s'" value))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
384 (let* ((deps (get symbol 'custom-dependencies))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
385 (new-deps deps))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
386 (while value
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
387 (let ((dep (car value)))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
388 (unless (symbolp dep)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
389 (error "Invalid custom dependency `%s'" dep))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
390 (unless (memq dep new-deps)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
391 (setq new-deps (cons dep new-deps)))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
392 (setq value (cdr value))))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
393 (unless (eq deps new-deps)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
394 (put symbol 'custom-dependencies new-deps))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 (defun custom-add-option (symbol option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 "To the variable SYMBOL add OPTION.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 If SYMBOL is a hook variable, OPTION should be a hook member.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 For other types variables, the effect is undefined."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 (let ((options (get symbol 'custom-options)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 (unless (member option options)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 (put symbol 'custom-options (cons option options)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 (defun custom-add-link (symbol widget)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 "To the custom option SYMBOL add the link WIDGET."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 (let ((links (get symbol 'custom-links)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 (unless (member widget links)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 (put symbol 'custom-links (cons widget links)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 (defun custom-add-version (symbol version)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 "To the custom option SYMBOL add the version VERSION."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 (put symbol 'custom-version version))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 (defun custom-add-load (symbol load)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 "To the custom option SYMBOL add the dependency LOAD.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 LOAD should be either a library file name, or a feature name."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 (puthash symbol t custom-group-hash-table)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 (let ((loads (get symbol 'custom-loads)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 (unless (member load loads)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 (put symbol 'custom-loads (cons load loads)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 ;;; deftheme macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 (defvar custom-known-themes '(user standard)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 "Themes that have been defthemed.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 ;; #### add strings for group
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 ;; #### during bootstrap we cannot use cl-macs stuff
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 (defun* custom-define-theme (theme feature &optional doc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 &key short-description immediate variable-reset-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 variable-set-string face-set-string face-reset-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 &allow-other-keys)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 (push theme custom-known-themes)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 (put theme 'theme-feature feature)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 (put theme 'theme-documentation doc)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 (if immediate (put theme 'theme-immediate immediate))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 (if variable-reset-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (put theme 'theme-variable-reset-string variable-reset-string ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 (if variable-set-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 (put theme 'theme-variable-set-string variable-set-string ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 (if face-reset-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 (put theme 'theme-face-reset-string face-reset-string ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 (if face-set-string
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 (put theme 'theme-face-set-string face-set-string ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 (if short-description
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 (put theme 'theme-short-description short-description )))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 (defun custom-make-theme-feature (theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 (intern (concat (symbol-name theme) "-theme")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (defmacro deftheme (theme &rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 "(deftheme THEME &optional DOC &key KEYWORDS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 Define a theme labeled by SYMBOL THEME. The optional argument DOC is a
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
456 doc string describing the theme. It is optionally followed by the
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
457 following keyword arguments
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 :short-description DESC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 DESC is a short (one line) description of the theme. If not given DOC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 :immediate FLAG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 If FLAG is non-nil variables set in this theme are bound
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 immediately when loading the theme.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 :variable-set-string VARIABLE_-SET-STRING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 A string used by the UI to indicate that the value takes it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 setting from this theme. It is passed to FORMAT with the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 name of the theme a additional argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 If not given, a generic description is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 :variable-reset-string VARIABLE-RESET-STRING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 As above but used in the case the variable has been forced to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 the value in this theme.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 :face-set-string FACE-SET-STRING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 :face-reset-string FACE-RESET-STRING
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 As above but for faces."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (let ((feature (custom-make-theme-feature theme)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 `(custom-define-theme (quote ,theme) (quote ,feature) ,@body)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 (defsubst custom-theme-p (theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 "Non-nil when THEME has been defined."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 (memq theme custom-known-themes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 (defsubst custom-check-theme (theme)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
484 "Check whether THEME is valid and signal an error if NOT."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 (unless (custom-theme-p theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 (error "Unknown theme `%s'" theme)))
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 ; #### do we need to deftheme 'user and/or 'standard here to make the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 ; code in cus-edit cleaner?.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 ;;; Initializing.
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-push-theme (prop symbol theme mode value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 (let ((old (get symbol prop)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 (if (eq (car-safe (car-safe old)) theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 (setq old (cdr old)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 (put symbol prop (cons (list theme mode value) old))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
500 (defvar custom-local-buffer nil
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
501 "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
502 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
503 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
504 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
505 in every Customization buffer.")
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
506 (put 'custom-local-buffer 'permanent-local t)
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
507
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 (defun custom-set-variables (&rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 "Initialize variables according to user preferences.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 The settings are registered as theme `user'.
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
511 Each argument should be a list of the form:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 The unevaluated VALUE is stored as the saved value for SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 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
517 the default value for the SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 REQUEST is a list of features we must 'require for SYMBOL.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 COMMENT is a comment string about SYMBOL."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 (apply 'custom-theme-set-variables 'user args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 (defun custom-theme-set-variables (theme &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 "Initialize variables according to settings specified by args.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 Records the settings as belonging to THEME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 See `custom-set-variables' for a description of the arguments ARGS."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 (custom-check-theme theme)
903
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
528 (setq args
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
529 (sort args
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
530 (lambda (a1 a2)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
531 (let* ((sym1 (car a1))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
532 (sym2 (car a2))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
533 (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
534 (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
535 (cond ((and 1-then-2 2-then-1)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
536 (error "Circular custom dependency between `%s' and `%s'"
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
537 sym1 sym2))
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
538 (1-then-2 t)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
539 (2-then-1 nil)
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
540 ;; Put symbols with :require last. The macro
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
541 ;; define-minor-mode generates a defcustom
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
542 ;; with a :require and a :set, where the
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
543 ;; setter function calls the mode function.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
544 ;; Putting symbols with :require last ensures
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
545 ;; that the mode function will see other
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
546 ;; customized values rather than default
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
547 ;; values.
4a27df428c73 [xemacs-hg @ 2002-07-06 05:48:14 by andyp]
andyp
parents: 771
diff changeset
548 (t (nth 3 a2)))))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 (let ((immediate (get theme 'theme-immediate)))
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
550 (while args
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 (let ((entry (car args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 (if (listp entry)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 (let* ((symbol (nth 0 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 (value (nth 1 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 (now (nth 2 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 (requests (nth 3 entry))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 (comment (nth 4 entry))
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
558 (set (or (get symbol 'custom-set) 'custom-set-default)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 (put symbol 'saved-value (list value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 (custom-push-theme 'theme-value symbol theme 'set value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 (put symbol 'saved-variable-comment comment)
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
562 ;; Allow for errors in the case where the setter has
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
563 ;; changed between versions, say, but let the user know.
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
564 (condition-case data
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 (cond ((or now immediate)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 ;; Rogue variable, set it now.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 (put symbol 'force-value (if now 'rogue 'immediate))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 (funcall set symbol (eval value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 ((default-boundp symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 ;; Something already set this, overwrite it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 (funcall set symbol (eval value))))
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
572 (error
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
573 (message "Error setting %s: %s" symbol data)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 (and (or now (default-boundp symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 (put symbol 'variable-comment comment))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 (when requests
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 (put symbol 'custom-requests requests)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 (mapc 'require requests))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 (setq args (cdr args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 ;; Old format, a plist of SYMBOL VALUE pairs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 (message "Warning: old format `custom-set-variables'")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 (ding)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 (sit-for 2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 (let ((symbol (nth 0 args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 (value (nth 1 args)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 (put symbol 'saved-value (list value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 (custom-push-theme 'theme-value symbol theme 'set value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 (setq args (cdr (cdr args))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 (defvar custom-loaded-themes nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 "Themes in the order they are loaded.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 (defun custom-theme-loaded-p (theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 "Return non-nil when THEME has been loaded."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 (memq theme custom-loaded-themes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 (defun provide-theme (theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 "Indicate that this file provides THEME."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 (custom-check-theme theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 (provide (get theme 'theme-feature))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 (push theme custom-loaded-themes))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 (defun require-theme (theme &optional soft)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 "Try to load a theme by requiring its feature."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 ;; Note we do no check for validity of the theme here.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 ;; This allows to pull in themes by a file-name convention
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 (require (get theme 'theme-feature (custom-make-theme-feature theme))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 (defun custom-do-theme-reset (theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 ; #### untested! slow!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 (let (spec-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 (mapatoms (lambda (symbol)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 (setq spec-list (get symbol 'theme-value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 (when spec-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 (setq spec-list (delete-if (lambda (elt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 (eq (car elt) theme))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 spec-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 (put symbol 'theme-value spec-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 (custom-theme-reset-internal symbol 'user))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 (setq spec-list (get symbol 'theme-face))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 (when spec-list
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 (setq spec-list (delete-if (lambda (elt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 (eq (car elt) theme))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 spec-list))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 (put symbol 'theme-face spec-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 (custom-theme-reset-internal-face symbol 'user))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 (defun custom-theme-load-themes (by-theme &rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 "Load the themes specified by BODY and record them as required by
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
630 theme BY-THEME. BODY is a sequence of
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 - a SYMBOL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 require the theme SYMBOL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 - a list (reset THEME)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 Undo all the settings made by THEME.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 - a list (hidden THEME)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 require the THEME but hide it from the user."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 (custom-check-theme by-theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 (dolist (theme body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 (cond ((and (consp theme) (eq (car theme) 'reset))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 (custom-do-theme-reset (cadr theme)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 ((and (consp theme) (eq (car theme) 'hidden))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 (require-theme (cadr theme))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 (unless (custom-theme-loaded-p (cadr theme))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 (put (cadr theme) 'theme-hidden t)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 (t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 (require-theme theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 (remprop theme 'theme-hidden)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 (push theme (get by-theme 'theme-loads-themes))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 (defun custom-load-themes (&rest body)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 "Load themes for the USER theme as specified by BODY.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 BODY is as with custom-theme-load-themes."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 (apply #'custom-theme-load-themes 'user body))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655
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
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 (defsubst copy-upto-last (elt list)
444
576fb035e263 Import from CVS: tag r21-2-37
cvs
parents: 442
diff changeset
660 "Copy all the elements of the list upto the last occurrence of elt."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 ;; Is it faster to do more work in C than to do less in elisp?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 (nreverse (cdr (member elt (reverse list)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 (defun custom-theme-value (theme theme-spec-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 "Determine the value for THEME defined by THEME-SPEC-LIST.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 Returns (list value) if found. Nil otherwise."
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
667 ;; Note we do _NOT_ signal an error if the theme is unknown
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 ;; it might have gone away without the user knowing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 (let ((theme-or-lower (memq theme (cons 'user custom-loaded-themes)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 (mapc #'(lambda (theme-spec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 (when (member (car theme-spec) theme-or-lower)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 (setq value (cdr theme-spec))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 ;; We need to continue because if theme =A and we found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 ;; B then if the load order is B A C B
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 ;; we actually want the value in C.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 (setq theme-or-lower (copy-upto-last (car theme-spec)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 theme-or-lower))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 ;; We could should circuit if this is now nil.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 ))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 theme-spec-list)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 (if value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 (if (eq (car value) 'set)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 (list (cadr value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 ;; Yet another reset spec. car value = reset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 (custom-theme-value (cadr value) theme-spec-list)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 (defun custom-theme-variable-value (variable theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 "Return (list value) value of VARIABLE in THEME if the THEME modifies the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 VARIABLE. Nil otherwise."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 (custom-theme-value theme (get variable 'theme-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 (defun custom-theme-reset-internal (symbol to-theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 (let ((value (custom-theme-variable-value symbol to-theme))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 was-in-theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 (setq was-in-theme value)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 (setq value (or value (get symbol 'standard-value)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 (when value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 (put symbol 'saved-value was-in-theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 (if (or (get 'force-value symbol) (default-boundp symbol))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 (funcall (get symbol 'custom-set 'set-default) symbol
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 (eval (car value)))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 value))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 (defun custom-theme-reset-variables (theme &rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 "Reset the value of the variables to values previously defined.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
709 Associate this setting with THEME.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 ARGS is a list of lists of the form
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 (variable to-theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 This means reset variable to its value in to-theme."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 (custom-check-theme theme)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 (mapc #'(lambda (arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 (apply #'custom-theme-reset-internal arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 (custom-push-theme 'theme-value (car arg) theme 'reset (cadr arg)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 (defun custom-reset-variables (&rest args)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 "Reset the value of the variables to values previously defined.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
724 Associate this setting with the `user' theme.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 The ARGS are as in `custom-theme-reset-variables'."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 (apply #'custom-theme-reset-variables 'user args))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728
988
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
729 (defun custom-set-default (variable value)
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
730 "Default :set function for a customizable variable.
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
731 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
732 but if `custom-local-buffer' is non-nil,
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
733 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
734 (if custom-local-buffer
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
735 (with-current-buffer custom-local-buffer
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
736 (set variable value))
5df795348f45 [xemacs-hg @ 2002-09-01 22:13:52 by andyp]
andyp
parents: 903
diff changeset
737 (set-default variable value)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 ;;; The End.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740
1333
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
741 ;; BEGIN SYNC WITH FSF 21.2
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
742
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
743 ;; 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
744 ;; `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
745 ;; 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
746 ;; (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
747 (while custom-declare-variable-list
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
748 (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
749 (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
750
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
751 ;; END SYNC WITH FSF 21.2
1b0339b048ce [xemacs-hg @ 2003-03-02 09:38:37 by ben]
ben
parents: 988
diff changeset
752
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 ;; custom.el ends here