Change to a different method for fixing kkp and map-y-or-n-p
This commit is contained in:
parent
87ec1690ee
commit
655eb827e1
37
init.el
37
init.el
@ -446,35 +446,22 @@ directory. Otherwise, run `find-file' on that file."
|
|||||||
(insert-and-inherit char)
|
(insert-and-inherit char)
|
||||||
(setq arg (1- arg))))))
|
(setq arg (1- arg))))))
|
||||||
(keymap-global-set "C-q" #'my/quoted-insert)
|
(keymap-global-set "C-q" #'my/quoted-insert)
|
||||||
(defun my/-kkp-fix-map-y-or-n-p (oldfun &rest args)
|
(defun my/kkp-disable-around-advice (oldfun &rest args)
|
||||||
"Fix `map-y-or-n-p' when used in a terminal with kkp enabled."
|
"Run OLDFUN with ARGS with kkp disabled."
|
||||||
(let ((status (kkp--this-terminal-has-active-kkp-p)))
|
(let ((status (kkp--this-terminal-has-active-kkp-p)))
|
||||||
(condition-case err
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(when status (kkp-disable-in-terminal))
|
(when status (kkp-disable-in-terminal))
|
||||||
(apply oldfun args))
|
(apply oldfun args))
|
||||||
(quit
|
(when status (kkp-enable-in-terminal))
|
||||||
;; We won't die in this case, so just re-enable kkp
|
;; consume the response from the terminal. If this is not here and this
|
||||||
(when (and status (not (kkp--this-terminal-has-active-kkp-p)))
|
;; function is set as advice for `map-y-or-n-p' called from
|
||||||
(kkp-enable-in-terminal))
|
;; `save-buffers-kill-terminal', a bunch of extra characters will be
|
||||||
(signal 'quit nil))
|
;; printed for the shell after Emacs exits because Emacs will die before
|
||||||
(t
|
;; it can read the terminal's response to `kkp-enable-in-terminal'
|
||||||
(when (and status (not (kkp--this-terminal-has-active-kkp-p)))
|
(while-no-input
|
||||||
;; this does async stuff that will make kitty send characters after
|
(sleep-for 0.1)))))
|
||||||
;; Emacs exits. We prevent that by not re-enabling if this frame (or
|
(advice-add #'map-y-or-n-p :around #'my/kkp-disable-around-advice))
|
||||||
;; Emacs) is about to die
|
|
||||||
(let ((will-die))
|
|
||||||
(mapbacktrace
|
|
||||||
(lambda (_evald func _args _flags)
|
|
||||||
(when (or (eq func 'save-buffers-kill-emacs)
|
|
||||||
(eq func 'server-save-buffers-kill-terminal))
|
|
||||||
(setq will-die t))))
|
|
||||||
(unless will-die
|
|
||||||
(kkp-enable-in-terminal))))
|
|
||||||
(when err
|
|
||||||
(signal (car err) (cdr err)))))))
|
|
||||||
(advice-add #'map-y-or-n-p :around
|
|
||||||
#'my/-kkp-fix-map-y-or-n-p))
|
|
||||||
|
|
||||||
;; some eww (status bar) stuff
|
;; some eww (status bar) stuff
|
||||||
(defun my/cmdline-for-pid (pid)
|
(defun my/cmdline-for-pid (pid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user