Subject: bug#32510: xref-find-definitions should return file names, too

From: Eli Zaretskii <[email-masked]>
Date: Thu, 18 Jul 2019 18:16:23 +0300

> Date: Thu, 18 Jul 2019 16:53:42 +0200
> From: Ludovic Brenta <[email-masked]>
> 
> I can confirm that the patch by Eli Zaretskii works, with a
> difference compared to find-tag: find-tag opens the first
> file whose name matches the searched string whereas
> xref-find-definitions opens a new buffer with all matches,
> forcing the user to use many keystrokes (or worse: reach
> for the mouse :)) to choose a match.

That's not what happened to me after the patch.  For me, M-. just
visited the one file whose name I typed.

Can you show the exact sequence of commands you typed, preferably
using the Emacs sources and corresponding TAGS tables and file names
as the basis, so that I could repeat it here?

> I suppose this change of behavior is intentional, consistent
> with all other cross-references, and only affects ergonomy;
> the patch more importantly restores the functionality that
> was previously lost.

I cannot tell whether it's intentional until I see the behavior you
describe.  What I can say is that if there's only one match, xref goes
there automatically and immediately, but if there are several
candidate matches, xref shows them and allows you to select the one(s)
you want.  The xref behavior is better when the match you want is not
one of the first few, because find-tag required you to continuously
type "C-u M-." in that case, and moreover do that blindly, since you
had no idea how far away is your match.  With xref you can select the
match you are after without iterating through all the previous ones.

However, I would expect the user to type the full file name in this
use case, since that's what this feature is about: finding a file
given its name.  In that case, both commands behave almost
identically.

Dmitry, any comments on the patch?  I admit I didn't study in detail
the role of the PATTERN slot of the object generated by the function
where I proposed to make the change, so perhaps I'm missing some use
case where the patch will not DTRT?

Thanks.