diff options
author | Glenn Morris <rgm@gnu.org> | 2012-12-08 17:04:43 -0800 |
---|---|---|
committer | Glenn Morris <rgm@gnu.org> | 2012-12-08 17:04:43 -0800 |
commit | c6c08d3f8fe4d2c9e588189e46d60a30ef3e8d20 (patch) | |
tree | 8e718fe194d3924669bdb8c4c28f74ad127ccaf9 /lisp/emacs-lisp | |
parent | 858aab4c0267bd9c3760f337e03916b238d712c1 (diff) | |
download | emacs-c6c08d3f8fe4d2c9e588189e46d60a30ef3e8d20.tar.gz emacs-c6c08d3f8fe4d2c9e588189e46d60a30ef3e8d20.tar.bz2 emacs-c6c08d3f8fe4d2c9e588189e46d60a30ef3e8d20.zip |
Make eval-defun on a pre-defined defcustom call any :set function
* lisp/emacs-lisp/lisp-mode.el (eval-defun-1): Doc fix.
Respect a defcustom's :set function, if appropriate.
(eval-defun): Doc fix.
* doc/lispref/customize.texi (Variable Definitions): Mention eval-defun
on a defcustom calls the :set function when appropriate.
* etc/NEWS: Mention this.
Fixes: debbugs:109
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index c0380c60e11..df6680a6d94 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -830,6 +830,7 @@ this command arranges for all errors to enter the debugger." (defun eval-defun-1 (form) "Treat some expressions specially. Reset the `defvar' and `defcustom' variables to the initial value. +\(For `defcustom', use the :set function if there is one.) Reinitialize the face according to the `defface' specification." ;; The code in edebug-defun should be consistent with this, but not ;; the same, since this gets a macroexpanded form. @@ -845,14 +846,19 @@ Reinitialize the face according to the `defface' specification." ;; `custom-declare-variable' with a quoted value arg. ((and (eq (car form) 'custom-declare-variable) (default-boundp (eval (nth 1 form) lexical-binding))) - ;; Force variable to be bound. - (set-default (eval (nth 1 form) lexical-binding) - ;; The second arg is an expression that evaluates to - ;; an expression. The second evaluation is the one - ;; normally performed not be normal execution but by - ;; custom-initialize-set (for example), which does not - ;; use lexical-binding. - (eval (eval (nth 2 form) lexical-binding))) + ;; Force variable to be bound, using :set function if specified. + (let ((setfunc (memq :set form))) + (when setfunc + (setq setfunc (car-safe (cdr-safe setfunc))) + (or (functionp setfunc) (setq setfunc nil))) + (funcall (or setfunc 'set-default) + (eval (nth 1 form) lexical-binding) + ;; The second arg is an expression that evaluates to + ;; an expression. The second evaluation is the one + ;; normally performed not by normal execution but by + ;; custom-initialize-set (for example), which does not + ;; use lexical-binding. + (eval (eval (nth 2 form) lexical-binding)))) form) ;; `defface' is macroexpanded to `custom-declare-face'. ((eq (car form) 'custom-declare-face) @@ -915,11 +921,12 @@ Return the result of evaluation." If the current defun is actually a call to `defvar' or `defcustom', evaluating it this way resets the variable using its initial value -expression even if the variable already has some other value. -\(Normally `defvar' and `defcustom' do not alter the value if there -already is one.) In an analogous way, evaluating a `defface' -overrides any customizations of the face, so that it becomes -defined exactly as the `defface' expression says. +expression (using the defcustom's :set function if there is one), even +if the variable already has some other value. \(Normally `defvar' and +`defcustom' do not alter the value if there already is one.) In an +analogous way, evaluating a `defface' overrides any customizations of +the face, so that it becomes defined exactly as the `defface' expression +says. If `eval-expression-debug-on-error' is non-nil, which is the default, this command arranges for all errors to enter the debugger. |