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. TAG defaults to nil.
If no parser is available, throw treesit-no-parser.
Other relevant functions are documented in the treesit group.
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. TAG defaults to nil.
If no parser is available, throw `treesit-no-parser'."
(let ((parser
(or (car (treesit-parser-list nil language tag))
(signal 'treesit-no-parser (list language)))))
(when parser
(treesit-parser-root-node parser))))