[Top][All Lists]

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

bug#19466: 25.0.50; xref-find-def doesn't find C functions

From: Eli Zaretskii
Subject: bug#19466: 25.0.50; xref-find-def doesn't find C functions
Date: Fri, 23 Jan 2015 11:03:14 +0200

> Date: Thu, 22 Jan 2015 23:02:22 +0200
> From: Dmitry Gutov <address@hidden>
> CC: address@hidden, address@hidden, address@hidden
> On 01/22/2015 08:02 PM, Eli Zaretskii wrote:
> > What I need is a way to find definitions of both C and Lisp symbols
> > (functions, macros, struct's, etc.) irrespective of the current
> > buffer's major mode.  If xref can do that, it's fine with me.
> Would it also be irrespective of the current file, or its project?

Most, if not all, projects I work on aren't "projects" in your sense
of the word, I think -- they lack any "project" files except the
sources and Makefile's.  With etags, I switch "projects" by invoking
visit-tags-table and typing a name of a different TAGS file (I'm then
given a choice of whether to keep the previous TAGS table or discard
it, which is important -- see below).

If xref can reliably deduce that I switched projects and automatically
update its database, that's fine with me, and would probably
constitute what you mean by "dependence on the current file or
project".  But I doubt that this can be done reliably enough to
satisfy users like me, when a project doesn't have a definitive
description of what is or isn't part of it.

Take, for example, the use case where I'm testing a program and found
a bug.  I then need to be able to quickly find and examine the
definition of symbols that might be involved in the bug, look at their
code, perhaps make some changes -- this all will be served well by
using the database (such as TAGS) of that single program.  But suppose
I now come to the conclusion that the bug is not in the program per
se, but involves one of the external libraries it uses.  Now I need to
go through the sources of that library (whose sources, by sheer luck
or maybe something else, I already have available on my system).  How
would xref or etags know whether I switched to that library as part of
my previous work (and therefore still need access to the previous
project's symbols), or because I'm now working on an entirely
different project?  What if investigating the bug needs to
intermittently look at the sources of the program and the library
(e.g., because the bug happens due to some incompatibility between

So I think there will always be a need for asking the user about this,
and in addition there are projects without "project" infrastructure,
where xref or etags or any similar feature will have to rely on the
user for telling them which database of symbols to use.

Is xref ready for these use cases?  If so, in what form (simple
variable customizations, specified commands, Lisp code that the use
must supply, something else) can the user specify what she wants?

> Would it not depend on major mode at all, so it would also be true
> in help-mode and similar buffers?

Sometimes, I guess.  Like doing that in *scratch* after "emacs -Q", or
in the *Help* buffer (which sometimes refers to external library

> If you want it in all major modes, you can use find-file-hook instead of 
> emacs-lisp-mode-hook. If in all files everywhere, then you can also drop 
> the buffer-file-name check, ending up with
> (add-hook 'find-file-hook #'xref-etags-mode t)
> That doesn't help with non-file buffers, though. But you can use a 
> separate major mode hook for each.

Is it possible to turn on xref-etags-mode (or its equivalents)
globally?  Are there any disadvantages of that?  IOW, why does it need
to be turned on by a hook?

reply via email to

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