This package lets you easily define “repeating commands,” which are commands that can be repeated by pressing the last key of the sequence bound to it.
For example, let’s say that you use winner-mode
, and you have C-c C-w p
bound to winner-undo
. Obviously, pressing that whole sequence repeatedly is tiresome when you want to go several steps back. But using this macro, you can press C-c C-w p
once, and then keep pressing p
to repeat winner-undo
, until you press a different key (you could press C-g
if you needed to stop the repetition so you could press p
normally).
First, define repeating commands:
;; Automatically defines `winner-redo-repeat' command:
(defrepeater #'winner-redo)
;; Optionally specify the name of the repeater, like using `defalias':
(defrepeater 'winner-undo-repeat #'winner-undo)
Then bind keys to the new commands (example using general):
(general-def
[remap winner-redo] #'winner-redo-repeat
[remap winner-undo] #'winner-undo-repeat)
For example, M-SPC w p was bound to winner-undo
, so now M-SPC w p p p can be pressed to call winner-undo
3 times.
defrepeater
can also be used directly in a key-binding expression:
(global-set-key (kbd "C-x o") (defrepeater #'other-window))
If you installed from MELPA, you’re done.
Put defrepeater.el
in your load-path
, and (require 'defrepeater)
in your init file.
Initial release.
This was inspired by this answer by Drew Adams. Thanks also to Fox Keister for his feedback.
Bug reports, feature requests, suggestions — oh my!
GPLv3