Function: treesit-defun-at-point

treesit-defun-at-point is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit-defun-at-point)

Documentation

Return the defun node at point, or nil if none is found.

Respects treesit-defun-tactic: returns the top-level defun if it is top-level(var)/top-level(fun), otherwise return the immediate parent defun if it is nested.

Return nil if treesit-defun-type-regexp isn't set and defun isn't defined in treesit-thing-settings.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-defun-at-point ()
  "Return the defun node at point, or nil if none is found.

Respects `treesit-defun-tactic': returns the top-level defun if it
is `top-level', otherwise return the immediate parent defun if it
is `nested'.

Return nil if `treesit-defun-type-regexp' isn't set and `defun'
isn't defined in `treesit-thing-settings'."
  (when (or treesit-defun-type-regexp
            (treesit-thing-defined-p
             'defun (treesit-language-at (point))))
    (treesit-thing-at-point
     (or treesit-defun-type-regexp 'defun) treesit-defun-tactic)))