From: Winston <wbe@psr.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 28403@debbugs.gnu.org, dgutov@yandex.ru
Subject: bug#28403: 25.2; find-tag works, but xref-find-definitions
Date: Sun, 10 Sep 2017 14:27 EDT [thread overview]
Message-ID: <201709101827.v8AIRMse018692@psr.com> (raw)
In-Reply-To: <201709092240.v89MeFUo014854@psr.com>
Eli kindly replied:
> Could you please post a complete example of the code in question,
> including the definition of the _ARGS1 macro, and any other macros and
> typedefs that would make the example stand-alone? I think I
> understand what has happened, but I'd like to be sure before we decide
> what to do about it.
Sure (well, it's a semi-complete example). The code, in general,
seeks to be as widely compatible with any compiler, ancient or modern,
as possible. That's in part because the earliest versions originated
back in the 90's when, for example, Sun's bundled cc was a K&R C
compiler. The _ARGS* macros provide compatibility between K&R C's
name (arg1, arg2)
type arg1; type arg2;
{ ... }
and ANSI C's
name (type arg1, type arg2)
{ ... }.
_ARGS1 through _ARGS# (enough for whatever function takes the most
arguments (or more)) are #define'd in a header file.
The other coding style that may matter here is the practice of
putting the return value type on a separate line at the function
definition (as you'll see below). That makes the function name easier
to see (always at the left edge) and allows more arguments to fit on the
function name line (nice when grep'ing).
The following edited extracts are the basic pieces:
----------
In a common header file:
#ifdef __STDC__
# define _ARGS(args) args
# define _ARGS0(void) \
(void)
# define _ARGS1(A,a) \
(A a)
# define _ARGS2(A,a,B,b) \
(A a, B b)
# define _ARGS3(A,a,B,b,C,c) \
(A a, B b, C c)
[...]
#else /* !__STDC__ */
# define _ARGS(args) ()
# define _ARGS0(args) ()
# define _ARGS1(A,a) \
(a) \
A a;
# define _ARGS2(A,a,B,b) \
(a, b) \
A a; B b;
# define _ARGS3(A,a,B,b,C,c) \
(a, b, c) \
A a; B b; C c;
[...]
#endif /* __STDC__ */
Function declarations use _ARGS():
extern void baz _ARGS((int x, int y));
Function definitions in the *.c files use _ARGS#():
static struct mumblefrotzage *
foo _ARGS2(const char *,s, int,n)
{
...
}
int
main _ARGS3(int,argc, char**,argv, char**,env)
{
struct mumblefrotzage *bar = foo ("example", 3);
...
}
etags would extract "foo _ARGS2(" and "main _ARGS3(" as tag lines.
(find-tag) would find foo and main.
----------
Earlier in this thread, Dmitry suggested:
>>> 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).
to which Eli replied:
> Dmitry, how about providing a more user-friendly customization to that
> effect? As a "fire escape"?
I initially replied to Dmitry's suggestion:
>> 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.
> I'd rather like to encourage you to continue using xref and report any
> issue you find.
As you may have seen in my reply to Dmitry, I tried his suggestion,
and it seemed to fix the problem in the quick testing I tried, so I'm
willing to switch.
The main issue I haven't gotten to yet is how best to change the
value of etags-xref-find-definitions-tag-order (exfdto) in a way that
will maximize long-term compatibility with future Emacs versions. Doing
just (setq exfdto '(..)) in ~/.emacs I would expect to be the worst,
because either the default value or the symbol names might change in
future releases; (setq exfdto (append exfdto '(tag-symbol-match-p)))
might be better, but requires preloading etags.el to get the variable's
default value. There are also onload hooks, site local lisp, etc. It's
not yet clear to me what the best approach is, so I like your suggestion
to Dmitry above. :)
> [The new xref function] is already better in several areas:
I noticed that, and I liked seeing the list of matches when there's >1,
rather than having to do {arg} find-tag, possibly repeatedly, when the
one find-tag finds first isn't the one I wanted. However, if the basic
find wasn't going to work, or was going to have a lot of false positives,
then I'd stick with find-tag, which has generally worked well (almost no
wrong matches, but it helps that my code tries to have all function
names in all files be unique, even when they're static, so there's
rarely >1 match).
> It is even possible that, given the details I requested above, I will
> be able to help you get your use case working with xref, so please
> don't give up on xref, not just yet.
I haven't. :)
Thanks! HTH,
-WBE
next prev parent reply other threads:[~2017-09-10 18:27 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-09 22:40 bug#28403: 25.2; find-tag works, but xref-find-definitions doesn't; bug? Winston
2017-09-09 22:58 ` Drew Adams
2017-09-09 23:10 ` Dmitry Gutov
2017-09-10 2:50 ` bug#28403: 25.2; find-tag works, but xref-find-definitions Winston
2017-09-10 9:01 ` Dmitry Gutov
2017-09-10 14:29 ` Eli Zaretskii
2017-09-10 21:43 ` Dmitry Gutov
2017-09-11 2:38 ` Eli Zaretskii
2017-09-11 8:58 ` Dmitry Gutov
2017-09-11 14:43 ` Eli Zaretskii
2017-09-12 23:40 ` Dmitry Gutov
2017-09-13 15:32 ` Eli Zaretskii
2017-09-14 12:13 ` Dmitry Gutov
2017-09-14 17:13 ` Eli Zaretskii
2017-09-19 0:44 ` Dmitry Gutov
2017-09-19 3:58 ` Eli Zaretskii
2017-09-10 14:52 ` Winston
2017-09-10 18:27 ` Winston [this message]
2017-09-10 19:09 ` Eli Zaretskii
2017-09-10 19:06 ` Winston
2017-09-10 19:10 ` Winston
2017-09-10 20:12 ` Winston
2017-09-11 2:31 ` Eli Zaretskii
2017-09-10 21:19 ` Winston
2017-09-10 21:35 ` Dmitry Gutov
2017-09-11 2:34 ` Eli Zaretskii
2017-09-11 3:19 ` Winston
2017-09-11 4:05 ` Winston
2017-09-11 16:23 ` Eli Zaretskii
2017-09-11 4:11 ` Winston
2017-09-11 5:02 ` Winston
2017-09-11 16:51 ` Eli Zaretskii
2017-09-14 17:37 ` Winston
2017-09-14 22:08 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201709101827.v8AIRMse018692@psr.com \
--to=wbe@psr.com \
--cc=28403@debbugs.gnu.org \
--cc=dgutov@yandex.ru \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.