* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-25 7:03 ` Gerd Möllmann
@ 2023-08-25 7:48 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-25 16:26 ` Dmitry Gutov
2023-08-25 8:26 ` Gerd Möllmann
` (2 subsequent siblings)
3 siblings, 1 reply; 12+ messages in thread
From: Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-08-25 7:48 UTC (permalink / raw)
To: Gerd Möllmann; +Cc: 65520, Visuwesh, Dmitry Gutov
Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>>> 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.
Note that specifically for Elisp functions, you can use `find-function`
from anywhere (including your C buffers).
>> 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.
> 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.
That sounds really interesting! The way I'd suggest structuring it is
introducing a new command `project-find-definitions` that prompts for an
identifier defined in the current project and jumps to it, similarly to
`xref-find-definitions` but limited to the current project and not
limited to the current `xref` backend. The way
`project-find-definitions` finds this definitions would be up to the
`project` backend. Crucially, ISTM that it would be better to build
this as an extension of `project`, not `xref`. Of course, the "naive
approach" based on `xref` described above would be a perfectly good
starting point for any `project` backend and may be used as a default.
Best,
Eshl
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-25 7:48 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-08-25 16:26 ` Dmitry Gutov
0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Gutov @ 2023-08-25 16:26 UTC (permalink / raw)
To: Eshel Yaron, Gerd Möllmann; +Cc: 65520, Visuwesh
On 25/08/2023 10:48, Eshel Yaron wrote:
> The way I'd suggest structuring it is
> introducing a new command `project-find-definitions` that prompts for an
> identifier defined in the current project and jumps to it, similarly to
> `xref-find-definitions` but limited to the current project and not
> limited to the current `xref` backend.
To make this work ootb (as opposed to custom user setup), this would
require some global-ish registry of languages available in a project.
project.el itself is unlikely to help too much, but it could host the
new variable(s).
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-25 7:03 ` Gerd Möllmann
2023-08-25 7:48 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-08-25 8:26 ` Gerd Möllmann
2023-08-25 16:17 ` Dmitry Gutov
2023-08-25 16:20 ` Dmitry Gutov
3 siblings, 0 replies; 12+ messages in thread
From: Gerd Möllmann @ 2023-08-25 8:26 UTC (permalink / raw)
To: 65520; +Cc: Dmitry Gutov, Visuwesh
Gerd Möllmann <gerd.moellmann@gmail.com> writes:
> 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
Just want to add, because I didn't clearly state that: these set of
files don't have to be disjoint, i.e. more than one backend might have
information about the same file.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-25 7:03 ` Gerd Möllmann
2023-08-25 7:48 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-25 8:26 ` Gerd Möllmann
@ 2023-08-25 16:17 ` Dmitry Gutov
2023-08-26 5:22 ` Gerd Möllmann
2023-08-25 16:20 ` Dmitry Gutov
3 siblings, 1 reply; 12+ messages in thread
From: Dmitry Gutov @ 2023-08-25 16:17 UTC (permalink / raw)
To: Gerd Möllmann, 65520; +Cc: Visuwesh
On 25/08/2023 10:03, Gerd Möllmann wrote:
> 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.
One possible alternative is to treat this situation not like a new
feature, and write a specialized new Xref backend which would collect
both the info from Lisp and from TAGS when you are anywhere inside the
Emacs sources. It shouldn't take too many lines either.
The current existing alternative for that, like Eli pointed out, is
xref-etags-mode: it disables Elisp's own backend and just uses TAGS
everywhere ('make tags' in Emacs generates tags for Lisp functions as
well). With the natural downside that you would need to regen tags
manually for both types of files now. And that you're using Eglot
instead ;-(.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-25 16:17 ` Dmitry Gutov
@ 2023-08-26 5:22 ` Gerd Möllmann
0 siblings, 0 replies; 12+ messages in thread
From: Gerd Möllmann @ 2023-08-26 5:22 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: 65520, Visuwesh
Dmitry Gutov <dmitry@gutov.dev> writes:
> On 25/08/2023 10:03, Gerd Möllmann wrote:
>> 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.
>
> One possible alternative is to treat this situation not like a new
> feature, and write a specialized new Xref backend which would collect
> both the info from Lisp and from TAGS when you are anywhere inside the
> Emacs sources. It shouldn't take too many lines either.
>
> The current existing alternative for that, like Eli pointed out, is
> xref-etags-mode: it disables Elisp's own backend and just uses TAGS
> everywhere ('make tags' in Emacs generates tags for Lisp functions as
> well). With the natural downside that you would need to regen tags
> manually for both types of files now. And that you're using Eglot
> instead ;-(.
Yeah ;-). That's not what I was looking for.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-25 7:03 ` Gerd Möllmann
` (2 preceding siblings ...)
2023-08-25 16:17 ` Dmitry Gutov
@ 2023-08-25 16:20 ` Dmitry Gutov
2023-08-26 5:31 ` Gerd Möllmann
3 siblings, 1 reply; 12+ messages in thread
From: Dmitry Gutov @ 2023-08-25 16:20 UTC (permalink / raw)
To: Gerd Möllmann, 65520; +Cc: Visuwesh
On 25/08/2023 10:03, Gerd Möllmann wrote:
> Dmitry Gutov <dmitry@gutov.dev> 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.
Have you tried it? By setting up both it and the xref-backend-functions
manually (in a hook) in every relevant buffer you might get more or less
the requested behavior. If not, what does feel unsatisfying still?
>> 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.
Indeed, it's also a question of mental model, which we might have
different. When I was saying "different projects" and "register
globally", I was thinking of being able to jump to Emacs' sources and
hack them from anywhere: from any other project I might be working on at
the moment.
If we're talking about Emacs development only, a "combined" backend
might make more sense (see the other email).
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-25 16:20 ` Dmitry Gutov
@ 2023-08-26 5:31 ` Gerd Möllmann
2023-08-27 0:32 ` Dmitry Gutov
0 siblings, 1 reply; 12+ messages in thread
From: Gerd Möllmann @ 2023-08-26 5:31 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: 65520, Visuwesh
Dmitry Gutov <dmitry@gutov.dev> writes:
> On 25/08/2023 10:03, Gerd Möllmann wrote:
>> Dmitry Gutov <dmitry@gutov.dev> 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.
>
> Have you tried it?
Not yet. I'm still hoping someone else (tm) builds something, so that I
don't have to do anything.
> By setting up both it and the
> xref-backend-functions manually (in a hook) in every relevant buffer
> you might get more or less the requested behavior. If not, what does
> feel unsatisfying still?
>
>>> 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.
>
> Indeed, it's also a question of mental model, which we might have
> different. When I was saying "different projects" and "register
> globally", I was thinking of being able to jump to Emacs' sources and
> hack them from anywhere: from any other project I might be working on
> at the moment.
>
> If we're talking about Emacs development only, a "combined" backend
> might make more sense (see the other email).
No, I didn't mean Emacs development specifically, although that's
probably the only things I'd use such a facility for.
The whole thing would be like in some IDEs, with their "usual" idea of
project. I'm not 100% sure, but I think I've seen vscode being used
with different languages (JS, CSS, Java...) and offering such
project-wide stuff.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-26 5:31 ` Gerd Möllmann
@ 2023-08-27 0:32 ` Dmitry Gutov
2023-08-27 6:32 ` Gerd Möllmann
0 siblings, 1 reply; 12+ messages in thread
From: Dmitry Gutov @ 2023-08-27 0:32 UTC (permalink / raw)
To: Gerd Möllmann; +Cc: 65520, Visuwesh
On 26/08/2023 08:31, Gerd Möllmann wrote:
>>>> 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.
>>
>> Have you tried it?
>
> Not yet. I'm still hoping someone else (tm) builds something, so that I
> don't have to do anything.
xref-union is a thing that somebody has already built. Either you try it
and like it, or you can come back with more targeted feedback.
Which we could then use to improve either it, or the core xref, of course.
>> Indeed, it's also a question of mental model, which we might have
>> different. When I was saying "different projects" and "register
>> globally", I was thinking of being able to jump to Emacs' sources and
>> hack them from anywhere: from any other project I might be working on
>> at the moment.
>>
>> If we're talking about Emacs development only, a "combined" backend
>> might make more sense (see the other email).
>
> No, I didn't mean Emacs development specifically, although that's
> probably the only things I'd use such a facility for.
>
> The whole thing would be like in some IDEs, with their "usual" idea of
> project. I'm not 100% sure, but I think I've seen vscode being used
> with different languages (JS, CSS, Java...) and offering such
> project-wide stuff.
IIRC the LSP protocol includes project type detection, and so Eglot can
automatically spin up several language servers already.
Without the addition of a similar registry, which all backends would
have to plug into, the best we could do is loop across the open project
buffers and see what backends exist there. But that would e.g. miss
Elisp if you haven't opened any .el files in the current session yet.
^ permalink raw reply [flat|nested] 12+ messages in thread
* bug#65520: 30.0.50; [FR Xref] Project-wide operations
2023-08-27 0:32 ` Dmitry Gutov
@ 2023-08-27 6:32 ` Gerd Möllmann
0 siblings, 0 replies; 12+ messages in thread
From: Gerd Möllmann @ 2023-08-27 6:32 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: 65520, Visuwesh
Dmitry Gutov <dmitry@gutov.dev> writes:
>>> Have you tried it?
>> Not yet. I'm still hoping someone else (tm) builds something, so
>> that I
>> don't have to do anything.
>
> xref-union is a thing that somebody has already built. Either you try
> it and like it, or you can come back with more targeted feedback.
>
> Which we could then use to improve either it, or the core xref, of
> course.
I know, I know. I'm procrastinating ;-).
...
>> No, I didn't mean Emacs development specifically, although that's
>> probably the only things I'd use such a facility for.
>> The whole thing would be like in some IDEs, with their "usual" idea
>> of
>> project. I'm not 100% sure, but I think I've seen vscode being used
>> with different languages (JS, CSS, Java...) and offering such
>> project-wide stuff.
>
> IIRC the LSP protocol includes project type detection, and so Eglot
> can automatically spin up several language servers already.
>
> Without the addition of a similar registry, which all backends would
> have to plug into, the best we could do is loop across the open
> project buffers and see what backends exist there. But that would
> e.g. miss Elisp if you haven't opened any .el files in the current
> session yet.
Can't say anything to that... BTW, I'm not planning on working on
anything in that are. Just wishing to have something like I described.
^ permalink raw reply [flat|nested] 12+ messages in thread