summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2023-01-18 15:32:12 -0800
committerYuan Fu <casouri@gmail.com>2023-01-19 14:47:24 -0800
commitc289786886bade70f284035d85ae2c9b10df67c5 (patch)
treeb1e0327765970c17b068adddc80bd39463a3645e
parent4fb7b0b0b889a317b4a98cce24ed08d5eadc2df1 (diff)
downloademacs-c289786886bade70f284035d85ae2c9b10df67c5.tar.gz
; Add commentary and dostring in c-ts-mode
* lisp/progmodes/c-ts-mode.el: Add commentary. (c-ts-mode, c++-ts-mode): Add docstring.
-rw-r--r--lisp/progmodes/c-ts-mode.el50
1 files 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)