Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

How to have limit which-key to subset of keymaps #277

Open
zcaudate opened this issue Dec 20, 2020 · 4 comments
Open

How to have limit which-key to subset of keymaps #277

zcaudate opened this issue Dec 20, 2020 · 4 comments

Comments

@zcaudate
Copy link

I'd like to have which-key only display only the choices for mode when it is present

for example, I'd like to toggle iedit mode and have which-key display just the iedit mode keys.

Is there a way to do this?

@justbur
Copy link
Owner

justbur commented Dec 20, 2020 via email

@zcaudate
Copy link
Author

is there an example that I can go off.

basically, I'd like to have a hook for a given minor-mode (iEdit) that only shows it's own keybindings (ignoring other modes like Paredit mode)

or, if there was some way to further customise key bindings are shown (in Ranger/Dired)

@justbur
Copy link
Owner

justbur commented Dec 21, 2020

Here's one way to go:

(setq which-key-allow-multiple-replacements nil)
(setq which-key-replacement-alist '(((nil . "iedit-") . (nil . nil))
                                    ((nil . nil) . t)))

In this setup, a command starting with iedit- will get passed through unchanged (the first item in the alist), while any other command will be discarded (the second item in the alist). Disallowing multiple matches through the first setting is important here.

@zcaudate
Copy link
Author

@justbur. thanks for that. Your example initially confused me until I started playing with it. I think there's actually an easier solution that's already in the library - which-key-show-keymap. I'll need to hook it in with the iedit mode itself.

Will play around with it once I get more time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants