emacs-devel
[Top][All Lists]
Advanced

[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: Wed, 28 Jul 2021 14:46:03 -0400


> On Jul 28, 2021, at 1:54 PM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
>> From: Yuan Fu <casouri@gmail.com>
>> Date: Wed, 28 Jul 2021 13:47:42 -0400
>> Cc: Stephen Leake <stephen_leake@stephe-leake.org>,
>> cpitclaudel@gmail.com,
>> monnier@iro.umontreal.ca,
>> emacs-devel@gnu.org
>> 
>> Could you describe the desired effect on tree-sitter when the buffer is 
>> narrowed?
> 
> The behavior should be the same as if the text before and after the
> narrowed region didn't exist.
> 
> If we just deny accessibility of the hidden region from tree-sitter, 
> tree-sitter is still aware of the hidden text, because it has previously 
> parsed the hidden text and stored the result in the parse tree.
> 
> 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. 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 is 
XXBAAXX. 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?

Yuan




reply via email to

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