diff options
| author | Axel Forsman <axel@axelf.se> | 2023-08-13 08:37:20 +0200 |
|---|---|---|
| committer | Tom Dalziel <tom_dl@hotmail.com> | 2023-08-20 23:46:23 +0100 |
| commit | 9eb69b7f5b3c72cfc66f69b3242e935015780654 (patch) | |
| tree | a07c1f4c931eeefde680707f5fdf6bc19ec01312 | |
| parent | 1c4c3bfff8987aa498d6bb8bd88e2e4ba9615ab9 (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.el | 12 |
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))) |
