Mercurial > hg > xemacs-beta
comparison lisp/custom.el @ 988:5df795348f45
[xemacs-hg @ 2002-09-01 22:13:52 by andyp]
apply various 21.4 patches
author | andyp |
---|---|
date | Sun, 01 Sep 2002 22:14:58 +0000 |
parents | 4a27df428c73 |
children | 1b0339b048ce |
comparison
equal
deleted
inserted
replaced
987:7ffc86e44409 | 988:5df795348f45 |
---|---|
184 variable. It takes two arguments, the symbol and value | 184 variable. It takes two arguments, the symbol and value |
185 given in the `defcustom' call. The default is | 185 given in the `defcustom' call. The default is |
186 `custom-initialize-set' | 186 `custom-initialize-set' |
187 :set VALUE should be a function to set the value of the symbol. | 187 :set VALUE should be a function to set the value of the symbol. |
188 It takes two arguments, the symbol to set and the value to | 188 It takes two arguments, the symbol to set and the value to |
189 give it. The default is `set-default'. | 189 give it. The default is `custom-set-default'. |
190 :get VALUE should be a function to extract the value of symbol. | 190 :get VALUE should be a function to extract the value of symbol. |
191 The function takes one argument, a symbol, and should return | 191 The function takes one argument, a symbol, and should return |
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 |
470 (let ((old (get symbol prop))) | 470 (let ((old (get symbol prop))) |
471 (if (eq (car-safe (car-safe old)) theme) | 471 (if (eq (car-safe (car-safe old)) theme) |
472 (setq old (cdr old))) | 472 (setq old (cdr old))) |
473 (put symbol prop (cons (list theme mode value) old)))) | 473 (put symbol prop (cons (list theme mode value) old)))) |
474 | 474 |
475 (defvar custom-local-buffer nil | |
476 "Non-nil, in a Customization buffer, means customize a specific buffer. | |
477 If this variable is non-nil, it should be a buffer, | |
478 and it means customize the local bindings of that buffer. | |
479 This variable is a permanent local, and it normally has a local binding | |
480 in every Customization buffer.") | |
481 (put 'custom-local-buffer 'permanent-local t) | |
482 | |
475 (defun custom-set-variables (&rest args) | 483 (defun custom-set-variables (&rest args) |
476 "Initialize variables according to user preferences. | 484 "Initialize variables according to user preferences. |
477 The settings are registered as theme `user'. | 485 The settings are registered as theme `user'. |
478 The arguments should be a list where each entry has the form: | 486 Each argument should be a list of the form: |
479 | 487 |
480 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]]) | 488 (SYMBOL VALUE [NOW [REQUEST [COMMENT]]]) |
481 | 489 |
482 The unevaluated VALUE is stored as the saved value for SYMBOL. | 490 The unevaluated VALUE is stored as the saved value for SYMBOL. |
483 If NOW is present and non-nil, VALUE is also evaluated and bound as | 491 If NOW is present and non-nil, VALUE is also evaluated and bound as |
512 ;; that the mode function will see other | 520 ;; that the mode function will see other |
513 ;; customized values rather than default | 521 ;; customized values rather than default |
514 ;; values. | 522 ;; values. |
515 (t (nth 3 a2))))))) | 523 (t (nth 3 a2))))))) |
516 (let ((immediate (get theme 'theme-immediate))) | 524 (let ((immediate (get theme 'theme-immediate))) |
517 (while args * etc/custom/example-themes/example-theme.el: | 525 (while args |
518 (let ((entry (car args))) | 526 (let ((entry (car args))) |
519 (if (listp entry) | 527 (if (listp entry) |
520 (let* ((symbol (nth 0 entry)) | 528 (let* ((symbol (nth 0 entry)) |
521 (value (nth 1 entry)) | 529 (value (nth 1 entry)) |
522 (now (nth 2 entry)) | 530 (now (nth 2 entry)) |
523 (requests (nth 3 entry)) | 531 (requests (nth 3 entry)) |
524 (comment (nth 4 entry)) | 532 (comment (nth 4 entry)) |
525 (set (or (get symbol 'custom-set) 'set-default))) | 533 (set (or (get symbol 'custom-set) 'custom-set-default))) |
526 (put symbol 'saved-value (list value)) | 534 (put symbol 'saved-value (list value)) |
527 (custom-push-theme 'theme-value symbol theme 'set value) | 535 (custom-push-theme 'theme-value symbol theme 'set value) |
528 (put symbol 'saved-variable-comment comment) | 536 (put symbol 'saved-variable-comment comment) |
537 ;; Allow for errors in the case where the setter has | |
538 ;; changed between versions, say, but let the user know. | |
539 (condition-case data | |
529 (cond ((or now immediate) | 540 (cond ((or now immediate) |
530 ;; Rogue variable, set it now. | 541 ;; Rogue variable, set it now. |
531 (put symbol 'force-value (if now 'rogue 'immediate)) | 542 (put symbol 'force-value (if now 'rogue 'immediate)) |
532 (funcall set symbol (eval value))) | 543 (funcall set symbol (eval value))) |
533 ((default-boundp symbol) | 544 ((default-boundp symbol) |
534 ;; Something already set this, overwrite it. | 545 ;; Something already set this, overwrite it. |
535 (funcall set symbol (eval value)))) | 546 (funcall set symbol (eval value)))) |
547 (error | |
548 (message "Error setting %s: %s" symbol data))) | |
536 (and (or now (default-boundp symbol)) | 549 (and (or now (default-boundp symbol)) |
537 (put symbol 'variable-comment comment)) | 550 (put symbol 'variable-comment comment)) |
538 (when requests | 551 (when requests |
539 (put symbol 'custom-requests requests) | 552 (put symbol 'custom-requests requests) |
540 (mapc 'require requests)) | 553 (mapc 'require requests)) |
686 Associate this setting with the `user' theme. | 699 Associate this setting with the `user' theme. |
687 | 700 |
688 The ARGS are as in `custom-theme-reset-variables'." | 701 The ARGS are as in `custom-theme-reset-variables'." |
689 (apply #'custom-theme-reset-variables 'user args)) | 702 (apply #'custom-theme-reset-variables 'user args)) |
690 | 703 |
704 (defun custom-set-default (variable value) | |
705 "Default :set function for a customizable variable. | |
706 Normally, this sets the default value of VARIABLE to VALUE, | |
707 but if `custom-local-buffer' is non-nil, | |
708 this sets the local binding in that buffer instead." | |
709 (if custom-local-buffer | |
710 (with-current-buffer custom-local-buffer | |
711 (set variable value)) | |
712 (set-default variable value))) | |
691 | 713 |
692 ;;; The End. | 714 ;;; The End. |
693 | 715 |
694 ;; custom.el ends here | 716 ;; custom.el ends here |