2
votes

I would like to record a medium-length screencast of some Emacs functionality using asciinema in a terminal. I could just start asciinema, then emacs -nw, do the recording, then stop. But I find that I always make multiple mistakes.

So I thought that it would be great if I could just write a "script" of keystrokes in some format, that would be fed to Emacs. Like replaying a keyboard macro, but a fairly long one, and with delays between keys (otherwise the recording goes way too fast).

Is this possible somehow? I am willing to do some elisp programming, but don't know where to start. Eg I could record my script as a list,

(list (kbd "C-x C-f") "filename.el" (kbd "C-e") (kbd "C-x C-e") ...)

and iterate through it, converting keystrokes and sending strings by character verbatim, but how do I "send" the result to Emacs?

It would be great if buffer switching etc would work.

1
Nice idea, did you get anywhere with this?Daniel Gerson

1 Answers

1
votes

You can record a sequence of user actions (keyboard, menus, etc.), creating a keyboard macro.

In a nutshell, you use <f3> to start recording and <f4> to stop recording. Then you can use <f4> (same key) to play back the recording. You can do all kinds of fancy things, in addition, but those are the basics.

See the Emacs manual, node Keyboard Macros for details.


You can show which keys are being used during your screencast in a tooltip, using mode showkey-tooltip-mode from library showkey.el - see ShowKey.

To show the keys recorded by the macro you will need to set or bind option showkey-tooltip-sleep-time to a number of seconds greater than zero. (By default it is zero, so that you can prevent some key display by typing quickly.)

Option showkey-tooltip-key-only-flag controls whether to show only the key, or the key and its command, in the tooltip.

Alternatively, you can show an incremental log of the keys using mode showkey-log-mode.