unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Glenn Morris <rgm@gnu.org>
Cc: 29334@debbugs.gnu.org, Allen Li <vianchielfaura@gmail.com>
Subject: bug#29334: 25.3; compiled commands don't respect special interactive expressions
Date: Thu, 23 Nov 2017 22:11:23 -0500	[thread overview]
Message-ID: <87efooz7z8.fsf@users.sourceforge.net> (raw)
In-Reply-To: <h4o9nvl8kk.fsf@fencepost.gnu.org> (Glenn Morris's message of "Tue, 21 Nov 2017 14:45:31 -0500")

[-- Attachment #1: Type: text/plain, Size: 142 bytes --]

tags 29334 + patch
quit

Glenn Morris <rgm@gnu.org> writes:

> Bisected to a46481370, our old friend "Use lexical-binding".

How about this:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 2783 bytes --]

From a8b43e98c592c84957ea304a0dc2d6423af9c5c5 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@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


  reply	other threads:[~2017-11-24  3:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17  6:17 bug#29334: 25.3; compiled commands don't respect special interactive expressions Allen Li
2017-11-17 14:55 ` Drew Adams
2018-01-04  5:25   ` Stefan Monnier
2017-11-21 19:45 ` Glenn Morris
2017-11-24  3:11   ` Noam Postavsky [this message]
2017-11-24  7:58     ` Eli Zaretskii
2017-11-24 12:17       ` Noam Postavsky
2018-01-04  2:56         ` Noam Postavsky
2018-01-07  2:55           ` Noam Postavsky
2022-02-10  7:56 ` Lars Ingebrigtsen

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=87efooz7z8.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=29334@debbugs.gnu.org \
    --cc=rgm@gnu.org \
    --cc=vianchielfaura@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).