emacs-which-key
emacs-which-key copied to clipboard
Fix paging with God mode
Paging in which-key
is not working when C-h
(help-char
) is entered in God mode.
This bug has been reported recently (emacsorphanage/god-mode#114), but it's been an issue for a while.
Current behaviour:
This PR attempts to fix this issue. The changes can be summarised as follows:
- Use
nadvice.el
instead ofadvice.el
. - Fix paging with God mode using an
:around
advice forgod-mode-lookup-key-sequence
.
Behaviour with these changes:
Known issues:
-
There's currently an issue when
which-key-undo-key
is invoked from the help menu. From what I can tell, this is caused bywhich-key--update
orwhich-key--hide-popup
being invoked through a timer. I've tried callingwhich-key--stop-timer
in the new advice function appropriately, but then the paging ofwhich-key-undo-key
has the same issue. Also, I'm not sure this is the best way to fix the problem. Here's what the behaviour looks like with the possible fix usingwhich-key--stop-timer
(ebcc4e6):It would be great if I could get some clues on how to fix this issue. However, if it's still complicated, this issue could be tracked separately and fixed later on.
Any feedback is more than welcome!
@justbur It would be really helpful if you could provide any feedback on this PR.
I'm not very familiar with god-mode to start with, but after some basic testing it looks like god-mode breaks the basic emacs mechanism of using help-char
to get help in the middle of an incomplete key sequence. In vanilla emacs, after say C-x
emacs waits for you to complete the key sequence. If in an incomplete sequence you type help-char
, which is C-h
by default you get the command stored in prefix-help-command
, which is describe-prefix-bindings
by default. which-key takes over this functionality to do paging.
I can't trigger describe-prefix-bindings
in god-mode in vanilla emacs (meaning with nothing else enabled) which points to a basic problem with how god-mode works. Neither x h
nor x C-h
works.
It seems to me that fixing this aspect of god-mode without worrying about which-key should be the first approach. If that is impossible for some reason, we can explore using the advice mechanism in which-key.
I'll try modifying God mode to call prefix-help-command
on entering help-char
and follow up soon.
I've converted this PR to a draft for now.
Great, thanks for your work.
@justbur I've managed to fix God mode's handling of help-char
.
This was done in commit emacsorphanage/god-mode@e80b6e6 as part of emacsorphanage/god-mode#115.
With the way God mode uses the command loop, this was possible only with the use of unread-command-events
to add key sequences to the command loop.
Even with this change, help-char
somehow fails to call which-key-C-h-dispatch
when which-key-mode
is enabled.
I'm open to suggestions for making the implementation in God mode better in any way.
That being said, as emacsorphanage/god-mode@e80b6e6 adds the god-mode-help-char-dispatch
function to handle help-char
, adding advice functions to call which-key-C-h-dispatch
for paging becomes a bit easier.
I've updated this PR to do just that.
However, the timer issue with which-key-undo-key
I described earlier is still present.
Any feedback to help fix this issue is more than welcome.
Alternatively, this particular issue can also be tracked and fixed separately.
@justbur Have you had a chance to review my fix in God mode and the changes in this PR?
I asked a couple of questions about the changes a while ago and was waiting to hear back
Please refer to this comment.
I've managed to fix God mode's handling of
help-char
. This was done in commit emacsorphanage/god-mode@e80b6e6 as part of emacsorphanage/god-mode#115.With the way God mode uses the command loop, this was possible only with the use of
unread-command-events
to add key sequences to the command loop. Even with this change,help-char
somehow fails to callwhich-key-C-h-dispatch
whenwhich-key-mode
is enabled. I'm open to suggestions for making the implementation in God mode better in any way.
So, help-char
now calls prefix-help-command
in God mode, but the issue with which-key
is not resolved.
I've updated this PR with simpler advice functions, which was possible due to the help-char
fix in God mode.