Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

emacs

elisp

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.


Repeat last command

C-xz

Once you pressed it, just press only z after that and it will repeat (without having to press C-x again).


Yes, there is a repeat command. It's called repeat:

  • You can repeat commands with C-x z, and hit z to keep repeating.

A bit shocking nobody mentioned repeat-complex-command, available from the key binding C-x ESC ESC.


with regards to 'describe-last-function':

There's a variable last-command which is set to a symbol representative of the last thing you did. So this elisp snippet - (describe-function last-command) - ought to bring up the documentation for the thing that immediately happened.

So you could make a trivial working describe-last-function like so

(defun describe-last-function() 
  (interactive) 
  (describe-function last-command))

Put that elisp in .emacs or equivalent, and you'll have a M-x describe-last-function.

If you've banged on a few keys or done something that modified last-command since the thing you're interested in, the command-history function might be of interest. You can get that by M-x command-history