devil icon indicating copy to clipboard operation
devil copied to clipboard

Replace read-event with read-key

Open gerd-moellmann opened this issue 10 months ago • 0 comments

I found a problem whiletrying Devil on a TTY together with kkp.el, https://github.com/benotn/kkp.

kkp.el uses input-decode-map to map all sorts of escape sequences that a KKP-capable terminal emulator like iTerm2 produces to Emacs keys. This way, keys liek S-<left> or C-M-b become available on a TTY.

The problem is that devil--read-key uses read-event to read keys, and read-event does not obey input-decode-map. That means that Devil doesn't work with keys like <f4> or <left>,

The fix is easy though: Replace read-event with read-key, and it works: , <left> becomes C-<left> and so on.

  (defun devil--read-key (prompt key)
    (setq key (vconcat key (vector (read-key (devil-format prompt key)))))
    (or (devil--find-special-command key)
	(devil--find-regular-command key)

(See also https://lists.gnu.org/archive/html/bug-gnu-emacs/2025-01/msg02175.html, for some further background.)

Thanks for nice idea! Defiantly.

gerd-moellmann avatar Mar 07 '25 03:03 gerd-moellmann