doom/escape: change this-command only if interactive

This commit is contained in:
Henrik Lissner 2020-12-13 19:48:09 -05:00
parent 084defb165
commit 04b29c70d2
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -72,20 +72,22 @@ and Emacs states, and for non-evil users.")
More specifically, when `doom/escape' is pressed. If any hook returns non-nil,
all hooks after it are ignored.")
(defun doom/escape ()
(defun doom/escape (&optional interactive)
"Run `doom-escape-hook'."
(interactive)
(interactive (list 'interactive))
(cond ((minibuffer-window-active-p (minibuffer-window))
;; quit the minibuffer if open.
(setq this-command 'abort-recursive-edit)
(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
((setq this-command 'keyboard-quit)
(keyboard-quit))))
((unwind-protect (keyboard-quit)
(when interactive
(setq this-command 'keyboard-quit))))))
(global-set-key [remap keyboard-quit] #'doom/escape)