fix(tty): meta keybinds in KKP supported terminals

In a KKP supported terminal, Emacs now receives a number of new input
events from the terminal, like [M-return] and [M-tab], but if they
aren't bound to, they don't fall through to bindings on "M-RET" and
"M-TAB", like [return], [tab], and others do, thus rendering those
keybinds inaccessible. Rather than play whack-a-mole with all the
keymaps out there, I just teach Emacs to let them fall through.

X->Y remappings on `local-function-key-map` do not apply if anything is
bound explicitly to X, so this change bows out if you (or packages, in
the future) do, for some reason, want to bind to them directly.
This commit is contained in:
Henrik Lissner
2024-08-30 20:04:12 -04:00
parent 34cc0c9d86
commit 0a38eeef4c

View File

@ -46,4 +46,15 @@
;; Add support for the Kitty keyboard protocol.
(use-package! kkp
:hook (after-init . global-kkp-mode))
:hook (after-init . global-kkp-mode)
:config
;; HACK: Emacs falls back to RET, TAB, and/or DEL if [return], [tab], and/or
;; [backspace] are unbound, but this isn't the case for all input events,
;; like these, which don't fall back to M-RET, M-TAB, etc. Therefore making
;; these keybinds inaccessible in KKP supported terminals.
;; REVIEW: See benjaminor/kkp#13.
(define-key! local-function-key-map
[M-return] (kbd "M-RET")
[M-tab] (kbd "M-TAB")
[M-backspace] (kbd "M-DEL")
[M-delete] (kbd "M-DEL")))