On 04/11/2016 06:56 PM, Eli Zaretskii wrote: > Unfortunately, it seems to miss matches: out of 1127 matches of > current_buffer with the original version, the new one only shows 963. > It sounds like some conditions on what exactly is a symbol need > adjustment, Ooh, that's a great catch, thanks! Turns out, auto-mode-alist wasn't getting applied because buffer-file-name wasn't set. Fixing that added ~25% performance hit, so I also added xref--find-buffer-visiting to cache the expensive lookup mentioned previously. See the new patch attached. That seems to about exhaust the optimization opportunity here. > As an aside, if I invoke xref-find-references without an ID file, > which AFAIU means Emacs will invoke find+grep, I get this error: > > semantic-symref-derive-find-filepatterns: Customize ‘semantic-symref-filepattern-alist’ for lisp-interaction-mode > > unless I invoke xref-find-references from a buffer in C mode. ...or the current major mode is one of the currently supported ones, via the above variable. > Curiously, this doesn't happen when there's an ID file and IDutils is > invoked. Is this expected? Yes. semantic-symref-filepattern-alist is defined in and used by semantic/symref/grep.el. We can add (lisp-interaction-mode "*.el") to it. > "gid" is just a short for "lid -R grep", so the > contents I get is the same as xref-find-references does, it's just > formatted differently. Not exactly: you get more false positives because it doesn't apply the language-aware filtering. >> What's the new time you get from the former? > > 3 sec (in an unoptimized build, I'd expect this to become 1 sec in an > optimized build). So we are OK speed-wise, we just need to fix the > misses mentioned above. Cool. >> By the way, the "insert-file-contents + set-auto-mode" dance comes with >> a new minor downside: extra chatter from the major modes. E.g. try >> project-file-regexp with "should have received a copy". > > I don't see this in xref-find-references. Should I? Not at all. xref-find-references only searches in the files related to the current one by type (or in a predefined database like id-utils's one). The chatter I got was from e.g. sh-mode (about the indentation variable being guessed), nxml-mode, and so on, with matches in ~4000 files. >> We can avoid saving it to the message log, but it appears in the >> echo area either way. > > Can't you bind inhibit-message to a non-nil value? That works! > Thanks again for working on this. Thanks for the thoughtful bug report.