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.devel Subject: Subversion of user chosen major mode by Emacs. [Was: My usage of imenu is broken.] Date: Wed, 29 May 2024 11:16:44 +0000 Message-ID: References: <86r0dmtbk2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25955"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 29 13:17:49 2024 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 1sCHJU-0006a8-R5 for ged-emacs-devel@m.gmane-mx.org; Wed, 29 May 2024 13:17:48 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCHIn-0008Ip-91; Wed, 29 May 2024 07:17:05 -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 1sCHIl-0008IN-5g for emacs-devel@gnu.org; Wed, 29 May 2024 07:17:03 -0400 Original-Received: from mail.muc.de ([193.149.48.3]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCHIh-00073C-2s for emacs-devel@gnu.org; Wed, 29 May 2024 07:17:02 -0400 Original-Received: (qmail 30674 invoked by uid 3782); 29 May 2024 13:16:45 +0200 Original-Received: from muc.de (p4fe15a59.dip0.t-ipconnect.de [79.225.90.89]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Wed, 29 May 2024 13:16:44 +0200 Original-Received: (qmail 10121 invoked by uid 1000); 29 May 2024 11:16:44 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de Received-SPF: pass client-ip=193.149.48.3; envelope-from=acm@muc.de; helo=mail.muc.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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:319680 Archived-At: Hello, Stefan. On Tue, May 28, 2024 at 17:55:28 -0400, Stefan Monnier wrote: > > I now understand what's happening. Stefan M committed a patch some > > while ago, the effect of which is to force users who've set up their > > auto-mode-alist for CC Mode to use c-ts-mode, etc., instead. > That's one way to see it. 🙂 > > Yesterday, I'd reverted src/eval.c (which normally gets loaded via > > desktop), and Stefan's patch converted it to c-ts-mode without me being > > aware of this. > The way I see it, the problem is in `c-ts-mode.el` where merely loading > the file changes the default mode to use for C files to `c-ts-mode` > (tho only in the current session, thank god). What's wrong with that? "Merely" loading CC Mode adds entries to auto-mode-alist for this. Surely lots of other libraries do this, too. > My patch(es) only change(s) the mechanism used for that. No. It/they subvert(s) the mode chosen by the user. As I said, when I did M-x revert-buffer yesterday, Emacs changed my major mode from C Mode to c-ts-mode. This is clearly unacceptable. It is unacceptable to subvert the major mode set up by the user to some other mode. This is exactly what major-mode-remap-defaults is designed to do. If a user wishes to make such a substition that is her good right, but for the Emacs maintainers silently to impose such a substition on users is something else entirely. > I think this is a misfeature of `c-ts-mode.el`, but this was the result > of a long discussion and I don't think we want to revisit that yet. Why did nobody involve me in this discussion, considering that the result involves "stealing" CC Mode users? > > I don't understand what major-mode-remap and major-mode-remap-defaults > > are for. > They are designed to allow specifying which C mode Emacs should use > (not only for C, obviously). That is what auto-mode-alist is for. These two new alists do not add useful functionality, they just add complexity, and they confuse users. > In the past, `auto-mode-alist` way used for that, but that did not > account for cases where the major mode is not specified via the file > name, but instead via `-*- mode -*-`, or via `interpreter-mode-alist`, > or via ... That's a case of going for 100% perfection at the expense of the normal case. People don't put -*- c-mode -*- into files. Not as a general rule. c-mode and c++-mode are registered trade marks of CC Mode, much as Emacs means GNU Emacs, not any other editor with similar functionality. If somebody has specified -*- c-mode -*-, then they mean CC Mode. If they don't, they should write -*- c-ts-mode -*- instead, or Emacs should provide something like -*- c-generic-mode -*-. > Also it encouraged `c-ts-mode.el` (and friends) duplicating > the regexps used to specify "this is probably a C file", often doing it > slightly differently from the other major mode. Surely a trivial problem, if a problem at all. > Instead, conceptually `auto-mode-alist` should now be used to specify > the type of content (tho represented not as something like a MIME type > but as a symbol that (usually) denotes a major mode), and then > `major-mode-remap` is used to decide which major mode to use for that > file type. Oh deity, no! auto-mode-alist specifies the MODE, not some abstract "content type". You're proposing duplicating the entries in auto-mode-alist with another list of the same size. This can only cause user confusion when instead of pushing an element to a-m-a, they also have to push one to m-m-remap, and make sure they match up. The solution to this problem is to emphasise that auto-mode-alist is an alist of filenames and major modes, like it always has been. > > They would appear to be duplicating and confusing the mechanism > > of auto-mode-alist, and seem unnecessary. It seems clear they are too > > difficult to use. > Clear as mud, indeed. Then lets sort this out. How about you proposing a solution to M-x revert-buffer changing a buffer's major mode? My solution would be to revert the patch that introduced major-mode-remap-defaults. > Stefan -- Alan Mackenzie (Nuremberg, Germany).