From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter and major mode inheritance Date: Sun, 20 Nov 2022 08:51:10 +0200 Message-ID: <83cz9i6rvl.fsf@gnu.org> References: <0249C656-21C8-49F2-B979-A1894BF80637@gmail.com> <1B76E73A-0DCD-456E-9F28-0E90723DA66D@gmail.com> <83sfif8cl2.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18759"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, emacs-devel@gnu.org, monnier@iro.umontreal.ca, theo@thornhill.no To: Dmitry Gutov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 20 07:52:02 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oweBN-0004f8-Et for ged-emacs-devel@m.gmane-mx.org; Sun, 20 Nov 2022 07:52:01 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oweAW-0000T8-W5; Sun, 20 Nov 2022 01:51:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oweAV-0000SU-Po for emacs-devel@gnu.org; Sun, 20 Nov 2022 01:51:07 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oweAT-00010K-OB; Sun, 20 Nov 2022 01:51:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=jI5zDZaaYzchXkdMxhnE2ecU6m8kfKReVOc1h/t0DXk=; b=OwL1U/XxTRuz t6zEjiHOLeZ4bzdvQnNPJmSnR110Lta3C0mZ/egMqD1NQCYrpYmIQPz2mD/PP7+wv2mdA7AqI+aU1 G6X1d157bNmZcTjisyagLfbLbAwMmv4+swO9rEikVtE4HERt673kccUJzMf81ImVsNbul2P6T15dP 3N9jo0gheSUQ3oRghGzchLaeEIaisFCFJQzUG/IpLefqj+94js0S20pbzik5M5/+XFsd1DIUv7u49 1QjXszTJqcuWxwJ3vsB3EpAoagVYkqYK+hPKlrujXnMCZeZdkUdSSkRbsD8UKCS/Y6wFdJmNSEoTV 2rFenmUYYQXwbdK0ifPouA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oweAQ-0000nf-C0; Sun, 20 Nov 2022 01:51:05 -0500 In-Reply-To: (message from Dmitry Gutov on Sat, 19 Nov 2022 23:39:37 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:300227 Archived-At: > Date: Sat, 19 Nov 2022 23:39:37 +0200 > Cc: emacs-devel@gnu.org, monnier@iro.umontreal.ca, theo@thornhill.no > From: Dmitry Gutov > > On 19.11.2022 12:26, Eli Zaretskii wrote: > >> From: Yuan Fu > >> Date: Sat, 19 Nov 2022 01:41:47 -0800 > >> Cc: Stefan Monnier, > >> Eli Zaretskii, > >> Theodor Thornhill > >> > >> 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.