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 | |
| 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
| -rw-r--r-- | doc/lispref/ChangeLog | 5 | ||||
| -rw-r--r-- | doc/lispref/customize.texi | 6 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 33 |
5 files changed, 40 insertions, 15 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog index a26bfdc2e4b..7238d958d8a 100644 --- a/doc/lispref/ChangeLog +++ b/doc/lispref/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-12-09 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * customize.texi (Variable Definitions): Mention eval-defun | ||
| 4 | on a defcustom calls the :set function when appropriate. | ||
| 5 | |||
| 1 | 2012-12-06 Paul Eggert <eggert@cs.ucla.edu> | 6 | 2012-12-06 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 7 | ||
| 3 | * doclicense.texi, gpl.texi: Update to latest version from FSF. | 8 | * doclicense.texi, gpl.texi: Update to latest version from FSF. |
diff --git a/doc/lispref/customize.texi b/doc/lispref/customize.texi index 1fb8bb3e71a..c8d09760b53 100644 --- a/doc/lispref/customize.texi +++ b/doc/lispref/customize.texi | |||
| @@ -308,8 +308,10 @@ Every @code{defcustom} should specify @code{:group} at least once. | |||
| 308 | When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp | 308 | When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp |
| 309 | mode (@code{eval-defun}), a special feature of @code{eval-defun} | 309 | mode (@code{eval-defun}), a special feature of @code{eval-defun} |
| 310 | arranges to set the variable unconditionally, without testing whether | 310 | arranges to set the variable unconditionally, without testing whether |
| 311 | its value is void. (The same feature applies to @code{defvar}.) | 311 | its value is void. (The same feature applies to @code{defvar}, |
| 312 | @xref{Defining Variables}. | 312 | @pxref{Defining Variables}.) Using @code{eval-defun} on a defcustom |
| 313 | that is already defined calls the @code{:set} function (see below), | ||
| 314 | if there is one. | ||
| 313 | 315 | ||
| 314 | If you put a @code{defcustom} in a pre-loaded Emacs Lisp file | 316 | If you put a @code{defcustom} in a pre-loaded Emacs Lisp file |
| 315 | (@pxref{Building Emacs}), the standard value installed at dump time | 317 | (@pxref{Building Emacs}), the standard value installed at dump time |
| @@ -24,6 +24,11 @@ so we will look at it and add it to the manual. | |||
| 24 | * Installation Changes in Emacs 24.4 | 24 | * Installation Changes in Emacs 24.4 |
| 25 | * Startup Changes in Emacs 24.4 | 25 | * Startup Changes in Emacs 24.4 |
| 26 | * Changes in Emacs 24.4 | 26 | * Changes in Emacs 24.4 |
| 27 | |||
| 28 | +++ | ||
| 29 | ** `eval-defun' on an already defined defcustom calls the :set function, | ||
| 30 | if there is one. | ||
| 31 | |||
| 27 | * Editing Changes in Emacs 24.4 | 32 | * Editing Changes in Emacs 24.4 |
| 28 | 33 | ||
| 29 | 34 | ||
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. |