all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 23223@debbugs.gnu.org
Subject: bug#23223: 25.0.92; Can xref-find-references be sped up?
Date: Thu, 07 Apr 2016 18:03:37 +0300	[thread overview]
Message-ID: <83mvp5lauu.fsf@gnu.org> (raw)
In-Reply-To: <ee794a61-5ff1-f14a-56de-9551fb74daa4@yandex.ru> (message from Dmitry Gutov on Thu, 7 Apr 2016 03:11:25 +0300)

> Cc: 23223@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> Date: Thu, 7 Apr 2016 03:11:25 +0300
> 
>     We invoke lid with the -w
>     switch, which should have reported only complete symbols, AFAIU
>     (although the documentation confusingly talks about "words").  Perhaps
>     report this to the developers.
> 
> I suspected the wording would mean that it just invokes Grep and uses the "boundary" anchors (\b), but no, doing a Grep search for "\beval-when\b" yields a bigger (and more consistent) set of matches.
> 
> So it's most likely a bug.

Heh, I completely forgot how IDutils work.  The ID database doesn't
store the locations where the identifiers were found, all it stores is
the list of identifiers found in each file.  When lid is invoked, it
queries the database about the files that reference the identifier;
then it opens each file in the query results, and searches for the
identifier on each line of that file.  When lid is invoked to produce
a Grep-like output and with the -w option (which is what we do), it
searches each line for the moral equivalent of

  [^[:alnum:]_]IDENT[^[:alnum:]_]

where IDENT is the identifier we asked about.

So therefore, your observation:

> For instance, if I run 'mkid' in the top directory of the Emacs sources, I can search for 'defmacro', and get a few lines with 'cl-defmacro' instead among the results. Or search for 'eval-when', and get some lines with 'eval-when-compile'. But not, curiously, 'cl-eval-when'.

can now be perfectly explained, because none of the files we have in
Emacs that reference cl-eval-when also reference eval-when, but some
files that reference defmacro have matches for cl-defmacro, and some
files that reference eval-when have matches for eval-when-compile.

IOW, the ID database is used to minimize the number of files to
search, i.e. avoid searching files that cannot possibly result in a
match, that's all.

>         Or can we ask 'lid' (and, ideally, Grep too) to include the column of a
>         match in the output?
> 
>     No, I don't think such an option exists.  It could be a great
>     enhancement request, though ;-)
> 
> I was hoping you could serve as a liaison in that, being the sole user of id-utils that I know of, so far.

I could do that, but given the explanation above of what -w means, it
will hardly help us, right?

> But anyway, if there is no such feature now, we have to choose another solution in Emacs 25.1. Even if id-utils were to add this today, it would take time to trickle to the majority of our users.
> 
> The bar is actually higher: to make use of the enhancement, we'd need Global and CScope to support it, too, or at least to be able to detect the feature at runtime.

Right.  So I think we need to assume that the program we invoke to
bring the matches is not smart enough anyway, and Emacs will have to
search in the matches for those we want to present, filtering out the
false positives.  This assumption seems to fit well all the programs
that can support the queries required by xref-find-references.

I'm not sure I understand what you have in mind for that, though.  Are
you going to switch the major mode of the temporary buffer as
determined by the file name of each match?  Maybe we should take a
hint from the major mode of the buffer in which the command was
invoked?  Also, how about just using the syntax table of the major
mode, instead of actually turning the mode in the buffer -- could that
be significantly cheaper?





  reply	other threads:[~2016-04-07 15:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05 15:16 bug#23223: 25.0.92; Can xref-find-references be sped up? Eli Zaretskii
2016-04-06  0:37 ` Dmitry Gutov
2016-04-06 15:09   ` Dmitry Gutov
2016-04-06 17:20     ` Eli Zaretskii
2016-04-06 23:11       ` Dmitry Gutov
2016-04-07  2:49         ` Eli Zaretskii
2016-04-06 17:12   ` Eli Zaretskii
2016-04-07  0:11     ` Dmitry Gutov
2016-04-07 15:03       ` Eli Zaretskii [this message]
2016-04-09  3:12         ` Dmitry Gutov
2016-04-09  7:25           ` Eli Zaretskii
2016-04-10 23:27             ` Dmitry Gutov
2016-04-11 15:56               ` Eli Zaretskii
2016-04-11 23:25                 ` Dmitry Gutov
2016-04-12 15:50                   ` Eli Zaretskii
2016-04-12 18:49                     ` Dmitry Gutov
2016-04-12 19:16                       ` Eli Zaretskii
2016-04-12 20:26                         ` Dmitry Gutov
2016-04-13  2:44                           ` Eli Zaretskii
2016-04-13 10:18                             ` Dmitry Gutov
2016-04-13 15:16                               ` Eli Zaretskii
2016-04-15 14:29                                 ` Eli Zaretskii

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=83mvp5lauu.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=23223@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /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.