[Top][All Lists]

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

Re: How to add pseudo vector types

From: Yuan Fu
Subject: Re: How to add pseudo vector types
Date: Thu, 29 Jul 2021 11:57:56 -0400

> On Jul 29, 2021, at 11:28 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Thu, 29 Jul 2021 10:35:10 -0400
>> Cc: Stephen Leake <stephen_leake@stephe-leake.org>,
>> Clément Pit-Claudel <cpitclaudel@gmail.com>,
>> Stefan Monnier <monnier@iro.umontreal.ca>,
>> emacs-devel@gnu.org
>>> We don't need to know.  The Lisp program which needs to handle this
>>> situation will have to figure out what is right in that case, "right"
>>> in the sense that it produces the desired results after communicating
>>> the changes to TS.
>> The difficulty is that what tree-sitter sees must be consistent. If Emacs 
>> updates tree-sitter with option 1 and lisp later choose option 2, the 
>> content that tree-sitter sees is not consistent.
> If that happens, it means the Lisp program which does that has a bug
> that needs to be fixed.
>> Anyway, I found a way that avoids this issue: the bounds of tree-sitter’s 
>> visible region never changes, and the next time when lisp narrows to a 
>> different region, we update tree-sitter’s bound to match that of the 
>> narrowing. Here is the latest patch. If the code is not entirely 
>> straightforward, I’m happy to add more comment to explain it.
> I'm not sure we should do this, because it means we second-guess what
> the Lisp program calling TS intends to do.  Why should we do that,
> instead of leaving it to the Lisp program to DTRT?  And what happens
> if our guess is wrong?

I don’t think the current implementation guesses anything. Let me turn around 
and ask you what is TRT: if the buffer is xxxAAAxxx, and lisp narrows to AAA 
and creates a parser, parser sees AAA; now widen, user inserts BBB in front of 
AAA, what do we tell tree-sitter? Nothing changed, or BBB inserted at the 
beginning? To where should lisp narrow? BBBAAA, or AAA, or BBB?


reply via email to

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