19

C-h l shows the lossage help buffer, which shows recent keystrokes. Pressing g appears to revert it, causing it to update. Unfortunately, enabling auto-revert-mode does not change it to update continuously.

It would be nice if I could open up another window or frame and just display lossage in real time to show viewers what I am typing. This could also be used for pairing in a tmux/tmate session. Some of the videos online have something like this, but they appear to be external applications and OS specific.

Is there a nice way to show keystrokes in real time as they occur from within Emacs?

dgtized
  • 4,169
  • 20
  • 41

4 Answers4

21

Addressing the last question in your post: you can get an auto-updating log of commands & key strokes by using https://github.com/lewang/command-log-mode which is also available on MELPA - by default it only shows non-trivial commands (so no self-insert or cursor movement commands). It looks like this:

enter image description here

10

Yes. There's a package called mwe-log-commands, which is available on GitHub.

Just run M-x mwe:log-keyboard-commands to start recording, then M-x mwe:open-command-log-buffer will open a buffer which shows the typed commands in real time.

command-log-mode is a newer and more actively-maintained fork of mwe-log-commands, so it might be preferable these days.

Ryan Hart
  • 3
  • 2
sanityinc
  • 2,871
  • 13
  • 17
9

You can use a post-command-hook to update the lossage buffer. The following snippet does that for you (on a buffer local basis), but it assumes you've renamed the lossage buffer to "Lossage" (so this way you can still open other help buffers).

(defun update-lossage-buffer ()
  "Update the \"Lossage\" buffer.
For this to work, visit the lossage buffer, and call
M-x rename-buffer Lossage RET"
  (save-excursion
    (let ((b (get-buffer "Lossage")))
      (when (buffer-live-p b)
        (with-current-buffer b
          (revert-buffer nil 'noconfirm))))))
(add-hook 'post-command-hook #'update-lossage-buffer nil 'local)
dgtized
  • 4,169
  • 20
  • 41
Malabarba
  • 22,878
  • 6
  • 78
  • 163
3

The lossage help buffer is not associated with a file on disk. Hence auto revert mode does not work. A pseudo realtime alternative can be using (open-dribble-file "FILE") which writes all keystrokes to FILE. Using auto-revert-tail-mode on FILE buffer can reflect the keystrokes.

Another way would be to advice self-insert-command(and some prefix keys) to echo to a buffer.

Vamsi
  • 3,916
  • 22
  • 35