File: c-ts-mode.el.html
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 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:
(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.
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 files, provided that you have the corresponding parser grammar libraries installed.
Defined variables (23)
c++-ts-mode-abbrev-table | Abbrev table for ‘c++-ts-mode’. |
c++-ts-mode-hook | Hook run after entering C++ mode. |
c++-ts-mode-map | Keymap for ‘c++-ts-mode’. |
c++-ts-mode-syntax-table | Syntax table for ‘c++-ts-mode’. |
c-ts-base-mode-abbrev-table | Abbrev table for ‘c-ts-base-mode’. |
c-ts-base-mode-hook | Hook run after entering C mode. |
c-ts-base-mode-map | Keymap for C and C-like languages with tree-sitter |
c-ts-mode--c-or-c++-regexp | A regexp applied to C header files to check if they are really C++. |
c-ts-mode--emacs-c-range-query | Query that finds a FOR_EACH_* macro with an unbracketed body. |
c-ts-mode--for-each-tail-ranges | Ranges covering all the FOR_EACH_* macros in the buffer. |
c-ts-mode--for-each-tail-regexp | A regexp matching all the variants of the FOR_EACH_* macro. |
c-ts-mode--operators | C/C++ operators for tree-sitter font-locking. |
c-ts-mode--preproc-keywords | C/C++ keywords for tree-sitter font-locking. |
c-ts-mode--syntax-table | Syntax table for ‘c-ts-mode’. |
c-ts-mode--type-keywords | Keywords that should be considered as part of a type. |
c-ts-mode-abbrev-table | Abbrev table for ‘c-ts-mode’. |
c-ts-mode-emacs-sources-support | Whether to enable Emacs source-specific features. |
c-ts-mode-hook | Hook run after entering C mode. |
c-ts-mode-indent-offset | Number of spaces for each indentation step in ‘c-ts-mode’. |
c-ts-mode-indent-style | Style used for indentation. |
c-ts-mode-map | Keymap for ‘c-ts-mode’. |
c-ts-mode-menu | Menu for ‘c-ts-mode’ and ‘c++-ts-mode’. |
c-ts-mode-syntax-table | Syntax table for ‘c-ts-mode’. |