[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d4e9d19: Add a command for redisplay during keyboard macros

From: Lars Ingebrigtsen
Subject: master d4e9d19: Add a command for redisplay during keyboard macros
Date: Fri, 29 Jan 2021 02:01:22 -0500 (EST)

branch: master
commit d4e9d191aeba9076db06857a90649f6fcddc7f3b
Author: Marco Wahl <marcowahlsoft@gmail.com>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Add a command for redisplay during keyboard macros
    * doc/emacs/kmacro.texi (Basic Keyboard Macro): Document it
    * lisp/kmacro.el (kdb-macro-redisplay): New function.
    (kmacro-keymap): Bind it.
 doc/emacs/kmacro.texi |  8 ++++++++
 etc/NEWS              |  3 +++
 lisp/kmacro.el        | 11 +++++++++++
 3 files changed, 22 insertions(+)

diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi
index adb2ab8..e713c6e 100644
--- a/doc/emacs/kmacro.texi
+++ b/doc/emacs/kmacro.texi
@@ -179,6 +179,14 @@ itself counts as the first repetition, since it is 
executed as you
 define it, so @kbd{C-u 4 C-x )} executes the macro immediately 3
 additional times.
+@findex kdb-macro-redisplay
+@kindex C-x C-k Q
+  While executing a long-running keyboard macro, it can sometimes be
+useful to trigger a redisplay (to show how far we've gotten).  The
+@kbd{C-x C-k Q} can be used for this.  As a not very useful example,
+@kbd{C-x ( M-f C-x C-k Q C-x )} will create a macro that will
+redisplay once per iteration when saying @kbd{C-u 42 C-x e}.
 @node Keyboard Macro Ring
 @section The Keyboard Macro Ring
diff --git a/etc/NEWS b/etc/NEWS
index f12c94d..8e233f8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1577,6 +1577,9 @@ This allows mode-specific alterations to how 
`thing-at-point' works.
 ** Miscellaneous
+*** New command `C-x C-k Q' to force redisplay in keyboard macros.
 *** New user option 'remember-diary-regexp'.
diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index bb8dacf..303f38a 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -172,6 +172,7 @@ macro to be executed before appending to it."
     (define-key map "\C-k" 'kmacro-end-or-call-macro-repeat)
     (define-key map "r"    'apply-macro-to-region-lines)
     (define-key map "q"    'kbd-macro-query)  ;; Like C-x q
+    (define-key map "Q"    'kdb-macro-redisplay)
     ;; macro ring
     (define-key map "\C-n" 'kmacro-cycle-ring-next)
@@ -1298,6 +1299,16 @@ To customize possible responses, change the \"bindings\" 
       (setq last-kbd-macro kmacro-step-edit-new-macro))))
+(defun kdb-macro-redisplay ()
+  "Force redisplay during kbd macro execution."
+  (interactive)
+  (or executing-kbd-macro
+      defining-kbd-macro
+      (user-error "Not defining or executing kbd macro"))
+  (when executing-kbd-macro
+    (let ((executing-kbd-macro nil))
+      (redisplay))))
 (provide 'kmacro)
 ;;; kmacro.el ends here

reply via email to

[Prev in Thread] Current Thread [Next in Thread]