bug#81462: [PATCH] Skip non-key events in `where-is-internal' with FIRSTONLY
Aaron Zeng via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <CAB7SQMGy-K+9uTr6gaPq2fDHWTEXxYBkv8z3kw7hZkNMyv6PKA@mail.gmail.com> |
On Wed, Aug 12, 2026 at 4:04 PM Stefan Monnier <[email protected]> wrote: > > > FWIW, here's a totally different idea that might solve the same > > problem. What if where-is-internal had a SHORTEST argument where you > > could ask it for the shortest binding rather than the first one? > > I thought that's already what it does. At least if you ask for all > bindings, they should be sorted shortest to longest. It doesn't seem to. With this in a scratch buffer in lisp-interaction-mode: (defun my-test-command () (interactive)) (keymap-global-set "<f4>" #'my-test-command) (defvar-keymap overriding-leader-minor-mode-map "\\ m t c" #'my-test-command) (define-minor-mode overriding-leader-minor-mode "Demo." :global t) (overriding-leader-minor-mode) (keymap-set lisp-interaction-mode-map "C-c C-a" #'my-test-command) I see that [\ m t c] is the first key binding returned by (where-is-internal #'my-test-command) ; => ([92 109 116 99] [3 1] [f4]) (where-is #'my-test-command) ; => "my-test-command is on \ m t c, C-c C-a, <f4>" And is what substitute-command-keys returns in: (substitute-command-keys "invoke my-test-command by typing \\[my-test-command]") ;; => #("invoke my-test-command by typing \\ m t c" 33 40 (font-lock-face help-key-binding face help-key-binding)) Also, setting where-is-preferred-modifier to `ctrl' doesn't seem to matter to any of the above function calls.