[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to add pseudo vector types
From: |
Fu Yuan |
Subject: |
Re: How to add pseudo vector types |
Date: |
Tue, 3 Aug 2021 07:53:54 -0400 |
> 在 2021年8月3日,上午7:42,Eli Zaretskii <eliz@gnu.org> 写道:
>
>
>>
>> From: Fu Yuan <casouri@gmail.com>
>> Date: Tue, 3 Aug 2021 06:24:34 -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’m about to change all lisp-facing functions from using byte position to
>> using point.
>
> I don't understand how can you do this. Point is set by Lisp, and
> generally cannot be changed from C, except for very short durations of
> time (or if the C code is the implementation of a Lisp command that
> just moved point). If you need to access some buffer position, you
> cannot in general use point, because you cannot control where point
> is.
>
>> Point is much easier to work with.
>
> In what way is it easier? I feel that I'm missing something here.
>
>> If lisp wants byte positions, they can just convert from point themselves.
>
> ??? What do you mean by that? Can you show an example?
Oh no, I don’t mean that. I meant that, for example, functions like
node_start_byte, which returns the byte position of the beginning of the node,
will now be node_start_pos, which returns a point position. And if I want the
byte position of the beginning of the node, I can use (position-to-byte
(tree-sitter-node-start-pos node))
Yuan