abo-abo / hydra

make Emacs bindings that stick around
1.84k stars 112 forks source link

Improve :pre-body hook semantics or add new hook #359

Open madand opened 4 years ago

madand commented 4 years ago

The code from :pre-body hook is called only when a hydra is activated by hydra-something/body command, but it is ignored when the hydra is activated implicitly by directly calling one of its heads (e.g. hydra-something/my-command).

In Spacemacs we have a thin abstraction on top of Hydra called a Transient State. And it is very common to activate transient state by directly calling one of its sub-commands (hydra heads), thus bypassing a call to hydra-something/body. I discovered this peculiarity of :pre-body while investigating a Spacemacs issue syl20bnr/spacemacs#13176.

I see 3 possible solutions for the above issue:

  1. Adjust :pre-body hook semantics, so it is also called when a hydra is activated by direct call to its head.
  2. Add new hook (e.g. :pre-hydra) with the described semantics and let :pre-body be as before.
  3. Reject this issue on hydra level. Then, I will hack the Spacemacs-specific solution on top of the existing :pre and :pre-body hooks.

If you choose 1 or 2, I am ready to make a PR.

Looking forward for your feedback @abo-abo.

madand commented 4 years ago

@abo-abo ping

abo-abo commented 4 years ago

Please PR with the first approach.

madand commented 4 years ago

OK, thanks for prompt response.

abo-abo commented 4 years ago

Thanks. I need an Emacs Copyright assignment for changes over 15 lines. Are you willing to get it? See CONTRIBUTING.org for more info.

madand commented 4 years ago

Yes, I am willing to get it. Already sent an email to GNU. Will keep you posted here.

madand commented 4 years ago

Assignment paperwork is done, here is the final signed document: https://pub.madand.net/gnu/Kmit.1505691.GNU.EMACS.pdf

Please let me know if anything more needs to be done for this PR to be merged.

madand commented 4 years ago

@abo-abo ping. See previous comment regarding the copyright assignment and #368 with the PR itself.

madand commented 4 years ago

@abo-abo ping

madand commented 3 years ago

Hi there, @abo-abo. GitHub has notified me that the Spacemacs' https://github.com/syl20bnr/spacemacs/pull/13176#issuecomment-774615850 was marked stale. Since "the right way" fix for that issue depends on #368 being merged into Hydra, I wonder whether you are still willing to merge it?

madand commented 3 years ago

@abo-abo ping

lebensterben commented 2 years ago

@abo-abo Hi I'm a co-maintainer of Spacemacs, please let us know whether you're still interested in the said PR.