* lisp/simple.el (repeat-complex-command--called-interactively-skip):
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 28 Aug 2013 21:19:54 +0000 (17:19 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 28 Aug 2013 21:19:54 +0000 (17:19 -0400)
New function.
(repeat-complex-command): Use it.

Fixes: debbugs:14136

lisp/ChangeLog
lisp/simple.el

index bb802db..690aca9 100644 (file)
@@ -1,5 +1,9 @@
 2013-08-28  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * simple.el (repeat-complex-command--called-interactively-skip):
+       New function.
+       (repeat-complex-command): Use it (bug#14136).
+
        * progmodes/cc-mode.el: Minor cleanup of var declarations.
        (c-define-abbrev-table): Add `doc' argument.
        (c-mode-abbrev-table, c++-mode-abbrev-table)
index 6825c41..c5e5b31 100644 (file)
@@ -1404,11 +1404,25 @@ to get different commands to edit and resubmit."
          ;; add it to the history.
          (or (equal newcmd (car command-history))
              (setq command-history (cons newcmd command-history)))
-         (eval newcmd))
+          (unwind-protect
+              (progn
+                ;; Trick called-interactively-p into thinking that `newcmd' is
+                ;; an interactive call (bug#14136).
+                (add-hook 'called-interactively-p-functions
+                          #'repeat-complex-command--called-interactively-skip)
+                (eval newcmd))
+            (remove-hook 'called-interactively-p-functions
+                         #'repeat-complex-command--called-interactively-skip)))
       (if command-history
          (error "Argument %d is beyond length of command history" arg)
        (error "There are no previous complex commands to repeat")))))
 
+(defun repeat-complex-command--called-interactively-skip (i _frame1 frame2)
+  (and (eq 'eval (cadr frame2))
+       (eq 'repeat-complex-command
+           (cadr (backtrace-frame i #'called-interactively-p)))
+       1))
+
 (defvar extended-command-history nil)
 
 (defun read-extended-command ()