From c896eb31e8afcfaa91d813659c28aa57fa5a6d14 Mon Sep 17 00:00:00 2001 From: Michael Russo Date: Fri, 3 Jan 2025 22:26:16 -0500 Subject: [PATCH] Handle KKP implementations that don't support "report alternate keys". Such as Zellij. See: https://github.com/zellij-org/zellij/issues/3789#issuecomment-2569862441 --- conf/terminal.el | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/conf/terminal.el b/conf/terminal.el index eebd158..6de7a20 100644 --- a/conf/terminal.el +++ b/conf/terminal.el @@ -43,6 +43,47 @@ (global-kkp-mode +1) ) +;; Zellij supports the "disambiguate escape codes" component of the Kitty +;; Keyboard protocol, but **not** "report alternate keys". (See +;; for more details and +;; discussion.) +;; +;; An implication is explained in the kpp.el README: +;; +;; > Note that when you activate only `disambiguate-escape-codes`, the terminal +;; > reports shifted keypresses which involve another modifier by sending the +;; > modifiers with the base layout of the key. +;; > +;; > This means "M-S-." (Meta-Shift-.) is not translated to "M-:" (on a German +;; > keyboard) and Emacs will probably not find the proper keybinding. +;; +;; As a workaround to Zellij's lack of support for `disambiguate-escape-codes`, +;; we simply add relevant entries to the key translation map. For example, for +;; an English layout, we map "M-S-." to "M-->". +(use-package emacs + :config + (define-key key-translation-map (kbd "M-S-`") (kbd "M-~")) + (define-key key-translation-map (kbd "M-S-1") (kbd "M-!")) + (define-key key-translation-map (kbd "M-S-2") (kbd "M-@")) + (define-key key-translation-map (kbd "M-S-3") (kbd "M-#")) + (define-key key-translation-map (kbd "M-S-4") (kbd "M-$")) + (define-key key-translation-map (kbd "M-S-5") (kbd "M-%")) + (define-key key-translation-map (kbd "M-S-6") (kbd "M-^")) + (define-key key-translation-map (kbd "M-S-7") (kbd "M-&")) + (define-key key-translation-map (kbd "M-S-8") (kbd "M-*")) + (define-key key-translation-map (kbd "M-S-9") (kbd "M-(")) + (define-key key-translation-map (kbd "M-S-0") (kbd "M-)")) + (define-key key-translation-map (kbd "M-S--") (kbd "M-_")) + (define-key key-translation-map (kbd "M-S-=") (kbd "M-+")) + (define-key key-translation-map (kbd "M-S-[") (kbd "M-{")) + (define-key key-translation-map (kbd "M-S-]") (kbd "M-}")) + (define-key key-translation-map (kbd "M-S-\\") (kbd "M-|")) + (define-key key-translation-map (kbd "M-S-;") (kbd "M-:")) + (define-key key-translation-map (kbd "M-S-'") (kbd "M-\"")) + (define-key key-translation-map (kbd "M-S-,") (kbd "M-<")) + (define-key key-translation-map (kbd "M-S-.") (kbd "M->")) + (define-key key-translation-map (kbd "M-S-/") (kbd "M-?"))) + (defun my/tty-setup-hook () (message "Running tty-setup hook..."))