noctuid/general.el

Consider using which-key's keymap based replacements

rgrinberg opened this issue · 1 comments

which-key added a new mechanism for adding documentation string to keymaps: justbur/emacs-which-key#261

This mechanism is much more performant because it saves the docs directly in the keymap. It would be nice if general used it instead of the old, slow mechanism.

General has always supported this syntax: (general-def "<key>" '("<description>" . <command>))

I can add an option to have :which-key rewrite the definition to this, but it will have to be opt-in because I don't think it's possible to be backwards compatible.

@leifhelm Sorry for not looking into how the new which-key system works until now. I can't use your PR because which-key-add-keymap-based-replacements doesn't just store the information somewhere in the keymap, it actually rebinds the key. General will then bind over the key. To use this mechanism, general would instead have to rewrite the definition to a cons like above (no which-key functions required). I've tested this, and it works, but this only would support changing the replacement text, and the current :which-key implementation allows you to change how the key description shows up and to use a function to generate the description.

@jgrey4296's approach might be compatible, but does which-key actually look at keybindings made under [which-key] in the current map? This doesn't seem to work for me, and it's not documented in the readme.

@justbur Does which-key have the above mechanism (i.e. look at binding for [which-key ?a] in current keymap to get replacement for a in current keymap) or did it used to?