emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter api


From: Eli Zaretskii
Subject: Re: Tree-sitter api
Date: Fri, 17 Sep 2021 09:06:25 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Thu, 16 Sep 2021 14:46:08 -0700
> Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
>  ubolonton@gmail.com,
>  theo@thornhill.no,
>  cpitclaudel@gmail.com,
>  emacs-devel@gnu.org,
>  stephen_leake@stephe-leake.org
> 
> >>> I wasn't talking about tree-sitter itself, I was talking about the
> >>> facilities Emacs will provide based on TS.  There will be in Emacs a
> >>> function to calculate indentation using TS, right?  And that function
> >>> will be language-agnostic, like indent-line-function is, right?
> >> 
> >> There is such a function but it doesn't do anything itself.  It relies
> >> on the major-mode to do the heavy lifting which consists in giving
> >> indentation rules for each one of the possible node types that can
> >> appear in the AST
> > 
> > Sure, and the new one will do that with help of TS.  But the principle
> > is the same.
> 
> My point is, major mode writers need to read the source of the tree-sitter 
> language definition to do anything useful with tree-sitter

If this is so, then why do we bother documenting the Lisp APIs for
TS-related features?  If Lisp programmers need to read the TS sources
to do anything useful in Emacs, let them read the sources, including
the Lisp and C sources you are working on?

That was somewhat sarcastic, but my point is that this is NOT how we
do this kind of stuff in Emacs.  We should have Lisp-level facilities
that reflect the TS features, and those Lisp-level facilities should
be documented and should be the ONLY thing a Lisp programmer needs to
read to adapt his/her major mode to TS.  We should NOT assume that
Lisp programmers read the TS source code, exactly like we don't assume
that for other libraries, like GnuTLS, librsvg, or libgccjit.  Under
that modus operandi, the way to glean the <lang> part from the major
mode's language name is something that should be part of the
facilities we provide.



reply via email to

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