unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Alan Mackenzie <acm@muc.de>
Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
Subject: Re: Subversion of user chosen major mode by Emacs.
Date: Wed, 29 May 2024 17:20:00 +0300	[thread overview]
Message-ID: <86v82wsnsf.fsf@gnu.org> (raw)
In-Reply-To: <ZlctviiEVl8j9FzV@ACM> (message from Alan Mackenzie on Wed, 29 May 2024 13:29:34 +0000)

> Date: Wed, 29 May 2024 13:29:34 +0000
> Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org
> From: Alan Mackenzie <acm@muc.de>
> 
> > 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?



  reply	other threads:[~2024-05-29 14:20 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 10:53 My usage of imenu is broken Alan Mackenzie
2024-05-28 11:34 ` Eli Zaretskii
2024-05-28 13:57   ` Alan Mackenzie
2024-05-28 18:29     ` Eli Zaretskii
2024-05-28 20:46       ` Alan Mackenzie
2024-05-28 21:28         ` Stefan Monnier
2024-05-29  6:04           ` Juri Linkov
2024-05-29 11:31         ` Eli Zaretskii
2024-05-29  5:38       ` Yuan Fu
2024-05-28 21:55     ` Stefan Monnier
2024-05-29 11:16       ` Subversion of user chosen major mode by Emacs. [Was: My usage of imenu is broken.] Alan Mackenzie
2024-05-29 11:43         ` Dmitry Gutov
2024-05-29 12:51           ` Subversion of user chosen major mode by Emacs Alan Mackenzie
2024-05-29 16:08             ` Dmitry Gutov
2024-05-29 16:38               ` Eli Zaretskii
2024-05-29 17:56                 ` Dmitry Gutov
2024-05-29 19:22               ` Alan Mackenzie
2024-05-29 19:45                 ` Andrea Corallo
2024-05-29 19:59                   ` Alan Mackenzie
2024-05-30  5:01                     ` Eli Zaretskii
2024-05-30 11:02                       ` Alan Mackenzie
2024-05-29 22:10                 ` Dmitry Gutov
2024-05-30  5:51                   ` Eli Zaretskii
2024-05-30  5:44                 ` Eli Zaretskii
2024-05-29 12:41         ` Subversion of user chosen major mode by Emacs. [Was: My usage of imenu is broken.] Eli Zaretskii
2024-05-29 13:29           ` Subversion of user chosen major mode by Emacs Alan Mackenzie
2024-05-29 14:20             ` Eli Zaretskii [this message]
2024-05-29 15:04               ` Stefan Monnier
2024-05-29 19:17         ` Subversion of user chosen major mode by Emacs. [Was: My usage of imenu is broken.] Eli Zaretskii
2024-05-30  1:32         ` Stefan Monnier
2024-05-30  5:25           ` Eli Zaretskii
2024-05-30  7:39             ` Po Lu
2024-05-30  7:53               ` Eli Zaretskii
2024-05-30 14:18             ` Stefan Monnier
2024-05-30 14:33               ` Po Lu
2024-05-30 15:08                 ` Stefan Monnier
2024-05-30 14:56               ` Eli Zaretskii
2024-05-30 15:12                 ` Stefan Monnier
2024-05-30 15:29                   ` Alan Mackenzie
2024-05-30 18:30                     ` Stefan Monnier
2024-05-30 16:06                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86v82wsnsf.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).