bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#28403: 25.2; find-tag works, but xref-find-definitions


From: Winston
Subject: bug#28403: 25.2; find-tag works, but xref-find-definitions
Date: Sat, 9 Sep 2017 22:50 EDT

I previously wrote:
>>     The C code in question uses macros around function arguments in its
>> definitions.  E.g.,
>> 
>>          name _ARGS1(type,variable)
>> 
>>     find-tag (and etags) work just fine with that, and such function
>> definition lines appear in the TAGS file (as they should), but
>> xref-find-definitions fails to find such function tags, saying instead
>> "No definitions found for: name".

Dmitry kindly replied:
> Which program are you generating TAGS with? Is it etags that comes with 
> Emacs?

Yes, and "etags --version" prints: etags (GNU Emacs 25.2)

> xref-find-definitions is somewhat stricter about its input than 
> find-tag.

Yes, that's what's causing the difference.  ;-)

> What does the entry for this function inside TAGS look like? [...]
> I'm guessing it looks like:
> 
> name _ARGS1(

Exactly.  E.g.,
name _ARGS1(^?188,5710

> which is an "implicit tag name" entry for "_ARGS1", but not for "name". 
> IOW, etags doesn't understand macros.

   Whether etags understands macros or not, it is correctly identifying
the lines containing function names, so I see no problem there.

Addressing the difference between find-tag and xref-find-definitions:

   find-tag acts as if it uses "^\([^(]+\) *(" [or similar] and
considers the function name to be &1.  I.e., it treats the entire string
"name _ARGS1" as the function name.  When I change the number of
arguments, e.g., "name _ARGS2(...)" and haven't yet updated TAGS,
find-tag reports that it searched for "name _ARGS1" and didn't find it.

   Sure, it would be great if find-tag knew that only the part before
the space is the function name, but *FOR THE PURPOSE OF MAKING
xref-find-definitions WORK AS WELL AS find-tag*, treating [^(]+ (the
entire string up to the '(', or the entire string between the return
value type and the '(' if find-tag is that smart) as the function name
looks like it would do well enough to allow xref-find-definitions to
obsolete find-tag.

>>     So, xref-find-definitions is not yet a complete replacement for
>> find-tag.  Since etags puts such lines in TAGS and xref-find-definitions
>> is unable to match up the name with the tag, it looks like a bug /
>> deficiency in xref-find-definitions.

> Try adding `tag-symbol-match-p' to 
> etags-xref-find-definitions-tag-order. This example should work then, 
> but you'll get more false positives (like treating return types as 
> function names).

   Noted for future reference...

   Since doing that doesn't change what etags writes to TAGS, I'm not
sure how that elisp change would result in function return types being
matched as function names, but no matter.  For the moment I think I'll
just continue to use find-tag and hope that xref-find-definitions will
eventually work as well as find-tag before find-tag disappears.  :)

   Thanks,
 -WBE





reply via email to

[Prev in Thread] Current Thread [Next in Thread]