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 12:02:56 +0200 Message-ID: <83sfie54fj.fsf@gnu.org> References: <0249C656-21C8-49F2-B979-A1894BF80637@gmail.com> <1B76E73A-0DCD-456E-9F28-0E90723DA66D@gmail.com> <83sfif8cl2.fsf@gnu.org> <43E997E4-3449-4974-AB8C-BD5A4AA8A738@gmail.com> <837czq6qxr.fsf@gnu.org> <37649367-0BCD-4FD5-AC6D-8034883BC4FE@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5926"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dgutov@yandex.ru, emacs-devel@gnu.org, monnier@iro.umontreal.ca, theo@thornhill.no To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 20 11:03:46 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 1owhAv-0001JK-OX for ged-emacs-devel@m.gmane-mx.org; Sun, 20 Nov 2022 11:03:45 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owhA8-000896-Qc; Sun, 20 Nov 2022 05:02:56 -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 1owhA2-00088u-LB for emacs-devel@gnu.org; Sun, 20 Nov 2022 05:02:50 -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 1owhA1-0002Iy-AD; Sun, 20 Nov 2022 05:02:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=bPsY6BrDjszEIJ4KPZFt5xkr/0Qt0G5QxpqKGv/tQsI=; b=pyhV78fIvSvOSTZc4f4r lIvio0wWEJV3lNyH/mSS+s1uPtG7Nv9ZJTqsUUrki2AZ+WjPNLa3akIsSIsfw1Ujeo95X3adiYQCd xvSGscV+SavzBV0zXG1cRZICcpciUFXIzNt7s+SIk4ab6tdsDaXWi5cp5b4n2SQ82Wp9oR6OYDMfS FXMO/LJBMIFlrgfFgR3LuGefKE2IwtdlrwPwmRKvkfYvwYYm3uzylQMmSwirQFL9t12HZRfsV1EX3 ySVfs/GhMX2Agik4jtbQYBlGiw7ybCQqwLbU/z5qodIrQlNV13Tf/kh7OgjsKE84V6Wp7aOpTuIsv AAmic/FyMMOUZQ==; 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 1owhA0-0008PS-KN; Sun, 20 Nov 2022 05:02:48 -0500 In-Reply-To: <37649367-0BCD-4FD5-AC6D-8034883BC4FE@gmail.com> (message from Yuan Fu on Sun, 20 Nov 2022 01:19:13 -0800) 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:300238 Archived-At: > From: Yuan Fu > Date: Sun, 20 Nov 2022 01:19:13 -0800 > Cc: Dmitry Gutov , > emacs-devel@gnu.org, > monnier@iro.umontreal.ca, > theo@thornhill.no > > > > > On Nov 19, 2022, at 11:11 PM, Eli Zaretskii wrote: > > > >> Date: Sun, 20 Nov 2022 00:03:35 +0200 > >> Cc: Eli Zaretskii , emacs-devel@gnu.org, > >> monnier@iro.umontreal.ca, theo@thornhill.no > >> From: Dmitry Gutov > >> > >> On 19.11.2022 23:49, Yuan Fu wrote: > >>> Actually, that’s evidence supporting his preference: js-mode will remain to be the native implementation, so inheriting from it is exactly as before. Js-ts-mode will install tree-sitter stuff. And js-base-mode wouldn’t do much. > >> > >> But js-base-mode will be used in auto-mode-alist? > > > > NO!!! auto-mode-alist should keep using js-mode, as it does today. > > > > js-base-mode, if we need it, should just be a vehicle for easy sharing of > > common stuff between several modes that pertain to the same or similar > > languages. It should NOT be visible to users, so should not appear in any > > variables users are likely to customize. > > Alright, changing js-mode to ja-native-mode is indeed a bad idea. So this is what I did: for eg, js-mode, I created js-ts-mode and js-base-mode. Js-mode and js-ts-mode inherits js-base-mode. Auto-mode-alist has javascript-mode (that’s what’s in the list right now, I didn’t change it). > > If a user wants to use tree-sitter for javascript, they can add (javascript-mode . js-ts-mode) into major-mode-remap-alist. Or manually turn on js-ts-mode. Or customize auto-mode-alist to have js-ts-mode be used in preference to js-mode. Right? > If someone wants js-mode and js-ts-mode to share the same configuration, he needs to configure js-base-mode. So js-base-mode isn’t completely invisible. We should not advertise js-base-mode. If people want to share configurations between two modes, they should do that explicitly via their own hook function, or via copying the configurations. (And some of the configurations cannot be shared anyway, because the two modes use different features for font-lock and indentation.)