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

From: Eli Zaretskii <[email-masked]>
Date: Sat, 16 Nov 2024 10:18:24 +0200

> From: Stefan Monnier <[email-masked]>
> Cc: Stefan Kangas <[email-masked]>,  Eli Zaretskii <[email-masked]>,
>   [email-masked]
> Date: Sat, 16 Nov 2024 01:17:41 -0500
> 
> > No, that is the problem.  Have a look at major-mode-remap-defaults, and
> > how c-ts-mode uses it to cause the symbol `c-mode' to start c-ts-mode in
> > certain circumstances.  This is what I'm unhappy about.
> 
> In which way is this worse than what we have in Emacs-29 where loading
> `c-ts-mode` does things like:
> 
>     (add-to-list 'auto-mode-alist
>                  '("\\(\\.[chi]\\|\\.lex\\|\\.y\\(acc\\)?\\)\\'" . c-ts-mode))
>     (add-to-list 'auto-mode-alist '("\\.x[pb]m\\'" . c-ts-mode))
> 
> ?
> 
> > That "somehow" is the loading of c-ts-mode.  I think that even C-h f
> > c-ts-mode counts as an "explicit indication" of a supposed preference for
> > c-ts-mode, given that it loads c-ts-mode (if it actually does).
> 
> Yup, and the same happens in Emacs-29.

Right.  Moreover, in Emacs 29 the modification of auto-mode-alist only
took care of visiting C files without a mode cookie.  In addition,
with Emacs 29, once the user loaded c-ts-mode, there was no way for
the user to go back to using C Mode; with the changes we propose to
make in cc-mode.el and c-ts-mode.el, this will be possible.

So Emacs 30 will not regress from Emacs 29, and will make the
situation at least a tad better.

> > I don't think the current mechanism is ready for the release of Emacs 30.
> 
> I don't see a regression here.

Right, and so no obstacles for releasing Emacs 30, once we make the
proposed changes in cc-mode.el and in c-ts-mode.el, which rectify the
tweaking of major-mode-remap-defaults.

> > What I think we're lacking is an explicit setting or command for the
> > user to state what her preferred mode for C actually is.

Yes, and we should work on adding that.  But this will not happen in
Emacs 30, especially since we don't yet have a clear idea how to do
this.

Alan, please help us release Emacs 30 sooner rather than later by
agreeing to the proposed changes in cc-mode.el and in c-ts-mode.el.