mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-24 06:20:43 -08:00
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
This commit is contained in:
parent
858aab4c02
commit
c6c08d3f8f
5 changed files with 40 additions and 15 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
2012-12-09 Glenn Morris <rgm@gnu.org>
|
||||||
|
|
||||||
|
* customize.texi (Variable Definitions): Mention eval-defun
|
||||||
|
on a defcustom calls the :set function when appropriate.
|
||||||
|
|
||||||
2012-12-06 Paul Eggert <eggert@cs.ucla.edu>
|
2012-12-06 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
* doclicense.texi, gpl.texi: Update to latest version from FSF.
|
* doclicense.texi, gpl.texi: Update to latest version from FSF.
|
||||||
|
|
|
||||||
|
|
@ -308,8 +308,10 @@ Every @code{defcustom} should specify @code{:group} at least once.
|
||||||
When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp
|
When you evaluate a @code{defcustom} form with @kbd{C-M-x} in Emacs Lisp
|
||||||
mode (@code{eval-defun}), a special feature of @code{eval-defun}
|
mode (@code{eval-defun}), a special feature of @code{eval-defun}
|
||||||
arranges to set the variable unconditionally, without testing whether
|
arranges to set the variable unconditionally, without testing whether
|
||||||
its value is void. (The same feature applies to @code{defvar}.)
|
its value is void. (The same feature applies to @code{defvar},
|
||||||
@xref{Defining Variables}.
|
@pxref{Defining Variables}.) Using @code{eval-defun} on a defcustom
|
||||||
|
that is already defined calls the @code{:set} function (see below),
|
||||||
|
if there is one.
|
||||||
|
|
||||||
If you put a @code{defcustom} in a pre-loaded Emacs Lisp file
|
If you put a @code{defcustom} in a pre-loaded Emacs Lisp file
|
||||||
(@pxref{Building Emacs}), the standard value installed at dump time
|
(@pxref{Building Emacs}), the standard value installed at dump time
|
||||||
|
|
|
||||||
5
etc/NEWS
5
etc/NEWS
|
|
@ -24,6 +24,11 @@ so we will look at it and add it to the manual.
|
||||||
* Installation Changes in Emacs 24.4
|
* Installation Changes in Emacs 24.4
|
||||||
* Startup Changes in Emacs 24.4
|
* Startup Changes in Emacs 24.4
|
||||||
* Changes in Emacs 24.4
|
* Changes in Emacs 24.4
|
||||||
|
|
||||||
|
+++
|
||||||
|
** `eval-defun' on an already defined defcustom calls the :set function,
|
||||||
|
if there is one.
|
||||||
|
|
||||||
* Editing Changes in Emacs 24.4
|
* Editing Changes in Emacs 24.4
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
2012-12-09 Glenn Morris <rgm@gnu.org>
|
||||||
|
|
||||||
|
* emacs-lisp/lisp-mode.el (eval-defun-1): Doc fix.
|
||||||
|
Respect a defcustom's :set function, if appropriate. (Bug#109)
|
||||||
|
(eval-defun): Doc fix.
|
||||||
|
|
||||||
2012-12-08 Juri Linkov <juri@jurta.org>
|
2012-12-08 Juri Linkov <juri@jurta.org>
|
||||||
|
|
||||||
* info.el (Info-copy-current-node-name, Info-breadcrumbs)
|
* info.el (Info-copy-current-node-name, Info-breadcrumbs)
|
||||||
|
|
|
||||||
|
|
@ -830,6 +830,7 @@ this command arranges for all errors to enter the debugger."
|
||||||
(defun eval-defun-1 (form)
|
(defun eval-defun-1 (form)
|
||||||
"Treat some expressions specially.
|
"Treat some expressions specially.
|
||||||
Reset the `defvar' and `defcustom' variables to the initial value.
|
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."
|
Reinitialize the face according to the `defface' specification."
|
||||||
;; The code in edebug-defun should be consistent with this, but not
|
;; The code in edebug-defun should be consistent with this, but not
|
||||||
;; the same, since this gets a macroexpanded form.
|
;; 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.
|
;; `custom-declare-variable' with a quoted value arg.
|
||||||
((and (eq (car form) 'custom-declare-variable)
|
((and (eq (car form) 'custom-declare-variable)
|
||||||
(default-boundp (eval (nth 1 form) lexical-binding)))
|
(default-boundp (eval (nth 1 form) lexical-binding)))
|
||||||
;; Force variable to be bound.
|
;; Force variable to be bound, using :set function if specified.
|
||||||
(set-default (eval (nth 1 form) lexical-binding)
|
(let ((setfunc (memq :set form)))
|
||||||
;; The second arg is an expression that evaluates to
|
(when setfunc
|
||||||
;; an expression. The second evaluation is the one
|
(setq setfunc (car-safe (cdr-safe setfunc)))
|
||||||
;; normally performed not be normal execution but by
|
(or (functionp setfunc) (setq setfunc nil)))
|
||||||
;; custom-initialize-set (for example), which does not
|
(funcall (or setfunc 'set-default)
|
||||||
;; use lexical-binding.
|
(eval (nth 1 form) lexical-binding)
|
||||||
(eval (eval (nth 2 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)
|
form)
|
||||||
;; `defface' is macroexpanded to `custom-declare-face'.
|
;; `defface' is macroexpanded to `custom-declare-face'.
|
||||||
((eq (car form) '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',
|
If the current defun is actually a call to `defvar' or `defcustom',
|
||||||
evaluating it this way resets the variable using its initial value
|
evaluating it this way resets the variable using its initial value
|
||||||
expression even if the variable already has some other value.
|
expression (using the defcustom's :set function if there is one), even
|
||||||
\(Normally `defvar' and `defcustom' do not alter the value if there
|
if the variable already has some other value. \(Normally `defvar' and
|
||||||
already is one.) In an analogous way, evaluating a `defface'
|
`defcustom' do not alter the value if there already is one.) In an
|
||||||
overrides any customizations of the face, so that it becomes
|
analogous way, evaluating a `defface' overrides any customizations of
|
||||||
defined exactly as the `defface' expression says.
|
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,
|
If `eval-expression-debug-on-error' is non-nil, which is the default,
|
||||||
this command arranges for all errors to enter the debugger.
|
this command arranges for all errors to enter the debugger.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue