File: repeat.el.html
Sometimes the fastest way to get something done is just to lean on a key;
moving forward through a series of words by leaning on M-f is an example.
But 'forward-page is orthodoxly bound to C-x ], so moving forward through
several pages requires
Loop until desired page is reached:
Hold down control key with left pinkie.
Tap <x>.
Lift left pinkie off control key.
Tap <]>.
This is a pain in the ass.
This package defines a command that repeats the preceding command, whatever that was, including its arguments, whatever they were. This command is connected to the key C-x z. To repeat the previous command once, type C-x z. To repeat it a second time immediately after, type just z. By typing z again and again, you can repeat the command over and over.
This works correctly inside a keyboard macro as far as recording and
playback go, but edit-kbd-macro gets it wrong. That shouldn't really
matter; if you need to edit something like
C-x ] ;; forward-page
C-x z ;; repeat
zz ;; self-insert-command * 2
C-x ;; Control-X-prefix
you can just kill the bogus final 2 lines, then duplicate the repeat line
as many times as it's really needed. Also, edit-kbd-macro works
correctly if repeat is invoked through a rebinding to a single keystroke
and the global variable repeat-on-final-keystroke is set to a value
that doesn't include that keystroke. For example, the lines
(keymap-global-set "C-z" #'repeat)
(setopt repeat-on-final-keystroke "z")
in your .emacs would allow edit-kbd-macro to work correctly when C-z was
used in a keyboard macro to invoke repeat, but would still allow C-x z
to be used for repeat elsewhere. The real reason for documenting this
isn't that anybody would need it for the edit-kbd-macro problem, but
that there might be other unexpected ramifications of re-executing on
repetitions of the final keystroke, and this shows how to do workarounds.
If the preceding command had a prefix argument, that argument is applied to the repeat command, unless the repeat command is given a new prefix argument, in which case it applies that new prefix argument to the preceding command. This means a key sequence like C-u - C-x C-t can be repeated. (It shoves the preceding line upward in the buffer.)
Here are some other key sequences with which repeat might be useful:
C-u - C-t [shove preceding character backward in line]
C-u - M-t [shove preceding word backward in sentence]
C-x ^ enlarge-window [one line] (assuming frame has > 1 window)
C-u - C-x ^ [shrink window one line]
C-x ` next-error
C-u - C-x ` [previous error]
C-x DEL backward-kill-sentence
C-x e call-last-kbd-macro
C-x r i insert-register
C-x r t string-rectangle
C-x TAB indent-rigidly [one character]
C-u - C-x TAB [outdent rigidly one character]
C-x { shrink-window-horizontally
C-x } enlarge-window-horizontally
Defined variables (18)
repeat--prev-mb | Previous minibuffer state. |
repeat--transient-exitfun | Function returned by ‘set-transient-map’. |
repeat-check-key | Whether to check that the last key exists in the repeat map. |
repeat-echo-function | Function to display a hint about available keys. |
repeat-echo-mode-line-string | String displayed in the mode line in repeating mode. |
repeat-exit-key | Key that stops the modal repeating of keys in sequence. |
repeat-exit-timeout | Break the repetition chain of keys after specified amount of idle time. |
repeat-exit-timer | Timer activated after the last key typed in the repeating key sequence. |
repeat-in-progress | Non-nil when the repeating transient map is active. |
repeat-keep-prefix | Whether to keep the prefix arg of the previous command when repeating. |
repeat-map | The value of the repeating transient map for the next command. |
repeat-message-function | If non-nil, function used by ‘repeat’ command to say what it’s doing. |
repeat-mode | Non-nil if Repeat mode is enabled. |
repeat-mode-hook | Hook run after entering or leaving ‘repeat-mode’. |
repeat-num-input-keys-at-repeat | # key sequences read in Emacs session when ‘repeat’ last invoked. |
repeat-on-final-keystroke | Allow ‘repeat’ to re-execute for repeating lastchar of a key sequence. |
repeat-previous-repeated-command | The previous repeated command. |
repeat-too-dangerous | Commands too dangerous to repeat with C-x z. |
Defined functions (17)
describe-repeat-maps | () |
repeat | (REPEAT-ARG) |
repeat--clear-prev | () |
repeat--command-property | (PROPERTY) |
repeat-check-key | (KEY MAP) |
repeat-check-map | (MAP) |
repeat-echo-message | (KEYMAP) |
repeat-echo-message-string | (KEYMAP) |
repeat-echo-mode-line | (KEYMAP) |
repeat-exit | () |
repeat-get-map | (MAP) |
repeat-get-map-sym | () |
repeat-is-really-this-command | () |
repeat-message | (FORMAT &rest ARGS) |
repeat-mode | (&optional ARG) |
repeat-post-hook | () |
repeat-pre-hook | () |