Function: evil-initial-state
evil-initial-state is a byte-compiled function defined in
evil-core.el.
Signature
(evil-initial-state MODE &optional DEFAULT FOLLOW-PARENT CHECKED-MODES)
Documentation
Return the Evil state to use for MODE or its alias.
Return DEFAULT if no initial state is associated with MODE.
The initial state for a mode can be set with
evil-set-initial-state.
If FOLLOW-PARENT is non-nil, also check parent modes of MODE and its alias. CHECKED-MODES is used internally and should not be set initially.
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-core.el
(defun evil-initial-state (mode &optional default follow-parent checked-modes)
"Return the Evil state to use for MODE or its alias.
Return DEFAULT if no initial state is associated with MODE.
The initial state for a mode can be set with
`evil-set-initial-state'.
If FOLLOW-PARENT is non-nil, also check parent modes of MODE and
its alias. CHECKED-MODES is used internally and should not be set
initially."
(when (memq mode checked-modes)
(error "Circular reference detected in ancestors of `%s'\n%s"
major-mode checked-modes))
(let ((mode-alias (let ((func (symbol-function mode)))
(when (symbolp func) func))))
(or (cl-dolist (entry (evil-state-property t :modes) default)
(let ((state (car entry))
(modes (symbol-value (cdr entry))))
(when (or (memq mode modes)
(and mode-alias (memq mode-alias modes)))
(cl-return state))))
(and follow-parent (get mode 'derived-mode-parent)
(evil-initial-state (get mode 'derived-mode-parent)
nil t (cons mode checked-modes)))
(and follow-parent mode-alias
(get mode-alias 'derived-mode-parent)
(evil-initial-state (get mode-alias 'derived-mode-parent)
nil t (cons mode-alias checked-modes))))))