justbur / emacs-which-key

Emacs package that displays available keybindings in popup
GNU General Public License v3.0
1.74k stars 87 forks source link

key-chords break with prefix keymaps #254

Closed aspiers closed 2 years ago

aspiers commented 4 years ago

Here's a minimal testcase; save it to testcase.el and run via emacs -Q -l testcase.el:

(package-initialize)

(package-install 'bundler)

(package-install 'key-chord)
(key-chord-mode 1)

(setq which-key-enable-extended-define-key t)
(package-install 'which-key)
(which-key-mode)

(defvar as-jump-map (make-sparse-keymap "Jump to stuff"))
(global-set-key (kbd "C-c j") as-jump-map)
(key-chord-define-global "zj" as-jump-map)
(key-chord-define-global "zr" 'dired)

(defvar as-jump-ruby-map (make-sparse-keymap "Jump to Ruby")
  "Adam's prefix keymap for quickly jumping to Ruby stuff")
(define-key as-jump-map "r" as-jump-ruby-map)
(define-key as-jump-ruby-map "g" 'bundle-open)

Now type the chord zj (i.e. press z and j at the same time). The minibuffer looks like:

image

So far so good. Now type r. You'll see:

image

which-key is getting confused between the sequence we just typed (zj r) and the completely unrelated keychord zr which is bound to dired.

aspiers commented 4 years ago

At a wild guess, this might be a bug with bf4c7d8559715e0fc6d620d4df99209c686c423b which was added to address #108.

jsy1001 commented 2 years ago

I'm having a similar problem. I've bound the chord "qp" to projectile-command-map (from the projectile package). When I hit "qp" which-key correctly displays the bindings, but when I hit one of bindings that is shown as a "+prefix", the bindings on that prefix within projectile-command-map are not displayed, and the which-key window disappears.

justbur commented 2 years ago

@jsy1001 thanks. I think I found a good solution. Please try 1bb1f72

jsy1001 commented 2 years ago

I just upgraded to which-key-20211209.131 which resolves the issue for me. Many thanks for the quick resolution!