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

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 11 Feb 2025 23:39:02 +0000

Your bug report

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

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74367: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74367
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74367: [PATCH] c-ts-mode.el: Adjust doc about how to change default modes
From: Stefan Kangas <[email-masked]>
To: Stefan Monnier <[email-masked]>, Eli Zaretskii <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Tue, 11 Feb 2025 15:38:22 -0800
List-Id: <debbugs-submit.debbugs.gnu.org>

Stefan Monnier <[email-masked]> writes:

>>> Any followup changes on master, for example?
>> I'm not sure anything else is needed.  But let's hear from Stefan
>> Monnier.
>
> IIRC I wanted further changes in `master` but there wasn't consensus
> that it was a good idea (ro at least not yet), so I think we're good
> (for now).

OK, I'm therefore closing this for now.  We can always revisit it later.

Subject: [PATCH] c-ts-mode.el: Adjust doc about how to change default modes
From: Stefan Monnier <[email-masked]>
To: [email-masked]
Date: Fri, 15 Nov 2024 11:45:38 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

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.

        Stefan

 In GNU Emacs 31.0.50 (build 1, i686-pc-linux-gnu, GTK+ Version 3.24.43,
 cairo version 1.18.2) of 2024-10-17 built on alfajor
Repository revision: 1df1a3f4a40aa6c49dd29db1b5a7ad47b6b2087c
Repository branch: work
Windowing system distributor 'The X.Org Foundation', version 11.0.12101013
System Description: Debian GNU/Linux trixie/sid

Configured using:
 'configure -C --enable-checking --enable-check-lisp-object-type --with-modules --with-cairo --with-tiff=ifavailable
 'CFLAGS=-Wall -g3 -Og -Wno-pointer-sign'
 PKG_CONFIG_PATH=/home/monnier/lib/pkgconfig'

>From f6cb19d44fe2ff1abdf890c609264f86ee74e2d7 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <[email-masked]>
Date: Fri, 15 Nov 2024 11:41:33 -0500
Subject: [PATCH] c-ts-mode.el: Adjust doc about how to change default modes

Don't recommend (require 'c-ts-mode) since it's not reliable (loading
`cc-mode.el` later on will override that preference) and also it
is incompatible with our policy that loading a package shouldn't
change Emacs's behavior.
Don't recommend customizing `auto-mode-alist` since it's more
complicated, only covers some of the ways a C mode can be selected,
and those who really want that kind of control probably know about
`auto-mode-alist` anyway.

* lisp/progmodes/c-ts-mode.el (Commentary:): Adjust
recommendation for how to use these modes by default:
(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`.
---
 lisp/progmodes/c-ts-mode.el | 35 +++++++----------------------------
 1 file changed, 7 insertions(+), 28 deletions(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 3823c553fda..19e511bbac3 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -28,36 +28,17 @@
 ;; functions that are useful generally to major modes for C-like
 ;; languages.
 ;;
-;; This package provides `c-ts-mode' for C, `c++-ts-mode' for C++, and
-;; `c-or-c++-ts-mode' which automatically chooses the right mode for
-;; C/C++ header files.
+;; This package provides `c-ts-mode' for C and `c++-ts-mode' for C++.
 ;;
 ;; To use these modes by default, assuming you have the respective
-;; tree-sitter grammars available, do one of the following:
-;;
-;; - If you have both C and C++ grammars installed, add
-;;
-;;    (require 'c-ts-mode)
-;;
-;;   to your init file.
-;;
-;; - Add one or mode of the following to your init file:
+;; tree-sitter grammars available, add one or more of the following to
+;; your init file:
 ;;
 ;;    (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))
-;;
-;;   If you have only C grammar available, use only the first one; if
-;;   you have only the C++ grammar, use only the second one.
-;;
-;; - Customize 'auto-mode-alist' to turn one or more of the modes
-;;   automatically.  For example:
-;;
-;;     (add-to-list 'auto-mode-alist
-;;                  '("\\(\\.ii\\|\\.\\(CC?\\|HH?\\)\\|\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\|\\.\\(cc\\|hh\\)\\)\\'"
-;;                    . c++-ts-mode))
 ;;
-;;   will turn on the c++-ts-mode for C++ source files.
+;; If you have only C grammar available, use only the first one; if
+;; you have only the C++ grammar, use only the second one.
 ;;
 ;; You can also turn on these modes manually in a buffer.  Doing so
 ;; will set up Emacs to use the C/C++ modes defined here for other
@@ -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.
 
@@ -1513,6 +1490,8 @@ c-ts-mode--c-or-c++-regexp
               "\\|" "#include"  ws-maybe "<" (regexp-opt headers) ">"
               "\\)")))
   "A regexp applied to C header files to check if they are really C++.")
+(make-obsolete-variable 'c-ts-mode--c-or-c++-regexp
+                        'c-or-c++-mode--regexp "30.1")
 
 ;;;###autoload
 (defun c-or-c++-ts-mode ()
-- 
2.45.2