summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Wahl <marcowahlsoft@gmail.com>2021-01-29 08:01:12 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2021-01-29 08:01:12 +0100
commitd4e9d191aeba9076db06857a90649f6fcddc7f3b (patch)
tree6a95d2ac53d149920ce4e2a900d42829074d3a29
parent1275dc4711af77c9c223063dcd149d782d497463 (diff)
downloademacs-d4e9d191aeba9076db06857a90649f6fcddc7f3b.tar.gz
Add a command for redisplay during keyboard macros
* doc/emacs/kmacro.texi (Basic Keyboard Macro): Document it (bug#39252). * lisp/kmacro.el (kdb-macro-redisplay): New function. (kmacro-keymap): Bind it.
-rw-r--r--doc/emacs/kmacro.texi8
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/kmacro.el11
3 files changed, 22 insertions, 0 deletions
diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi
index adb2ab8d561..e713c6ef8c0 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 f12c94d6491..8e233f8f196 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 bb8dacf4f48..303f38a59b6 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\" in
(kmacro-push-ring)
(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