]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix command repetition with lexical-binding (Bug#29334)
authorNoam Postavsky <npostavs@gmail.com>
Fri, 24 Nov 2017 02:57:09 +0000 (21:57 -0500)
committerNoam Postavsky <npostavs@gmail.com>
Thu, 4 Jan 2018 01:51:28 +0000 (20:51 -0500)
`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
src/callint.c

index 2f5f9f8c0544915353b9a7337a68a48353dbdfad..564aac2fc6a526b5a74a16bd22a95ab8b7ed5208 100644 (file)
@@ -2839,11 +2839,7 @@ for symbols generated by the byte compiler itself."
                 (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)
index c713e08d4d4d595507170ce61fda957db35417aa..dcda0bcf7a0272a297c160a74a9ba3c312d09a5e 100644 (file)
@@ -357,7 +357,9 @@ invoke it.  If KEYS is omitted or nil, the return value of
       /* 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.  */