aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love1999-09-13 13:03:05 +0000
committerDave Love1999-09-13 13:03:05 +0000
commit70647e337e404182d45ed4d29e179773fcadf9be (patch)
treebfef555842b5b4d6688fa87e1e29243a26c6e4ac
parentb86bd3dd37e63d13ba3657f5e9dd084d04a254e5 (diff)
downloademacs-70647e337e404182d45ed4d29e179773fcadf9be.tar.gz
emacs-70647e337e404182d45ed4d29e179773fcadf9be.zip
Don't define-widget-keywords.
Change from Didier Verna: (custom-set-variables): the arguments can now have a custom comment as fifth element.
-rw-r--r--lisp/custom.el61
1 files changed, 30 insertions, 31 deletions
diff --git a/lisp/custom.el b/lisp/custom.el
index 1f510c3d85d..e07aea2c953 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1,11 +1,10 @@
1;;; custom.el -- Tools for declaring and initializing options. 1;;; custom.el -- Tools for declaring and initializing options.
2;; 2;;
3;; Copyright (C) 1996, 1997 Free Software Foundation, Inc. 3;; Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
4;; 4;;
5;; Author: Per Abrahamsen <abraham@dina.kvl.dk> 5;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
6;; Keywords: help, faces 6;; Keywords: help, faces
7;; Version: 1.9900 7;; X-URL: http://www.dina.kvl.dk/~abraham/custom/ (probably obsolete)
8;; X-URL: http://www.dina.kvl.dk/~abraham/custom/
9 8
10;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
11 10
@@ -26,11 +25,9 @@
26 25
27;;; Commentary: 26;;; Commentary:
28;; 27;;
29;; If you want to use this code, please visit the URL above.
30;;
31;; This file only contain the code needed to declare and initialize 28;; This file only contain the code needed to declare and initialize
32;; user options. The code to customize options is autoloaded from 29;; user options. The code to customize options is autoloaded from
33;; `cus-edit.el'. 30;; `cus-edit.el' and is documented in the Emacs Lisp Reference manual.
34 31
35;; The code implementing face declarations is in `cus-face.el' 32;; The code implementing face declarations is in `cus-face.el'
36 33
@@ -38,10 +35,6 @@
38 35
39(require 'widget) 36(require 'widget)
40 37
41(define-widget-keywords :initialize :set :get :require :prefix :tag
42 :load :link :options :type :group)
43
44
45(defvar custom-define-hook nil 38(defvar custom-define-hook nil
46 ;; Customize information for this option is in `cus-edit.el'. 39 ;; Customize information for this option is in `cus-edit.el'.
47 "Hook called after defining each customize option.") 40 "Hook called after defining each customize option.")
@@ -69,7 +62,7 @@ The value is either the value in the symbol's `saved-value' property,
69if any, or VALUE." 62if any, or VALUE."
70 (unless (default-boundp symbol) 63 (unless (default-boundp symbol)
71 (funcall (or (get symbol 'custom-set) 'set-default) 64 (funcall (or (get symbol 'custom-set) 'set-default)
72 symbol 65 symbol
73 (if (get symbol 'saved-value) 66 (if (get symbol 'saved-value)
74 (eval (car (get symbol 'saved-value))) 67 (eval (car (get symbol 'saved-value)))
75 (eval value))))) 68 (eval value)))))
@@ -82,7 +75,7 @@ The value is either the symbol's current value
82or the value in the symbol's `saved-value' property if any, 75or the value in the symbol's `saved-value' property if any,
83or (last of all) VALUE." 76or (last of all) VALUE."
84 (funcall (or (get symbol 'custom-set) 'set-default) 77 (funcall (or (get symbol 'custom-set) 'set-default)
85 symbol 78 symbol
86 (cond ((default-boundp symbol) 79 (cond ((default-boundp symbol)
87 (funcall (or (get symbol 'custom-get) 'default-value) 80 (funcall (or (get symbol 'custom-get) 'default-value)
88 symbol)) 81 symbol))
@@ -93,7 +86,7 @@ or (last of all) VALUE."
93 86
94(defun custom-initialize-changed (symbol value) 87(defun custom-initialize-changed (symbol value)
95 "Initialize SYMBOL with VALUE. 88 "Initialize SYMBOL with VALUE.
96Like `custom-initialize-reset', but only use the `:set' function if the 89Like `custom-initialize-reset', but only use the `:set' function if the
97not using the standard setting. 90not using the standard setting.
98For the standard setting, use the `set-default'." 91For the standard setting, use the `set-default'."
99 (cond ((default-boundp symbol) 92 (cond ((default-boundp symbol)
@@ -116,13 +109,13 @@ not the default value itself."
116 (put symbol 'standard-value (list default)) 109 (put symbol 'standard-value (list default))
117 ;; Maybe this option was rogue in an earlier version. It no longer is. 110 ;; Maybe this option was rogue in an earlier version. It no longer is.
118 (when (get symbol 'force-value) 111 (when (get symbol 'force-value)
119 ;; It no longer is. 112 ;; It no longer is.
120 (put symbol 'force-value nil)) 113 (put symbol 'force-value nil))
121 (when doc 114 (when doc
122 (put symbol 'variable-documentation doc)) 115 (put symbol 'variable-documentation doc))
123 (let ((initialize 'custom-initialize-reset) 116 (let ((initialize 'custom-initialize-reset)
124 (requests nil)) 117 (requests nil))
125 (while args 118 (while args
126 (let ((arg (car args))) 119 (let ((arg (car args)))
127 (setq args (cdr args)) 120 (setq args (cdr args))
128 (unless (symbolp arg) 121 (unless (symbolp arg)
@@ -168,27 +161,27 @@ Neither SYMBOL nor VALUE needs to be quoted.
168If SYMBOL is not already bound, initialize it to VALUE. 161If SYMBOL is not already bound, initialize it to VALUE.
169The remaining arguments should have the form 162The remaining arguments should have the form
170 163
171 [KEYWORD VALUE]... 164 [KEYWORD VALUE]...
172 165
173The following keywords are meaningful: 166The following keywords are meaningful:
174 167
175:type VALUE should be a widget type for editing the symbols value. 168:type VALUE should be a widget type for editing the symbols value.
176 The default is `sexp'. 169 The default is `sexp'.
177:options VALUE should be a list of valid members of the widget type. 170:options VALUE should be a list of valid members of the widget type.
178:group VALUE should be a customization group. 171:group VALUE should be a customization group.
179 Add SYMBOL to that group. 172 Add SYMBOL to that group.
180:initialize 173:initialize
181 VALUE should be a function used to initialize the 174 VALUE should be a function used to initialize the
182 variable. It takes two arguments, the symbol and value 175 variable. It takes two arguments, the symbol and value
183 given in the `defcustom' call. The default is 176 given in the `defcustom' call. The default is
184 `custom-initialize-default' 177 `custom-initialize-default'
185:set VALUE should be a function to set the value of the symbol. 178:set VALUE should be a function to set the value of the symbol.
186 It takes two arguments, the symbol to set and the value to 179 It takes two arguments, the symbol to set and the value to
187 give it. The default choice of function is `custom-set-default'. 180 give it. The default choice of function is `custom-set-default'.
188:get VALUE should be a function to extract the value of symbol. 181:get VALUE should be a function to extract the value of symbol.
189 The function takes one argument, a symbol, and should return 182 The function takes one argument, a symbol, and should return
190 the current value for that symbol. The default choice of function 183 the current value for that symbol. The default choice of function
191 is `custom-default-value'. 184 is `custom-default-value'.
192:require 185:require
193 VALUE should be a feature symbol. If you save a value 186 VALUE should be a feature symbol. If you save a value
194 for this option, then when your `.emacs' file loads the value, 187 for this option, then when your `.emacs' file loads the value,
@@ -264,13 +257,13 @@ information."
264 257
265(defun custom-declare-group (symbol members doc &rest args) 258(defun custom-declare-group (symbol members doc &rest args)
266 "Like `defgroup', but SYMBOL is evaluated as a normal argument." 259 "Like `defgroup', but SYMBOL is evaluated as a normal argument."
267 (while members 260 (while members
268 (apply 'custom-add-to-group symbol (car members)) 261 (apply 'custom-add-to-group symbol (car members))
269 (setq members (cdr members))) 262 (setq members (cdr members)))
270 (put symbol 'custom-group (nconc members (get symbol 'custom-group))) 263 (put symbol 'custom-group (nconc members (get symbol 'custom-group)))
271 (when doc 264 (when doc
272 (put symbol 'group-documentation doc)) 265 (put symbol 'group-documentation doc))
273 (while args 266 (while args
274 (let ((arg (car args))) 267 (let ((arg (car args)))
275 (setq args (cdr args)) 268 (setq args (cdr args))
276 (unless (symbolp arg) 269 (unless (symbolp arg)
@@ -301,7 +294,7 @@ Useful widgets are `custom-variable' for editing variables,
301 294
302The remaining arguments should have the form 295The remaining arguments should have the form
303 296
304 [KEYWORD VALUE]... 297 [KEYWORD VALUE]...
305 298
306The following KEYWORD's are defined: 299The following KEYWORD's are defined:
307 300
@@ -329,7 +322,7 @@ If there already is an entry for that option, overwrite it."
329(defun custom-handle-all-keywords (symbol args type) 322(defun custom-handle-all-keywords (symbol args type)
330 "For customization option SYMBOL, handle keyword arguments ARGS. 323 "For customization option SYMBOL, handle keyword arguments ARGS.
331Third argument TYPE is the custom option type." 324Third argument TYPE is the custom option type."
332 (while args 325 (while args
333 (let ((arg (car args))) 326 (let ((arg (car args)))
334 (setq args (cdr args)) 327 (setq args (cdr args))
335 (unless (symbolp arg) 328 (unless (symbolp arg)
@@ -339,7 +332,7 @@ Third argument TYPE is the custom option type."
339 (unless args 332 (unless args
340 (error "Keyword %s is missing an argument" keyword)) 333 (error "Keyword %s is missing an argument" keyword))
341 (setq args (cdr args)) 334 (setq args (cdr args))
342 (custom-handle-keyword symbol keyword value type))))) 335 (custom-handle-keyword symbol keyword value type)))))
343 336
344(defun custom-handle-keyword (symbol keyword value type) 337(defun custom-handle-keyword (symbol keyword value type)
345 "For customization option SYMBOL, handle KEYWORD with VALUE. 338 "For customization option SYMBOL, handle KEYWORD with VALUE.
@@ -394,28 +387,32 @@ in every Customization buffer.")
394(put 'custom-local-buffer 'permanent-local t) 387(put 'custom-local-buffer 'permanent-local t)
395 388
396(defun custom-set-variables (&rest args) 389(defun custom-set-variables (&rest args)
397 "Initialize variables according to user preferences. 390 "Initialize variables according to user preferences.
398 391
399The arguments should be a list where each entry has the form: 392The arguments should be a list where each entry has the form:
400 393
401 (SYMBOL VALUE [NOW]) 394 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]])
402 395
403The unevaluated VALUE is stored as the saved value for SYMBOL. 396The unevaluated VALUE is stored as the saved value for SYMBOL.
404If NOW is present and non-nil, VALUE is also evaluated and bound as 397If NOW is present and non-nil, VALUE is also evaluated and bound as
405the default value for the SYMBOL." 398the default value for the SYMBOL.
406 (while args 399REQUEST is a list of features we must require for SYMBOL.
400COMMENT is a comment string about SYMBOL."
401 (while args
407 (let ((entry (car args))) 402 (let ((entry (car args)))
408 (if (listp entry) 403 (if (listp entry)
409 (let* ((symbol (nth 0 entry)) 404 (let* ((symbol (nth 0 entry))
410 (value (nth 1 entry)) 405 (value (nth 1 entry))
411 (now (nth 2 entry)) 406 (now (nth 2 entry))
412 (requests (nth 3 entry)) 407 (requests (nth 3 entry))
408 (comment (nth 4 entry))
413 set) 409 set)
414 (when requests 410 (when requests
415 (put symbol 'custom-requests requests) 411 (put symbol 'custom-requests requests)
416 (mapcar 'require requests)) 412 (mapcar 'require requests))
417 (setq set (or (get symbol 'custom-set) 'custom-set-default)) 413 (setq set (or (get symbol 'custom-set) 'custom-set-default))
418 (put symbol 'saved-value (list value)) 414 (put symbol 'saved-value (list value))
415 (put symbol 'saved-variable-comment comment)
419 ;; Allow for errors in the case where the setter has 416 ;; Allow for errors in the case where the setter has
420 ;; changed between versions, say. 417 ;; changed between versions, say.
421 (condition-case nil 418 (condition-case nil
@@ -427,7 +424,9 @@ the default value for the SYMBOL."
427 ;; Something already set this, overwrite it. 424 ;; Something already set this, overwrite it.
428 (funcall set symbol (eval value)))) 425 (funcall set symbol (eval value))))
429 (error nil)) 426 (error nil))
430 (setq args (cdr args))) 427 (setq args (cdr args))
428 (and (or now (default-boundp symbol))
429 (put symbol 'variable-comment comment)))
431 ;; Old format, a plist of SYMBOL VALUE pairs. 430 ;; Old format, a plist of SYMBOL VALUE pairs.
432 (message "Warning: old format `custom-set-variables'") 431 (message "Warning: old format `custom-set-variables'")
433 (ding) 432 (ding)
@@ -456,4 +455,4 @@ this sets the local binding in that buffer instead."
456 455
457(provide 'custom) 456(provide 'custom)
458 457
459;; custom.el ends here 458;;; custom.el ends here