annotate lisp/custom/custom.el @ 134:34a5b81f86ba r20-2b1

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