all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#74367: [PATCH] c-ts-mode.el: Adjust doc about how to change default modes
@ 2024-11-15 16:45 Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-11-15 21:15 ` Stefan Kangas
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-11-15 16:45 UTC (permalink / raw)
  To: 74367

[-- Attachment #1: Type: text/plain, Size: 1009 bytes --]

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'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-c-ts-mode.el-Adjust-doc-about-how-to-change-default-.patch --]
[-- Type: text/patch, Size: 4041 bytes --]

From f6cb19d44fe2ff1abdf890c609264f86ee74e2d7 Mon Sep 17 00:00:00 2001
From: Stefan Monnier <monnier@iro.umontreal.ca>
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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-11-18 12:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 16:45 bug#74367: [PATCH] c-ts-mode.el: Adjust doc about how to change default modes Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-15 21:15 ` Stefan Kangas
2024-11-16 10:59   ` Eli Zaretskii
2024-11-16 16:52     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 18:35       ` Eli Zaretskii
2024-11-16 20:26         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-16 21:00           ` Eli Zaretskii
2024-11-17 22:19             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-11-18 12:09               ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.