annotate lisp/custom/custom.el @ 193:f53b5ca2e663 r20-3b23

Import from CVS: tag r20-3b23
author cvs
date Mon, 13 Aug 2007 09:58:30 +0200
parents 489f57a838ef
children a2f645c6b9f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
1 ;;; custom.el -- Tools for declaring and initializing options.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
2 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
3 ;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
4 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
5 ;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
6 ;; Keywords: help, faces
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 189
diff changeset
7 ;; Version: 1.9960
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
8 ;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
9
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
10 ;; This file is part of GNU Emacs.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
11
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
15 ;; any later version.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
16
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
20 ;; GNU General Public License for more details.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
21
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
22 ;; You should have received a copy of the GNU General Public License
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
25 ;; Boston, MA 02111-1307, USA.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
26
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
27 ;;; Commentary:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
28 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
29 ;; If you want to use this code, please visit the URL above.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
30 ;;
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
31 ;; This file only contain the code needed to declare and initialize
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
32 ;; user options. The code to customize options is autoloaded from
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
33 ;; `cus-edit.el'.
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 189
diff changeset
34 ;;
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
35 ;; The code implementing face declarations is in `cus-face.el'
193
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 189
diff changeset
36 ;;
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 189
diff changeset
37 ;; IMPORTANT: This version of custom is for Emacs 19.34 and XEmacs
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 189
diff changeset
38 ;; 19.15 - 20.2 only. If you use Emacs 20.1, XEmacs 20.3, or anything
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 189
diff changeset
39 ;; newer, please use the version of custom bundled with your emacs.
f53b5ca2e663 Import from CVS: tag r20-3b23
cvs
parents: 189
diff changeset
40 ;; If you use an older emacs, please upgrade.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
41
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
42 ;;; Code:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
43
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
44 (require 'widget)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
45
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
46 (define-widget-keywords :initialize :set :get :require :prefix :tag
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
47 :load :link :options :type :group)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
48
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
49 ;; These autoloads should be deleted eventually.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
50 (unless (fboundp 'load-gc)
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
51 ;; From cus-edit.el
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
52 (autoload 'customize-set-value "cus-edit" nil t)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 163
diff changeset
53 (autoload 'customize-set-variable "cus-edit" nil t)
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
54 (autoload 'customize "cus-edit" nil t)
163
0132846995bd Import from CVS: tag r20-3b8
cvs
parents: 161
diff changeset
55 (autoload 'customize-browse "cus-edit" nil t)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
56 (autoload 'customize-group "cus-edit" nil t)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
57 (autoload 'customize-group-other-window "cus-edit" nil t)
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
58 (autoload 'customize-variable "cus-edit" nil t)
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
59 (autoload 'customize-variable-other-window "cus-edit" nil t)
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
60 (autoload 'customize-face "cus-edit" nil t)
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
61 (autoload 'customize-face-other-window "cus-edit" nil t)
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
62 (autoload 'customize-apropos "cus-edit" nil t)
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
63 (autoload 'customize-customized "cus-edit" nil t)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
64 (autoload 'customize-saved "cus-edit" nil t)
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
65 (autoload 'custom-buffer-create "cus-edit")
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
66 (autoload 'custom-make-dependencies "cus-edit")
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
67 (autoload 'custom-menu-create "cus-edit")
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
68 (autoload 'customize-menu-create "cus-edit")
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
69
106
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
70 ;; From cus-face.el
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
71 (autoload 'custom-declare-face "cus-face")
8ff55ebd4be9 Import from CVS: tag r20-1b5
cvs
parents: 102
diff changeset
72 (autoload 'custom-set-faces "cus-face"))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
73
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
74 (defvar custom-define-hook nil
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
75 ;; Customize information for this option is in `cus-edit.el'.
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
76 "Hook called after defining each customize option.")
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
77
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
78 ;;; The `defcustom' Macro.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
79
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
80 (defun custom-initialize-default (symbol value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
81 "Initialize SYMBOL with VALUE.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
82 This will do nothing if symbol already has a default binding.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
83 Otherwise, if symbol has a `saved-value' property, it will evaluate
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
84 the car of that and used as the default binding for symbol.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
85 Otherwise, VALUE will be evaluated and used as the default binding for
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
86 symbol."
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
87 (unless (default-boundp symbol)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
88 ;; Use the saved value if it exists, otherwise the standard setting.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
89 (set-default symbol (if (get symbol 'saved-value)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
90 (eval (car (get symbol 'saved-value)))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
91 (eval value)))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
92
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
93 (defun custom-initialize-set (symbol value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
94 "Initialize SYMBOL with VALUE.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
95 Like `custom-initialize-default', but use the function specified by
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
96 `:set' to initialize SYMBOL."
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
97 (unless (default-boundp symbol)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
98 (funcall (or (get symbol 'custom-set) 'set-default)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
99 symbol
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
100 (if (get symbol 'saved-value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
101 (eval (car (get symbol 'saved-value)))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
102 (eval value)))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
103
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
104 (defun custom-initialize-reset (symbol value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
105 "Initialize SYMBOL with VALUE.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
106 Like `custom-initialize-set', but use the function specified by
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
107 `:get' to reinitialize SYMBOL if it is already bound."
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
108 (funcall (or (get symbol 'custom-set) 'set-default)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
109 symbol
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
110 (cond ((default-boundp symbol)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
111 (funcall (or (get symbol 'custom-get) 'default-value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
112 symbol))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
113 ((get symbol 'saved-value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
114 (eval (car (get symbol 'saved-value))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
115 (t
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
116 (eval value)))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
117
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
118 (defun custom-initialize-changed (symbol value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
119 "Initialize SYMBOL with VALUE.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
120 Like `custom-initialize-reset', but only use the `:set' function if the
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
121 not using the standard setting. Otherwise, use the `set-default'."
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
122 (cond ((default-boundp symbol)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
123 (funcall (or (get symbol 'custom-set) 'set-default)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
124 symbol
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
125 (funcall (or (get symbol 'custom-get) 'default-value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
126 symbol)))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
127 ((get symbol 'saved-value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
128 (funcall (or (get symbol 'custom-set) 'set-default)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
129 symbol
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
130 (eval (car (get symbol 'saved-value)))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
131 (t
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
132 (set-default symbol (eval value)))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
133
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
134 (defun custom-declare-variable (symbol value doc &rest args)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
135 "Like `defcustom', but SYMBOL and VALUE are evaluated as normal arguments."
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
136 ;; Remember the standard setting.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
137 (put symbol 'standard-value (list value))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
138 ;; Maybe this option was rogue in an earlier version. It no longer is.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
139 (when (get symbol 'force-value)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
140 ;; It no longer is.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
141 (put symbol 'force-value nil))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
142 (when doc
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
143 (put symbol 'variable-documentation doc))
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 185
diff changeset
144 (let ((initialize 'custom-initialize-reset)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
145 (requests nil))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
146 (while args
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
147 (let ((arg (car args)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
148 (setq args (cdr args))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
149 (unless (symbolp arg)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
150 (error "Junk in args %S" args))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
151 (let ((keyword arg)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
152 (value (car args)))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
153 (unless args
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
154 (error "Keyword %s is missing an argument" keyword))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
155 (setq args (cdr args))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
156 (cond ((eq keyword :initialize)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
157 (setq initialize value))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
158 ((eq keyword :set)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
159 (put symbol 'custom-set value))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
160 ((eq keyword :get)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
161 (put symbol 'custom-get value))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
162 ((eq keyword :require)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
163 (setq requests (cons value requests)))
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
164 ((eq keyword :type)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
165 (put symbol 'custom-type value))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
166 ((eq keyword :options)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
167 (if (get symbol 'custom-options)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
168 ;; Slow safe code to avoid duplicates.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
169 (mapcar (lambda (option)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
170 (custom-add-option symbol option))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
171 value)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
172 ;; Fast code for the common case.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
173 (put symbol 'custom-options (copy-sequence value))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
174 (t
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
175 (custom-handle-keyword symbol keyword value
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
176 'custom-variable))))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
177 (put symbol 'custom-requests requests)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
178 ;; Do the actual initialization.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
179 (funcall initialize symbol value))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
180 (run-hooks 'custom-define-hook)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
181 symbol)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
182
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
183 (defmacro defcustom (symbol value doc &rest args)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
184 "Declare SYMBOL as a customizable variable that defaults to VALUE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
185 DOC is the variable documentation.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
186
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
187 Neither SYMBOL nor VALUE needs to be quoted.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
188 If SYMBOL is not already bound, initialize it to VALUE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
189 The remaining arguments should have the form
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
190
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
191 [KEYWORD VALUE]...
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
192
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
193 The following KEYWORD's are defined:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
194
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
195 :type VALUE should be a widget type for editing the symbols value.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
196 The default is `sexp'.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
197 :options VALUE should be a list of valid members of the widget type.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
198 :group VALUE should be a customization group.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
199 Add SYMBOL to that group.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
200 :initialize VALUE should be a function used to initialize the
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
201 variable. It takes two arguments, the symbol and value
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
202 given in the `defcustom' call. The default is
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 167
diff changeset
203 `custom-initialize-set'
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
204 :set VALUE should be a function to set the value of the symbol.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
205 It takes two arguments, the symbol to set and the value to
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
206 give it. The default is `set-default'.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
207 :get VALUE should be a function to extract the value of symbol.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
208 The function takes one argument, a symbol, and should return
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
209 the current value for that symbol. The default is
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
210 `default-value'.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
211 :require VALUE should be a feature symbol. Each feature will be
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
212 required after initialization, of the the user have saved this
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
213 option.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
214
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
215 Read the section about customization in the Emacs Lisp manual for more
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
216 information."
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
217 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
218
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
219 ;;; The `defface' Macro.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
220
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
221 (defmacro defface (face spec doc &rest args)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
222 "Declare FACE as a customizable face that defaults to SPEC.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
223 FACE does not need to be quoted.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
224
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
225 Third argument DOC is the face documentation.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
226
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
227 If FACE has been set with `custom-set-face', set the face attributes
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
228 as specified by that function, otherwise set the face attributes
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
229 according to SPEC.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
230
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
231 The remaining arguments should have the form
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
232
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
233 [KEYWORD VALUE]...
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
234
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
235 The following KEYWORDs are defined:
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
236
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
237 :group VALUE should be a customization group.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
238 Add FACE to that group.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
239
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
240 SPEC should be an alist of the form ((DISPLAY ATTS)...).
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
241
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
242 ATTS is a list of face attributes and their values. The possible
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
243 attributes are defined in the variable `custom-face-attributes'.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
244
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
245 The ATTS of the first entry in SPEC where the DISPLAY matches the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
246 frame should take effect in that frame. DISPLAY can either be the
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
247 symbol t, which will match all frames, or an alist of the form
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
248 \((REQ ITEM...)...)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
249
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
250 For the DISPLAY to match a FRAME, the REQ property of the frame must
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
251 match one of the ITEM. The following REQ are defined:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
252
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
253 `type' (the value of `window-system')
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
254 Should be one of `x' or `tty'.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
255
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
256 `class' (the frame's color support)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
257 Should be one of `color', `grayscale', or `mono'.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
258
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
259 `background' (what color is used for the background text)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
260 Should be one of `light' or `dark'.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
261
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
262 Read the section about customization in the Emacs Lisp manual for more
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
263 information."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
264 `(custom-declare-face (quote ,face) ,spec ,doc ,@args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
265
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
266 ;;; The `defgroup' Macro.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
267
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
268 (defun custom-declare-group (symbol members doc &rest args)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
269 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
270 (while members
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
271 (apply 'custom-add-to-group symbol (car members))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
272 (setq members (cdr members)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
273 (put symbol 'custom-group (nconc members (get symbol 'custom-group)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
274 (when doc
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
275 (put symbol 'group-documentation doc))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
276 (while args
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
277 (let ((arg (car args)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
278 (setq args (cdr args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
279 (unless (symbolp arg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
280 (error "Junk in args %S" args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
281 (let ((keyword arg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
282 (value (car args)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
283 (unless args
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
284 (error "Keyword %s is missing an argument" keyword))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
285 (setq args (cdr args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
286 (cond ((eq keyword :prefix)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
287 (put symbol 'custom-prefix value))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
288 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
289 (custom-handle-keyword symbol keyword value
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
290 'custom-group))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
291 (run-hooks 'custom-define-hook)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
292 symbol)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
293
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
294 (defmacro defgroup (symbol members doc &rest args)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
295 "Declare SYMBOL as a customization group containing MEMBERS.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
296 SYMBOL does not need to be quoted.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
297
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
298 Third arg DOC is the group documentation.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
299
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
300 MEMBERS should be an alist of the form ((NAME WIDGET)...) where NAME
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
301 is a symbol and WIDGET is a widget for editing that symbol. Useful
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
302 widgets are `custom-variable' for editing variables, `custom-face' for
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 173
diff changeset
303 edit faces, and `custom-group' for editing groups.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
304
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
305 The remaining arguments should have the form
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
306
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
307 [KEYWORD VALUE]...
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
308
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
309 The following KEYWORD's are defined:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
310
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
311 :group VALUE should be a customization group.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
312 Add SYMBOL to that group.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
313
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
314 Read the section about customization in the Emacs Lisp manual for more
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
315 information."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
316 `(custom-declare-group (quote ,symbol) ,members ,doc ,@args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
317
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
318 (defun custom-add-to-group (group option widget)
118
7d55a9ba150c Import from CVS: tag r20-1b11
cvs
parents: 116
diff changeset
319 "To existing GROUP add a new OPTION of type WIDGET.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
320 If there already is an entry for that option, overwrite it."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
321 (let* ((members (get group 'custom-group))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
322 (old (assq option members)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
323 (if old
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
324 (setcar (cdr old) widget)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
325 (put group 'custom-group (nconc members (list (list option widget)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
326
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
327 ;;; Properties.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
328
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
329 (defun custom-handle-all-keywords (symbol args type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
330 "For customization option SYMBOL, handle keyword arguments ARGS.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
331 Third argument TYPE is the custom option type."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
332 (while args
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
333 (let ((arg (car args)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
334 (setq args (cdr args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
335 (unless (symbolp arg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
336 (error "Junk in args %S" args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
337 (let ((keyword arg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
338 (value (car args)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
339 (unless args
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
340 (error "Keyword %s is missing an argument" keyword))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
341 (setq args (cdr args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
342 (custom-handle-keyword symbol keyword value type)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
343
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
344 (defun custom-handle-keyword (symbol keyword value type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
345 "For customization option SYMBOL, handle KEYWORD with VALUE.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
346 Fourth argument TYPE is the custom option type."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
347 (cond ((eq keyword :group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
348 (custom-add-to-group value symbol type))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
349 ((eq keyword :link)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
350 (custom-add-link symbol value))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
351 ((eq keyword :load)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
352 (custom-add-load symbol value))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
353 ((eq keyword :tag)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
354 (put symbol 'custom-tag value))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
355 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
356 (error "Unknown keyword %s" symbol))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
357
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
358 (defun custom-add-option (symbol option)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
359 "To the variable SYMBOL add OPTION.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
360
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
361 If SYMBOL is a hook variable, OPTION should be a hook member.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
362 For other types variables, the effect is undefined."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
363 (let ((options (get symbol 'custom-options)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
364 (unless (member option options)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
365 (put symbol 'custom-options (cons option options)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
366
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
367 (defun custom-add-link (symbol widget)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
368 "To the custom option SYMBOL add the link WIDGET."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
369 (let ((links (get symbol 'custom-links)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
370 (unless (member widget links)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
371 (put symbol 'custom-links (cons widget links)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
372
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
373 (defun custom-add-load (symbol load)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
374 "To the custom option SYMBOL add the dependency LOAD.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
375 LOAD should be either a library file name, or a feature name."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
376 (let ((loads (get symbol 'custom-loads)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
377 (unless (member load loads)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
378 (put symbol 'custom-loads (cons load loads)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
379
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
380 ;;; Initializing.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
381
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
382 (defun custom-set-variables (&rest args)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
383 "Initialize variables according to user preferences.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
384
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
385 The arguments should be a list where each entry has the form:
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
386
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
387 (SYMBOL VALUE [NOW])
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
388
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
389 The unevaluated VALUE is stored as the saved value for SYMBOL.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
390 If NOW is present and non-nil, VALUE is also evaluated and bound as
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
391 the default value for the SYMBOL."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
392 (while args
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
393 (let ((entry (car args)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
394 (if (listp entry)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
395 (let* ((symbol (nth 0 entry))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
396 (value (nth 1 entry))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
397 (now (nth 2 entry))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
398 (requests (nth 3 entry))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
399 (set (or (get symbol 'custom-set) 'set-default)))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
400 (put symbol 'saved-value (list value))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
401 (cond (now
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
402 ;; Rogue variable, set it now.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
403 (put symbol 'force-value t)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
404 (funcall set symbol (eval value)))
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
405 ((default-boundp symbol)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 118
diff changeset
406 ;; Something already set this, overwrite it.
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
407 (funcall set symbol (eval value))))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
408 (when requests
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
409 (put symbol 'custom-requests requests)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 136
diff changeset
410 (mapcar 'require requests))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
411 (setq args (cdr args)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
412 ;; Old format, a plist of SYMBOL VALUE pairs.
124
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
413 (message "Warning: old format `custom-set-variables'")
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
414 (ding)
9b50b4588a93 Import from CVS: tag r20-1b15
cvs
parents: 120
diff changeset
415 (sit-for 2)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
416 (let ((symbol (nth 0 args))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
417 (value (nth 1 args)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
418 (put symbol 'saved-value (list value)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
419 (setq args (cdr (cdr args)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
420
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
421 ;;; The End.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
422
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
423 (provide 'custom)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
424
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents:
diff changeset
425 ;; custom.el ends here