Subject: Re: bug#74339: 30.0.92; CC Mode stomps C TS Mode

From: Eli Zaretskii <[email-masked]>
Date: Thu, 14 Nov 2024 22:21:02 +0200

> Date: Thu, 14 Nov 2024 19:53:33 +0000
> Cc: [email-masked], [email-masked], [email-masked]
> From: Alan Mackenzie <[email-masked]>
> 
> > I prefer to make a simpler and more localized change, which only
> > manipulates major-mode-remap-defaults.  I would not like to risk
> > changes like modifying auto-mode-alist, which might have other
> > unintended consequences, at least on the release branch.
> 
> I thought we'd agreed to fix things by modifying auto-mode-alist.

I wasn't aware of that.  I apologize if I missed some words to that
effect.  I thought we were always talking about fixing the values
pushed into major-mode-remap-defaults.

> What we definitely agreed was that the old modes and the tree-sitter
> modes should be handled symmetrically, and that C Mode and friends
> wouldn't be disadvantaged.

Yes.

> > Let's stay with major-mode-remap-defaults, since we already understand
> > well enough what the code does, and need just to tweak it in minor
> > ways.
> 
> OK, then the following suggests itself.  We have symbols like
> `current-c-mode' which would be remapped in major-mode-defaults-alist,
> and would be the cdrs of the entries in auto-mode-alist.  We would remap
> `current-c-mode' each time cc-mode.el or c-ts-mode.el was loaded.  This
> would avoid the need to modify auto-mode-alist at run time, and also
> avoid all the disadvantages of remapping `c-mode' itself.

There's no current-c-mode in Emacs now.  So doing it that way would
mean significant changes to Emacs, and I'd like to avoid that on the
release branch.

What I meant is to modify cc-mode so that it removes the entries
pushed to major-mode-remap-defaults by c-ts-mode and then pushes its
own entries which map c-mode etc. to themselves.  And c-ts-mode will
be changed to do the opposite.  This is a small, localized change,
which will leave everything else intact, and will allow users to
express their preferences by just loading the mode they want to use.