From f6cb19d44fe2ff1abdf890c609264f86ee74e2d7 Mon Sep 17 00:00:00 2001 From: Stefan Monnier 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