From: Marco Wahl Date: Fri, 29 Jan 2021 07:01:12 +0000 (+0100) Subject: Add a command for redisplay during keyboard macros X-Git-Tag: emacs-28.0.90~4050 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d4e9d191aeba9076db06857a90649f6fcddc7f3b;p=emacs.git 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. --- 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