Function: evil-set-leader

evil-set-leader is a byte-compiled function defined in evil-core.el.

Signature

(evil-set-leader STATE KEY &optional LOCALLEADER)

Documentation

Set KEY to trigger leader bindings in STATE.

KEY should be in the form produced by kbd. STATE is one of normal, insert, visual, replace, operator, motion, emacs, a list of one or more of these, or nil, which means all of the above. If LOCALLEADER is non-nil, set the local leader instead.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-core.el
(defun evil-set-leader (state key &optional localleader)
  "Set KEY to trigger leader bindings in STATE.
KEY should be in the form produced by `kbd'. STATE is one of
`normal', `insert', `visual', `replace', `operator', `motion',
`emacs', a list of one or more of these, or `nil', which means
all of the above. If LOCALLEADER is non-nil, set the local leader
instead."
  (let* ((all-states '(normal insert visual replace operator motion emacs))
         (states (cond ((null state) all-states)
                       ((consp state) state)
                       (t (list state))))
         (leaderkey (if localleader [localleader] [leader]))
         (binding
          `(menu-item "" nil :filter ,(lambda (_cmd) (key-binding leaderkey)))))
    (dolist (state states)
      (evil-global-set-key state key binding))))