How to identify long named commands in which-key?

What happened?

If a command name is too long, it is cut in the which key menu.

For example, in any .el file, if you press SPC m d, it shows these options

image

which are identical up to the three dots parts ...

What did you expect to happen?

Have some mechanism like a running text, popout or alt-text to show the rest of the command.

Steps to reproduce

  1. Open any menu with long named commands.

System information


Loading data dump...

Press ? (or C-h if ? is bound) and you can search the active prefix in the minibuffer (using ivy/vertico/helm/etc).

image

1 Like

Thanks Henrik! This is exactly what I am looking for.

Just to understand, the ? menu show all the existing commands loaded in Emacs.

However, there isn’t a ? menu version for only the current submenu (in this case, SPC m d in elisp-mode).

Best.

Not at all. The ? menu shows commands under the current prefix. I.e. SPCm? should list all keys bound under SPCm (recursively).

E.g. SPCm? in emacs-lisp-mode:

image

I see you have only 11 options.

In my case I have 3449 options if I press SPC m ? in the init.el for example.

image

In a random org file I have 3815 options,

image

Have a look at your private config. I can’t reproduce that on vanilla Doom. I’ll have to look into it further another time; a little swamped atm.

Thanks! Maybe just throw me some pointers or variables to look at, and I’m glad to report back my findings. For the moment I don’t have anything related to which-key, consult or vertico in my private config.

FYI, I confirm that I also only have 11 options in elisp files. It looks like you have global key bindings bound to your minor mode binding.

Thanks to both!

I’ve debugged my private config and disabled all the map! calls just in case. I still have the problem.

What do you think could be triggering this strange behavior?

Best.

I finally found it!

image

The malevolent lines were this

(setq which-key-use-C-h-commands t
      prefix-help-command #'which-key-C-h-dispatch)

(defadvice! fix-which-key-dispatcher-a (fn &rest args)
  :around #'which-key-C-h-dispatch
  (let ((keys (this-command-keys-vector)))
    (if (equal (elt keys (1- (length keys))) ?\?)
        (let ((keys (which-key--this-command-keys)))
          (embark-bindings (seq-take keys (1- (length keys)))))
      (apply fn args))))

Basically, I wanted to have paging in the which-key menus. I copied this from the discord (Discord)

Maybe the effects of those lines should be clear in the docs.

Thanks for the help!

1 Like