From: Stefan Monnier Date: Wed, 28 Aug 2013 21:19:54 +0000 (-0400) Subject: * lisp/simple.el (repeat-complex-command--called-interactively-skip): X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1686^2~71 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f663baa7dd99e6ea45120175d5ecd3514c7e33bc;p=emacs.git * lisp/simple.el (repeat-complex-command--called-interactively-skip): New function. (repeat-complex-command): Use it. Fixes: debbugs:14136 --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bb802db3b1b..690aca9540f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2013-08-28 Stefan Monnier + * 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) diff --git a/lisp/simple.el b/lisp/simple.el index 6825c41becc..c5e5b313b7b 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -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 ()