[Top][All Lists]

[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: Mon, 26 Jul 2021 19:49:02 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Mon, 26 Jul 2021 12:40:31 -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
> > Once again, we are talking about the function used by TS to read
> > buffer text.  Not about the parser or its caller.  Low-level code,
> > which knows nothing about the context, should never look beyond the
> > restriction.
> It doesn’t harm for tree-sitter to see the rest of the buffer, it doesn’t 
> modify anything, all it does it reading the text. OTOH, restricting 
> tree-sitter to the bounds of narrows adds complexity for no benefit (as far 
> as I can see).

Which complexity does it add?  You just compare with BEGV_BYTE instead
of BEG_BYTE etc.

If we let TS look where it wants, we will lose the ability to restrict
it to a certain part of the buffer text.  This is needed at least for
some specialized modes, and is generally desirable, as it gives Lisp
programs an easy way to impose such restrictions whenever they need.

> Maybe narrowing is the context that low level code should ignore

No other code in Emacs does, and for a good reason.

> The only benefit that I can think of is “we firmly adhere to the ‘contract’ 
> that no one can look beyond the narrowed region”, but is it a good contract? 
> Is there really a contract in the first place?

It served us very well until now, so yes, I think it's a good

> IMO, narrowing acts like masking tapes over the rest of the buffer, so that 
> user edits like re-replace wouldn’t spill out. Demanding everything in Emacs 
> to not have access to the rest of the buffer is dogmatic (in the sense that 
> it is too rigid and is simply following the doctrine blindly). 

Again, this "dogma" is used and adhered everywhere else in Emacs by
such low-level code.

reply via email to

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