Skip to content

Make embark-prefix-help-command work under which-key#810

Open
LemonBreezes wants to merge 1 commit into
oantolin:masterfrom
LemonBreezes:which-key-prefix-help
Open

Make embark-prefix-help-command work under which-key#810
LemonBreezes wants to merge 1 commit into
oantolin:masterfrom
LemonBreezes:which-key-prefix-help

Conversation

@LemonBreezes
Copy link
Copy Markdown
Contributor

@LemonBreezes LemonBreezes commented May 30, 2026

Ok. I have been using this code change for over a year in my config. It makes it so C-h in which-key brings up the Embark prefix help. Very useful and nice!

@LemonBreezes LemonBreezes marked this pull request as ready for review May 30, 2026 21:40
@oantolin
Copy link
Copy Markdown
Owner

I'm not 100% sure but I think that the mere fact that the commit is coauthored by an LLM means I cannot accept it, since Embark is in GNU ELPA and they won't take any LLM-generated code. This is for copyright reasons: it seems likely that LLM code cannot be copyrighted, but anything in GNU ELPA needs to be copyrightable and have its copyright assigned to the FSF. I believe GNU hasn't made a final decision on this, but in the meantime GNU Emacs specifically is not taking any LLM-generated code contributions.

@LemonBreezes
Copy link
Copy Markdown
Contributor Author

LemonBreezes commented May 31, 2026

I'm not 100% sure but I think that the mere fact that the commit is coauthored by an LLM means I cannot accept it, since Embark is in GNU ELPA and they won't take any LLM-generated code. This is for copyright reasons: it seems likely that LLM code cannot be copyrighted, but anything in GNU ELPA needs to be copyrightable and have its copyright assigned to the FSF. I believe GNU hasn't made a final decision on this, but in the meantime GNU Emacs specifically is not taking any LLM-generated code contributions.

Oh, the LLM did not write the code. I had it in my config for over a year, before LLM was mainstream. I just asked the LLM to make a draft PR out of the code.

So the LLM did not write any code, it updated the README and copy-pasted my code then added whitespace, comments, and function documentation.

@oantolin
Copy link
Copy Markdown
Owner

I don't know if that changes the situation, I'll ask around.

@LemonBreezes LemonBreezes force-pushed the which-key-prefix-help branch from d141613 to a16c425 Compare May 31, 2026 18:04
@oantolin
Copy link
Copy Markdown
Owner

Okay, so the advice I received is that since you wrote the code, I can review the pull request in the usual way, but I should probably rewrite the change log entry to be safe.

@minad
Copy link
Copy Markdown
Contributor

minad commented May 31, 2026

FWIW I am not fond of adding a which-key integration here. I don't even have it installed in my Emacs. Any reason why this code cannot go as well into the wiki? Embark even offers a better alternative to which-key.

@oantolin
Copy link
Copy Markdown
Owner

oantolin commented May 31, 2026

I used to feel the same way, @minad, but which-key comes with Emacs now, so I think which-key integration is reasonable (for people who don't recognize the superiority of embark-prefix-help-command 🤷). If which-key were not included with Emacs I would have immediately said "this should go in the wiki".

@oantolin
Copy link
Copy Markdown
Owner

I don't even have it installed in my Emacs.

How did you pull that off? 🙂

@LemonBreezes
Copy link
Copy Markdown
Contributor Author

I figured instead of PRing the shim into Doom Emacs that 99% of people using Emacs enable which-key so a little glue for an edge case made sense. Basically, if you call which-key with a command explicitly then type C-h to bring up Embark, you need this code.

@oantolin
Copy link
Copy Markdown
Owner

Upon further reflection, it does feel a little odd to add support to switch from which-key to embark-prefix-help-command, which is an alternative to which-key. It feels similar to adding markdown syntax support to org mode or a command to vertico to switch to icomplete, which sound like strange things to do.

Maybe it would be better to make an embark-which-key package? You could also add the which-key indicator that's on the embark wiki to that package.

@LemonBreezes
Copy link
Copy Markdown
Contributor Author

Upon further reflection, it does feel a little odd to add support to switch from which-key to embark-prefix-help-command, which is an alternative to which-key. It feels similar to adding markdown syntax support to org mode or a command to vertico to switch to icomplete, which sound like strange things to do.

Maybe it would be better to make an embark-which-key package? You could also add the which-key indicator that's on the embark wiki to that package.

Maybe as a separate file like embark-which-key in this repo? Those which-key commands like which-key-show-major-mode I do use and I use them with embark + grid view too.

@oantolin
Copy link
Copy Markdown
Owner

Yes, a separate embark-which-key.el file might make sense. I'll think about it a bit. What I use instead of which-key-show-major-mode is embark-bindings, which by default shows only commands bound in the local map and minor mode maps (i.e., commands from the major mode and enabled minor modes).

@minad
Copy link
Copy Markdown
Contributor

minad commented May 31, 2026

How did you pull that off?

I use a stripped-down Emacs.

I used to feel the same way, @minad, but which-key comes with Emacs now, so I think which-key integration is reasonable.

Well, I maintain my opinion that not every addition to Emacs is or was reasonable. The amount of old cruft in Emacs is staggering.

Given that we have a better alternative here I don't see why one should not promote and recommend that instead.

In particular I disagree with the way the addition is made here via globally installed advices. This does not look like a clean addition to me.

When `embark-prefix-help-command' is used as `prefix-help-command' and
the which-key package is active, which-key rebinds the help key to its
own paging menu while its popup is showing, which shadows the prefix
help.  Add `:around' advice on `which-key-C-h-dispatch' that routes the
help key to Embark when `prefix-help-command' is set to
`embark-prefix-help-command', and otherwise defers to which-key.

This also handles which-key being summoned explicitly (e.g. via
`which-key-show-top-level' or `which-key-show-keymap') rather than from
an incomplete key sequence: in that case there is no active prefix to
describe, so the keymap which-key is currently displaying is recorded
via `:before' advice on `which-key--show-keymap' and passed to
`embark-bindings-in-keymap'.
@LemonBreezes LemonBreezes force-pushed the which-key-prefix-help branch from a16c425 to cde9d27 Compare May 31, 2026 22:30
@minad
Copy link
Copy Markdown
Contributor

minad commented Jun 2, 2026

Note that there is also https://github.com/oantolin/embark/wiki/Additional-Configuration#use-which-key-like-a-key-menu-prompt. I think all of the which-key related code should go into a separate package, and not only minor integrations like this one. It could be part of this repository as embark-which-key.el, but then, Omar is not using which-key, so it won't go maintained, I guess?

@LemonBreezes
Copy link
Copy Markdown
Contributor Author

LemonBreezes commented Jun 2, 2026

Note that there is also https://github.com/oantolin/embark/wiki/Additional-Configuration#use-which-key-like-a-key-menu-prompt. I think all of the which-key related code should go into a separate package, and not only minor integrations like this one. It could be part of this repository as embark-which-key.el, but then, Omar is not using which-key, so it won't go maintained, I guess?

I can maintain it. I'm really awesome and I'm probably gonna use Emacs for another 60 years.

@minad
Copy link
Copy Markdown
Contributor

minad commented Jun 2, 2026

I can maintain it. I'm really awesome and I'm probably gonna use Emacs for another 60 years.

That's good. But then the which-key integration should be "complete" and also contain this indicator stuff from the wiki. And it should be a separate file at least, or maybe a separate package.

To be honest, I had hoped that we could avoid the which-key discussion for a little longer, given that Embark still supports Emacs 29, so we would have to add a dependency here for which-key or make sure that it also compiles fine without which-key or distribute it as separate package or even put it in a separate repository.

@oantolin
Copy link
Copy Markdown
Owner

oantolin commented Jun 5, 2026

I think I would prefer if you made a separate embark-which-key package, @LemonBreezes, for integration. I just added a which-key-like embark-automatic-prefix-help-mode, so even more than before it feels like Embark is an alternative to which-key and thus an integration package between the two is sort of a niche concern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants