From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: feature/tree-sitter: Where to Put C/C++ Stuff Date: Tue, 01 Nov 2022 09:32:18 -0400 Message-ID: References: <83pme7cf23.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38686"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Theodor Thornhill , emacs-devel@gnu.org, dev@rjt.dev To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 01 15:37:14 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 1opsOA-0009ou-3z for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Nov 2022 15:37:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oprNt-0001lb-AY; Tue, 01 Nov 2022 09:32:53 -0400 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 1oprNY-0001iD-1E for emacs-devel@gnu.org; Tue, 01 Nov 2022 09:32:44 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oprNU-0001aZ-AZ; Tue, 01 Nov 2022 09:32:31 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 3C11A440BF1; Tue, 1 Nov 2022 09:32:22 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 467D6441052; Tue, 1 Nov 2022 09:32:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1667309540; bh=+BVq3kVwyZtbLFSL2aKaLErntps0wbJoY63LMiN2msA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=SYADKf65a5nb4eRm1yVxcroTBi6OVbkCU6py0CuVaiB3tKvnbV2Pgo34Dw1lfAJ0e ENUVz1kEc7cgv3k56/zlv2DShpERxZgTX9OY6+Y+hCzEOuc+BxJJ49T6vf1+n0yLNg L822nAUNCtG9+rPUXCNUIgqxCcuXooTT4odeWIXzj541eYDyuaKvjPPmUTFFwb4OBX S1vN0W/UBwEDyepFtjbUW6AiZIZ0whOlfClwlUILjoQXY+OF0Au6MOvQU0W42vgi1s zajAXAJTXk0VbLbAQxoIcGqEE25ttbBnJrl161Uqmhw+5OqHEXK0Uzju+bm1r91qT7 FXK8Yj7ByKaJQ== Original-Received: from pastel (65-110-220-202.cpe.pppoe.ca [65.110.220.202]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1AFFE120FD1; Tue, 1 Nov 2022 09:32:20 -0400 (EDT) In-Reply-To: <83pme7cf23.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 01 Nov 2022 09:24:52 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298935 Archived-At: >> I'm no authority on the matter, but I'd love for us not to complicate >> things too much. I vote for separate, non-cc-prefixed _new_ modes, that >> derives from prog-mode. > > That'd mean people will need either to invent all the other goodies in > CC mode (everything except fontifications and indentation) from > scratch, or give up all those other goodies. Does that make sense? I'm a strong proponent of keeping "one mode" but from what I've seen so far, trying to mix tree-sitter with CC-mode's `c-mode`, I agree with Theodor that it might be better to start from scratch :-( I have not looked at other languages in CC-mode, so I don't know if the same should apply to all CC-mode's modes (my guess is that it does, tho). My best hope so far is to: - Rename `c-mode` to `cc-c-mode`. - Make a new `c-mode` which delegates to `cc-c-mode` by default unless the user asked for the "new, tree-sitter based, c-mode" in which case it uses the brand new code base. `cc-c-mode` would still set `major-mode` to `c-mode`, so from the users's point of view there's still only one `c-mode` but the two variants (tree-sitter and CC-mode) are almost completely separate. We should make some effort to avoid users thinking "oh, there's the legacy CC-mode-based c-mode and the shiny new tree-sitter-based C-mode", but rather think "should I stay with the trusty CC-mode-based c-mode, or try the toddler c-mode". > Tree-sitter doesn't (and cannot) replace everything a major mode does > for a programming language. No, indeed. But it's hard to use one part of CC-mode without another. One of the great things about CC-mode is how it is all nicely integrated. But that cuts both ways :-( > So a completely new mode means we through the baby with the bathwater. The way I see it is that it will not break backward compatibility, and in the short term it may fail to provide a strict superset of CC-mode's `c-mode` features, but it's still going to be better than mixing the two and then trying to fix the corresponding breakage. > CC Mode has a full-blown manual, where this question is answered. > Here's a partial list of features outside of the fontification and > indentation area, which I collected just by looking at the top-level > menus of that manual: > > . filling and breaking text in comments and strings This should be broken out of CC-mode so that all modes can benefit from it. AFAIK this is the most valuable feature of CC-mode that's sorely missing in our generic infrastructure (lots and lots of other major modes suffer from it, so making it available to all major modes will be a great improvement). > . automatic insertion of newlines after braces, colons, commas, semi-colons This is already provided by `electric-layout-mode`. [ More specifically it's one of the parts of CC-mode which I "broke out of CC-mode so that all modes can benefit from it". Of course, CC-mode doesn't use it, because when you try to implement something to be more generic, you rarely end up with 100% identical behavior; and CC-mode wants to be backward compatible with old Emacsen that don't have `electric-layout-mode`. ] > . whitespace cleanups Not very familiar with this, but I'd be surprised if it wouldn't benefit from "break out of CC-mode so that all modes can benefit from it". > . minor modes: electric, hungry-delete, comment-style "Break out of CC-mode so that all modes can benefit from it". > . c-offsets-alist and interactive indentation customization (related > to indentation, but still extremely important, and not directly in > tree-sitter) This is indeed important, but we can't use CC-mode's code for that in any case: it needs to be reimplemented for tree-sitter's indentation. And it'd be better if we could do that without having to worry about backward compatibility with existing CC-mode users's settings (i.e. we're free to cover the same functionality in a different way). Stefan