Skip to content

Which-key shows wrong labels from inactive keymaps #557

@ay4

Description

@ay4

Hi,

I was looking at other issues and on Reddit, and saw that which-key doesn't always play well with general. That said, I'm not certain that this particular issue has been reported.

My goal in this minimal example is to construct a nested menu that works as follows:

  1. Outside of org-mode: press s-o, see 's→+system', press s, see 'c→open config'
  2. Inside org-mode: press press s-o, see 's→+system i→+insert', press i, see 's→source code', press s, see 's→shell'

What actually happens:

  1. Outside of org-mode: press s-o, see 's→shell', press s, see 'c→open config'. In other words, what the menu does is correct, but the label is incorrect: it shows shell instead of system.
  2. Inside org-mode: press press s-o, see 's→+shell i→+insert', press i, see 's→shell', press s, see 's→shell'. So, each time we see an s, the logic is correct but the label always chooses a certain keymap that, as I understand, shouldn't be even active (admittedly I don't exactly understand how keymaps work down to the last detail).

Here's the code that produces the above:

  (defconst ayleader "s-o")

  (general-define-key
  :prefix ayleader
  "s" '(:prefix-command aysystem-map :which-key "system")
)

(general-define-key
:keymaps 'aysystem-map
:wk-full-keys nil
"c" '((lambda()(interactive)(find-file "~/.emacs.d/README.org")) :which-key "open config")
)

(general-define-key
:prefix ayleader
:wk-full-keys nil
:keymaps 'org-mode-map
"i" '(:prefix-command ayorg-insert-map :which-key "insert")
)

(general-define-key
:keymaps 'ayorg-insert-map
:wk-full-keys nil
"s" '(:prefix-command ayorg-insert-source-map :which-key "source code")
)


(general-define-key
:keymaps 'ayorg-insert-source-map
:wk-full-keys nil
"s" '((lambda()(interactive)(insert "#+begin_src sh")) :which-key "shell")
) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions