unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Drew Adams <drew.adams@oracle.com>
Cc: 15718@debbugs.gnu.org
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	[thread overview]
Message-ID: <877e7f5e69.fsf@mouse.gnus.org> (raw)
In-Reply-To: <07396814-cb70-42aa-b3e1-a3c4449ad43b@default> (Drew Adams's message of "Fri, 25 Oct 2013 08:44:44 -0700 (PDT)")

Drew Adams <drew.adams@oracle.com> 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
happen.

Closing.

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





  reply	other threads:[~2019-08-15  2:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25 15:44 bug#15718: 24.3.50; `C-M-x' does not work, with `defcustom' inside `when' Drew Adams
2019-08-15  2:57 ` Lars Ingebrigtsen [this message]
2019-08-15  4:41   ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877e7f5e69.fsf@mouse.gnus.org \
    --to=larsi@gnus.org \
    --cc=15718@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).