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: Eli Zaretskii
Subject: Re: How to add pseudo vector types
Date: Thu, 29 Jul 2021 20:38:45 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Thu, 29 Jul 2021 12:59:43 -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
> 
> >> 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?
> > 
> > Neither.  We should tell TS that instead of AAA there's now
> > xxxBBBAAAxxx, because the narrowing was removed.
> 
> This is the common usage that I imagined:
> 
> Narrow
> Calls tree-sitter (for fontification etc)
> Widen
> 
> Users edit the buffer
> 
> narrow
> Calls tree-sitter (for fontification etc)
> Widen
>
> Ideally, tree-sitter only sees the narrowed region because everytime it is 
> called, the buffer is narrowed. However, tree-sitter doesn’t work that way, 
> it needs to be updated when user edits the buffer, when the buffer is 
> widened. If your goal is give lisp control of what tree-sitter sees, we can’t 
> just give tree-sitter the whole buffer whenever the user makes some change.

In the above scenario, then the Lisp program that narrows the buffer
should figure out how to do that correctly.  The call to TS will then
express the changes in the narrowed region only.

> > Anyway, you are once again bothered by a scenario that should not
> > happen at all: a Lisp program should not call TS first with, then
> > without narrowing (or the other way around).  I don't see why such
> > situation should happen, and if they do, the Lisp programs which need
> > them will have to figure out what to do and how.
> 
> Even if lisp always call tree-sitter with narrowing, we still need to update 
> tree-sitter when the buffer is widened.

No, I don't think so.  Why would we need to?  From the TS POV the text
outside the restriction doesn't exist because it never sees it.



reply via email to

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