emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: feature/tree-sitter 06db8015ea 1/5: Extract out treesit_make_ranges


From: Po Lu
Subject: Re: feature/tree-sitter 06db8015ea 1/5: Extract out treesit_make_ranges
Date: Tue, 15 Nov 2022 19:52:22 +0800
User-agent: Gnus/5.13 (Gnus v5.13)

Yuan Fu <casouri@gmail.com> writes:

> +/* Generate a list of ranges in Lisp from RANGES.  This function
> +   doens't take ownership of RANGES.  BUFFER is used to convert
> +   between tree-sitter buffer offset and buffer position.  */
> +static Lisp_Object
> +treesit_make_ranges (const TSRange *ranges, uint32_t len,
> +                  struct buffer *buffer)
> +{
> +  Lisp_Object list = Qnil;
> +  for (int idx = 0; idx < len; idx++)
> +    {
> +      TSRange range = ranges[idx];
> +      uint32_t beg_byte = range.start_byte + BUF_BEGV_BYTE (buffer);
> +      uint32_t end_byte = range.end_byte + BUF_BEGV_BYTE (buffer);
> +      eassert (BUF_BEGV_BYTE (buffer) <= beg_byte);
> +      eassert (beg_byte <= end_byte);
> +      eassert (end_byte <= BUF_ZV_BYTE (buffer));
> +
> +      Lisp_Object lisp_range
> +     = Fcons (make_fixnum (buf_bytepos_to_charpos (buffer, beg_byte)),
> +              make_fixnum (buf_bytepos_to_charpos (buffer, end_byte)));
> +      list = Fcons (lisp_range, list);
> +    }
> +  return Fnreverse (list);
> +
> +}

There is a trailing newline after "return Fnreverse..."


reply via email to

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