Properly handle tab and backtab in kkp-enabled terminals

This commit is contained in:
Alexander Rosenberg 2024-11-03 05:47:25 -08:00
parent 71fb77f758
commit 4dc28f50d7
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

10
init.el
View File

@ -372,6 +372,15 @@ directory. Otherwise, run `find-file' on that file."
:bind ("C-q" . my/quoted-insert) :bind ("C-q" . my/quoted-insert)
:config :config
(global-kkp-mode 1) (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) (defun my/quoted-insert (arg)
"Insert the next character using read-key, not read-char." "Insert the next character using read-key, not read-char."
(interactive "*p") (interactive "*p")
@ -385,6 +394,7 @@ directory. Otherwise, run `find-file' on that file."
(while (> arg 0) (while (> arg 0)
(insert-and-inherit char) (insert-and-inherit char)
(setq arg (1- arg)))))) (setq arg (1- arg))))))
(defun my/-kkp-fix-save-some-buffers (oldfun &optional arg pred) (defun my/-kkp-fix-save-some-buffers (oldfun &optional arg pred)
"Fix `save-some-buffers' when used in a terminal with kkp enabled." "Fix `save-some-buffers' when used in a terminal with kkp enabled."
(let ((status (kkp--terminal-has-active-kkp-p))) (let ((status (kkp--terminal-has-active-kkp-p)))