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 09:17:11 -0800 Message-ID: <386C85F3-C183-4C00-B19B-8D4E1B254E89@gmail.com> References: <0249C656-21C8-49F2-B979-A1894BF80637@gmail.com> <1B76E73A-0DCD-456E-9F28-0E90723DA66D@gmail.com> <83sfif8cl2.fsf@gnu.org> 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="17382"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org, theo@thornhill.no To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 19 18:17:56 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 1owRTW-0004H9-Qz for ged-emacs-devel@m.gmane-mx.org; Sat, 19 Nov 2022 18:17:54 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owRSx-0001Vx-Ja; Sat, 19 Nov 2022 12:17:19 -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 1owRSv-0001VN-5R for emacs-devel@gnu.org; Sat, 19 Nov 2022 12:17:17 -0500 Original-Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owRSt-00022E-G4; Sat, 19 Nov 2022 12:17:16 -0500 Original-Received: by mail-pf1-x42c.google.com with SMTP id d192so7779254pfd.0; Sat, 19 Nov 2022 09:17:14 -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=Pn7xkGu6bkkx4cKcDJMYEtqcItj0yEtq9gVD4RZu3J8=; b=EHUiHNsm9UsLQnh6UhkdCWHxjcURDYAtvr6JXMwvh9jb5oSsayXJGjbQW9mLpTH03G sKBSy1n8rZf1wxuUl6n8K1T0D/7SZDK5KLW4FbHP8dWNv98R6YCja6bIJ06R7HNWM7LE ERD7SkVgoLSdLQ0KvUE0k8Z504oku8IZQYJKZJkIjUwwggfsTz8v2VrVUOue9n5frASl Om/HA/gD70CscumekS7RgqZrR+w5mP77RuL/gZgzyM0P2pg0gw43SYuWoj+JbGAiDeBT Qv/LtI/nmDa60wSvSD4Kda7mekKaLVXJGlvv9vXOfSVQKk7/g0/VWrZEahFfc51MtgQk iONA== 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=Pn7xkGu6bkkx4cKcDJMYEtqcItj0yEtq9gVD4RZu3J8=; b=m7j5WWbvX7yUm8s0pUEuOaqyiPmTY0qmWRSMOVaFaoDT4lz9azUbiJwgtMtiyTjMF2 34gNYFyQTadUiSaRFYfLWkYiq4GoCz6R4p737MveseQ+ciN3Lu6exdRgJyu5PjelDQEr D1KZHdZqsW0bCif+sY7XRO4Z0/7Rz07CDOvpfVSDZV8A8JFKiXnpbyU7LMGQ3mvjNBky WIM2zp/mY3PFGGLbiR48Vjlw6LMRyNw2C6WZmtLid3yH9oyA3yJyMBZRmKe/c4GbvCWG +wAd6g0CKeFuetNl8ihROCRhFq/zfowiyLqpKNI8OoaHnXCEPnK4dun8VQwPTUxdatU0 chNQ== X-Gm-Message-State: ANoB5pmd2r1MHVQYQ3Rlhb3wz8J9mCVoAwXuRbDj2VnS1QJH18XcNUp+ 3/TPmb9C6C8L4LfoFbqvN4M= X-Google-Smtp-Source: AA0mqf7fC+cib7jd0gurHq3HvxC+q5OdqfnevhhQpDgcn2pc8J6vlL0s5QiHBeosQ724wmZ9ZS2jPA== X-Received: by 2002:a62:ed03:0:b0:558:99cc:8b40 with SMTP id u3-20020a62ed03000000b0055899cc8b40mr12956211pfh.25.1668878233524; Sat, 19 Nov 2022 09:17:13 -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 j6-20020a17090a840600b0020d51aefb82sm4811521pjn.19.2022.11.19.09.17.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Nov 2022 09:17:13 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=casouri@gmail.com; helo=mail-pf1-x42c.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:300192 Archived-At: > On Nov 19, 2022, at 7:19 AM, Stefan Monnier = wrote: >=20 >>> 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. >>=20 >> I'd prefer leaving the original modes as-is. That should cause less >> compatibility problems, I think. >>=20 >> Stefan, any thoughts? >=20 > To the extent that Emacs-29's new `major-mode-remap-alist` can be used > to select which mode to use, we can indeed leave the original modes > as-is. >=20 > Another argument in favor is that it's a bit tricky to make = `-mode` > both the parent mode and the standard entry point: we do that for > `tex-mode` but the implementation is ugly. > [ If it weren't for this implementation problem, it would be my > favorite choice. So maybe the better option is to add specific = support > for that in `define-derived-mode`, where we could implement it > cleanly and thus also fix the ugly gymnastics of `tex-mode`. ] >=20 > OTOH it's a bit jarring to have the generic term `-mode` refer to > a specific implementation. >=20 > For that reason, my preference is for: >=20 > - `--mode` as the shared parent. > - `-mode` as a dispatch function that calls the appropriate = specific > major mode which could be `-ts-mode`, or `cc--mode`, or > `-with-JSX-mode`, or =E2=80=A6 If we are already renaming existing modes (cc--mode), why don=E2=80=99= t we use the generic name -mode for the virtual parent mode? It = would be nicer if the generic mode (-mode) is an actual mode, with = mode hooks, keycaps, etc, rather than simply a dispatch function. Plus, if we make -mode a command rather, all existing configuration = of -mode breaks: there is no such major mode anymore, users need to = use either -base-mode or one of -cc/ts-mode. Yuan