Is there a (repeat-last-command) in Emacs?

ack picture ack · Nov 9, 2008 · Viewed 39.7k times · Source

Frequently, I've dug into apropos and docs looking for something like the following only to give up to get back to the task at hand:

(repeat-last-command)

do the last C- or M- command I just executed (to be rebound to a fn key)

or sometimes the related:

(describe-last-function)

what keystroke did I just mistakenly issue, the effect of which I'd like to add to my bag of tricks. describe-key is close, but requires knowing what I typed.

Am I simply asking too much from my trusty sidekick?

Answer

Emerick Rogul picture Emerick Rogul · Nov 9, 2008

Repeat functionality is provided by the repeat.el Emacs Lisp package, which is included with standard Emacs distributions. From repeat.el's documentation:

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.

To see additional information about the repeat command, type C-h F repeat RET from within Emacs.