Skip to content

alphapapa/defrepeater.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

defrepeater.el

https://melpa.org/packages/defrepeater-badge.svg

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).

Usage

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))

Installation

MELPA

If you installed from MELPA, you’re done.

Manual

Put defrepeater.el in your load-path, and (require 'defrepeater) in your init file.

Changelog

1.0

Initial release.

Credits

This was inspired by this answer by Drew Adams. Thanks also to Fox Keister for his feedback.

Development

Bug reports, feature requests, suggestions — oh my!

License

GPLv3

About

Easily define repeatable Emacs commands

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published