-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make leader key descriptions in the keymap itself #7339
base: master
Are you sure you want to change the base?
fix: make leader key descriptions in the keymap itself #7339
Conversation
6cf64d9
to
caff7de
Compare
4a967eb
to
4860b33
Compare
So I removed the |
Now you can define any key to Basically, now doing
works as expected with respect to the |
626d679
to
11163bc
Compare
I just pushed an update to exclude some minibuffer modes from |
This commit moves leader key descriptions from `which-key-replacement-alist` to the keymap itself. This helps with performance because that way, which-key does not have to calculate every single leader key description for each keypress. Furthermore, this fixes issues like doomemacs#1413 where relocating leader keymaps resulted in which-key not showing the correct leader key descriptions. I also made the leader prefix maps have their own prefix commands by populating the function slot of the keymap variables. This is an Emacs convention. I made `doom-leader-map` follow this convention as well.
With this commit, now you can define any key to `doom-locallleader-map` symbol and it will work as expected. The `which-key` descriptions will work as expected too. The only caveat is that the localleader map is now updated using hooks so there the potential for bugs where the incorrect map is selected.
11163bc
to
afaf293
Compare
Okay. I am currently testing using |
adee892
to
8429b60
Compare
Hi. I have updated this to use |
(set-keymap-parent doom-localleader-map | ||
(cdr (assq major-mode doom-localleader-map-alist)))) | ||
|
||
(add-hook 'post-command-hook #'doom-update-localleader-key-h) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does this need to run after each and every command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally I had it hooked to doom-switch-buffer-hook
, doom-switch-frame-hook
, doom-switch-window-hook
, and after-change-major-mode-hook
but then it kept running in unexpected scenarios that happened inter-command like when the Corfu popup would show up so I had to set a bunch of predicates for that hook to run and I was not able to find a working set of predicates. After switching it to a post-command-hook
, I was able to remove all those predicates and just run the set-keymap-parent
action itself. It runs fast enough to not cause any noticeable latency:
Just want to say that I've been testing this pr with my meow config, and it fixes the issues with using meow and doom's leader/localleader instead of meow's keypad mode. localleader now appears where it should and works perfectly along with meow's modes and doom's standard leader key (spc). Before, with meow, the localleader would not work via the doom leader (it had to be bound to a different top level key combination). |
This is because immediately after switching persps or using similar commands, the current-buffer is not the buffer that is displayed in the window.
I just discovered issues with edge cases where the localleader map is used for a minor mode or for a derived mode, so for |
could we merge or consider #7189 as a previous step please? for me the ability to activate the leader key or alt-key combos in more evil states already solves my use-case. and it extends the more general approach from this patch to specify which evil states the leader and localleader map is for. |
I am going to try to fix this this weekend. I really want to get this PR merged too because it's critical for my config. |
Ok. I am going to stop working on this for some time since Hlissner said he was going to make major changes to the core keybindings code. |
I realize this is on hold pending bigger changes ... but at the moment it's holding me back from updating with more recent doom commits. When I update to the current main branch with this PR I get errors from modules about bindings:
I've looked around to see if I can figure out how to adapt the changes, but it's beyond my knowledge of Doom's inner workings and the time i have at the moment. For now I'm just not updating, but I'd love to be able to keep my bindings working and update to get the latest changes occasionally. |
This commit moves leader key descriptions from
which-key-replacement-alist
to the keymap itself. This helps with performance because that way, which-key does not have to calculate every single leader key description for each keypress. Furthermore, this fixes issues like #1413 where relocating leader keymaps resulted in which-key not showing the correct leader key descriptions.I also made the leader prefix maps have their own prefix commands by populating the function slot of the keymap variables. This is an Emacs convention. I made
doom-leader-map
follow this convention as well, though I kept thedoom/leader
so as to not break existing configs.