Fix void-variable sym errors

And remove trailing hyphen on anonymous transient hooks.
This commit is contained in:
Henrik Lissner 2019-05-05 00:01:52 -04:00
parent e9b750cc74
commit c42600d771
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -227,13 +227,14 @@ advised)."
(let ((append (if (eq (car forms) :after) (pop forms)))
(fn (if (symbolp (car forms))
(intern (format "doom|transient-hook-%s" (pop forms)))
(make-symbol "doom|transient-hook-"))))
(make-symbol "doom|transient-hook"))))
`(let ((sym ,hook-or-function))
(fset ',fn
(lambda (&rest _)
,@forms
(let ((sym ,hook-or-function))
(cond ((functionp sym) (advice-remove sym #',fn))
((symbolp sym) (remove-hook sym #',fn)))
((symbolp sym) (remove-hook sym #',fn))))
(unintern ',fn nil)))
(cond ((functionp sym)
(advice-add ,hook-or-function ,(if append :after :before) #',fn))