Subject: Re: bug#74367: [PATCH] c-ts-mode.el: Adjust doc about how to change default modes

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

> From: Stefan Kangas <[email-masked]>
> Date: Fri, 15 Nov 2024 13:15:38 -0800
> 
> Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <[email-masked]> writes:
> 
> > Tags: patch
> >
> > The doc of `c-ts-mode.el` currently recommends things we deprecate.
> > The patch below fixes this.
> >
> > I think this can go into `emacs-30`, but I believe Eli prefers we leave
> > this alone there, so I guess it would go to `master`.  If we can install
> > at least part of it into `emacs-30` (such as the removal of the
> > recommendation to `require` or the suggestion to use the obsolete
> > `c-or-c++-ts-mode`), I'll happily split it.
> 
> FWIW, I agree that we should at least remove the recommendation to use
> `require` on emacs-30, as it encourages bad habits and contributes to an
> already poor understanding of autoloading among users.

This all should have been discussed when major-mode-remap-defaults was
added and c-ts-mode was modified to use it.  Not now, sigh.

Anyway, I don't want to remove the 'require' part from the commentary,
but I think we should modify it to use 'load', not 'require' (given
the discussion in bug#74339), and we should make it the second
alternative, after the one that talks about using
major-mode-remap-alist.

I also don't think I agree with these removals:

> @@ -1340,8 +1321,6 @@ c-ts-mode
>  
>      (add-to-list \\='major-mode-remap-alist \\='(c-mode . c-ts-mode))
>      (add-to-list \\='major-mode-remap-alist \\='(c++-mode . c++-ts-mode))
> -    (add-to-list \\='major-mode-remap-alist
> -                 \\='(c-or-c++-mode . c-or-c++-ts-mode))
>  
>  in your init files."
>    :group 'c
> @@ -1410,8 +1389,6 @@ c++-ts-mode
>  
>      (add-to-list \\='major-mode-remap-alist \\='(c-mode . c-ts-mode))
>      (add-to-list \\='major-mode-remap-alist \\='(c++-mode . c++-ts-mode))
> -    (add-to-list \\='major-mode-remap-alist
> -                 \\='(c-or-c++-mode . c-or-c++-ts-mode))
>  
>  in your init files.

The commit log message says

> (c-ts-mode, c++-ts-mode): Don't suggest remapping `c-or-c++-mode`
> to `c-or-c++-ts-mode` since `c-or-c++-ts-mode` is deprecated
> since `c-or-c++-mode` already obeys the remapping of `c/c++-mode`.

However, if we don't remap c-or-c++-mode, it will load cc-mode.el,
which loads a bunch of other cc-*.el files, which is not clean, since
all we need is a single regexp.  (And note that c-ts-mode doesn't
limit the search for the regexp, whereas cc-mode.el does.)  So I think
if we want to _really_ deprecate c-or-c++-ts-mode, we should make this
variable defined on a separate file, common to CC Mode and c-ts-mode,
which doesn't load anything else.  Perhaps in subr.el or files.el.

P.S. As an aside, I find our handling of this and related issues quite
appalling.  Variables introduced (or should I say "sneaked in"?),
without properly discussing their effects on the users and without
properly documenting those effects; unclean tricks to "fight off"
changes installed by others, without properly describing those changes
and triggering a discussion; etc.  This is unbecoming, and almost
feels like some kind of court intrigues.  We should know better how to
deal with controversial changes.