emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter and major mode inheritance


From: Eli Zaretskii
Subject: Re: Tree-sitter and major mode inheritance
Date: Sun, 20 Nov 2022 08:51:10 +0200

> Date: Sat, 19 Nov 2022 23:39:37 +0200
> Cc: emacs-devel@gnu.org, monnier@iro.umontreal.ca, theo@thornhill.no
> From: Dmitry Gutov <dgutov@yandex.ru>
> 
> On 19.11.2022 12:26, Eli Zaretskii wrote:
> >> From: Yuan Fu<casouri@gmail.com>
> >> Date: Sat, 19 Nov 2022 01:41:47 -0800
> >> Cc: Stefan Monnier<monnier@iro.umontreal.ca>,
> >>   Eli Zaretskii<eliz@gnu.org>,
> >>   Theodor Thornhill<theo@thornhill.no>
> >>
> >> Anyway, does anyone think this is a good/bad idea? Should I go implement 
> >> this on css, js, c, etc? It can also be the other way around: instead of 
> >> having c-mode being the virtual mode, we can leave c-mode as-is, and have 
> >> a c-base-mode inherited by c-mode and c-ts-mode. And similarly 
> >> rss-base-mode, rss-mode, and rss-ts-mode.
> > I'd prefer leaving the original modes as-is.  That should cause less
> > compatibility problems, I think.
> 
> Eli, what's your solution for the problem, then?

I don't think I understand the question.  Several (3, AFAIU) solutions were
proposed, one of them leaves the original modes intact and either adds
opt-in features to the original modes to turn on tree-sitter support, or
adds an entirely new mode which requires tree-sitter.  This is the solution
I prefer.

> E.g. js-mode enables tree-sitter, and installs some stuff based on it.

Only if tree-sitter is available, AFAICT.  Btw, if that happens
automatically, then it isn't what I meant -- I meant tree-sitter to be an
explicitly opt-in feature in modes which existed before Emacs 29 and worked
without tree-sitter.

> But js2-mode inherits from js-mode (meaning, it will run the same setup 
> code, and then some of its own), yet it has its own parser. Which will 
> cause all sorts of conflicts with tree-sitter.

js2-mode is not in Emacs, so I cannot control what it does.  Ideally, it
will need only minor adjustments (like making sure it doesn't turn on
tree-sitter if it doesn't want to) or none at all.

If our changes somehow break js2-mode, we should discuss the details and try
to fix the breakage as much as is reasonable from our side.  The details
aren't important from where I stand; what is important is that users of
js-mode can still use the mode even if they don't have tree-sitter installed
or don't want to use it even if it is installed.



reply via email to

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