From: "Daniel Martín" <mardani29@yahoo.es>
To: emacs-devel@gnu.org
Subject: Simplify the tree-sitter parser creation API
Date: Sun, 15 May 2022 16:39:36 +0200 [thread overview]
Message-ID: <m1pmke7tcn.fsf@yahoo.es> (raw)
In-Reply-To: m1pmke7tcn.fsf.ref@yahoo.es
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?
next parent reply other threads:[~2022-05-15 14:39 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 ` Daniel Martín [this message]
2022-05-16 20:50 ` Simplify the tree-sitter parser creation API Yuan Fu
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=m1pmke7tcn.fsf@yahoo.es \
--to=mardani29@yahoo.es \
--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 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).