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.devel Subject: Re: Subversion of user chosen major mode by Emacs. Date: Wed, 29 May 2024 17:20:00 +0300 Message-ID: <86v82wsnsf.fsf@gnu.org> References: <86r0dmtbk2.fsf@gnu.org> <86y17sssc6.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38367"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 29 16:22:21 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 1sCKC2-0009Yp-Od for ged-emacs-devel@m.gmane-mx.org; Wed, 29 May 2024 16:22:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCKBD-0000kV-3j; Wed, 29 May 2024 10:21:27 -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 1sCKB9-0000j1-Vb for emacs-devel@gnu.org; Wed, 29 May 2024 10:21:24 -0400 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 1sCKB8-0008HN-1J; Wed, 29 May 2024 10:21:22 -0400 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=zuoxmbwx35v/NVAUbvW7fuFfDRz+ZbjdLEvbP183ym4=; b=GbDqW9L+e5Rk WZlFLMBCYmdgvqry26v+pwfkc5+s9s0NtIKzRG0ZrvJ3AhcVW8MCtm2SIe0Bzv/ivOB5vYZiySkCC mFUdGu7RLuQ5yo2w5sZ6O8qurkW5CzYI1HADHtjF27gwFZAKczpgw+rP5qwZ8B6pgyFjyGggy8a/T l7ICt47XI72tXqpCqqPqMTF4F64xj6Hww0E0JlPVd7fuaeJeYFSYOsLslYHp2GhOK1KTlsvaLP4zk AAEMANBtM+Pbr++XcjSDF8+alwj959WMmVGqBV0Xdxjda7O22uBmq69/e5t1UEFMa2B/0t5MTWYWV 7kcQKbYnLuiM8HYDTTZzEA==; In-Reply-To: (message from Alan Mackenzie on Wed, 29 May 2024 13:29:34 +0000) 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:319690 Archived-At: > Date: Wed, 29 May 2024 13:29:34 +0000 > Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org > From: Alan Mackenzie > > > Please show a minimal recipe, starting from "emacs -Q", where > > reverting a buffer changes from c-mode to c-ts-mode. > > With a recent master emacs: > (i) emacs -Q > (ii) Insert the following into *scratch* and evaluate it: > > (defun c-make-ts-undefault-mode () > "Make the older C and C++ Modes the default major modes for C(++) > files." > (interactive) > (let (c) > (dolist (l '(c-ts-mode c++-ts-mode c-or-c++-ts-mode)) > (while (setq c (rassq l auto-mode-alist)) > (setq auto-mode-alist (remq c auto-mode-alist)))))) > (eval-after-load 'c-ts-mode '(c-make-ts-undefault-mode)) > > (load-library "cc-mode") > > .. > > (iii) C-x C-f src/xdisp.c. This is loaded with C Mode. > (iv) M-: (load-library "c-ts-mode"). > (v) M-x revert-buffer. Emacs reloads the buffer in c-ts-mode. I can't say I'm happy with Stefan's change in commit 2b5d43081a, especially with the fact that it overruled my opinions about such a change without even mentioning that, let alone asking me, but frankly I'm tired of holding this fort alone, with everyone else and their dog telling me I don't know what I'm talking about, major-mode-remap-alist/defaults being the best invention since sliced bread. Let others fight this battle now, because all that is left to me to do, if I'm unwilling to give in, is to step down. Maybe I will... But anyway, why do you consider the above kludges wrt auto-mode-alist more "kosher" and worthy of our support than the similar kludge you could do with major-mode-remap-defaults for Emacs 30 and later? They are both kludges one isn't supposed to do. > > As a general rule, revert-buffer does not guarantee the major mode > > will remain the same, not by default. It calls normal-mode, so if > > anything has changed in automatic determination of the mode, you will > > get a different mode. This is by design. > > Such changes to the automatic determination should be as a result of > user choices. There shouldn't be nasty surprises in store. When you load c-ts-mode, you tell Emacs you want to visit C files in c-ts-mode. If you want to go back, restart Emacs. That has not changed with Stefan's commit. Yes, there are kludges to undo the effect of loading c-ts-mode, and they are still there, you just need to adapt them. How is that a grave problem?