bug#81624: New command: xref-find-by-kind

Dmitry Gutov <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
On 18/08/2026 14:45, Sean Whitton wrote:
> Dmitry Gutov [15/Aug  8:04pm +03] wrote:
>> The patch takes up the existing M-' binding which would be very handy,
>> but I understand that might take some persuading (or a change).
> 
> I think we should consider unbinding M-' by default but I'm less sure
> about using it for xref-find-by-kind.  Specifically, I'm wondering
> whether we can combine this new functionality into M-. or M-? in some
> sensible way.  Fundamentally it's a generalisation of those, isn't it?
Maybe I'm missing some interesting possibilities, but hopefully not.

First, if we decide to replace either of the above command with a new 
"wrapping" one, we would either make its current feature at least one 
step further away (e.g. if we declare "references" to be a new kind), or 
the new additions would use some new way of invocation. One big 
advantage of the current bindings are how economical they are.

Problems reusing M-?:

* "find references" moves one character away. Not only that, the user 
would have to adapt first, reading the new prompt. Elisp has 8 kinds 
already, this will be noisy. I guess we would mandate that "r" is 
reserved for references...

* "xref-find-references" and "xref-find-definitions" use different 
behaviors; depending on the user's choice, could be significantly 
different, if they customize xref-show-definitions-function to 
xref-show-definitions-completing-read and keep xref-show-xrefs-function 
at its default. We could start annotating the kinds with the "category" 
like this as well, but the result would be that the UI behavior depends 
on the first choice. Not very intuitive.

Problems reusing M-.:

* We either insert a mandatory new step "choose kind", "definitions" now 
being among them (and say bye to the quick "M-."),

* Or we add some new way of invocation to specify the kind. It would be 
harder to discover, but documented, so possibly usable too. Something 
like "M-0 M-." to get the "kinds" prompt, and "C-u C-u M-." to get both 
of the prompts: "kind" and "identifier".

If the decision would be not to give it a separate nice binding (which I 
totally get, it's an ambitious ask), I would rather include a separate 
command and a recommendation how to bind it in the init script.

But I invite you and others to try the new feature live, to get a feel 
for it with both of the supporting backends.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.