How to view history of various commands in Emacs
Asked Answered
T

5

21

Commands entered after pressing M-x can be viewed using the up/down arrow keys.

How can I get a list of all the commands including menu bar invocation, commands triggered using mouse clicks, etc. in Emacs?

Thistle answered 7/3, 2012 at 13:44 Comment(0)
E
15

I've used mwe-log-commands to make screencasts. It shows events and the commands they trigger as you work in Emacs.


command-log-mode

screen shot

I've just forked it and made it into a proper minor-mode and global-minor-mode along with some other improvements as command-log-mode.

Give it a shot and file issues against me if the documentation is unclear or if you find any bugs.

Estuary answered 7/3, 2012 at 15:40 Comment(1)
I know you're not supposed to write this type of comment but I can't help it: thank you for being a living example of what makes open source so great.Enchondroma
C
28

For a complete list of history, type C-h l (lowercase "L").

Note: this list is complete in the sense that it keeps all events and commands that happened recently, but it's not complete in the sense that it only keeps track of the last 300 or so events (and corresponding commands).

Coenosarc answered 7/3, 2012 at 13:47 Comment(4)
He wanted mouse clicks, menu selection, "etc" as well, and C-h l will show these.Coenosarc
The title is pretty clear: command history. Event history does not show commands.Estuary
i would also like to see the command that is triggered by the eventThistle
@Tom: in older Emacsen, C-h l only showed events, but it has since been improved to also show the commands triggered in response to those events.Barlow
E
15

I've used mwe-log-commands to make screencasts. It shows events and the commands they trigger as you work in Emacs.


command-log-mode

screen shot

I've just forked it and made it into a proper minor-mode and global-minor-mode along with some other improvements as command-log-mode.

Give it a shot and file issues against me if the documentation is unclear or if you find any bugs.

Estuary answered 7/3, 2012 at 15:40 Comment(1)
I know you're not supposed to write this type of comment but I can't help it: thank you for being a living example of what makes open source so great.Enchondroma
C
2

So you want the history of of all commands, regardless of where they are executed? I don't know if emacs provides this by default, but you can add your own function to post-command-hook which is executed after every command, so you can use it to collect all the executed commands.

Clad answered 7/3, 2012 at 15:37 Comment(0)
M
0

M-x view-lossage

From emacs documentation

(view-lossage)

Display last few input keystrokes and the commands run. For convenience this uses the same format as edit-last-kbd-macro. See lossage-size to update the number of recorded keystrokes.

To record all your input, use open-dribble-file.

(open-dribble-file FILE)

Start writing input events to a dribble file called FILE. Any previously open dribble file will be closed first. If FILE is nil, just close the dribble file, if any. If the file is still open when Emacs exits, it will be closed then.

The events written to the file include keyboard and mouse input events, but not events from executing keyboard macros. The events are written to the dribble file immediately without line buffering.

Be aware that this records all characters you type! This may include sensitive information such as passwords.

Margalit answered 3/12, 2021 at 14:16 Comment(0)
T
0

You can also use the keycast package which comes with a handy keycast-mode-line-mode which displays the last executed keybinding along with its command in the modeline.

It also has a keycast-log-mode which

displays a list of recent bindings in a dedicated frame.

But this only keeps track of the commands after enabling the mode


In my opinion M-x view-lossage OR C-h l (lowercase "L") as mentioned by others here is the best option and additionally, it is also an in-built tool, so no additional packages..

Thirddegree answered 22/6, 2024 at 16:34 Comment(2)
For what it's worth, there is no "above" or "below"; answers are sorted according to each visitor's preference.Housen
good point, changed the contentThirddegree

© 2022 - 2025 — McMap. All rights reserved.