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
This commit is contained in:
Henrik Lissner 2023-03-11 10:54:22 -05:00
parent 7c7ee6602c
commit adb125f41f
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -55,6 +55,14 @@ directives. By default, this only recognizes C directives.")
((modulep! :emacs undo) 'undo-fu) ((modulep! :emacs undo) 'undo-fu)
((> emacs-major-version 27) 'undo-redo))) ((> 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 ;; Slow this down from 0.02 to prevent blocking in large or folded buffers
;; like magit while incrementally highlighting matches. ;; like magit while incrementally highlighting matches.
(setq-hook! '(magit-mode-hook so-long-minor-mode-hook) (setq-hook! '(magit-mode-hook so-long-minor-mode-hook)