Skip to content
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

Paging with which-key not working #114

Open
pascal-huber opened this issue May 25, 2020 · 10 comments
Open

Paging with which-key not working #114

pascal-huber opened this issue May 25, 2020 · 10 comments

Comments

@pascal-huber
Copy link

Hi, I am delighted to see that god-mode is maintained again and even with us evil-users in mind! 👍

I created my own copy of god-mode a while back to work in evil-mode. Though I have changed god-modes behavior as suggested here (e.g. C-c p f = cpf) and removed quite a lot of stuff I don't need.

One challenge I faced was to get which-key paging working. I ended up hard-coding internal which-key commands. I just installed your melpa release (2.16.2) and which-key help & paging doesn't seem to work. I get: God: Unknown key binding for ‘C-c C-^H‘. Or am I doing something wrong?

Also I want to ask about your intentions on the above mentioned issue 73 - but maybe this should be discussed in that issue.

@darth10
Copy link
Collaborator

darth10 commented May 26, 2020

Hi @SirPscl!
Thanks for the positive feedback.

Have you tried calling which-key-enable-god-mode-support as described here in the which-key README?

For example, if you're using use-package, you'd need something like this to get which-key paging to work correctly with god-mode:

(use-package which-key
  :config
  (which-key-enable-god-mode-support))

@pascal-huber
Copy link
Author

pascal-huber commented May 26, 2020

Hi @darth10

Thanks for your reply. Yes, I have enabled god-mode support. and the which-key menu also shows up. Its the paging which doesn't work. Sorry for not describing the problem better, Ill give it another shot:

Sometimes there is not enough space to show all key bindings in the which-key minibuffer. With "normal" which-key you can then use C-h to show the help-menu followed by n and p to get to the next/previous page. This doesn't seem to work with god-mode because the help-menu doesn't show up on C-h. At least not on my end. There are some more functions which-key offers in its help-menu that I don't use but also don't seem to work with god-mode (undo-key, toggle-docstring, help, abort and digit-arg).

@darth10
Copy link
Collaborator

darth10 commented May 26, 2020

Yes, which-key-enable-god-mode-support is particularly useful for paging with which-key.

Another recommended which-key option is to use a dedicated window instead of the minibuffer.
This can be done using which-key-setup-side-window-bottom, which-key-setup-side-window-right or which-key-setup-side-window-right-bottom as described here.

I used to have several issues with which-key and god-mode in vanilla Emacs, but finally got them working with paging using this configuration:

(use-package which-key
  :bind (("C-' k" . which-key-mode)
         ("C-' C-k" . which-key-mode))
  :init
  (which-key-setup-side-window-bottom)
  (which-key-enable-god-mode-support)
  ;; ...
  (which-key-mode t))

If you're using Doom Emacs, which-key is already configured to use a dedicated window.
Unfortunately, to work properly with god-mode, you'll still need to call which-key-enable-god-mode-support like this:

(after! which-key
  (which-key-enable-god-mode-support))

I will try to get this configuration added to Doom Emacs soon.

If you're still having issues, could you please send me more details such as your Emacs configuration and which OS you're using.

@pascal-huber
Copy link
Author

@darth10 thank you

If you're still having issues, could you please send me more details such as your Emacs configuration

A minimal vanilla config with which it doesn't work on my machine (with and without the dedicated window, and the order doesn't seem to matter)

(require 'package)
(setq package-archives
      '(("gnu"   . "https://elpa.gnu.org/packages/")
        ("melpa" . "https://melpa.org/packages/")))
(package-initialize)

;; God
(require 'god-mode)
(god-mode)

;; Which-key
(require 'which-key)
(which-key-setup-side-window-bottom)
(which-key-enable-god-mode-support)
(global-set-key (kbd "<escape>") #'god-local-mode)
(which-key-mode t)

and which OS you're using.

emacs 26.3 on Void Linux.

@darth10
Copy link
Collaborator

darth10 commented May 26, 2020

@SirPscl I've managed to recreate this issue even with a dedicated window.
Sorry about the confusion.
I will get back to you with a workaround or fix soon.

@darth10 darth10 changed the title Which-key (and Prefix settings) Paging with which-key not working May 26, 2020
@darth10 darth10 added bug and removed question labels May 26, 2020
@darth10
Copy link
Collaborator

darth10 commented May 29, 2020

Looks like this can be fixed in which-key's God mode support.
I've created a PR (justbur/emacs-which-key#247) to fix this.
Theres a known issue, but hopefully that can be ironed out soon.

@SirPscl It would be really helpful if you could try out this fix from my which-key fork/branch and report any issues.

@darth10 darth10 self-assigned this May 29, 2020
@pascal-huber
Copy link
Author

pascal-huber commented May 29, 2020

@darth10 Thanks!

Just gave it a shot. That looks promising :) I did encounter a weird behavior though:

  1. call god-execute-with-current-bindings OR with god-mode enabled and evil-mode disabled
  2. enter for example c p (for projectile)
  3. enter C-h
  4. wait approx. 0.5 seconds
    -> the which key-window now disappears - the which-key help-menu is still present
  5. enter n
    -> A which-key error message briefly appears before the which-key menu shows again on page 1 (the error: - which-key can’t show keys: There is not enough space based on your settings and frame size.)

If in step 3 I quickly enter C-h n the paging works fine though. Also if I enter the key sequence in Emacs manner (C-c p C-h ) I don't get the error.

Edit: I think this may be an issue on my side - If I use the minimal init.el I don't get the issue described above.

@darth10
Copy link
Collaborator

darth10 commented May 29, 2020

@SirPscl That sounds like the timer issue I mentioned in the PR.
I've pushed a fix for as well (darth10/emacs-which-key@ebcc4e6), so that you can try it out.
Note that these commits may change due to commit squashes or amends.

@pascal-huber
Copy link
Author

@darth10

Just tried it out - works like a charm :)

Thanks a lot! 👍

@darth10
Copy link
Collaborator

darth10 commented Dec 31, 2022

Since justbur/emacs-which-key#247 hasn't been merged yet (and still has issues), my current workaround is to use embark-prefix-help-command from embark for prefix-help-command instead:

(setq which-key-use-C-h-commands nil
      prefix-help-command #'embark-prefix-help-command)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants