Fix kkp for the latest update

This commit is contained in:
Alexander Rosenberg 2025-02-08 15:40:52 -08:00
parent 4282129190
commit 641aa325dc
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

18
init.el
View File

@ -432,18 +432,6 @@ directory. Otherwise, run `find-file' on that file."
:defer nil
:config
(global-kkp-mode 1)
;; (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])
;; (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)
"Insert the next character using read-key, not read-char."
(interactive "*p")
@ -460,18 +448,18 @@ directory. Otherwise, run `find-file' on that file."
(keymap-global-set "C-q" #'my/quoted-insert)
(defun my/-kkp-fix-map-y-or-n-p (oldfun &rest args)
"Fix `map-y-or-n-p' when used in a terminal with kkp enabled."
(let ((status (kkp--terminal-has-active-kkp-p)))
(let ((status (kkp--this-terminal-has-active-kkp-p)))
(condition-case err
(progn
(when status (kkp-disable-in-terminal))
(apply oldfun args))
(quit
;; We won't die in this case, so just re-enable kkp
(when (and status (not (kkp--terminal-has-active-kkp-p)))
(when (and status (not (kkp--this-terminal-has-active-kkp-p)))
(kkp-enable-in-terminal))
(signal 'quit nil))
(t
(when (and status (not (kkp--terminal-has-active-kkp-p)))
(when (and status (not (kkp--this-terminal-has-active-kkp-p)))
;; this does async stuff that will make kitty send characters after
;; Emacs exits. We prevent that by not re-enabling if this frame (or
;; Emacs) is about to die