From 0a38eeef4cbf27bf3f98a39f48f752e0dd3a1a72 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 30 Aug 2024 20:04:12 -0400 Subject: [PATCH] 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. --- modules/os/tty/config.el | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/modules/os/tty/config.el b/modules/os/tty/config.el index 93cbc1a4f..8acc88848 100644 --- a/modules/os/tty/config.el +++ b/modules/os/tty/config.el @@ -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")))