Function: evil-with-delay
evil-with-delay is a macro defined in evil-common.el.
Signature
(evil-with-delay CONDITION HOOK &rest BODY)
Documentation
Execute BODY when CONDITION becomes true, checking with HOOK.
HOOK can be a simple symbol or of the form (HOOK APPEND LOCAL NAME) where: NAME specifies the name of the entry added to HOOK. If APPEND is non-nil, the entry is appended to the hook. If LOCAL is non-nil, the buffer-local value of HOOK is modified.
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-common.el
(defmacro evil-with-delay (condition hook &rest body)
"Execute BODY when CONDITION becomes true, checking with HOOK.
HOOK can be a simple symbol or of the form (HOOK APPEND LOCAL NAME)
where:
NAME specifies the name of the entry added to HOOK.
If APPEND is non-nil, the entry is appended to the hook.
If LOCAL is non-nil, the buffer-local value of HOOK is modified."
(declare (debug (form sexp body)) (indent 2))
(cl-destructuring-bind (hook-sym &optional append local name)
(mapcar #'macroexp-quote (if (consp hook) hook (list hook)))
(macroexp-let2* nil
((fun-name `(make-symbol
,(or name (format "evil-delay-in-%s" hook-sym))))
;; `apply-partially' is used in case this macro is expanded
;; (via `evil-define-key') in a file which still does not
;; activate `lexical-binding'.
(fun `(apply-partially
(lambda (name &rest _)
(when ,(or condition t)
(remove-hook ,hook-sym name ,local)
,@body
t))
,fun-name)))
`(unless ,(and condition `(funcall ,fun))
(progn (fset ,fun-name ,fun)
,@(when local `((put ,fun-name 'permanent-local-hook t)))
(add-hook ,hook-sym ,fun-name ,append ,local))))))