diff options
| author | Axel Forsman <axel@axelf.se> | 2023-08-13 08:37:20 +0200 |
|---|---|---|
| committer | Axel Forsman <axel@axelf.se> | 2023-08-13 08:37:20 +0200 |
| commit | 1e9b2434264529fe0dd964b68fe89236a4abeac3 (patch) | |
| tree | 4be7acb5cc30ae798d8aaf827f7bf6b4cadf5d40 | |
| parent | 0cbd61f2de104fab16602d0418605cd0513b16f3 (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))) |
