emacs-devel
[Top][All Lists]
Advanced

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

Re: Helpful in Emacs?


From: Arthur Miller
Subject: Re: Helpful in Emacs?
Date: Fri, 10 Sep 2021 02:52:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 09.09.2021 23:23, Arthur Miller wrote:
>> What do you need to build  xref backend you mention? As mentioned on 
>> elisp-refs
>> gh page:
>> "xref-find-references: This command is included in Emacs 25.1, but it's based
>> on
>> a text search. It is confused by comments and strings, and cannot distinguish
>> between functions and variables."
>> Would rebuilding this command to use read instead of text search do the 
>> thing?
>
> You can easily plug another search implementation in xref-find-references. You
> can even make summaries multiline (though that would feel weird to me).
Ok, that sounds good.

> But is elisp-refs that much better at searching? Distinguishing variables from
> functions sounds nice, but then you might want to rename the function -- and
> you'll probably want to rename the variable with the same name as well.

I can't really tell you since I am not an expert. The quote was from the
elisp-refs project. Read does have semantic information about symbols readily
avialable, plain string searching does not have it immidiately, but strings can
always be interned and looked up, so I really don't know how it compares to
xref. I do believe that the author is correct in what it says, otherwise I don't
think he would be doing that work. Observe also that the comment is old, a
couple of years or more.

> Same about comments: if elisp-refs skips comments altogether (rather than
> smartly parsing references inside), you might miss some references to your
> function when doing a rename.

> I also wonder how it compares in performance.

I haven't benchmarked or done any deeper investigations; I haven't even had time
to look at his code yet; but I don't think the performance would be much
different than just search through buffer. Read might be somewhat faster since
it isn't as general regex matcher as regex-search is I guess, but that would be
just my wild guessing, I don't think I am qualified to speak much about
performance here without benchmarking.

However what I have experienced, in my own little experiment, is that searching 
for
all symbol definitions in entire Emacs lisp directory went fast on my computer,
~2 seconds, with flushing the database to the disk. Now I don't do much, I just
collect all defuns, defmacros, defvars and defcustoms, so it is not terribly
lots of work, finding references is probably much more work, but at least as an
experiment it indicates that it could be very fast. I attached the code for the
reference.

(benchmark-run (ff-build-emacs-db))

(2.037053179 0 0.0)

Now I don't know how fast is xref-find-references nor how it does what it does
yet either, so lots here is just speculations, most of them probably wrong :). 

Attachment: func-freq.el
Description: Text document


reply via email to

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