justbur / emacs-which-key

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

rebind `which-key-show-next/previous-page` #326

Closed ghost closed 2 years ago

ghost commented 2 years ago

Hi and thank you for the package.

I want to change some of the default which-key key binds used to turn the pages.

In which-key.el they are set like so:

(defvar which-key-C-h-map
  (let ((map (make-sparse-keymap)))
    (dolist (bind `(("\C-a" . which-key-abort)
                    ;;abbreviated...
                    ("n" . which-key-show-next-page-cycle)
                    ("p" . which-key-show-previous-page-cycle)
                    ;;abbreviated...
      (define-key map (car bind) (cdr bind)))
    map)
  "Keymap for C-h commands.")

when I do :

(define-key which-key-C-h-map (kbd "z") 'which-key-show-next-page-cycle)

I can turn the pages ok.

but when I want to use PgUp/PgDown and do :

(define-key which-key-C-h-map (kbd "<next>") 'which-key-show-next-page-cycle)

I get: which-key-C-h-dispatch: Wrong type argument: characterp, next

Why can't I use those two keys?

ghost commented 2 years ago

had to rewrite the issue because it was not very clear. hopefully better now.

ghost commented 2 years ago

Friendly stack exchange user proposed a solution : https://emacs.stackexchange.com/a/69383/33489

justbur commented 2 years ago

Thank you. Try 2165957749e4874425b5c03f079b23725b331819

ghost commented 2 years ago

Hello @justbur thanks for the quick fix. Binding to symbols work good!

Please take a look at the hint message displayed by which-key on following screenshots. When I use a "symbol bind" i am getting the hint n -> next-page instead of <next> -> next-page

image

image

justbur commented 2 years ago

This message is generated automatically using substitute-command-keys. If you have multiple bindings to the same command, it's just going to pick one of them. You can try unbinding n in which-key-C-h-map.