GNU bug report logs -
#29334
25.3; compiled commands don't respect special interactive expressions
Previous Next
To reply to this bug, email your comments to 29334 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Fri, 17 Nov 2017 06:18:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Allen Li <vianchielfaura <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 17 Nov 2017 06:18:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Repro:
1. emacs -Q
2. Mark some text in the buffer
3. M-x append-to-buffer RET *scratch* RET
4. C-x ESC ESC
Expected last command:
(append-to-buffer "*scratch*" (region-beginning) (region-end))
Actual last command:
(append-to-buffer "*scratch*" 1 145)
If you then go and re-evaluate append-to-buffer (thus loading the
source version instead of the compiled version, you get
(append-to-buffer "*scratch*" (region-beginning) (region-end))
Thus, it looks like the compiled command doesn't handle special
interactive forms correctly.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Fri, 17 Nov 2017 14:56:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 29334 <at> debbugs.gnu.org (full text, mbox):
> 1. emacs -Q
> 2. Mark some text in the buffer
> 3. M-x append-to-buffer RET *scratch* RET
> 4. C-x ESC ESC
>
> Expected last command:
>
> (append-to-buffer "*scratch*" (region-beginning) (region-end))
>
> Actual last command:
>
> (append-to-buffer "*scratch*" 1 145)
>
> If you then go and re-evaluate append-to-buffer (thus loading the
> source version instead of the compiled version, you get
>
> (append-to-buffer "*scratch*" (region-beginning) (region-end))
>
> Thus, it looks like the compiled command doesn't handle special
> interactive forms correctly.
Yes, thank you! This is something that has bugged me
for a while. This change is actually a regression (or
else on purpose?), introduced in Emacs 24. In all
Emacs releases prior to 24 it works as a user expects.
Dunno whether this bug report might be a duplicate. It
seems unlikely that no one (including me) has reported
this before. It reduces the utility of `C-x ESC ESC'
considerably.
An inexperienced user will likely give up altogether
trying to use such a command with `C-x ESC ESC', if
not give up on `C-x ESC ESC' entirely, through not
fully understanding. And an experienced user has
the annoyance of having to edit the hard-coded values
to get the behavior expected.
bug Marked as found in versions 24.4.
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Tue, 21 Nov 2017 19:16:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Tue, 21 Nov 2017 19:46:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 29334 <at> debbugs.gnu.org (full text, mbox):
Allen Li wrote:
> 1. emacs -Q
> 2. Mark some text in the buffer
> 3. M-x append-to-buffer RET *scratch* RET
> 4. C-x ESC ESC
>
> Expected last command:
>
> (append-to-buffer "*scratch*" (region-beginning) (region-end))
>
> Actual last command:
>
> (append-to-buffer "*scratch*" 1 145)
Bisected to a46481370, our old friend "Use lexical-binding".
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Fri, 24 Nov 2017 03:12:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 29334 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
tags 29334 + patch
quit
Glenn Morris <rgm <at> gnu.org> writes:
> Bisected to a46481370, our old friend "Use lexical-binding".
How about this:
[0001-Fix-command-repetition-with-lexical-binding-Bug-2933.patch (text/x-diff, inline)]
From a8b43e98c592c84957ea304a0dc2d6423af9c5c5 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Thu, 23 Nov 2017 21:57:09 -0500
Subject: [PATCH] Fix command repetition with lexical-binding (Bug#29334)
`call-interactively' relies on analyzing the source of `interactive'
forms in order to preserve arguments like (region-end) in the command
history, rather than just storing the resulting position. However,
the byte-compiler does not preserve the source of the interactive form
when lexical-binding is in effect, because `call-interactively' would
evaluate the form with dynamic binding in that case.
To fix this, change `call-interactively' so that it checks compiled
functions for lexical-binding as well. Then the byte-compiler can
preserve the source of interactive forms regardless of the value of
lexical-binding.
* src/callint.c (Fcall_interactively): Functions compiled with
lexical-binding have their arglist encoded as an integer, use this to
choose the right kind of binding for compiled functions too.
* lisp/emacs-lisp/bytecomp.el (byte-compile-lambda): Preserve the
uncompiled form of the interactive form when lexical-binding is
enabled too.
---
lisp/emacs-lisp/bytecomp.el | 6 +-----
src/callint.c | 4 +++-
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 590db570c5..e16405f09b 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -2823,11 +2823,7 @@ byte-compile-lambda
(while (consp (cdr form))
(setq form (cdr form)))
(setq form (car form)))
- (if (and (eq (car-safe form) 'list)
- ;; The spec is evalled in callint.c in dynamic-scoping
- ;; mode, so just leaving the form unchanged would mean
- ;; it won't be eval'd in the right mode.
- (not lexical-binding))
+ (if (eq (car-safe form) 'list)
nil
(setq int `(interactive ,newform)))))
((cdr int)
diff --git a/src/callint.c b/src/callint.c
index 5d88082e38..48ea9ba7a3 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -356,7 +356,9 @@ DEFUN ("call-interactively", Fcall_interactively, Scall_interactively, 1, 3, 0,
/* Compute the arg values using the user's expression. */
specs = Feval (specs,
CONSP (funval) && EQ (Qclosure, XCAR (funval))
- ? CAR_SAFE (XCDR (funval)) : Qnil);
+ ? CAR_SAFE (XCDR (funval))
+ : COMPILEDP (funval) && INTEGERP (AREF (funval, COMPILED_ARGLIST))
+ ? Qt : Qnil);
if (events != num_input_events || !NILP (record_flag))
{
/* We should record this command on the command history. */
--
2.11.0
Added tag(s) patch.
Request was from
Noam Postavsky <npostavs <at> users.sourceforge.net>
to
control <at> debbugs.gnu.org
.
(Fri, 24 Nov 2017 03:12:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Fri, 24 Nov 2017 08:00:02 GMT)
Full text and
rfc822 format available.
Message #21 received at 29334 <at> debbugs.gnu.org (full text, mbox):
> From: Noam Postavsky <npostavs <at> users.sourceforge.net>
> Date: Thu, 23 Nov 2017 22:11:23 -0500
> Cc: 29334 <at> debbugs.gnu.org, Allen Li <vianchielfaura <at> gmail.com>
>
> > Bisected to a46481370, our old friend "Use lexical-binding".
>
> How about this:
>
> >From a8b43e98c592c84957ea304a0dc2d6423af9c5c5 Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <npostavs <at> gmail.com>
> Date: Thu, 23 Nov 2017 21:57:09 -0500
> Subject: [PATCH] Fix command repetition with lexical-binding (Bug#29334)
>
> `call-interactively' relies on analyzing the source of `interactive'
> forms in order to preserve arguments like (region-end) in the command
> history, rather than just storing the resulting position. However,
> the byte-compiler does not preserve the source of the interactive form
> when lexical-binding is in effect, because `call-interactively' would
> evaluate the form with dynamic binding in that case.
>
> To fix this, change `call-interactively' so that it checks compiled
> functions for lexical-binding as well. Then the byte-compiler can
> preserve the source of interactive forms regardless of the value of
> lexical-binding.
Thanks. If no objections are voiced to this approach, please push it
to the master branch. I think this is too radical for the release
branch.
P.S. Should this change be reflected in the ELisp manual somehow?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Fri, 24 Nov 2017 12:19:01 GMT)
Full text and
rfc822 format available.
Message #24 received at 29334 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
>> To fix this, change `call-interactively' so that it checks compiled
>> functions for lexical-binding as well. Then the byte-compiler can
>> preserve the source of interactive forms regardless of the value of
>> lexical-binding.
>
> Thanks. If no objections are voiced to this approach, please push it
> to the master branch. I think this is too radical for the release
> branch.
Hah, okay, but that was the conservative approach! The radical one
would be resolving this FIXME:
static void
fix_command (Lisp_Object input, Lisp_Object values)
{
/* FIXME: Instead of this ugly hack, we should provide a way for an
interactive spec to return an expression/function that will re-build the
args without user intervention. */
> P.S. Should this change be reflected in the ELisp manual somehow?
I don't see where.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Thu, 04 Jan 2018 02:57:01 GMT)
Full text and
rfc822 format available.
Message #27 received at 29334 <at> debbugs.gnu.org (full text, mbox):
tags 29334 fixed
close 29334 27.1
quit
Noam Postavsky <npostavs <at> users.sourceforge.net> writes:
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> To fix this, change `call-interactively' so that it checks compiled
>>> functions for lexical-binding as well. Then the byte-compiler can
>>> preserve the source of interactive forms regardless of the value of
>>> lexical-binding.
>>
>> Thanks. If no objections are voiced to this approach, please push it
>> to the master branch. I think this is too radical for the release
>> branch.
Pushed to master.
[1: ce48658191]: 2018-01-03 20:51:28 -0500
Fix command repetition with lexical-binding (Bug#29334)
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ce48658191befb7734a7af484e368af5ed8b9447
Added tag(s) fixed.
Request was from
Noam Postavsky <npostavs <at> users.sourceforge.net>
to
control <at> debbugs.gnu.org
.
(Thu, 04 Jan 2018 02:57:02 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 27.1, send any further explanations to
29334 <at> debbugs.gnu.org and Allen Li <vianchielfaura <at> gmail.com>
Request was from
Noam Postavsky <npostavs <at> users.sourceforge.net>
to
control <at> debbugs.gnu.org
.
(Thu, 04 Jan 2018 02:57:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Thu, 04 Jan 2018 05:27:02 GMT)
Full text and
rfc822 format available.
Message #34 received at 29334 <at> debbugs.gnu.org (full text, mbox):
> Yes, thank you! This is something that has bugged me
> for a while. This change is actually a regression (or
> else on purpose?), introduced in Emacs 24.
Indeed. As for the question in parenthesis, yes I consciously decided
to break this "ugly hack" back then, wondering how much time it would
take for people to notice it (and hoping I'd find the time/motivation
to "do it right" in the mean time).
> Hah, okay, but that was the conservative approach! The radical one
> would be resolving this FIXME:
>
> static void
> fix_command (Lisp_Object input, Lisp_Object values)
> {
> /* FIXME: Instead of this ugly hack, we should provide a way for an
> interactive spec to return an expression/function that will re-build the
> args without user intervention. */
E.g. we could allow the interactive spec to return either a list of
argument *values*, or a list of argument *expressions* (and we could
distinguish the two by having the second be a vector instead of a list,
for example).
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Sun, 07 Jan 2018 02:56:01 GMT)
Full text and
rfc822 format available.
Message #37 received at 29334 <at> debbugs.gnu.org (full text, mbox):
notfixed 29334 27.1
reopen 29334
tag 29334 - fixed patch
quit
Noam Postavsky <npostavs <at> users.sourceforge.net> writes:
> Pushed to master.
>
> [1: ce48658191]: 2018-01-03 20:51:28 -0500
> Fix command repetition with lexical-binding (Bug#29334)
> https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=ce48658191befb7734a7af484e368af5ed8b9447
Turns out this doesn't actually work, so I've reverted it.
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=29988#11
bug No longer marked as fixed in versions 27.1.
Request was from
Noam Postavsky <npostavs <at> users.sourceforge.net>
to
control <at> debbugs.gnu.org
.
(Sun, 07 Jan 2018 02:56:02 GMT)
Full text and
rfc822 format available.
Did not alter fixed versions and reopened.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 07 Jan 2018 02:56:02 GMT)
Full text and
rfc822 format available.
Removed tag(s) patch and fixed.
Request was from
Noam Postavsky <npostavs <at> users.sourceforge.net>
to
control <at> debbugs.gnu.org
.
(Sun, 07 Jan 2018 02:56:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#29334
; Package
emacs
.
(Thu, 10 Feb 2022 07:57:02 GMT)
Full text and
rfc822 format available.
Message #46 received at 29334 <at> debbugs.gnu.org (full text, mbox):
Allen Li <vianchielfaura <at> gmail.com> writes:
> 1. emacs -Q
> 2. Mark some text in the buffer
> 3. M-x append-to-buffer RET *scratch* RET
> 4. C-x ESC ESC
>
> Expected last command:
>
> (append-to-buffer "*scratch*" (region-beginning) (region-end))
>
> Actual last command:
>
> (append-to-buffer "*scratch*" 1 145)
This bug is still present in Emacs 29.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) confirmed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 10 Feb 2022 07:58:02 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 130 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.