diff --git a/init.el b/init.el index 3cc2827..a6d4671 100644 --- a/init.el +++ b/init.el @@ -377,15 +377,19 @@ directory. Otherwise, run `find-file' on that file." ;; kitty keyboard protocol (use-package kkp + :defer nil :config (global-kkp-mode 1) - (defun my/-kkp-after-terminal-setup (&rest _) + (defun my/-kkp-after-terminal-setup () ;; Make tab and backtab work properly (define-key input-decode-map [(control ?i)] [tab]) - (define-key input-decode-map [(control ?I)] [backtab])) - (defun my/-kkp-after-terminal-teardown (&rest _) - (define-key input-decode-map [(control ?i)] nil t) - (define-key input-decode-map [(control ?I)] nil t)) + (define-key input-decode-map [(control ?I)] [backtab]) + (define-key input-decode-map [(control ?m)] [return])) + (defun my/-kkp-after-terminal-teardown (term) + (with-selected-frame (car (frames-on-display-list term)) + (define-key input-decode-map [(control ?i)] nil t) + (define-key input-decode-map [(control ?I)] nil t) + (define-key input-decode-map [(control ?m)] nil t))) (advice-add 'kkp--terminal-setup :after 'my/-kkp-after-terminal-setup) (advice-add 'kkp--terminal-teardown :after 'my/-kkp-after-terminal-teardown) (defun my/quoted-insert (arg) @@ -407,7 +411,7 @@ directory. Otherwise, run `find-file' on that file." (let ((status (kkp--terminal-has-active-kkp-p))) (unwind-protect (progn - (when status (kkp--terminal-teardown (kkp--selected-terminal))) + (when status (kkp-disable-in-terminal)) (apply oldfun args)) (when (and status (not (kkp--terminal-has-active-kkp-p))) ;; this does async stuff that will make kitty send characters after