diff options
| author | Gerd Moellmann | 1999-12-14 12:56:36 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-12-14 12:56:36 +0000 |
| commit | 13b5da04463fb47706fb881760d8cb2b5a6ffada (patch) | |
| tree | 9b784b31f91de9a2512b1096a244fe87cddabbb2 /lisp | |
| parent | c3c60f13d5c823bd96bd0834a47ca6c77ed37032 (diff) | |
| download | emacs-13b5da04463fb47706fb881760d8cb2b5a6ffada.tar.gz emacs-13b5da04463fb47706fb881760d8cb2b5a6ffada.zip | |
(custom-handle-keyword): Add :set-after.
(custom-add-dependencies): New function.
(custom-set-variables): Take dependencies between args into
account.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/custom.el | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lisp/custom.el b/lisp/custom.el index 88b03e51bf3..1d7bf311ea4 100644 --- a/lisp/custom.el +++ b/lisp/custom.el | |||
| @@ -353,9 +353,30 @@ Fourth argument TYPE is the custom option type." | |||
| 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 | ||
| @@ -404,6 +425,18 @@ 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) |