From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 74367@debbugs.gnu.org
Subject: bug#74367: [PATCH] c-ts-mode.el: Adjust doc about how to change default modes
Date: Fri, 15 Nov 2024 11:45:38 -0500 [thread overview]
Message-ID: <jwvv7wola8r.fsf-monnier+emacs@gnu.org> (raw)
[-- 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
next reply other threads:[~2024-11-15 16:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 16:45 Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-11-15 21:15 ` bug#74367: [PATCH] c-ts-mode.el: Adjust doc about how to change default modes 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwvv7wola8r.fsf-monnier+emacs@gnu.org \
--to=bug-gnu-emacs@gnu.org \
--cc=74367@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.