[Top][All Lists]

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

Re: How to add pseudo vector types

From: Stephen Leake
Subject: Re: How to add pseudo vector types
Date: Thu, 29 Jul 2021 16:06:15 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (windows-nt)

Yuan Fu <casouri@gmail.com> writes:

>> On Jul 28, 2021, at 1:54 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>> From: Yuan Fu <casouri@gmail.com>

>> The adherence to narrowing is for the use cases where TS is _always_
>> invoked on the same narrowed region.  You seem to be thinking about
>> changes in the narrowing while TS is parsing, or between consecutive
>> re-parsing calls, but I see no interesting/important use cases which
>> would need to do that.  And if there are some tricky cases which do
>> need this, the respective Lisp programs will have to deal with the
>> problem.
> That makes sense. However it bring up a problem. Consider such a
> buffer: XXAAXX.

There is always a delimiter in the text that defines the boundary
between XX and AA; say "{{" for example, with "}}" at the other end of

> Say lisp narrows to AA and creates a tree-sitter parser. Then lisp
> widens the buffer, and user inserts B in front of AA. Now the buffer

before or after the delimiter?

XX {{ BAA }} XX :   B is a change to AA

XXB {{ AA }} XX :   B is a change to XX

> Emacs has two options to convey this change to the tree-sitter parser:
> 1) it does not, then tree-sitter still thinks the buffer is AA,
> essentially the portion where tree-sitter sees is pushed forward by
> one character, 2) it tells tree-sitter the user inserted a character
> at the beginning, then tree-sitter thinks the buffer is BAA. Which
> option is correct depends on how does lisp later narrows: if lisp
> narrows to AA, then option 1 is correct, if lisp narrows to BAA, then
> option 2 is correct. But how do we know which option is correct before
> lisp narrows?

The major mode determines the boundaries and the narrowing, so leave it
up to that code to be consistent, not your code.

-- Stephe

reply via email to

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