Function: evil-define-minor-mode-key

evil-define-minor-mode-key is a byte-compiled function defined in evil-core.el.

Signature

(evil-define-minor-mode-key STATE MODE KEY DEF &rest BINDINGS)

Documentation

Similar to evil-define-key but the bindings are associated with the minor-mode symbol MODE instead of a particular map. Associating bindings with a mode symbol instead of a map allows evil to use Emacs' built-in mechanisms to enable the bindings automatically when MODE is active without relying on calling evil-normalize-keymaps. Another less significant difference is that the bindings can be created immediately, because this function only uses the symbol MODE and does not rely on its value.

See evil-define-key for the usage of STATE, KEY, DEF and BINDINGS.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-core.el
(defun evil-define-minor-mode-key (state mode key def &rest bindings)
  "Similar to `evil-define-key' but the bindings are associated
with the minor-mode symbol MODE instead of a particular map.
Associating bindings with a mode symbol instead of a map allows
evil to use Emacs' built-in mechanisms to enable the bindings
automatically when MODE is active without relying on calling
`evil-normalize-keymaps'. Another less significant difference is
that the bindings can be created immediately, because this
function only uses the symbol MODE and does not rely on its
value.

See `evil-define-key' for the usage of STATE, KEY, DEF and
BINDINGS."
  (declare (indent defun))
  (let ((maps (mapcar
               (lambda (st)
                 (evil-get-minor-mode-keymap st mode))
               (if (listp state) state (list state)))))
    (while key
      (dolist (map maps)
        (define-key map key def))
      (setq key (pop bindings)
            def (pop bindings)))))