fix: prevent quit in the middle of doom/escape

This commit is contained in:
Henrik Lissner 2023-09-12 18:56:01 +02:00
parent 7acb67285c
commit f26b038ec3
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -93,19 +93,20 @@ all hooks after it are ignored.")
(defun doom/escape (&optional interactive)
"Run `doom-escape-hook'."
(interactive (list 'interactive))
(cond ((minibuffer-window-active-p (minibuffer-window))
;; quit the minibuffer if open.
(when interactive
(setq this-command 'abort-recursive-edit))
(abort-recursive-edit))
;; Run all escape hooks. If any returns non-nil, then stop there.
((run-hook-with-args-until-success 'doom-escape-hook))
;; don't abort macros
((or defining-kbd-macro executing-kbd-macro) nil)
;; Back to the default
((unwind-protect (keyboard-quit)
(let ((inhibit-quit t))
(cond ((minibuffer-window-active-p (minibuffer-window))
;; quit the minibuffer if open.
(when interactive
(setq this-command 'keyboard-quit))))))
(setq this-command 'abort-recursive-edit))
(abort-recursive-edit))
;; Run all escape hooks. If any returns non-nil, then stop there.
((run-hook-with-args-until-success 'doom-escape-hook))
;; don't abort macros
((or defining-kbd-macro executing-kbd-macro) nil)
;; Back to the default
((unwind-protect (keyboard-quit)
(when interactive
(setq this-command 'keyboard-quit)))))))
(global-set-key [remap keyboard-quit] #'doom/escape)