From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#23223: 25.0.92; Can xref-find-references be sped up? Date: Thu, 07 Apr 2016 18:03:37 +0300 Message-ID: <83mvp5lauu.fsf@gnu.org> References: <83pou4m6h7.fsf@gnu.org> <902ac022-3a76-c363-0c77-12b1cdb8d521@yandex.ru> <8360vumzk4.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1460041532 27882 80.91.229.3 (7 Apr 2016 15:05:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 7 Apr 2016 15:05:32 +0000 (UTC) Cc: 23223@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 07 17:05:21 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aoBUm-00017T-Gy for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Apr 2016 17:05:20 +0200 Original-Received: from localhost ([::1]:50419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBUl-0008Dy-UQ for geb-bug-gnu-emacs@m.gmane.org; Thu, 07 Apr 2016 11:05:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39301) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBUb-00081f-EJ for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2016 11:05:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoBUV-0004Dd-E4 for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2016 11:05:09 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBUV-0004DZ-AQ for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2016 11:05:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1aoBUV-0001WP-4O for bug-gnu-emacs@gnu.org; Thu, 07 Apr 2016 11:05:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Apr 2016 15:05:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23223 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23223-submit@debbugs.gnu.org id=B23223.14600414545762 (code B ref 23223); Thu, 07 Apr 2016 15:05:03 +0000 Original-Received: (at 23223) by debbugs.gnu.org; 7 Apr 2016 15:04:14 +0000 Original-Received: from localhost ([127.0.0.1]:53030 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoBTe-0001Up-Ho for submit@debbugs.gnu.org; Thu, 07 Apr 2016 11:04:14 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:47982) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aoBTa-0001UH-08 for 23223@debbugs.gnu.org; Thu, 07 Apr 2016 11:04:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoBTP-00041f-1g for 23223@debbugs.gnu.org; Thu, 07 Apr 2016 11:04:00 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36391) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoBTO-00041b-VQ; Thu, 07 Apr 2016 11:03:54 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:2905 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aoBTO-0001Nh-CA; Thu, 07 Apr 2016 11:03:54 -0400 In-reply-to: (message from Dmitry Gutov on Thu, 7 Apr 2016 03:11:25 +0300) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:116155 Archived-At: > Cc: 23223@debbugs.gnu.org > From: Dmitry Gutov > 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?