From: Michael Heerdegen <michael_heerdegen@web.de>
To: "Gerd Möllmann" <gerd.moellmann@gmail.com>
Cc: 65209@debbugs.gnu.org
Subject: bug#65209: 30.0.50; Unexpected behaviour of setq-local
Date: Fri, 11 Aug 2023 07:53:18 +0200 [thread overview]
Message-ID: <87h6p6dt0x.fsf@web.de> (raw)
In-Reply-To: <2c06d6df-dd6d-78c4-f4dd-44cac8d95d84@gmail.com> ("Gerd Möllmann"'s message of "Fri, 11 Aug 2023 06:56:01 +0200")
Gerd Möllmann <gerd.moellmann@gmail.com> writes:
> That's right, but here's what the docs say about setq-local:
>
> -- Macro: setq-local &rest pairs
> PAIRS is a list of variable and value pairs. This macro creates a
> buffer-local binding in the current buffer for each of the
> variables, and gives them a buffer-local value. It is equivalent
> to calling ‘make-local-variable’ followed by ‘setq’ for each of the
> variables.
>
> In my first example, setq-local doesn't create a buffer-local
> binding. In the second example, it doesn't set a buffer-local value.
> So setq-local doesn't what the first sentence of the doc says it does.
I think it does - it's only that `let' restores the old value.
>
> The second sentence of the doc says something quite different than the
> first sentence because setq in the presence of a let-binding of course
> sets the value of the let-binding.
I don't think this is what is happening. E.g.
#+begin_src emacs-lisp
(progn
(defvar my-var :default-value)
(let ((my-var :let-value))
(make-local-variable 'my-var)
(setq my-var :buffer-local-new))
(list my-var (local-variable-p 'my-var))) ;; (:buffer-local-new t)
#+end_src
`setq' sets the buffer local binding, not the global value the `let'
binding refers to.
> I mean, the let-binding which changes the behaviour of
> lisp-interaction-mode in my case could be anywhere. It's kind of like
> a spooky action at a distance.
A different perspective on your recipe could also be: it changes the
value of a variable that controls evaluation of a buffer while
evaluating the contents of the buffer. Probably not a good idea.
> Good luck debugging something like that.
The same can happen if you `setq' a global binding that happens to be
undone by a surrounding `let'. Or that is `setq'd again by other code.
Michael.
next prev parent reply other threads:[~2023-08-11 5:53 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 13:50 bug#65209: 30.0.50; Unexpected behaviour of setq-local Gerd Möllmann
2023-08-10 14:00 ` Eli Zaretskii
2023-08-11 0:17 ` Michael Heerdegen
2023-08-11 4:56 ` Gerd Möllmann
2023-08-11 5:53 ` Michael Heerdegen [this message]
2023-08-11 8:17 ` Gerd Möllmann
2023-08-11 11:09 ` Eli Zaretskii
2023-08-11 11:34 ` Gerd Möllmann
2023-08-11 11:36 ` Eli Zaretskii
2023-08-13 4:16 ` Michael Heerdegen
2023-08-13 5:53 ` Eli Zaretskii
2023-08-11 14:58 ` Drew Adams
2023-08-13 16:43 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-13 19:51 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-14 3:24 ` Michael Heerdegen
2023-08-14 4:05 ` Gerd Möllmann
2023-08-18 23:24 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-20 4:43 ` Michael Heerdegen
2023-08-20 6:49 ` Eli Zaretskii
2023-08-22 3:09 ` Michael Heerdegen
2023-08-22 10:56 ` Eli Zaretskii
2023-08-23 3:47 ` Michael Heerdegen
2023-08-23 11:39 ` Eli Zaretskii
2023-08-23 12:51 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-24 1:06 ` Michael Heerdegen
2023-08-24 5:22 ` Eli Zaretskii
2023-08-26 2:09 ` Michael Heerdegen
2023-08-26 6:02 ` Eli Zaretskii
2023-08-26 14:25 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-27 4:19 ` Michael Heerdegen
2023-08-24 3:31 ` Michael Heerdegen
2023-08-24 5:35 ` Eli Zaretskii
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=87h6p6dt0x.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=65209@debbugs.gnu.org \
--cc=gerd.moellmann@gmail.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).