From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#74339: 30.0.92; CC Mode stomps C TS Mode Date: Thu, 14 Nov 2024 21:20:12 +0200 Message-ID: <8634jtk4gj.fsf@gnu.org> References: <868qtnfd2d.fsf@gnu.org> <86r07elwoh.fsf@gnu.org> <86h68al2qz.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5441"; mail-complaints-to="usenet@ciao.gmane.io" Cc: acm@muc.de, 74339@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 14 20:21:44 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 1tBfPR-0001BM-PW for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Nov 2024 20:21:42 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBfPB-00054L-VG; Thu, 14 Nov 2024 14:21:26 -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 1tBfOt-000500-Bg for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 14:21:09 -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 1tBfOo-0000cW-Q6 for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 14:21:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=e6h5XLQ1+4Lk1/M0iI4VwD3PbIcNkeb/rcsjxxpKvlg=; b=Iu9B3KhB6x1mHCjHHn/YzhxOTjDf9Ieo9/aC0+hp3akSDg7jiyPNqi1wpYK+OcC/jUHLeuz/xY5KZVDyzR5IB+RY29ZD2PrCODQ9Pl0oxaMI5fBGaq/Ut3TY/vyfg0V7ugbFtqS1RtcPavGAWq2136B8mjaXXX57XhG1NQdlR4/x+3Mjf26ShA2vAoI89MiCWnwh+DiARX0tMLefynBQO19slCJ55awnjKURwwNeTM0BvTVWtWPNR+SKp/3QykmjIn+cCgaKfBQRj2XPeE6a/Wh7Cx3xaTIfEdxWB21PIK9oKhoYYGW8LzML75TvoetgeKk2RhNe8TOKhslgQLIdHw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBfOo-0007N3-GE for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 14:21:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Nov 2024 19:21: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.173161203028273 (code B ref 74339); Thu, 14 Nov 2024 19:21:02 +0000 Original-Received: (at 74339) by debbugs.gnu.org; 14 Nov 2024 19:20:30 +0000 Original-Received: from localhost ([127.0.0.1]:47211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBfOH-0007Lw-IM for submit@debbugs.gnu.org; Thu, 14 Nov 2024 14:20:29 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:55238) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBfOE-0007Lg-Ai for 74339@debbugs.gnu.org; Thu, 14 Nov 2024 14:20:27 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBfO7-0000XO-H3; Thu, 14 Nov 2024 14:20:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=e6h5XLQ1+4Lk1/M0iI4VwD3PbIcNkeb/rcsjxxpKvlg=; b=JFN4Dfgj2eFS Dn8WvLIyj2s+JxfLLzk7/vPOmkXACd/TB50VrmrhozOCjKex3I9jD1b2aXXKuNuXnlF7/LS3slMhr sdBKfzttbBclqF6m7DauqbU4kkVrKF8UvFG1J9vKC2/nwgDm8J5NRb/q264vNnj6AzyRb7Ng+K5/H /5MrBZdq6Zqh/Pu/vKvHpDRuy3YnKAZkxvIWTzRhfBGsN4uDV0xqwyuWy4XWouLIKqJmrrvIYXfi2 oWRweyBM0ueTp5VtfVEkBhKsMKq6TwHtNuYb/B6Mv+gEsB7drSbjC9K7cnqsJit+fICODKH6P1wBh dQ9e6FjFhi1Hvon4eI7nrw==; In-Reply-To: (message from Stefan Monnier on Thu, 14 Nov 2024 12:29:49 -0500) 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:295359 Archived-At: > From: Stefan Monnier > Cc: Eli Zaretskii , 74339@debbugs.gnu.org > Date: Thu, 14 Nov 2024 12:29:49 -0500 > > Not quite: `auto-mode-alist` should always map `.c` files to `c-mode`. Why "always"? > The choice between `c-mode` and `c-ts-mode` should be made > via `major-mode-remap-*`. That's one implementation, but it isn't the only one, and I'm not sure it is the best one. > That's what those vars are for. major-mode-remap-alist is for remapping major modes in general, for whatever reasons. The non-TS vs TS modes is just one case where it can be used, but it is not the only one, and maybe not even the most important one. > So loading either mode should not change `auto-mode-alist`. It doesn't have to be due to loading the mode, it could be due to the user flipping some option. auto-mode-alist could stay the same, but the result of looking up the proper mode for a .c file will be different, depending on such a user option. > IIUC the proposal to use the "last loaded" mode would be obtained, by > making the two files set `major-mode-remap-defaults` accordingly. > `c-ts-mode.el` already does that, so all we need is to change > `cc-mode.el` so it puts itself first but doesn't prevent `c-ts-mode.el` > from putting itself first in the future (contrary to what it currently > does). I think both files should first remove the existing elements that remap c-mode and c++-mode. Otherwise add-to-list will do nothing. > The patch I sent earlier should do just that (by removing the entries > added by `c-ts-mode.el` rather than by adding entries, so as to avoid > growing `major-mode-remap-defaults` unnecessarily). This is not enough, I think. What will happen if, by some happenstance, major-mode-remap-defaults has both elements added by cc-mode and those added by c-ts-mode?