comparison lisp/custom.el @ 903:4a27df428c73

[xemacs-hg @ 2002-07-06 05:48:14 by andyp] sync with 21.4
author andyp
date Sat, 06 Jul 2002 05:48:22 +0000
parents 943eaba38521
children 5df795348f45
comparison
equal deleted inserted replaced
902:2fd2239ea63a 903:4a27df428c73
192 the current value for that symbol. The default is 192 the current value for that symbol. The default is
193 `default-value'. 193 `default-value'.
194 :require VALUE should be a feature symbol. Each feature will be 194 :require VALUE should be a feature symbol. Each feature will be
195 required after initialization, of the user have saved this 195 required after initialization, of the user have saved this
196 option. 196 option.
197 :version VALUE should be a string specifying that the variable was
198 first introduced, or its default value was changed, in Emacs
199 version VERSION.
200 :set-after VARIABLE specifies that SYMBOL should be set after VARIABLE when
201 both have been customized.
197 202
198 Read the section about customization in the Emacs Lisp manual for more 203 Read the section about customization in the Emacs Lisp manual for more
199 information." 204 information."
200 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args)) 205 `(custom-declare-variable (quote ,symbol) (quote ,value) ,doc ,@args))
201 206
328 333
329 (defun custom-handle-keyword (symbol keyword value type) 334 (defun custom-handle-keyword (symbol keyword value type)
330 "For customization option SYMBOL, handle KEYWORD with VALUE. 335 "For customization option SYMBOL, handle KEYWORD with VALUE.
331 Fourth argument TYPE is the custom option type." 336 Fourth argument TYPE is the custom option type."
332 (cond ((eq keyword :group) 337 (cond ((eq keyword :group)
333 (custom-add-to-group value symbol type)) 338 (custom-add-to-group value symbol type))
334 ((eq keyword :version) 339 ((eq keyword :version)
335 (custom-add-version symbol value)) 340 (custom-add-version symbol value))
336 ((eq keyword :link) 341 ((eq keyword :link)
337 (custom-add-link symbol value)) 342 (custom-add-link symbol value))
338 ((eq keyword :load) 343 ((eq keyword :load)
339 (custom-add-load symbol value)) 344 (custom-add-load symbol value))
340 ((eq keyword :tag) 345 ((eq keyword :tag)
341 (put symbol 'custom-tag value)) 346 (put symbol 'custom-tag value))
342 (t 347 ((eq keyword :set-after)
343 (signal 'error (list "Unknown keyword" keyword))))) 348 (custom-add-dependencies symbol value))
349 (t
350 (signal 'error (list "Unknown keyword" keyword)))))
351
352 (defun custom-add-dependencies (symbol value)
353 "To the custom option SYMBOL, add dependencies specified by VALUE.
354 VALUE should be a list of symbols. For each symbol in that list,
355 this specifies that SYMBOL should be set after the specified symbol, if
356 both appear in constructs like `custom-set-variables'."
357 (unless (listp value)
358 (error "Invalid custom dependency `%s'" value))
359 (let* ((deps (get symbol 'custom-dependencies))
360 (new-deps deps))
361 (while value
362 (let ((dep (car value)))
363 (unless (symbolp dep)
364 (error "Invalid custom dependency `%s'" dep))
365 (unless (memq dep new-deps)
366 (setq new-deps (cons dep new-deps)))
367 (setq value (cdr value))))
368 (unless (eq deps new-deps)
369 (put symbol 'custom-dependencies new-deps))))
344 370
345 (defun custom-add-option (symbol option) 371 (defun custom-add-option (symbol option)
346 "To the variable SYMBOL add OPTION. 372 "To the variable SYMBOL add OPTION.
347 373
348 If SYMBOL is a hook variable, OPTION should be a hook member. 374 If SYMBOL is a hook variable, OPTION should be a hook member.
464 "Initialize variables according to settings specified by args. 490 "Initialize variables according to settings specified by args.
465 Records the settings as belonging to THEME. 491 Records the settings as belonging to THEME.
466 492
467 See `custom-set-variables' for a description of the arguments ARGS." 493 See `custom-set-variables' for a description of the arguments ARGS."
468 (custom-check-theme theme) 494 (custom-check-theme theme)
495 (setq args
496 (sort args
497 (lambda (a1 a2)
498 (let* ((sym1 (car a1))
499 (sym2 (car a2))
500 (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
501 (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
502 (cond ((and 1-then-2 2-then-1)
503 (error "Circular custom dependency between `%s' and `%s'"
504 sym1 sym2))
505 (1-then-2 t)
506 (2-then-1 nil)
507 ;; Put symbols with :require last. The macro
508 ;; define-minor-mode generates a defcustom
509 ;; with a :require and a :set, where the
510 ;; setter function calls the mode function.
511 ;; Putting symbols with :require last ensures
512 ;; that the mode function will see other
513 ;; customized values rather than default
514 ;; values.
515 (t (nth 3 a2)))))))
469 (let ((immediate (get theme 'theme-immediate))) 516 (let ((immediate (get theme 'theme-immediate)))
470 (while args * etc/custom/example-themes/example-theme.el: 517 (while args * etc/custom/example-themes/example-theme.el:
471 (let ((entry (car args))) 518 (let ((entry (car args)))
472 (if (listp entry) 519 (if (listp entry)
473 (let* ((symbol (nth 0 entry)) 520 (let* ((symbol (nth 0 entry))