unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#55428: [feature/tree-sitter] Simplify the parser creation API
       [not found] <m1wnem990i.fsf.ref@yahoo.es>
@ 2022-05-15 14:15 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-05-15 14:26   ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-05-15 14:15 UTC (permalink / raw)
  To: 55428


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?





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#55428: [feature/tree-sitter] Simplify the parser creation API
  2022-05-15 14:15 ` bug#55428: [feature/tree-sitter] Simplify the parser creation API Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-05-15 14:26   ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2022-05-15 14:26 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 55428

> Date: Sun, 15 May 2022 16:15:57 +0200
> From:  Daniel Martín via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> 
> 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)

I suggest that discussions about the API be held on emacs-devel, not
hear.  That way, more people will see them and could decide whether to
participate.

Thanks.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-15 14:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <m1wnem990i.fsf.ref@yahoo.es>
2022-05-15 14:15 ` bug#55428: [feature/tree-sitter] Simplify the parser creation API Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-05-15 14:26   ` Eli Zaretskii

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).