From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#74339: 30.0.92; CC Mode stomps C TS Mode Date: Fri, 15 Nov 2024 19:46:03 +0000 Message-ID: References: <861pzdk4aq.fsf@gnu.org> <86zfm1in2p.fsf@gnu.org> <86wmh5hrya.fsf@gnu.org> <86cyiwimlr.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20241"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, Eli Zaretskii , 74339@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 15 20:47:36 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1tC2I2-00057u-Ac for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Nov 2024 20:47:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tC2Hc-0005El-0s; Fri, 15 Nov 2024 14:47: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 1tC2HY-0005EA-F0 for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 14:47:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tC2HX-0004du-GG for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 14:47:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=From:In-Reply-To:MIME-Version:References:Date:To:Subject; bh=rS/tBqYKhNj4UjXtA7IwNbGvLyt+v6vZS2gWRKrrZhM=; b=JYQbGp1bs7s4dePeHrRhYL5fVu+DFnFJhS+8NZlVh8JWhKgGbRXaV/263c/pCssd0hYJwoLdwIXzZJgKyPNyou4nS0vzGHYCs9i+STTXDWa9gcMc7yh8hUnhdGMWIPEp9UkfeLDOBqEmR1YSV9oTtk9zV689ZZ7cHFzlQRgKkEFji2gODRoCRgJWa/ay0fQiFmVMDLgShdRKS++bTFpV/gxw6tx4igVKBsnwD48KSiumDlhrDJHVO88cgTk3qp5Joca6UOEn9V2EE2h2EE7jns0JAjXaawh+flkVvUi1T08Tgf755e+Wi5ugBqznFxAM0pgIvBFZ59v9Iee4Bn61sw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tC2HW-0004s8-DF for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 14:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Nov 2024 19:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74339 X-GNU-PR-Package: emacs Original-Received: via spool by 74339-submit@debbugs.gnu.org id=B74339.173169997318638 (code B ref 74339); Fri, 15 Nov 2024 19:47:02 +0000 Original-Received: (at 74339) by debbugs.gnu.org; 15 Nov 2024 19:46:13 +0000 Original-Received: from localhost ([127.0.0.1]:50932 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tC2Gi-0004qY-FL for submit@debbugs.gnu.org; Fri, 15 Nov 2024 14:46:12 -0500 Original-Received: from mail.muc.de ([193.149.48.3]:42874) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tC2Gg-0004qL-HL for 74339@debbugs.gnu.org; Fri, 15 Nov 2024 14:46:11 -0500 Original-Received: (qmail 57842 invoked by uid 3782); 15 Nov 2024 20:46:04 +0100 Original-Received: from muc.de (p4fe1581d.dip0.t-ipconnect.de [79.225.88.29]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 15 Nov 2024 20:46:03 +0100 Original-Received: (qmail 19401 invoked by uid 1000); 15 Nov 2024 19:46:03 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295415 Archived-At: Hello, Stefan. On Fri, Nov 15, 2024 at 14:01:26 -0500, Stefan Monnier wrote: > > One can write, in the Local Variables: section > > mode: c-ts > FWIW, unless this file is personal, this is very bad practice, and not > only because `c-ts-mode` may not be available (in older Emacsen or if > the user didn't build Emacs with tree-sitter support or doesn't have the > appropriate grammar installed): the choice between `c-mode` and > `c-ts-mode` is a personal preference, so it's not the file's business to > tell the user which mode to use, just like it's not the file's business > to tell the user which editor to use. > There might be special situations where such a setting might be > warranted, but they're sufficiently hypothetical or rare that they > should not drive our decisions, as long as the users can still get the > behavior they want in such cases (which they can, regardless of what we > do with `major-mode-remap-defaults`). Here is a section of a test file sent to bug-cc-mode some while ago: /* ** Local Variables: ** mode:c ** indent-tabs-mode:nil ** c-basic-offset:4 ** End: */ Here it is evident that by "mode:c" the OP means C Mode, not whatever random mode happens to have taken the symbol `c-mode'. > > .. This will cause the buffer to start in c-ts-mode regardless of any > > other current settings. > Actually, no: `major-mode-remap-*` can also remap `c-ts-mode` to some > other mode, such as `c-mode`. Maybe I should have said "regardless of any non-crazy settings". > > .. When that line is followed by setting other CC Mode variables (as is > > surely common for any such use of the major mode setting) that will > > signal some sort of error on opening the buffer, should c-mode have been > > "remapped" to c-ts-mode. Or if it doesn't do that, those local variables > > will be disregarded. This is a Bad Thing. > If you really insist, we can add > (add-to-list 'major-mode-remap-defaults '(c-ts-mode . c-mode)) > (add-to-list 'major-mode-remap-defaults '(c++-ts-mode . c++-mode)) > to your `cc-mode.el` together with corresponding removals in > `c-ts-mode.el`, even though in my book file-local settings of > `mode: c-ts-mode` in non-personal files are just bugs. The problem is that entries in major-mode-remap-defaults (and the other one) do not accurately represent user preferences. As a value for mode: in C files, we need three distinct settings: for C Mode, for c-ts-mode, and for any mode which handles C. Currently we've only got two: c-mode and c-ts-mode. This can't work properly. > > ... there will be no way for a user to specify c-mode unambiguously ... > Where/when? AFAICT the only case where this might be true are the cases > where it does not do any damage. In an auto-mode-alist entry, for example. As already discussed, in a Local Variables: section, for another example. > > OK, thanks. He is proposing that the meaning of -*- c -*-, `c-mode' > > as used in normal-mode, etc., should, from the user's point of view, > > be changed in an opt-out fashion. He is proposing that there be no > > way to specify C Mode in a local variables section. Such changes > > should be opt-in, not opt-out. They would certainly need an entry in > > NEWS. if there's not already one there. > It is supposed to opt-in, indeed. So, for a user trying out Emacs 30, with a desktop file containing at least one file with major mode c-ts-mode; visiting a file with the above Local Variables section will indeed start the buffer with C Mode? I haven't looked just yet, but can I assume there's a recipe in the Emacs 30 NEWS file telling users how to switch between old behaviour (-*- c -*- always means C mode) and new behaviour (-*- c -*- can mean c-ts-mode depending on other settings)? Is the default to keep the old behaviour, as is customary with new features in Emacs? > Stefan -- Alan Mackenzie (Nuremberg, Germany).