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: Stephen Leake
Subject: Re: emacs-tree-sitter and Emacs
Date: Tue, 31 Mar 2020 16:27:35 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (windows-nt)

Eli Zaretskii <address@hidden> writes:

>> From: Jorge Javier Araya Navarro <address@hidden>
>> Date: Sun, 29 Mar 2020 21:23:49 -0600
>> 
>> I have gone through th0rex's pull request[2] and nothing suggests
>> that hooks are being used in order to do
>> the fontification of buffers, the only hook we have is
>> `tree-sitter--after-change', it does re-parsing and keeps
>> the tree updated
>
> Can you explain why an after-change hook is at all needed?  Why not
> pass to tree-sitter the chunk that jit-lock is going to fontify?
> AFAIU, tree-sitter is well suited for parsing incomplete source
> chunks.  

It depends on what you mean by "incomplete". If the full buffer is
syntactically correct, and the "incomplete" source is a region chosen by
font-lock, then yes; tree-sitter can efficiently update the parse tree
to match that region.

On the other hand, if the buffer is not syntactically correct, there is
no guarrantee that tree-sitter can handle it; it's supposed to be
"robust" to syntax errors. One of the links to an error recovery
algorithm is broken; the other link describes an algorithm that is not
as sophisticated as the one wisi uses (I'm working on writing a paper
about that).

> OTOH, using an after-change hook has its downsides, even if disregard
> slow-down (which I wouldn't).

In wisi (used by ada-mode), the after-change hooks just record what
regions have been changed; font-lock then triggers a parse if the region
being fontified contains or is after a change region. Navigation and
indent also trigger parses.

By default font-lock runs after every character typed, which is often
too slow in an ada-mode buffer; I always set jit-lock-defer-time to
1.0 seconds. 

-- 
-- Stephe



reply via email to

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