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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 16 Nov 2024 12:25:57 +0200

> From: Stefan Monnier <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked]
> Date: Fri, 15 Nov 2024 15:45:46 -0500
> 
> > Here is a section of a test file sent to bug-cc-mode some while ago:
> >
> > /*
> > ** Local Variables:
> > ** mode:c
> > ** indent-tabs-mode:nil
> > ** c-basic-offset:4
> > ** End:
> > */
> >
> > Here it is evident that by "mode:c" the OP means C Mode, not whatever
> > random mode happens to have taken the symbol `c-mode'.
> 
> It is evident that the OP means CC-mode's C Mode because the bug report
> is sent to `bug-cc-mode`, indeed.

Perhaps we should introduce (on master) a boolean variable to disable
mode remapping?  Then files which want to force a mode could specify
that.

> >> If you really insist, we can add
> >>     (add-to-list 'major-mode-remap-defaults '(c-ts-mode . c-mode))
> >>     (add-to-list 'major-mode-remap-defaults '(c++-ts-mode . c++-mode))
> >> to your `cc-mode.el` together with corresponding removals in
> >> `c-ts-mode.el`, even though in my book file-local settings of
> >> `mode: c-ts-mode` in non-personal files are just bugs.
> > The problem is that entries in major-mode-remap-defaults (and the other
> > one) do not accurately represent user preferences.
> 
> Entries in `major-mode-remap-defaults` indeed do not reflect
> a user preference, just a "circumstantial" preference.
> 
> [ Ideally, they shouldn't be set just by loading a file (whether
>   `cc-mode.el` or `c-ts-mode.el`).  But after a long protracted
>   discussion the Emacs maintainers decided that it was the least bad
>   choice in Emacs-29.  This may be revisited in the future, e.g. for
>   Emacs-31, but AFAICT it's too late to make such a change in
>   Emacs-30.  ]

yes, it's too late to change this for Emacs 30.  So Emacs 30 will make
only a half-step in this direction.

> But entries in `major-mode-remap-alist` very much reflect a user preference.

Yes.  I have now added to the Emacs user manual explicit advice to
customize that to express user's firm preferences that override any
"internally-motivated" mode remapping.

> > I haven't looked just yet, but can I assume there's a recipe in the
> > Emacs 30 NEWS file telling users how to switch between old behaviour
> > (-*- c -*- always means C mode) and new behaviour (-*- c -*- can mean
> > c-ts-mode depending on other settings)?
> 
> If anything, Emacs-30 makes it easier than Emacs-29:
> 
>     (add-to-list 'major-mode-remap-alist '(c-mode))

This is now in NEWS and in the manual.