Function: evil-save-state

evil-save-state is a macro defined in evil-core.el.

Signature

(evil-save-state &rest BODY)

Documentation

Save the current state; execute BODY; restore the state.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-core.el
(defmacro evil-save-state (&rest body)
  "Save the current state; execute BODY; restore the state."
  (declare (indent defun)
           (debug t))
  `(let ((evil-state evil-state)
         (evil-previous-state evil-previous-state)
         (evil-previous-state-alist (copy-tree evil-previous-state-alist))
         (evil-next-state evil-next-state)
         (old-state evil-state)
         (inhibit-quit t)
         (buf (current-buffer)))
     (unwind-protect
         (progn ,@body)
       (when (buffer-live-p buf)
         (with-current-buffer buf
           (evil-change-state old-state))))))