branch: elpa/evil commit 1e9b2434264529fe0dd964b68fe89236a4abeac3 Author: Axel Forsman <a...@axelf.se> Commit: Axel Forsman <a...@axelf.se>
Fix evil-with-delay with dynamic binding If dynamic binding is used when expanding the macro, then the function will not capture fun-name as a closure. Fix this by using apply-partially which is defined in a source file that uses lexical binding. --- evil-common.el | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/evil-common.el b/evil-common.el index 84b0817c17..9504cda27f 100644 --- a/evil-common.el +++ b/evil-common.el @@ -59,11 +59,13 @@ If LOCAL is non-nil, the buffer-local value of HOOK is modified." (macroexp-let2* nil ((fun-name `(make-symbol ,(or name (format "evil-delay-in-%s" hook-sym)))) - (fun `(lambda (&rest _) - (when ,(or condition t) - (remove-hook ,hook-sym ,fun-name ,local) - ,@body - t)))) + (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)))