Function: treesit-buffer-root-node

treesit-buffer-root-node is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit-buffer-root-node &optional LANGUAGE TAG)

Documentation

Return the root node of the current buffer.

Use the first parser in the parser list if LANGUAGE is omitted.

If LANGUAGE is non-nil, use the first parser for LANGUAGE with TAG in the parser list. If there's no such parser, return nil. TAG defaults to nil.

Other relevant functions are documented in the treesit group.

View in manual

Shortdoc

;; treesit
(treesit-buffer-root-node)
    e.g. => #<treesit-node (translation_unit) in 1-4830>

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-buffer-root-node (&optional language tag)
  "Return the root node of the current buffer.

Use the first parser in the parser list if LANGUAGE is omitted.

If LANGUAGE is non-nil, use the first parser for LANGUAGE with TAG in
the parser list.  If there's no such parser, return nil.  TAG defaults
to nil."
  (let ((parser
         (or (car (treesit-parser-list nil language tag))
             (signal 'treesit-no-parser (list language)))))
    (when parser
      (treesit-parser-root-node parser))))