feature/evil: refactor evil-force-normal-state advice into +evil-esc-hook
This commit is contained in:
parent
69f6eab913
commit
cce294fcf6
7 changed files with 29 additions and 16 deletions
|
@ -94,13 +94,26 @@
|
|||
;; evil hacks
|
||||
;;
|
||||
|
||||
(defun +evil*esc ()
|
||||
"Disable search highlights and quit the minibuffer if open."
|
||||
(defvar +evil-esc-hook nil
|
||||
"A hook run after ESC is pressed in normal mode (invoked by
|
||||
`evil-force-normal-state').")
|
||||
|
||||
(defun +evil*attach-escape-hook ()
|
||||
"Run the `+evil-esc-hook'."
|
||||
(run-hooks '+evil-esc-hook))
|
||||
(advice-add #'evil-force-normal-state :after #'+evil*attach-escape-hook)
|
||||
|
||||
(defun +evil|escape-minibuffer ()
|
||||
"Quit the minibuffer if open."
|
||||
(when (minibuffer-window-active-p (minibuffer-window))
|
||||
(abort-recursive-edit))
|
||||
(abort-recursive-edit)))
|
||||
|
||||
(defun +evil|escape-highlights ()
|
||||
"Disable ex search buffer highlights."
|
||||
(when (evil-ex-hl-active-p 'evil-ex-search)
|
||||
(evil-ex-nohighlight)))
|
||||
(advice-add #'evil-force-normal-state :after #'+evil*esc)
|
||||
|
||||
(add-hook! '+evil-esc-hook '(+evil|escape-minibuffer +evil|escape-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,
|
||||
|
@ -272,9 +285,9 @@ across windows."
|
|||
(def-package! evil-exchange
|
||||
:commands evil-exchange
|
||||
:config
|
||||
(defun +evil*exchange-off ()
|
||||
(defun +evil|escape-exchange ()
|
||||
(if evil-exchange--overlays (evil-exchange-cancel)))
|
||||
(advice-add #'evil-force-normal-state :after #'+evil*exchange-off))
|
||||
(add-hook '+evil-esc-hook #'+evil|escape-exchange))
|
||||
|
||||
|
||||
(def-package! evil-indent-plus
|
||||
|
@ -330,7 +343,7 @@ algorithm is just confusing, like in python or ruby."
|
|||
:commands (evil-textobj-anyblock-inner-block evil-textobj-anyblock-a-block)
|
||||
:config
|
||||
(global-evil-search-highlight-persist t)
|
||||
(advice-add #'evil-force-normal-state :after #'evil-search-highlight-persist-remove-all))
|
||||
(add-hook '+evil-esc-hook #'evil-search-highlight-persist-remove-all))
|
||||
|
||||
|
||||
(def-package! evil-snipe :demand t
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
:v "<tab>" #'+snippets/expand-on-region))
|
||||
|
||||
;; Exit snippets on ESC in normal mode
|
||||
(advice-add #'evil-force-normal-state :before #'yas-exit-all-snippets)
|
||||
(add-hook '+evil-esc-hook #'yas-exit-all-snippets)
|
||||
;; Once you're in normal mode, you're out
|
||||
(add-hook 'evil-normal-state-entry-hook #'yas-abort-snippet)
|
||||
;; Strip out whitespace before a line selection
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
;; Flycheck buffer on ESC in normal mode.
|
||||
(defun +syntax-checkers|flycheck-buffer ()
|
||||
(if flycheck-mode (flycheck-buffer)))
|
||||
(advice-add #'evil-force-normal-state :after #'+syntax-checkers|flycheck-buffer)))
|
||||
(add-hook '+evil-esc-hook #'+syntax-checkers|flycheck-buffer)))
|
||||
|
||||
|
||||
(def-package! flycheck-pos-tip
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
(add-hook 'focus-in-hook #'git-gutter:update-all-windows)
|
||||
|
||||
(after! evil
|
||||
;; Refreshing git-gutter on ESC
|
||||
(advice-add #'evil-force-normal-state :after #'git-gutter)))
|
||||
;; Refresh git-gutter on ESC
|
||||
(add-hook '+evil-esc-hook #'git-gutter)))
|
||||
|
||||
|
||||
(def-package! git-timemachine
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue