diff --git a/core/core-keybinds.el b/core/core-keybinds.el index 942c9b475..9bd8070c5 100644 --- a/core/core-keybinds.el +++ b/core/core-keybinds.el @@ -24,7 +24,7 @@ ;; (defvar doom-escape-hook nil "A hook run after C-g is pressed (or ESC in normal mode, for evil users). Both -keys trigger `doom/escape'. +trigger `doom/escape'. If any hook returns non-nil, all hooks after it are ignored.") @@ -34,16 +34,12 @@ If any hook returns non-nil, all hooks after it are ignored.") (cond ((minibuffer-window-active-p (minibuffer-window)) ;; quit the minibuffer if open. (abort-recursive-edit)) - ((and (featurep 'evil) (evil-ex-hl-active-p 'evil-ex-search)) - ;; disable ex search buffer highlights. - (evil-ex-nohighlight)) ;; Run all escape hooks. If any returns non-nil, then stop there. ((run-hook-with-args-until-success 'doom-escape-hook)) ;; Back to the default (t (keyboard-quit)))) (global-set-key [remap keyboard-quit] #'doom/escape) -(advice-add #'evil-force-normal-state :after #'doom/escape) ;; diff --git a/modules/feature/evil/config.el b/modules/feature/evil/config.el index 86269f6d9..7ca2fff24 100644 --- a/modules/feature/evil/config.el +++ b/modules/feature/evil/config.el @@ -88,6 +88,15 @@ ;; --- evil hacks ------------------------- + (advice-add #'evil-force-normal-state :after #'doom/escape) + + (defun +evil|disable-highlights () + "Disable ex search buffer highlights." + (when (evil-ex-hl-active-p 'evil-ex-search) + (evil-ex-nohighlight) + t)) + (add-hook 'doom-escape-hook #'+evil|disable-highlights) + (defun +evil*restore-normal-state-on-windmove (orig-fn &rest args) "If in anything but normal or motion mode when moving to another window, restore normal mode. This prevents insert state from bleeding into other modes