From 4dc28f50d71f86c33b27f3deb22069f4231bce5a Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sun, 3 Nov 2024 05:47:25 -0800 Subject: [PATCH] Properly handle tab and backtab in kkp-enabled terminals --- init.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/init.el b/init.el index 9bde3ca..06e8816 100644 --- a/init.el +++ b/init.el @@ -372,6 +372,15 @@ directory. Otherwise, run `find-file' on that file." :bind ("C-q" . my/quoted-insert) :config (global-kkp-mode 1) + (defun my/-kkp-after-terminal-setup (&rest _) + ;; 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)) + (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) "Insert the next character using read-key, not read-char." (interactive "*p") @@ -385,6 +394,7 @@ directory. Otherwise, run `find-file' on that file." (while (> arg 0) (insert-and-inherit char) (setq arg (1- arg)))))) + (defun my/-kkp-fix-save-some-buffers (oldfun &optional arg pred) "Fix `save-some-buffers' when used in a terminal with kkp enabled." (let ((status (kkp--terminal-has-active-kkp-p)))