Function: evil-mode@body

evil-mode@body is a byte-compiled function defined in evil-core.el.

Signature

(evil-mode@body &optional ARG)

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-core.el
;; `define-globalized-minor-mode' supports a BODY argument but only since
;; GNU Emacs 27.1, so resort to this ugly advice in the mean time.
(define-advice evil-mode (:after (&optional _arg) body)
  ;; Hooks used to not run in Fundamental buffers (bug#23827), so
  ;; other measures are necessary to initialize Evil there. When Evil
  ;; is enabled globally, the default value of `major-mode' is set to
  ;; the `evil--fundamental-mode' alias, sidestepping the restriction.
  (if evil-mode
      (progn
        (and (eval-when-compile (version< emacs-version "26.1"))
             (eq (default-value 'major-mode) 'fundamental-mode)
             (setq-default major-mode #'evil--fundamental-mode))
        (dolist (advice evil--advices) (apply #'advice-add advice))
        (with-no-warnings (evil-esc-mode 1)))
    (when (eq (default-value 'major-mode) #'evil--fundamental-mode)
      (setq-default major-mode 'fundamental-mode))
    (pcase-dolist (`(,funname ,_where ,adfun) evil--advices)
      (advice-remove funname adfun))
    (with-no-warnings (evil-esc-mode -1))))