Variable: treesit-defun-type-regexp

treesit-defun-type-regexp is a buffer-local variable defined in treesit.el.gz.

Documentation

A regexp that matches the node type of defun nodes.

For example, "(function|class)_definition".

Sometimes not all nodes matched by the regexp are valid defuns. In that case, set this variable to a cons cell of the form (REGEXP . PRED), where PRED is a function that takes a node (the matched node) and returns t if node is valid, or nil for invalid node.

This is used by treesit-beginning-of-defun and friends.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
;;; Navigation, defun, things
;;
;; Emacs lets you define "things" by a regexp that matches the type of
;; a node, and here are some functions that lets you find the "things"
;; at/around point, navigate backward/forward a "thing", etc.
;;
;; The most obvious "thing" is a defun, and there are thin wrappers
;; around thing functions for defun for convenience.
;;
;; We have more command-like functions like:
;; - treesit-beginning-of-thing/defun
;; - treesit-end-of-thing/defun
;; - treesit-thing/defun-at-point
;;
;; And more generic functions like:
;; - treesit-thing-prev/next
;; - treesit-thing-at
;; - treesit-top-level-thing
;; - treesit-navigate-thing
;;
;; There are also some defun-specific functions, like
;; treesit-defun-name, treesit-add-log-current-defun.

(defvar-local treesit-defun-type-regexp nil
  "A regexp that matches the node type of defun nodes.
For example, \"(function|class)_definition\".

Sometimes not all nodes matched by the regexp are valid defuns.
In that case, set this variable to a cons cell of the
form (REGEXP . PRED), where PRED is a function that takes a
node (the matched node) and returns t if node is valid, or nil
for invalid node.

This is used by `treesit-beginning-of-defun' and friends.")