From adb125f41f49e5f3561091b3d1ea9209afec3dc0 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 11 Mar 2023 10:54:22 -0500 Subject: [PATCH] fix(evil): persist evil state after mode changes For example: when doom-guess-mode-h is triggered (see #7141), or when the user invokes a mode function through M-x. Fix: #7141 --- modules/editor/evil/config.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index e99caec42..5315d3f5c 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -55,6 +55,14 @@ directives. By default, this only recognizes C directives.") ((modulep! :emacs undo) 'undo-fu) ((> emacs-major-version 27) 'undo-redo))) + ;; Fix #7141 + (defadvice! +evil--persist-state-a (fn &rest args) + "When changing major modes, Evil's state is lost. This advice preserves it." + :around #'set-auto-mode + (if evil-state + (evil-save-state (apply fn args)) + (apply fn args))) + ;; Slow this down from 0.02 to prevent blocking in large or folded buffers ;; like magit while incrementally highlighting matches. (setq-hook! '(magit-mode-hook so-long-minor-mode-hook)