aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxel Forsman <axel@axelf.se>2023-08-13 08:37:20 +0200
committerAxel Forsman <axel@axelf.se>2023-08-13 08:37:20 +0200
commit1e9b2434264529fe0dd964b68fe89236a4abeac3 (patch)
tree4be7acb5cc30ae798d8aaf827f7bf6b4cadf5d40
parent0cbd61f2de104fab16602d0418605cd0513b16f3 (diff)
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.
-rw-r--r--evil-common.el12
1 files changed, 7 insertions, 5 deletions
diff --git a/evil-common.el b/evil-common.el
index 84b0817..9504cda 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)))