justbur / emacs-which-key

Emacs package that displays available keybindings in popup
GNU General Public License v3.0
1.74k stars 87 forks source link

possible to rename existing prefix? #280

Open mmcnl opened 3 years ago

mmcnl commented 3 years ago

Hello and thank you @justbur for providing such a helpful package!

I'm wondering if it's possible to rename an existing prefix that's already been defined (in my case by spacemacs). (The functionality to rename an existing command works perfectly:

    (which-key-add-key-based-replacements "SPC :" "abc") ;; changes command name as expected to 'abc'

But if I wanted to rename the SPC a prefix (currently applications in spacemacs), this code doesn't seem to do anything for me:

(which-key-add-key-based-replacements "SPC a" "abc")

If this is possible, what's the correct approach?

justbur commented 3 years ago

It depends a bit on how spacemacs is defining the prefix name, but there should be a way to override it. It's possible the prefix naming is being deferred, so they are renaming it after you do.

The simplest way to do it might be to use a method that has higher precedence on which-key's side. If you know the keymap that the key definition is going into you can try

(which-key-add-keymap-based-replacements keymap "SPC a" "abc")
mmcnl commented 3 years ago

Cool, thanks for the tip @justbur! :)