Emacs中是否存在(repeat-last-command)?

通常,我已经挖掘了apropos和docs寻找类似下面的东西只是为了放弃回到手头的任务:

(重复-最后命令)

做刚刚执行过的最后一个C-或M-命令(被反弹到一个fn键)

或者有时是相关的:

(形容 – 最后function)

我只是错误地发出了什么按键,我想添加到我的袋子的技巧的效果。 describe-key很接近,但需要知道我input的内容。

我只是从我可靠的伙伴那里问得太多了吗?

关于“ 描述最后的function ”:

有一个variableslast-command ,它被设置为代表你所做的最后一件事的符号。 因此,这个elisp片段(describe-function last-command)应该提供立即发生的事情的文档。

所以你可以像这样做一个微不足道的工作describe-last-function

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

把这个elisp放入.emacs或等价的,你将有一个Mx描述最后的function

如果你已经触动了几个键或者做了一些你最感兴趣的事情,那么command-historyfunction可能是有趣的。 你可以通过Mx命令历史来获得

repeat.el Emacs Lisp包提供了重复function,包含在标准的Emacs发行版中。 从repeat.el的文档:

这个包定义了一个重复上述命令的命令,无论它是什么,包括它的参数,不pipe它们是什么。 该命令连接到Cx z键。 要重复上一个命令,请键入Cx z。 要立即重复第二次,请inputz。 通过一次又一次inputz,您可以反复重复该命令。

要查看有关重复命令的其他信息,请在Emacs中键入Ch F repeat RET

重复上一个命令

Cx z

一旦你按下它,只需按z ,然后重复(不必再次按Cx )。

您可以用Cx z重复命令,然后按z来继续重复。

有点令人震惊没有人提到repeat-complex-command ,可从键绑定Cx ESC ESC中获得

此外, Mx view-lossage显示您input的最后一百(?)个按键。 所以,你将能够看到命令在哪里。 这是我使用,直到我现在才发现有关Mx command-history ,我想我现在将使用Ch w

我不是很确定,但也许你正在寻找这个?

命令Cx zrepeat )提供了多次重复Emacs命令的另一种方法。 这个命令重复以前的Emacs命令,不pipe是什么。 重复一个命令使用之前使用过的相同的参数; 它不会每次都读新的参数。

Emacs手册,8.11重复一个命令

可能是这也会有所帮助…从emacs帮助逐字:

 Cx M-ESC runs the command repeat-complex-command which is an interactive compiled Lisp function in `simple.el'. It is bound to <again>, <redo>, Cx M-:, Cx M-ESC. (repeat-complex-command ARG) Edit and re-evaluate last complex command, or ARGth from last. A complex command is one which used the minibuffer. The command is placed in the minibuffer as a Lisp form for editing. The result is executed, repeating the command as changed. If the command has been changed or is not the most recent previous command it is added to the front of the command history. You can use the minibuffer history commands Mn and Mp to get different commands to edit and resubmit. 

我个人认为塞巴斯蒂安的想法很有用。 这是一个工作版本

 (global-set-key "\Cr" #'(lambda () (interactive) (eval (car command-history))))