GNU bug report logs - #70137
30.0.50; pp-macroexpand-last-sexp buffers should turn lexical binding on

Previous Next

Package: emacs;

Reported by: Augusto Stoffel <arstoffel <at> gmail.com>

Date: Tue, 2 Apr 2024 06:02:02 UTC

Severity: normal

Found in version 30.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

To reply to this bug, email your comments to 70137 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#70137; Package emacs. (Tue, 02 Apr 2024 06:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Augusto Stoffel <arstoffel <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 02 Apr 2024 06:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; pp-macroexpand-last-sexp buffers should turn lexical
 binding on
Date: Tue, 02 Apr 2024 08:01:18 +0200
If you call pp-macroexpand-last-sexp in a buffer with lexical binding,
the resulting *Pp Macroexpand Output* buffer has lexical binding turned
off.

The problem with this is that if you now go the *Pp Macroexpand Output*
buffer and call pp-macroexpand-last-sexp again, this second macro
expansion step may not reflect what would happen in the original buffer;
I don't recall an example, but some macros expand differently in the two
variable scoping modes.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70137; Package emacs. (Tue, 02 Apr 2024 12:01:01 GMT) Full text and rfc822 format available.

Message #8 received at 70137 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Augusto Stoffel <arstoffel <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 70137 <at> debbugs.gnu.org
Subject: Re: bug#70137: 30.0.50;
 pp-macroexpand-last-sexp buffers should turn lexical binding on
Date: Tue, 02 Apr 2024 14:59:21 +0300
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Date: Tue, 02 Apr 2024 08:01:18 +0200
> 
> If you call pp-macroexpand-last-sexp in a buffer with lexical binding,
> the resulting *Pp Macroexpand Output* buffer has lexical binding turned
> off.
> 
> The problem with this is that if you now go the *Pp Macroexpand Output*
> buffer and call pp-macroexpand-last-sexp again, this second macro
> expansion step may not reflect what would happen in the original buffer;
> I don't recall an example, but some macros expand differently in the two
> variable scoping modes.

Adding Stefan.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70137; Package emacs. (Tue, 02 Apr 2024 20:56:03 GMT) Full text and rfc822 format available.

Message #11 received at 70137 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 70137 <at> debbugs.gnu.org
Subject: Re: bug#70137: 30.0.50; pp-macroexpand-last-sexp buffers should
 turn lexical binding on
Date: Tue, 02 Apr 2024 22:56:07 +0200
Augusto Stoffel <arstoffel <at> gmail.com> writes:

> If you call pp-macroexpand-last-sexp in a buffer with lexical binding,
> the resulting *Pp Macroexpand Output* buffer has lexical binding turned
> off.

Same as with any other displayed pp output buffer btw, or any temp
buffer.  All inherit the global lexical-binding -> nil binding.  Not
ideal indeed.

Michael.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70137; Package emacs. (Wed, 10 Apr 2024 21:43:02 GMT) Full text and rfc822 format available.

Message #14 received at 70137 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 70137 <at> debbugs.gnu.org
Subject: Re: bug#70137: 30.0.50; pp-macroexpand-last-sexp buffers should
 turn lexical binding on
Date: Wed, 10 Apr 2024 17:39:43 -0400
> If you call pp-macroexpand-last-sexp in a buffer with lexical binding,
> the resulting *Pp Macroexpand Output* buffer has lexical binding turned off.
>
> The problem with this is that if you now go the *Pp Macroexpand Output*
> buffer and call pp-macroexpand-last-sexp again, this second macro
> expansion step may not reflect what would happen in the original buffer;
> I don't recall an example, but some macros expand differently in the two
> variable scoping modes.

Indeed.  `dolist` and `dotimes` were such examples (tho nowadays they
return the same result).  Most other examples I can think of signal
an error when used without lexical binding.  There are a few more subtle
examples where the macro tests `macroexp--dynamic-variable-p`.

Do you happen to have a patch to propagate the value of
`lexical-binding` to the new buffer?


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70137; Package emacs. (Sun, 14 Apr 2024 07:43:03 GMT) Full text and rfc822 format available.

Message #17 received at 70137 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 70137 <at> debbugs.gnu.org
Subject: Re: bug#70137: 30.0.50; pp-macroexpand-last-sexp buffers should
 turn lexical binding on
Date: Sun, 14 Apr 2024 09:42:12 +0200
[Message part 1 (text/plain, inline)]
On Wed, 10 Apr 2024 at 17:39, Stefan Monnier wrote:

> Do you happen to have a patch to propagate the value of
> `lexical-binding` to the new buffer?

This would be the patch to propagate the lexical binding value.  (A less
magical alternative I guess would be to just always set it to t.  Who
needs to debug non-lexical code these days anyway?)

It doesn't cover the new `pp-insert-short-sexp'.  Here again setting
lexical-binding=t by default might be okay.

[0001-Propagate-lexical-binding-value-to-pp-buffers.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70137; Package emacs. (Wed, 17 Apr 2024 17:47:02 GMT) Full text and rfc822 format available.

Message #20 received at 70137 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 70137 <at> debbugs.gnu.org
Subject: Re: bug#70137: 30.0.50; pp-macroexpand-last-sexp buffers should
 turn lexical binding on
Date: Wed, 17 Apr 2024 13:43:07 -0400
> This would be the patch to propagate the lexical binding value.

LGTM.  Can you install it, or do you want me to do it?

> (A less magical alternative I guess would be to just always set it to
> t.  Who needs to debug non-lexical code these days anyway?)

Not sure why you think it'd be less magical.  🙂

> It doesn't cover the new `pp-insert-short-sexp'.  Here again setting
> lexical-binding=t by default might be okay.

`pp-insert-short-sexp` should use `lisp-data-mode` rather than
`emacs-lisp-mode` anyway.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70137; Package emacs. (Wed, 17 Apr 2024 18:56:01 GMT) Full text and rfc822 format available.

Message #23 received at 70137 <at> debbugs.gnu.org (full text, mbox):

From: Augusto Stoffel <arstoffel <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 70137 <at> debbugs.gnu.org
Subject: Re: bug#70137: 30.0.50; pp-macroexpand-last-sexp buffers should
 turn lexical binding on
Date: Wed, 17 Apr 2024 20:55:03 +0200
On Wed, 17 Apr 2024 at 13:43, Stefan Monnier wrote:

> LGTM.  Can you install it, or do you want me to do it?

I don't have commit access to the repo and I absolutely don't mind the
status quo :-).




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Wed, 17 Apr 2024 21:07:01 GMT) Full text and rfc822 format available.

Notification sent to Augusto Stoffel <arstoffel <at> gmail.com>:
bug acknowledged by developer. (Wed, 17 Apr 2024 21:07:02 GMT) Full text and rfc822 format available.

Message #28 received at 70137-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Augusto Stoffel <arstoffel <at> gmail.com>
Cc: 70137-done <at> debbugs.gnu.org
Subject: Re: bug#70137: 30.0.50; pp-macroexpand-last-sexp buffers should
 turn lexical binding on
Date: Wed, 17 Apr 2024 17:03:08 -0400
Thanks, pushed to `master`, closing,


        Stefan





This bug report was last modified 16 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.