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 20:35:25 +0200

> From: Stefan Monnier <[email-masked]>
> Cc: Stefan Kangas <[email-masked]>,  [email-masked], Alan
>  Mackenzie <[email-masked]>
> Date: Sat, 16 Nov 2024 11:52:48 -0500
> 
> > 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.
> 
> `load`?  Yuck!
> But well, better than nothing (tho it likely won't make much difference
> in an init file: the problem of later loading `cc-mode` will still bite
> just as much).
> 
> I don't understand why you insist on suggesting such a "setting" since
> it's unreliable now and probably even more so in the future.

Because that's what users did in Emacs 29.  I don't want us to make an
impression it no longer works.

> What advantage do you see in it for the user over the
> `major-mode-remap-alist` option?

Since I agreed to make the major-mode-remap-alist the first item, is
there still a question of the advantages of 'load' wrt
major-mode-remap-alist?

> > 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 the `c-or-c++-mode` function itself.
> 
> Good point.
> 
> > (And note that c-ts-mode doesn't limit the search for the regexp,
> > whereas cc-mode.el does.)
> 
> Should we harmonize the two?  Do we know if there's a reason other than
> accidental for the difference?  Presumably the `cc-mode.el` one has been
> more widely tested.

I don't mind limiting the search in c-ts-mode, but then we need two
common variables.

> > 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.
> 
> BTW, there's a similar issue with the `c-string-list-p` and
> `c-string-or-string-list-p` functions which are used for
> `safe-local-variable` which would cause `cc-vars.el` to be loaded for
> `c-ts-mode` users when a `dir-locals.el` sets some `c-mode` vars.

I think we should have a string-or-list-p function in subr.el, like
string-or-null-p we already have there.

> Maybe we should move those things to a small `cc-utils.el` file which
> doesn't load other CC-mode files?

That would also work for me.