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

From: Eli Zaretskii <[email-masked]>
Date: Fri, 15 Nov 2024 09:33:17 +0200

> Date: Thu, 14 Nov 2024 20:38:40 +0000
> Cc: [email-masked], [email-masked], [email-masked]
> From: Alan Mackenzie <[email-masked]>
> 
> > 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.
> 
> How is that symmetrical between c-mode and c-ts-mode?  The very nature of
> the entries you're intending to make in major-mode-remap-defaults is
> asymmetric, in that they would remap `c-mode', but wouldn't remap
> `c-ts-mode'.  Or have I missed something?

The symmetry that I was talking about is in handling c-mode
specification in auto-mode-alist: it will either invoke c-mode or
c-ts-mode.  This is the issue at hand: to allow users to express their
preferences about c-mode in a way that is reversible.  The symmetry is
in what cc-mode and c-ts-mode do with major-mode-remap-defaults: each
one of them removes the existing elements that remap c-mode and adds
its own elements which prefer itself for C files.  IOW, the symmetry
is in allowing users to prefer c-mode or c-ts-mode as they wish, and
allow them to change the preference during a session with predictable
results, regardless of the preference: the preferred mode will be used
after its file is reloaded.

There was never a feature in Emacs to invoke c-mode when a file
specifies c-ts-mode.  (There are also no files which specify c-ts-mode
in their file-local variables, and auto-mode-alist doesn't mention
c-ts-mode, so such a remapping has a largely academic value.)  The
current code in cc-mode.el, which adds elements to
major-mode-remap-defaults, doesn't remap c-ts-mode to c-mode, either.
So this interpretation of "symmetry" is a separate issue that should
be discussed separately, and we definitely don't want to add such
features to the release branch at this point, even if we agree to
having that in the future.

(Stefan's thinking is that it's probably wrong to specify c-ts-mode in
in auto-mode-alist and in file-local variables anyway, although this
is still under discussion.  If we agree to that, it would mean that
specifying c-mode in auto-mode-alist and -* c -*- cookies in a file
does not necessarily mean to invoke c-mode literally, but instead to
invoke the mode in which the user wants to visit C files, i.e. a mode
that is subject to user options.  With that concept, remapping
c-ts-mode to c-mode makes very little sense.  But this all is not yet
finalized, certainly not in Emacs 30, and thus is not relevant to the
release branch, which is my main concern in this bug report.)