[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#15718: 24.3.50; `C-M-x' does not work, with `defcustom' inside `when

From: Lars Ingebrigtsen
Subject: bug#15718: 24.3.50; `C-M-x' does not work, with `defcustom' inside `when'
Date: Wed, 14 Aug 2019 19:57:02 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Drew Adams <address@hidden> writes:

> emacs -Q
> (when t
>   (defcustom foo nil
>    "..."
>    :type boolean))
> M-x set-variable foo t
> Put point on foo in the defcustom sexp, and do `C-M-x'.  `foo' is echoed
> in the echo area, giving you the impression that the defcustom was
> reevaluated, reinitializing `foo'.
> C-h v foo ;; => t, not nil.
> Without the `when', i.e., with the `defcustom' at top level, the value
> is nil, as a user would expect.

I think this works as documented:

Evaluate the top-level form containing point, or after point.

If the current defun is actually a call to ‘defvar’ or ‘defcustom’,
evaluating it this way resets the variable using its initial value
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.)

So only if the def* is top-level does the magic DWIM value-setting thing


(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

[Prev in Thread] Current Thread [Next in Thread]