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: Wed, 15 Sep 2021 09:15:00 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Tue, 14 Sep 2021 17:50:48 -0700
> Cc: Tuấn-Anh Nguyễn <ubolonton@gmail.com>,
>  Theodor Thornhill <theo@thornhill.no>,
>  Clément Pit-Claudel <cpitclaudel@gmail.com>,
>  Emacs developers <emacs-devel@gnu.org>,
>  Stefan Monnier <monnier@iro.umontreal.ca>,
>  stephen_leake@stephe-leake.org
> 
> > Almost: there's the (minor) problem of obtaining the "<lang>" part by
> > the major-mode.  I think it would be good to have a utility function
> > to do that so that major modes won't need to reinvent the wheel, do
> > the research, etc.
> 
> That’s where I don’t understand: the major mode is written by major mode 
> writers, who certainly know the correct “<lang>” name: they need to read the 
> source of the language definition to use language’s tree-sitter features. You 
> seem to agree on that because you said that this function can be extended by 
> major mode writers.

I don't understand what you are saying here.  Why would major mode
programmers need to know the correct <lang> name?  The TS facilities
we will have in Emacs will be language-agnostic, right?  For example,
to correctly indent a line of code, the major mode will call some
hypothetical tree-sitter-get-indentation function, and that function
will work in any major mode, provided that the major mode told TS to
load the support for the programming language of the buffer.  Right?
So when the major mode initializes for working with TS, it should tell
TS which language to load, and why would we request the major mode
programmer to know the correct <lang> name which corresponds to the
major mode's programming language?  Why would they need to "read the
source of the language definition to use language’s tree-sitter
features"?  The specifics of the TS implementation of, say,
indentation calculations won't be exposed on the level of the
indentation facilities provided by TS integration in Emacs, right?

There's some misunderstanding here, and I cannot for the life of me
figure out where is it.

> But if you mean an ordinary end user need to know the correct <lang> name

No, that's not the issue I'm talking about.



reply via email to

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