Function: evil-ex-set-initial-state
evil-ex-set-initial-state is an interactive and byte-compiled function
defined in evil-commands.el.
Signature
(evil-ex-set-initial-state STATE)
Documentation
Set the initial state for the current major mode to STATE.
This is the state the buffer comes up in. See evil-set-initial-state.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
;; TODO: should we merge this command with `evil-set-initial-state'?
(evil-define-command evil-ex-set-initial-state (state)
"Set the initial state for the current major mode to STATE.
This is the state the buffer comes up in. See `evil-set-initial-state'."
:repeat nil
(interactive "<state>")
(if (not (or (assq state evil-state-properties)
(null state)))
(user-error "State %s cannot be set as initial Evil state" state)
(let ((current-initial-state (evil-initial-state major-mode)))
(unless (eq current-initial-state state)
;; only if we selected a new mode
(when (y-or-n-p (format "Major-mode `%s' has initial mode `%s'. \
Change to `%s'? "
major-mode
(or current-initial-state "DEFAULT")
(or state "DEFAULT")))
(evil-set-initial-state major-mode state)
(when (y-or-n-p "Save setting in customization file? ")
(dolist (s (list current-initial-state state))
(when s
(let ((var (intern (format "evil-%s-state-modes" s))))
(customize-save-variable var (symbol-value var)))))))))))