Variable: c-ts-mode-hook
c-ts-mode-hook is a variable defined in c-ts-mode.el.gz.
Value
nil
Documentation
Hook run after entering C mode.
No problems result if this variable is not bound.
add-hook automatically binds it. (This is true for all hook variables.)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/c-ts-mode.el.gz
;;;###autoload
(define-derived-mode c-ts-mode c-ts-base-mode "C"
"Major mode for editing C, powered by tree-sitter.
This mode is independent from the classic cc-mode.el based
`c-mode', so configuration variables of that mode, like
`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
:after-hook (c-ts-mode-set-modeline)
(when (treesit-ready-p 'c)
;; Add a fake "emacs-c" language which is just C. Used for
;; skipping FOR_EACH_* macros, see `c-ts-mode--emacs-set-ranges'.
(setf (alist-get 'emacs-c treesit-load-name-override-list)
'("libtree-sitter-c" "tree_sitter_c"))
;; If Emacs source support is enabled, make sure emacs-c parser is
;; after c parser in the parser list. This way various tree-sitter
;; functions will automatically use the c parser rather than the
;; emacs-c parser.
(when c-ts-mode-emacs-sources-support
(treesit-parser-create 'emacs-c))
(treesit-parser-create 'c)
;; Comments.
(setq-local comment-start "/* ")
(setq-local comment-end " */")
;; Indent.
(setq-local treesit-simple-indent-rules
(c-ts-mode--get-indent-style 'c))
;; Font-lock.
(setq-local treesit-font-lock-settings (c-ts-mode--font-lock-settings 'c))
;; Navigation.
(setq-local treesit-defun-tactic 'top-level)
(treesit-major-mode-setup)
;; Emacs source support: handle DEFUN and FOR_EACH_* gracefully.
(when c-ts-mode-emacs-sources-support
(setq-local add-log-current-defun-function
#'c-ts-mode--emacs-current-defun-name)
(setq-local treesit-range-settings
(treesit-range-rules 'c-ts-mode--emacs-set-ranges))
(setq-local treesit-language-at-point-function
(lambda (_pos) 'c))
(treesit-font-lock-recompute-features '(emacs-devel)))))