emacs-devel
[Top][All Lists]
Advanced

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

Re: emacs-tree-sitter and Emacs


From: Stefan Monnier
Subject: Re: emacs-tree-sitter and Emacs
Date: Thu, 02 Apr 2020 13:39:15 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Can we do something similar to fontified text property? I.e., only parse the
> first screen full of text when a buffer is opened, and mark the rest as
> unparsed with text property. Then when we need to access the parse tree (for
> fortification, etc), send all unparsed text before some point (e.g., last
> visible char in the window) to the parser.

If you follow the idea that parsing is always done "from point-min",
then you don't need text-properties: you only need to remember the
position up to which parsing has been done.

That's what `syntax-propertize` does, and it keeps the corresponding
info in `syntax-propertize--done` (it doesn't even need to be marker
since any changes to the text before `syntax-propertize--done` should
cause it to be reset to the beginning of those modifications).

As mentioned in some other message, this design becomes inefficient when
you have two windows displaying a large buffer, one display near the end,
and the other near the beginning, and you make changes at the beginning
of the buffer.  I haven't seen any performance bug-reports or complaints
about it, so it appears that those circumstances are very rare.

BTW, one of the potential benefits of font-locking done via tree-sitter
is that it generally doesn't care about lines, so it should be possible
to make it work just as efficiently on long lines (that won't solve all
the problems we have with long lines, but still).


        Stefan




reply via email to

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