From c289786886bade70f284035d85ae2c9b10df67c5 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Wed, 18 Jan 2023 15:32:12 -0800 Subject: [PATCH] ; Add commentary and dostring in c-ts-mode * lisp/progmodes/c-ts-mode.el: Add commentary. (c-ts-mode, c++-ts-mode): Add docstring. --- lisp/progmodes/c-ts-mode.el | 50 +++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index f9f75a0e452..0cf77c21d83 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -24,6 +24,34 @@ ;;; Commentary: ;; +;; This package provides major modes for C and C++, plus some handy +;; 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. +;; +;; To use these more by default, evaluate +;; +;; (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 configuration. +;; +;; For C-like language major modes: +;; +;; - Use `c-ts-mode-comment-setup' to setup comment variables and +;; filling. +;; +;; - Use simple-indent matcher `c-ts-mode--looking-at-star' and anchor +;; `c-ts-mode--comment-start-after-first-star' for indenting block +;; comments. See `c-ts-mode--indent-styles' for example. +;; +;; - Use variable `c-ts-mode-indent-block-type-regexp' with indent +;; offset c-ts-mode--statement-offset for indenting statements. +;; Again, see `c-ts-mode--indent-styles' for example. ;;; Code: @@ -936,7 +964,16 @@ Set up: This mode is independent from the classic cc-mode.el based `c-mode', so configuration variables of that mode, like -`c-basic-offset', don't affect this mode." +`c-basic-offset', doesn't affect this mode. + +To use tree-sitter C/C++ modes by default, evaluate + + (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 configuration." :group 'c (when (treesit-ready-p 'c) @@ -957,7 +994,16 @@ This mode is independent from the classic cc-mode.el based This mode is independent from the classic cc-mode.el based `c++-mode', so configuration variables of that mode, like -`c-basic-offset', don't affect this mode." +`c-basic-offset', don't affect this mode. + +To use tree-sitter C/C++ modes by default, evaluate + + (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 configuration." :group 'c++ (when (treesit-ready-p 'cpp) -- 2.39.2