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)
|
||||
(setq arg (1- arg))))))
|
||||
(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."
|
||||
(defun my/kkp-disable-around-advice (oldfun &rest args)
|
||||
"Run OLDFUN with ARGS with kkp disabled."
|
||||
(let ((status (kkp--this-terminal-has-active-kkp-p)))
|
||||
(condition-case err
|
||||
(unwind-protect
|
||||
(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--this-terminal-has-active-kkp-p)))
|
||||
(kkp-enable-in-terminal))
|
||||
(signal 'quit nil))
|
||||
(t
|
||||
(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
|
||||
(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))
|
||||
(when status (kkp-enable-in-terminal))
|
||||
;; consume the response from the terminal. If this is not here and this
|
||||
;; function is set as advice for `map-y-or-n-p' called from
|
||||
;; `save-buffers-kill-terminal', a bunch of extra characters will be
|
||||
;; printed for the shell after Emacs exits because Emacs will die before
|
||||
;; it can read the terminal's response to `kkp-enable-in-terminal'
|
||||
(while-no-input
|
||||
(sleep-for 0.1)))))
|
||||
(advice-add #'map-y-or-n-p :around #'my/kkp-disable-around-advice))
|
||||
|
||||
;; some eww (status bar) stuff
|
||||
(defun my/cmdline-for-pid (pid)
|
||||
|
Loading…
x
Reference in New Issue
Block a user