GNU bug report logs -
#77883
31.0.50; C-c C-e in *scratch* generates a missing lexical binding cookie warning
Previous Next
To reply to this bug, email your comments to 77883 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 02:37:09 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Sean Whitton <spwhitton <at> spwhitton.name>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 18 Apr 2025 02:37:10 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello,
Found another case.
*scratch* should probably remain under the dynamic binding dialect of
Emacs Lisp until and unless we switch the default.
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 10:50:04 GMT)
Full text and
rfc822 format available.
Message #8 received at 77883 <at> debbugs.gnu.org (full text, mbox):
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Date: Fri, 18 Apr 2025 10:35:42 +0800
>
> Found another case.
IMO, it's a bug, because "C-x C-e" doesn't generate any such warnings,
and lexical-binding is t in *scratch* anyway.
> *scratch* should probably remain under the dynamic binding dialect of
> Emacs Lisp until and unless we switch the default.
I think we intentionally decided to switch to t, and I don't see a
reason to revert that decision. Please provide a rationale for your
suggestion, because without that there's no way of reasoning about
this.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 11:12:05 GMT)
Full text and
rfc822 format available.
Message #11 received at 77883 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> IMO, it's a bug, because "C-x C-e" doesn't generate any such warnings,
> and lexical-binding is t in *scratch* anyway.
I agree it is a bug.
C-c C-e calls `eval-buffer' which "ignores the current value of the
`lexical-binding' variable. Instead it will heed any
-*- lexical-binding: t -*- settings in the buffer, and if there is no such
setting, the buffer will be evaluated without lexical binding."
Not good in this case.
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 11:38:03 GMT)
Full text and
rfc822 format available.
Message #14 received at 77883 <at> debbugs.gnu.org (full text, mbox):
Hello,
On Fri 18 Apr 2025 at 01:49pm +03, Eli Zaretskii wrote:
>> From: Sean Whitton <spwhitton <at> spwhitton.name>
>> Date: Fri, 18 Apr 2025 10:35:42 +0800
>>
>> Found another case.
>
> IMO, it's a bug, because "C-x C-e" doesn't generate any such warnings,
> and lexical-binding is t in *scratch* anyway.
Right.
>> *scratch* should probably remain under the dynamic binding dialect of
>> Emacs Lisp until and unless we switch the default.
>
> I think we intentionally decided to switch to t, and I don't see a
> reason to revert that decision.
Oh, me neither, I had forgotten/missed that discussion.
What I really meant is that we shouldn't be adding a lexical binding
cookie to the file.
--
Sean Whitton
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 12:15:04 GMT)
Full text and
rfc822 format available.
Message #17 received at 77883 <at> debbugs.gnu.org (full text, mbox):
> From: Michael Heerdegen <michael_heerdegen <at> web.de>
> Cc: Sean Whitton <spwhitton <at> spwhitton.name>, Stefan Monnier
> <monnier <at> iro.umontreal.ca>, 77883 <at> debbugs.gnu.org
> Date: Fri, 18 Apr 2025 13:12:48 +0200
>
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
> > IMO, it's a bug, because "C-x C-e" doesn't generate any such warnings,
> > and lexical-binding is t in *scratch* anyway.
>
> I agree it is a bug.
>
> C-c C-e calls `eval-buffer' which "ignores the current value of the
> `lexical-binding' variable. Instead it will heed any
> -*- lexical-binding: t -*- settings in the buffer, and if there is no such
> setting, the buffer will be evaluated without lexical binding."
>
> Not good in this case.
Is it good in any other case?
I mean, what's the logic behind ignoring the current value of
lexical-binding, but heeding the cookie? let alone defaulting to
dynamic binding if there's no cookie? If the reason is backward
compatibility, I think I'd like to see the details: where would
changing this cause problems?
And note that this aspect of the eval-buffer's behavior is not
documented in the ELisp manual, which is also not a good thing.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 12:22:03 GMT)
Full text and
rfc822 format available.
Message #20 received at 77883 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> I mean, what's the logic behind ignoring the current value of
> lexical-binding, but heeding the cookie? let alone defaulting to
> dynamic binding if there's no cookie? If the reason is backward
> compatibility, I think I'd like to see the details: where would
> changing this cause problems?
>
> And note that this aspect of the eval-buffer's behavior is not
> documented in the ELisp manual, which is also not a good thing.
Indeed. This looks like an anachronism to me. But I would have to
investigate how the current situation evolved. Unless someone else
remembers...
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 13:11:05 GMT)
Full text and
rfc822 format available.
Message #23 received at 77883 <at> debbugs.gnu.org (full text, mbox):
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> Indeed. This looks like an anachronism to me. But I would have to
> investigate how the current situation evolved. Unless someone else
> remembers...
See Bug#20139. That was quite a while ago (2019) and just documented
the status quo (and in the docstring only) at that point of time because
someone had been surprised by the behavior.
Looks like `eval-buffer' has just been completely forgotten in the
transition to making lexical binding the default.
Michael.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 13:17:03 GMT)
Full text and
rfc822 format available.
Message #26 received at 77883 <at> debbugs.gnu.org (full text, mbox):
>> C-c C-e calls `eval-buffer' which "ignores the current value of the
>> `lexical-binding' variable. Instead it will heed any
>> -*- lexical-binding: t -*- settings in the buffer, and if there is no such
>> setting, the buffer will be evaluated without lexical binding."
>>
>> Not good in this case.
>
> Is it good in any other case?
>
> I mean, what's the logic behind ignoring the current value of
> lexical-binding, but heeding the cookie? let alone defaulting to
> dynamic binding if there's no cookie? If the reason is backward
> compatibility, I think I'd like to see the details: where would
> changing this cause problems?
I can't remember how we ended up with this, but I strongly suspect it
has to do with the use of `eval-buffer` in `load-with-code-conversion`,
which is the most common use of `eval-buffer` (in dynamic counts, not
static counts, of course).
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 13:47:06 GMT)
Full text and
rfc822 format available.
Message #29 received at 77883 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, spwhitton <at> spwhitton.name,
> 77883 <at> debbugs.gnu.org
> Date: Fri, 18 Apr 2025 09:16:18 -0400
>
> >> C-c C-e calls `eval-buffer' which "ignores the current value of the
> >> `lexical-binding' variable. Instead it will heed any
> >> -*- lexical-binding: t -*- settings in the buffer, and if there is no such
> >> setting, the buffer will be evaluated without lexical binding."
> >>
> >> Not good in this case.
> >
> > Is it good in any other case?
> >
> > I mean, what's the logic behind ignoring the current value of
> > lexical-binding, but heeding the cookie? let alone defaulting to
> > dynamic binding if there's no cookie? If the reason is backward
> > compatibility, I think I'd like to see the details: where would
> > changing this cause problems?
>
> I can't remember how we ended up with this, but I strongly suspect it
> has to do with the use of `eval-buffer` in `load-with-code-conversion`,
> which is the most common use of `eval-buffer` (in dynamic counts, not
> static counts, of course).
If load-with-code-conversion is the only case where this is needed, we
could do that locally in load-with-code-conversion, right? I mean,
there's no need to "punish" all the users of eval-buffer for that
single use. Right?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#77883
; Package
emacs
.
(Fri, 18 Apr 2025 15:37:05 GMT)
Full text and
rfc822 format available.
Message #32 received at 77883 <at> debbugs.gnu.org (full text, mbox):
> If load-with-code-conversion is the only case where this is needed, we
> could do that locally in load-with-code-conversion, right? I mean,
> there's no need to "punish" all the users of eval-buffer for that
> single use. Right?
I guess someone should look at the other uses of `eval-buffer` to figure
out if that's the case.
Another approach might be to check if `lexical-binding` is set
buffer-locally and if so to obey it without even checking the
`lexical-binding` cookie.
Stefan
This bug report was last modified 5 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.