From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74339: 30.0.92; CC Mode stomps C TS Mode Date: Wed, 13 Nov 2024 15:28:08 -0500 Message-ID: References: <868qtnfd2d.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 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="4653"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Alan Mackenzie , 74339@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 13 21:29:31 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 1tBJzW-00014l-TJ for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Nov 2024 21:29:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBJz6-00046u-Df; Wed, 13 Nov 2024 15:29:04 -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 1tBJz4-00046l-NI for bug-gnu-emacs@gnu.org; Wed, 13 Nov 2024 15:29:02 -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 1tBJz4-0007r5-5A for bug-gnu-emacs@gnu.org; Wed, 13 Nov 2024 15:29:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=XzF8u4dSnPgyhK7bXE5AJdhoLa8aTkeyJ2Xbk+b/0dc=; b=JAe5MRsHqSzJ6Dvl5O6rUyxoHB1txANiZoVpyF2WnB5NAIfsb9DKNZlyukN2VyT+uZKJHkrI2fQ/+EEFdrLWIV9x7M/4smR6u61PHEBV7qQOH+/v0ChlceLp1Xe+OHYUX/3ja72CecO/GSPt7YS6judVJUA6RubDMSV1r9OgWVZX8AIjy4xQ52IkDGJfCpFECIMJYEjIgs8Ew+kaseB6C6TR2o/1KLTVX8yAh6QZOBbkm0jTLtC5TClk9WGkFH6DiF6KfgLuVqjoy8TF8eZE1Kd6wMXQh66pX4KlAS9I+lw6qDaYGkf8zpDC8f4C+bQYAMefukLpCEAlYHvMX/cVlg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBJz3-0001W0-R7 for bug-gnu-emacs@gnu.org; Wed, 13 Nov 2024 15:29:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Nov 2024 20:29:01 +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.17315297005734 (code B ref 74339); Wed, 13 Nov 2024 20:29:01 +0000 Original-Received: (at 74339) by debbugs.gnu.org; 13 Nov 2024 20:28:20 +0000 Original-Received: from localhost ([127.0.0.1]:43794 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBJyN-0001UQ-ND for submit@debbugs.gnu.org; Wed, 13 Nov 2024 15:28:20 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:2987) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBJyL-0001UC-EF for 74339@debbugs.gnu.org; Wed, 13 Nov 2024 15:28:18 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id DEA27100126; Wed, 13 Nov 2024 15:28:11 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1731529691; bh=wSz/etLbk5osYi3A3/C16UaPlH6jOvfhGJbkNSc5CCI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=jevCnLBMouuwpHvVfRjv2MkDsKLuH8nQrocb68f+/p9hLJrJa7JrTwQVQb+65cU/3 52scikHiuEsf9hdBY6Xp95ChsMM6Lbh8boqRG2hihd20oPufd36qEitslH+q0gM6rn aro2MfH4pxOoWjJ1p/iKRoENtFFn7CFgcvn8ky3FE2a+VDik3C+bzNfefhacKbdTDG pJFuCy7xeFGnKtQvPriHY1I+NymusolcZBRBYCBH4aB9gEt8s3ICRhGHVfFvayo/Xe N+AG0BPJscoOuZ2jv5wHk6v9yO//prV18yqtQaDmmNro169NS+npXYgXxeoyONKVaT BZGgNOLNUbpBQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 10A4A100042; Wed, 13 Nov 2024 15:28:11 -0500 (EST) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id F003C12047F; Wed, 13 Nov 2024 15:28:10 -0500 (EST) In-Reply-To: <868qtnfd2d.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 13 Nov 2024 16:00:58 +0200") 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:295287 Archived-At: > This seems to happen due to this code in cc-mode.el: > > ;; Make entries in `major-mode-remap-defaults' to ensure that when CC > ;; Mode has been loaded, the symbols `c-mode' etc., will call CC Mode's > ;; modes rather than c-ts-mode etc.. > (when (boundp 'major-mode-remap-defaults) > (add-to-list 'major-mode-remap-defaults '(c++-mode . c++-ts-mode)) > (add-to-list 'major-mode-remap-defaults '(c-mode . c-ts-mode)) > (add-to-list 'major-mode-remap-defaults '(c-or-c++-mode . c-or-c++-ts= -mode)) > (let (entry) > (dolist (mode '(c-mode c++-mode c-or-c++-mode)) > (if (and (setq entry (assq mode major-mode-remap-defaults)) > (null (cdr entry))) > (setq major-mode-remap-defaults > (delq entry major-mode-remap-defaults))) > (push (cons mode nil) major-mode-remap-defaults)))) Interesting! I hadn't actually looked at that code. AFAICT it's the result of the decision to make `c-ts-mode.el` add itself to `major-mode-remap-defaults` when the file is loaded (which AFAIK we don't want to re-discuss). To defend against the case where that file was loaded without the intention to use c-ts-mode everywhere the above code "one ups" `c-ts-mode.el`s settings so as to take precedence over them. Looks like an arms race to me. =F0=9F=99=82 I think a "more fair" solution would be to do something like: ;; Make entries in `major-mode-remap-defaults' to ensure that when CC ;; Mode has been loaded, the symbols `c-mode' etc., will call CC Mode's ;; modes rather than c-ts-mode etc.. (when (boundp 'major-mode-remap-defaults) (dolist (mode '(c-mode c++-mode c-or-c++-mode)) (let ((entry (assq mode major-mode-remap-defaults))) (when entry (setq major-mode-remap-defaults (delq entry major-mode-remap-defaults)))))) The idea being that whichever file was loaded last (`c-mode.el` or `c-ts-mode.el`) would take precedence. Personally, my vote is for neither file to touch that `major-mode-remap-defaults` variable when it is loaded. Instead, they each could emit a message encouraging the user to customize `major-mode-remap-alist`. Maybe they could do that only when they see that the "other" file/mode is also loaded (i.e. only once we have evidence that there is a conflict). Stefan