From: Po Lu <luangruo@yahoo.com>
To: emacs-devel@gnu.org
Cc: Yuan Fu <casouri@gmail.com>
Subject: Re: feature/tree-sitter 06db8015ea 1/5: Extract out treesit_make_ranges
Date: Tue, 15 Nov 2022 19:52:22 +0800 [thread overview]
Message-ID: <87bkp8h1u1.fsf@yahoo.com> (raw)
In-Reply-To: <20221115104926.4D491C0E4C8@vcs2.savannah.gnu.org> (Yuan Fu's message of "Tue, 15 Nov 2022 05:49:25 -0500 (EST)")
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..."
next parent reply other threads:[~2022-11-15 11:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <166850936462.27011.17289179422833914249@vcs2.savannah.gnu.org>
[not found] ` <20221115104926.4D491C0E4C8@vcs2.savannah.gnu.org>
2022-11-15 11:52 ` Po Lu [this message]
[not found] ` <20221115104926.5143AC0E4CA@vcs2.savannah.gnu.org>
2022-11-15 11:54 ` feature/tree-sitter 34e50dc4a2 2/5: Allow tree-sitter to notify parse-tree changes Po Lu
2022-11-15 17:25 ` Yuan Fu
2022-11-15 18:06 ` Eli Zaretskii
2022-11-15 18:06 ` Visuwesh
2022-11-15 18:20 ` Yuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bkp8h1u1.fsf@yahoo.com \
--to=luangruo@yahoo.com \
--cc=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.