From: Yuan Fu <casouri@gmail.com>
To: "Daniel Martín" <mardani29@yahoo.es>
Cc: emacs-devel@gnu.org
Subject: Re: Simplify the tree-sitter parser creation API
Date: Mon, 16 May 2022 13:50:52 -0700 [thread overview]
Message-ID: <CBAFADC7-174E-40DC-A26A-175CC7A84C99@gmail.com> (raw)
In-Reply-To: <m1pmke7tcn.fsf@yahoo.es>
> On May 15, 2022, at 7:39 AM, Daniel Martín <mardani29@yahoo.es> wrote:
>
>
> Currently, there are three functions to create a tree-sitter parser:
>
> - treesit-get-parser-create
> - treesit-get-parser
> - treesit-parser-create
>
> I think this set of similarly named functions can be reduced, so that
> developers don't need to remember a lot of APIs. How I understand the
> problem of creating a tree-sitter parser is that we need three things
> from the developer:
>
> - A programming language (a symbol).
> - A buffer (optional, default to the current buffer).
> - Whether to create or reuse an existing parser for that language.
>
> I think it would be simpler to have just one parser creation API like
>
> (treesit-make-parser LANGUAGE &optional BUFFER ALWAYS-NEW)
>
> There are similar API patterns like this one already in Emacs. With
> this proposed API, the common case, which is to create a parser for the
> current buffer, and to try to reuse one if it already exists, is very
> simple from the POV of an ELisp developer integrating with tree-sitter:
>
> (treesit-make-parser 'c)
>
> Any thoughts?
>
Thanks! I think it makes sense. Though I’d keep the treesit-parser-create function because it directly corresponds to the tree-sitter C API. I can extend the C definition of treesit-parser-create to
(treesit-parser-create LANGUAGE &optional BUFFER NO-REUSE)
Yuan
next prev parent reply other threads:[~2022-05-16 20:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <m1pmke7tcn.fsf.ref@yahoo.es>
2022-05-15 14:39 ` Simplify the tree-sitter parser creation API Daniel Martín
2022-05-16 20:50 ` Yuan Fu [this message]
2022-06-16 19:21 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CBAFADC7-174E-40DC-A26A-175CC7A84C99@gmail.com \
--to=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=mardani29@yahoo.es \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).