Hopefuly fix more kkp stuff
This commit is contained in:
32
init.el
32
init.el
@ -537,22 +537,30 @@ directory. Otherwise, run `find-file' on that file."
|
||||
(insert-and-inherit char)
|
||||
(setq arg (1- arg))))))
|
||||
(keymap-global-set "C-q" #'my/quoted-insert)
|
||||
(cl-defun my/-in-callstack-p (needle)
|
||||
"Return non-nil if FUNC is above us in the call-stack."
|
||||
(let ((needle (indirect-function needle)))
|
||||
(mapbacktrace (lambda (_evald func _args _flags)
|
||||
(when (eq (indirect-function func)
|
||||
needle)
|
||||
(cl-return-from my/-in-callstack-p t))))))
|
||||
(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)))
|
||||
(let ((status (kkp--this-terminal-has-active-kkp-p))
|
||||
(will-frame-die (my/-in-callstack-p
|
||||
#'server-save-buffers-kill-terminal))
|
||||
flag)
|
||||
(unwind-protect
|
||||
(progn
|
||||
(when status (kkp-disable-in-terminal))
|
||||
(apply oldfun args))
|
||||
(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))
|
||||
(when status (kkp--suspend-in-terminal))
|
||||
(prog1 (apply oldfun args)
|
||||
(setq flag t)))
|
||||
;; if flag is nil, it means the user did a C-g (or another error
|
||||
;; happened), anyway, Emacs will probably not exit so re-enable kkp
|
||||
(when (and status (or (not flag) (not will-frame-die)))
|
||||
(kkp--resume-in-terminal)))))
|
||||
(advice-add #'map-y-or-n-p :around #'my/kkp-disable-around-advice)
|
||||
(advice-add #'read-multiple-choice :around #'my/kkp-disable-around-advice))
|
||||
|
||||
;; some eww (status bar) stuff
|
||||
(defun my/cmdline-for-pid (pid)
|
||||
|
||||
Reference in New Issue
Block a user