From 654bb18772ef438a2db7079575a0d8ae4a181f35 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 18 May 2017 02:01:40 +0200 Subject: [PATCH] Use advice to jump to new splits The old method left window history unupdated, so when you delete a window, you end up pretty far from where you were, window-wise. --- modules/feature/evil/config.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/feature/evil/config.el b/modules/feature/evil/config.el index 39b049348..1ee341bf1 100644 --- a/modules/feature/evil/config.el +++ b/modules/feature/evil/config.el @@ -35,9 +35,6 @@ evil-ex-visual-char-range t ; column range for ex commands evil-insert-skip-empty-lines t evil-mode-line-format 'nil - ;; Move to new split - evil-split-window-below t - evil-vsplit-window-right t ;; more vim-like behavior evil-symbol-word-search t ;; don't activate mark on shift-click @@ -188,7 +185,16 @@ across windows." ;; Must be aggressively defined here, otherwise the above highlighting won't ;; work on first invocation (evil-ex-define-cmd "g[lobal]" #'+evil:global) - (evil-ex-define-cmd "al[ign]" #'+evil:align)) + (evil-ex-define-cmd "al[ign]" #'+evil:align) + + ;; Move to new split -- setting `evil-split-window-below' & + ;; `evil-vsplit-window-right' to non-nil mimics this, but that doesn't update + ;; window history. That means when you delete a new split, Emacs leaves you on + ;; the 2nd to last window on the history stack, which is jarring. + (defun +evil*window-follow (&rest _) (evil-window-down 1)) + (defun +evil*window-vfollow (&rest _) (evil-window-right 1)) + (advice-add #'evil-window-split :after #'+evil*window-follow) + (advice-add #'evil-window-vsplit :after #'+evil*window-vfollow)) ;;