comparison lisp/custom.el @ 26831:ddaafb816c3e

(custom-handle-keyword): Add :set-after. (custom-add-dependencies): New function. (custom-set-variables): Take dependencies between args into account.
author Gerd Moellmann <gerd@gnu.org>
date Tue, 14 Dec 1999 12:56:36 +0000
parents fbd1f4d3000d
children 755f54893c1f
comparison
equal deleted inserted replaced
26830:e0b76e95d7be 26831:ddaafb816c3e
351 (custom-add-link symbol value)) 351 (custom-add-link symbol value))
352 ((eq keyword :load) 352 ((eq keyword :load)
353 (custom-add-load symbol value)) 353 (custom-add-load symbol value))
354 ((eq keyword :tag) 354 ((eq keyword :tag)
355 (put symbol 'custom-tag value)) 355 (put symbol 'custom-tag value))
356 ((eq keyword :set-after)
357 (custom-add-dependencies symbol value))
356 (t 358 (t
357 (error "Unknown keyword %s" keyword)))) 359 (error "Unknown keyword %s" keyword))))
358 360
361 (defun custom-add-dependencies (symbol value)
362 "To the custom option SYMBOL, add dependencies specified by VALUE.
363 VALUE should be a list of symbols. For each symbol in that list,
364 this specifies that SYMBOL should be set after the specified symbol, if
365 both appear in constructs like `custom-set-variables'."
366 (unless (listp value)
367 (error "Invalid custom dependency `%s'" value))
368 (let* ((deps (get symbol 'custom-dependencies))
369 (new-deps deps))
370 (while value
371 (let ((dep (car value)))
372 (unless (symbolp dep)
373 (error "Invalid custom dependency `%s'" dep))
374 (unless (memq dep new-deps)
375 (setq new-deps (cons dep new-deps)))
376 (setq value (cdr value))))
377 (unless (eq deps new-deps)
378 (put symbol 'custom-dependencies new-deps))))
379
359 (defun custom-add-option (symbol option) 380 (defun custom-add-option (symbol option)
360 "To the variable SYMBOL add OPTION. 381 "To the variable SYMBOL add OPTION.
361 382
362 If SYMBOL is a hook variable, OPTION should be a hook member. 383 If SYMBOL is a hook variable, OPTION should be a hook member.
363 For other types variables, the effect is undefined." 384 For other types variables, the effect is undefined."
402 The unevaluated VALUE is stored as the saved value for SYMBOL. 423 The unevaluated VALUE is stored as the saved value for SYMBOL.
403 If NOW is present and non-nil, VALUE is also evaluated and bound as 424 If NOW is present and non-nil, VALUE is also evaluated and bound as
404 the default value for the SYMBOL. 425 the default value for the SYMBOL.
405 REQUEST is a list of features we must require for SYMBOL. 426 REQUEST is a list of features we must require for SYMBOL.
406 COMMENT is a comment string about SYMBOL." 427 COMMENT is a comment string about SYMBOL."
428 (setq args
429 (sort args
430 (lambda (a1 a2)
431 (let* ((sym1 (car a1))
432 (sym2 (car a2))
433 (1-then-2 (memq sym1 (get sym2 'custom-dependencies)))
434 (2-then-1 (memq sym2 (get sym1 'custom-dependencies))))
435 (cond ((and 1-then-2 2-then-1)
436 (error "Circular custom dependency between `%s' and `%s'"
437 sym1 sym2))
438 (2-then-1 nil)
439 (t t))))))
407 (while args 440 (while args
408 (let ((entry (car args))) 441 (let ((entry (car args)))
409 (if (listp entry) 442 (if (listp entry)
410 (let* ((symbol (nth 0 entry)) 443 (let* ((symbol (nth 0 entry))
411 (value (nth 1 entry)) 444 (value (nth 1 entry))