corgi-emacs / corgi

Unbundled Emacs configuration aimed at Clojure developers
180 stars 18 forks source link

Consider replacing which-key #13

Closed plexus closed 2 years ago

plexus commented 2 years ago

I've been looking at a lingering issue in Corkey. When you pop up which-key with a prefix key it generally shows the descriptions provided in the binding/signal files as it should, but for some commands it just shows the function name.

The problem turns out is that which-key can't do minor-mode based replacement, and we have quite a few minor-mode specific bindings.

Going through the which-key sources it struck me that this package is doing a lot of stuff that we don't use/need/want, and the way it goes about its work is needlessly complicated. In Corkey we have all the information we need up-front, so we don't need to deal with replacement data structures. We can just render the normalized signal/binding data directly. Store that in a buffer-local var and be done with it.

which-key is also 2700 lines of code, I think it would be well within the spirit of Corgi to find something smaller that we can more easily adapt to our needs. Or potentially to take inspiration of what's out there and roll our own.

Main candidates I've seen

plexus commented 2 years ago

Scratch Hercules, it actually just uses which-key under the hood :/

plexus commented 2 years ago

transient looks like it's worth a good look as well. At first glance it seems like it's the keybinding system from magit, but split out into its own package, and apparently from Emacs 28 bundled with Emacs (or just elpa?).

Looking at the manual I'm guessing this will not be a small and simple package, but having it built (with fallback to a package for Emacs 27) could be a compelling argument.

I'm still tempted to try to roll something ourself, because I feel like our needs are actually really modest, but maybe I'm underestimating the difficulty of certain aspects. Maybe I need to try to implementing it to start to appreciate what these packages can offer.

theophilusx commented 2 years ago

I like the idea of developing something specific which works with corkey. Don't know enough about transient to judge how suitable it would be. However, I do believe transient will/is in elpa, which means that it could also be used in Emacs 27 (possibly even Emacs 26).

As you mention, pretty much all the information we need is in the corkey keys file. Having something which uses that information to generate something similar to what which-key does would be great.

Another idea, not deeply considered, might be using hydra? However, that would possibly have a larger impact on corkey and it isn't part of Emacs. Still, might be a source for some ideas.

plexus commented 2 years ago

Turns out there was a glaringly obvious solution to fixing all of our which-key issues, and reading through more of which-key's source has given me a better appreciation of all the cases it covers, so I no longer see a need to replace it.

https://github.com/corgi-emacs/corkey/pull/3