From 004290b3731b5648958d5049c024401420ebd9ca Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 6 May 2017 23:30:35 +0200 Subject: [PATCH] feature/evil: normal state before window switching (to prevent state bleed) --- modules/feature/evil/config.el | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/feature/evil/config.el b/modules/feature/evil/config.el index 74989408c..3eed87ac2 100644 --- a/modules/feature/evil/config.el +++ b/modules/feature/evil/config.el @@ -95,6 +95,15 @@ (evil-ex-nohighlight))) (advice-add #'evil-force-normal-state :after #'+evil*esc) +(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 +across windows." + (unless (memq evil-state '(normal motion)) + (evil-normal-state +1)) + (apply orig-fn args)) +(advice-add #'windmove-do-window-select :around #'+evil*restore-normal-state-on-windmove) + (defun +evil*static-reindent (orig-fn &rest args) "Don't move cursor on indent." (save-excursion (apply orig-fn args)))