[Top][All Lists]

[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: Fri, 23 Jul 2021 16:22:59 -0400

> We must replace this function, if only because the MS-Windows build of
> Emacs uses a custom malloc implementation.  Does TS allow the client
> to use its own malloc?

Yes, in that case, we need to embed tree-sitter into Emacs, instead of using it 
as a dynamic library, I think.

// Allow clients to override allocation functions
#ifndef ts_malloc
#define ts_malloc  ts_malloc_default
#ifndef ts_calloc
#define ts_calloc  ts_calloc_default
#ifndef ts_realloc
#define ts_realloc ts_realloc_default
#ifndef ts_free
#define ts_free    ts_free_default

How do we handle such thing in Emacs?

>>>> Also, we don’t call change hooks in replace_range_2, why?
>>> Because it is called in a loop, one character at a time.  The caller
>>> of replace_range_2 calls these hooks for the entire region, once.
>>>> Should I update tree-sitter trees in that function, or should I not?
>>> The only caller is casify_region, so you could update there.
>> casify_region doesn’t have access to byte positions.
> You can compute them using CHAR_TO_BYTE.

Ok. I’ll do that.


reply via email to

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