Change add-transient-hook! to take hook suffix as 2nd arg

By default, transient hooks are defined as doom-transient-hook-N, where
N is a counter. This makes debugging them difficult.

Now, you may specify an id for the second argument. e.g.

  (add-transient-hook! 'find-file-hook load-evil (require 'evil))

Will define doom|transient-hook-load-evil, which is easier to debug and
remove, if necessary.
This commit is contained in:
Henrik Lissner 2018-05-15 13:40:18 +02:00
parent af079e5f6f
commit 6b8520d189
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395

View File

@ -110,9 +110,12 @@ invoked, then never again.
HOOK can be a quoted hook or a sharp-quoted function (which will be advised)."
(declare (indent 1))
(let ((append (eq (car forms) :after))
(fn (intern (format "doom-transient-hook-%s" (cl-incf doom--transient-counter)))))
`(when ,hook
(let ((append (if (eq (car forms) :after) (pop forms)))
(fn (intern (format "doom|transient-hook-%s"
(if (not (symbolp (car forms)))
(cl-incf doom--transient-counter)
(pop forms))))))
`(progn
(fset ',fn
(lambda (&rest _)
,@forms