Function: evil-state-keymaps
evil-state-keymaps is a byte-compiled function defined in
evil-core.el.
Signature
(evil-state-keymaps STATE &rest EXCLUDED)
Documentation
Return a keymap alist of keymaps activated by STATE.
If STATE references other states in its :enable property,
these states are recursively processed and added to the list.
(The EXCLUDED argument is an internal safeguard against
infinite recursion, keeping track of processed states.)
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-core.el
(defun evil-state-keymaps (state &rest excluded)
"Return a keymap alist of keymaps activated by STATE.
If STATE references other states in its :enable property,
these states are recursively processed and added to the list.
\(The EXCLUDED argument is an internal safeguard against
infinite recursion, keeping track of processed states.)"
(let* ((state (or state evil-state))
(enable (evil-state-property state :enable))
(map (cons
(evil-state-property state :mode)
(evil-state-property state :keymap t)))
(local-map (cons
(evil-state-property state :local)
(evil-state-property state :local-keymap t)))
(minor-mode-maps (evil-state-minor-mode-keymaps state))
(aux-maps (evil-state-auxiliary-keymaps state))
(overriding-maps
(evil-state-overriding-keymaps state))
(intercept-maps
(evil-state-intercept-keymaps state))
(result `(,intercept-maps))
(remove-duplicates (null excluded)))
(unless (memq state enable)
(setq enable (cons state enable)))
;; process STATE's :enable property
(dolist (entry enable)
(cond
((memq entry excluded))
;; the keymaps for STATE
((eq entry state)
(setq result `(,@result
(,local-map)
,minor-mode-maps
,aux-maps
,overriding-maps
(,map)))
(push state excluded))
;; the keymaps for another state: call `evil-state-keymaps'
;; recursively, but keep track of processed states
((evil-state-p entry)
(setq result `(,@result
,(apply #'evil-state-keymaps entry excluded))))
;; a single keymap
((or (keymapp entry)
(and (keymapp (symbol-value entry))
(setq entry (symbol-value entry)))
(setq entry (evil-keymap-for-mode entry)))
(setq result `(,@result
((,(evil-mode-for-keymap entry t) .
,entry)))))))
;; postpone the expensive filtering of duplicates to the top level
(if remove-duplicates
(apply #'evil-concat-keymap-alists result)
(apply #'append result))))