[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: |
Mon, 26 Jul 2021 13:09:13 -0400 |
>>
>>> 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.
We need to “delete” the hidden text and “re-insert” when we widen the buffer.
I’ll try to make it a no-op as long as we remember to widen before calling
tree-sitter to parse anything.
>
> 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.
Tree-sitter lets you set ranges for a parser to limit it self within, in order
to support multi-language files.
>
>> 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
> contract.
>
>> 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.
Ok. I trust you to know better than I do.
Yuan
- Re: How to add pseudo vector types, (continued)
- Re: How to add pseudo vector types, Stephen Leake, 2021/07/24
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/24
- Re: How to add pseudo vector types, Stephen Leake, 2021/07/25
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/25
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/26
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/26
- Re: How to add pseudo vector types,
Yuan Fu <=
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/26
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/26
- Re: How to add pseudo vector types, Perry E. Metzger, 2021/07/26
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/26
- Re: How to add pseudo vector types, Eli Zaretskii, 2021/07/26
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/26
- Re: How to add pseudo vector types, Dmitry Gutov, 2021/07/26
- Re: How to add pseudo vector types, Stephen Leake, 2021/07/27
- Re: How to add pseudo vector types, Yuan Fu, 2021/07/27
- Re: How to add pseudo vector types, Stephen Leake, 2021/07/27