Fix kkp, again
This commit is contained in:
parent
4e94728235
commit
32b3042418
38
init.el
38
init.el
@ -409,22 +409,30 @@ directory. Otherwise, run `find-file' on that file."
|
||||
(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)))
|
||||
(unwind-protect
|
||||
(condition-case err
|
||||
(progn
|
||||
(when status (kkp-disable-in-terminal))
|
||||
(apply oldfun args))
|
||||
(when (and status (not (kkp--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)))))))
|
||||
(quit
|
||||
;; We won't die in this case, so just re-enable kkp
|
||||
(when (and status (not (kkp--terminal-has-active-kkp-p)))
|
||||
(kkp-enable-in-terminal))
|
||||
(signal 'quit nil))
|
||||
(t
|
||||
(when (and status (not (kkp--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))
|
||||
|
||||
@ -524,7 +532,7 @@ With NO-EDGE, return nil if beg or end fall on the edge of the range."
|
||||
(save-excursion
|
||||
;; this fixes that fact that `thing-at-point-bounds-of-string-at-point'
|
||||
;; errors if called at the end of the buffer
|
||||
(condition-case _
|
||||
(condition-case nil
|
||||
(let ((sb (progn (goto-char beg) (bounds-of-thing-at-point thing)))
|
||||
(eb (progn (goto-char end) (bounds-of-thing-at-point thing))))
|
||||
(and sb eb (equal sb eb)
|
||||
@ -1370,7 +1378,7 @@ entry, return nil."
|
||||
;; go to top level and check if the character at point is {
|
||||
(let ((start-pos (point))
|
||||
(last-valid (point)))
|
||||
(condition-case _
|
||||
(condition-case nil
|
||||
(while t
|
||||
(backward-up-list 1 t t)
|
||||
(setq last-valid (point)))
|
||||
|
Loading…
Reference in New Issue
Block a user