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

From: Stefan Monnier <[email-masked]>
Date: Sat, 16 Nov 2024 15:26:31 -0500

>> 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.

In Emacs-29, it did work, because it modified `auto-mode-alist` and
CC-mode never modified it back.

In `emacs-30`, it doesn't work reliably any more because loading
`cc-mode.el` after `c-ts-mode.el` causes the default mode to revert to
`c-mode`.  Loading `cc-mode.el` happens when you do `C-h f c-mode RET`,
or when you load a file that requires it, e.g.:

    lisp/cedet/semantic/bovine/c.el:(eval-when-compile (require 'cc-mode))
    lisp/generic-x.el:(require 'cc-mode)
    lisp/org/ob-C.el:(require 'cc-mode)
    lisp/org/ob-fortran.el:(require 'cc-mode)
    lisp/progmodes/antlr-mode.el:(require 'cc-mode)
    lisp/progmodes/cc-mode.el:;; (require 'cc-mode)
    lisp/progmodes/cmacexp.el:(require 'cc-mode)
    lisp/progmodes/csharp-mode.el:(require 'cc-mode)
    lisp/progmodes/cwarn.el:(require 'cc-mode)
    lisp/progmodes/hideif.el:(require 'cc-mode)
    lisp/progmodes/js.el:(require 'cc-mode)

or:

    ../elpa/packages/csharp-mode/csharp-mode.el:(require 'cc-mode)
    ../elpa/packages/electric-spacing/electric-spacing.el:(require 'cc-mode)
    ../elpa/packages/gnome-c-style/gnome-c-align.el:(require 'cc-mode)
    ../elpa/packages/javaimp/javaimp-parse.el:(require 'cc-mode) ;for java-mode-syntax-table
    ../elpa/packages/vcl-mode/vcl-mode.el:(require 'cc-mode)
    ../nongnu/packages/arduino-mode/arduino-mode.el:(require 'cc-mode)
    ../nongnu/packages/bison-mode/bison-mode.el:(require 'cc-mode)
    ../nongnu/packages/d-mode/d-mode.el:(require 'cc-mode)
    ../nongnu/packages/php-mode/lisp/php.el:  (require 'cc-mode)
    ../nongnu/packages/php-mode/lisp/php-mode-debug.el:(require 'cc-mode)
    ../nongnu/packages/php-mode/lisp/php-mode.el:(require 'cc-mode)
    ../nongnu/packages/scad-mode/scad-mode.el:(require 'cc-mode)
    ../nongnu/packages/typescript-mode/typescript-mode.el:  (require 'cc-mode)

Also we're discussing changing `c-ts-mode.el` so loading it doesn't have
that effect at all, which means that there's a good chance it will work
even less well in the future.  So to me it's clear that suggesting the use of
`require` or `load` to change the default C mode is doing a disservice
to our users.

        Stefan