embark
embark copied to clipboard
Working around the absence of embark-around-action-hooks
embark--cd
and embark--narrow-to-target
have a very similar and, in my opinion, complex implementations. I think these implementations are complex because the code is trying to implement the concept of "around" in a code that is only executed before the command.
I suggest introducing an embark-around-action-hooks
variable instead. This will not only simplify the implementation of the 2 functions but will also make it simpler for others to have around hooks.
I volunteer for implementing that if you want to.
Maybe embark--confirm
could be moved to the new hooks variable. This would avoid using an exception for what is normal behavior.
I've actually been thinking about doing this for a while.
I've just discovered I need that for my own package as well:
(cl-defun mpdel-embark-fake-selected-entities (&key target &allow-other-keys)
(cl-labels ((fake-selected-entities
()
(advice-remove 'mpdel-core-selected-entities #'fake-selected-entities)
(list target)))
(advice-add 'mpdel-core-selected-entities :override #'fake-selected-entities)))
(dolist (command mpdel-embark--commands)
(setf (alist-get command embark-pre-action-hooks)
(list #'mpdel-embark-fake-selected-entities)))
Would you like a PR?
Hi @DamienCassou! I wrote an around hook implementation in a separate branch called around-hooks. I'd greatly appreciate it if you could test it.
I've switched to the new branch and will report any issue.