From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Tree-sitter and major mode inheritance Date: Sat, 19 Nov 2022 01:41:47 -0800 Message-ID: <1B76E73A-0DCD-456E-9F28-0E90723DA66D@gmail.com> References: <0249C656-21C8-49F2-B979-A1894BF80637@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24379"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Eli Zaretskii , Theodor Thornhill To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 19 10:42:42 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 1owKMz-00069x-DY for ged-emacs-devel@m.gmane-mx.org; Sat, 19 Nov 2022 10:42:41 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owKMM-0004Vs-7L; Sat, 19 Nov 2022 04:42:02 -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 1owKME-0004UR-E5 for emacs-devel@gnu.org; Sat, 19 Nov 2022 04:41:55 -0500 Original-Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owKMB-0008N2-VF; Sat, 19 Nov 2022 04:41:53 -0500 Original-Received: by mail-pj1-x102e.google.com with SMTP id y14-20020a17090a2b4e00b002189a1b84d4so778501pjc.2; Sat, 19 Nov 2022 01:41:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=699er5X7cWDmQFGsQiL5Ny5Lw+ZcTMtTevax0oP6KoY=; b=SgRdhV8QLid/A3W2AaxGK0WJIMb+IGGjW7CnvhgbZeZpWQYNP4fBqe+9wGiBsyvWbu il7HdD5QK9qiMS/w6fu5DVFOWofVafw87hiLG3zNYcMnNRkDehogyxy3VqWYkPwvVZjb YYtR031AbyrWeJQcfOZQ9p1DqKLkpSB1moeP4C0h668N/rWOOS0+VXL1V9n3sdkZvWec Q2O43QTgmr0fNxFk127nt6yXZ92QTKbclcmZ5zhp46W/jTdXaA9Pb2qoLJv3eEKwVjyi ySsO2S4PikqiUE3+XHY4lW1M944033QcdIvNXIfOzLHSzMd3hYQl2scs41ZterxMAKJs +AYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=699er5X7cWDmQFGsQiL5Ny5Lw+ZcTMtTevax0oP6KoY=; b=sJ4EjnGju8ohD/KikVT+VkLQb3gauBXk3qLbhVQayfj90rxyEX3VLKpNe5+iY5tDN3 Vanwv+54sIcMKkgeG6gLthl4KAvVpDxIYG335388ouXVoLAXuSSMachy31ht0mgUsk6q Q0Od7ypVDyQ1FR/VDhTEY7lKIJzuR0lH3e/cX4tI7XjEJOhi8qCAQL+7qh8/lcwJAh5X R4GOMwHP1AG1GhFuvDEeX3E/Fm0IrYbSbwE7PcfA4q28KL70Kh1QCZn7XRa2/p5IFytX Ak+4b8bw6nO0tYWxvZQqA/ex7NpqcJdseSLrfch4AepGTyRfhDcxaaXgMUShvF/jDwTh ViAQ== X-Gm-Message-State: ANoB5pkpBaRkWbtHW+X3XQEraPqx+PumBk26IB93zIrQkpcWuSvxwYpB Dflsn3oPXViZlA/Ft8p2lyI68O8VF5M= X-Google-Smtp-Source: AA0mqf7yhdCFjviogZa37lDeAWxLITv89LMxeb85Q5m307P0Ln5F+P8KGBG/ekuM5KN+rTHXilv0ZA== X-Received: by 2002:a17:902:c9cb:b0:186:c483:f017 with SMTP id q11-20020a170902c9cb00b00186c483f017mr3265792pld.136.1668850909575; Sat, 19 Nov 2022 01:41:49 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id s11-20020a170902ea0b00b00188f07c10c9sm5272112plg.192.2022.11.19.01.41.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Nov 2022 01:41:49 -0800 (PST) In-Reply-To: <0249C656-21C8-49F2-B979-A1894BF80637@gmail.com> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::102e; envelope-from=casouri@gmail.com; helo=mail-pj1-x102e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:300145 Archived-At: > On Nov 16, 2022, at 12:45 PM, Yuan Fu wrote: >=20 > So I=E2=80=99m trying to merge css-ts-mode with css-mode. Scss-mode = inherits css-mode, but if user enables tree-sitter for css-mode, = scss-mode will inherit all that tree-sitter setup, and lose all the = native css setup. Then if a user doesn=E2=80=99t want to enable = tree-sitter in scss-mode, too bad: scss-mode breaks. >=20 > Essentially scss-mode needs to be able to control which parts of = css-mode=E2=80=99s setup it wants to inherit=E2=80=94native setup or = tree-sitter setup=E2=80=94regardless of whether css-mode enables = tree-sitter or not. >=20 > I wonder if we can do something like this: >=20 > css-mode > | > +---------+-----+-----------+ > | | | > css-native-mode css-ts-mode scss-mode > | > +----+------------+ > | | > scss-native-mode scss-ts-mode >=20 > css-mode: a virtual mode, only sets up basic things that both native = and tree-sitter mode needs, like comment-start. > css-native-mode: native setup > css-ts-mode: tree-sitter setup >=20 > scss-mode: a virtual mode, inherits css-mode > scss-native-mode: native setup > scss-ts-mode: tree-sitter setup >=20 > And user could use major-mode-remap-alist to choose which mode they = want: >=20 > (css-mode . css-ts-mode) for enabling tree-sitter > (css-mode . css-native-mode) for not enabling tree-sitter >=20 > This could also used for other modes, like c-mode: c-mode, = c-native-mode (cc-mode), c-ts-mode. >=20 > Yuan 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. Yuan=