From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs 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 Message-ID: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16211"; mail-complaints-to="usenet@ciao.gmane.io" To: 74367@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 15 17:46:33 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tBzSq-00044b-VS for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Nov 2024 17:46:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBzSR-0006ed-HV; Fri, 15 Nov 2024 11:46:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzSM-0006Z9-GE for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 11:46:02 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tBzSM-000327-7T for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 11:46:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=VsNTvXvouGH+X8VHZ2SmM/J5UJfFhdkDdvvmr/h0Kbg=; b=fY84jhiXJU2G33cBJMIYqN2rt6lBHU11iqMlnuWkDGJxvDXzucKrHizbRXEiHC3CtgOaZBkecGd3kX5Sk8RruiveJAOnI3Oh1KuahzNtQg3y39WNksCU1NpW1LVGEw1JeH2ejS6FRVDvVeCFpKF/oV3KMC2WCWzOYzr7Rr4eAIihqL8YNNwHg/25aiQfbiULK8UrI8exIaG1gb7qjYrjhRssc7JST9nGjnbcak48lcTWLinRjdvQlMTXPNhOYG7viy26udTwwif8ulvO0grw+1CRGSlm9AnGkMrD122/vUbC5XJPmLjJFDy5Rsuvi/lZJFkMx9juQcG04o7lwK3gPw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBzSL-0005W2-R5 for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 11:46:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Nov 2024 16:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74367 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.173168915921192 (code B ref -1); Fri, 15 Nov 2024 16:46:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Nov 2024 16:45:59 +0000 Original-Received: from localhost ([127.0.0.1]:50666 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBzSI-0005Vj-EP for submit@debbugs.gnu.org; Fri, 15 Nov 2024 11:45:58 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:55812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBzSC-0005VW-Mf for submit@debbugs.gnu.org; Fri, 15 Nov 2024 11:45:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzSB-0006F8-VE for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 11:45:52 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tBzS6-00030Z-Si for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2024 11:45:51 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id EA31444051F for ; Fri, 15 Nov 2024 11:45:43 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1731689139; bh=91limI3RDImqyuYkEgAaIDEe/NF1nYQXXraZy3LaMgc=; h=From:To:Subject:Date:From; b=eG/5R8UpbA00jl0ZdZo0+59TSDyfv6TeQWcJEauALsW3sHB5rUtqz1U9Rt6WkTIo+ poYvAYCSwH9JEL5aOh3eQNik067KW/1kRSzI0iWuEBsZd4sXhUfnCfWeZI49D3EgPe 8n28HUqR+gmMrQ8MBJEtyqB6Hbl8/SD5kMkkXr5wMADKFrX43cyCFAvBm4MeJ3gCGW WLq6TgmPViO7Gt9Fd+IlBLdV+it+XhI4hU5NyanDffivSfIvK3XmTudGrJh1e3BzMN Aw1KVNyPpyZW1WJafQ9TR+5z3Utv6ZsbKVtZ1zkUWhVScjiyJorRyugZM8LYyYkGQ+ dRC4HOHVBLioA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 45AF8440674 for ; Fri, 15 Nov 2024 11:45:39 -0500 (EST) Original-Received: from alfajor (unknown [23.233.149.155]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 30A7E1206CB for ; Fri, 15 Nov 2024 11:45:39 -0500 (EST) Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:295400 Archived-At: --=-=-= Content-Type: text/plain 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' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-c-ts-mode.el-Adjust-doc-about-how-to-change-default-.patch >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 --=-=-=--