Subject: Re: bug#65520: 30.0.50; [FR Xref] Project-wide operations

From: Gerd Möllmann <[email-masked]>
Date: Fri, 25 Aug 2023 09:03:39 +0200

Dmitry Gutov <[email-masked]> writes:

>> In C mode, Xref works using Eglot, in ELisp mode it uses something
>> else
>> (I have no tags tables).  Both work really well, but I apparently have
>> to be in an ELisp buffer to use one and in a C buffer to use the other.
>> Feature request: Is it possible to use more than one backend at the
>> same
>> time?  So that I could C-M-. to find an ELisp function while being in a
>> C file?  I couldn't find something like that mentioned in the docs, so I
>> guess it's not yet possible.
>
> No such capability at the moment, but we indeed have an ELPA package
> xref-union which implements the "merging" feature that has been
> requested in the past.

Thanks also to Visuwesh for pointing me to xref-union.

> You are asking for something a little different, though: to be able to
> switch to a different language/project that's also present in the
> current Emacs session. Its backend function cannot be found in the
> xref-backend-functions in the current buffer (local or global), unlike
> the examples with mixing in etags or imenu results, like mentioned by
> Visuwesh.
>
> A naive approach, or for the new code to search across different open
> buffers and look for different available xref-backend-functions
> elements. And then prompt the user, and then call (?) the said
> function in one of the buffers it was found in, because in all
> likelihood it would fail in unrelated ones.
>
> Perhaps the solution is to add a new facility to Xref, where different
> "projects" would be able to register globally in. A feature request
> indeed.

I'm not sure about the "different project in the same session" thing.

My mental model is like so: I'm in a Git repo (Emacs), which is, I think
also a project in the project.el sense.  This project contains differnt
sets of files for which information is available using different
backends (Eglot, Etags, others depending on the kind of project).  What
U'd like to have is something on the level of such a project, if you
know what mean.  That is, M-. would take all available info for such a
project into account.