diff options
| author | Glenn Morris | 2012-12-08 17:04:43 -0800 |
|---|---|---|
| committer | Glenn Morris | 2012-12-08 17:04:43 -0800 |
| commit | c6c08d3f8fe4d2c9e588189e46d60a30ef3e8d20 (patch) | |
| tree | 8e718fe194d3924669bdb8c4c28f74ad127ccaf9 /lisp | |
| parent | 858aab4c0267bd9c3760f337e03916b238d712c1 (diff) | |
| download | emacs-c6c08d3f8fe4d2c9e588189e46d60a30ef3e8d20.tar.gz 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')
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 33 |
2 files changed, 26 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6bf6726986e..8515c110c42 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-12-09 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * emacs-lisp/lisp-mode.el (eval-defun-1): Doc fix. | ||
| 4 | Respect a defcustom's :set function, if appropriate. (Bug#109) | ||
| 5 | (eval-defun): Doc fix. | ||
| 6 | |||
| 1 | 2012-12-08 Juri Linkov <juri@jurta.org> | 7 | 2012-12-08 Juri Linkov <juri@jurta.org> |
| 2 | 8 | ||
| 3 | * info.el (Info-copy-current-node-name, Info-breadcrumbs) | 9 | * info.el (Info-copy-current-node-name, Info-breadcrumbs) |
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." | |||
| 830 | (defun eval-defun-1 (form) | 830 | (defun eval-defun-1 (form) |
| 831 | "Treat some expressions specially. | 831 | "Treat some expressions specially. |
| 832 | Reset the `defvar' and `defcustom' variables to the initial value. | 832 | Reset the `defvar' and `defcustom' variables to the initial value. |
| 833 | \(For `defcustom', use the :set function if there is one.) | ||
| 833 | Reinitialize the face according to the `defface' specification." | 834 | Reinitialize the face according to the `defface' specification." |
| 834 | ;; The code in edebug-defun should be consistent with this, but not | 835 | ;; The code in edebug-defun should be consistent with this, but not |
| 835 | ;; the same, since this gets a macroexpanded form. | 836 | ;; the same, since this gets a macroexpanded form. |
| @@ -845,14 +846,19 @@ Reinitialize the face according to the `defface' specification." | |||
| 845 | ;; `custom-declare-variable' with a quoted value arg. | 846 | ;; `custom-declare-variable' with a quoted value arg. |
| 846 | ((and (eq (car form) 'custom-declare-variable) | 847 | ((and (eq (car form) 'custom-declare-variable) |
| 847 | (default-boundp (eval (nth 1 form) lexical-binding))) | 848 | (default-boundp (eval (nth 1 form) lexical-binding))) |
| 848 | ;; Force variable to be bound. | 849 | ;; Force variable to be bound, using :set function if specified. |
| 849 | (set-default (eval (nth 1 form) lexical-binding) | 850 | (let ((setfunc (memq :set form))) |
| 850 | ;; The second arg is an expression that evaluates to | 851 | (when setfunc |
| 851 | ;; an expression. The second evaluation is the one | 852 | (setq setfunc (car-safe (cdr-safe setfunc))) |
| 852 | ;; normally performed not be normal execution but by | 853 | (or (functionp setfunc) (setq setfunc nil))) |
| 853 | ;; custom-initialize-set (for example), which does not | 854 | (funcall (or setfunc 'set-default) |
| 854 | ;; use lexical-binding. | 855 | (eval (nth 1 form) lexical-binding) |
| 855 | (eval (eval (nth 2 form) lexical-binding))) | 856 | ;; The second arg is an expression that evaluates to |
| 857 | ;; an expression. The second evaluation is the one | ||
| 858 | ;; normally performed not by normal execution but by | ||
| 859 | ;; custom-initialize-set (for example), which does not | ||
| 860 | ;; use lexical-binding. | ||
| 861 | (eval (eval (nth 2 form) lexical-binding)))) | ||
| 856 | form) | 862 | form) |
| 857 | ;; `defface' is macroexpanded to `custom-declare-face'. | 863 | ;; `defface' is macroexpanded to `custom-declare-face'. |
| 858 | ((eq (car form) 'custom-declare-face) | 864 | ((eq (car form) 'custom-declare-face) |
| @@ -915,11 +921,12 @@ Return the result of evaluation." | |||
| 915 | 921 | ||
| 916 | If the current defun is actually a call to `defvar' or `defcustom', | 922 | If the current defun is actually a call to `defvar' or `defcustom', |
| 917 | evaluating it this way resets the variable using its initial value | 923 | evaluating it this way resets the variable using its initial value |
| 918 | expression even if the variable already has some other value. | 924 | expression (using the defcustom's :set function if there is one), even |
| 919 | \(Normally `defvar' and `defcustom' do not alter the value if there | 925 | if the variable already has some other value. \(Normally `defvar' and |
| 920 | already is one.) In an analogous way, evaluating a `defface' | 926 | `defcustom' do not alter the value if there already is one.) In an |
| 921 | overrides any customizations of the face, so that it becomes | 927 | analogous way, evaluating a `defface' overrides any customizations of |
| 922 | defined exactly as the `defface' expression says. | 928 | the face, so that it becomes defined exactly as the `defface' expression |
| 929 | says. | ||
| 923 | 930 | ||
| 924 | If `eval-expression-debug-on-error' is non-nil, which is the default, | 931 | If `eval-expression-debug-on-error' is non-nil, which is the default, |
| 925 | this command arranges for all errors to enter the debugger. | 932 | this command arranges for all errors to enter the debugger. |