Function: treesit-language-at

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

Signature

(treesit-language-at POSITION)

Documentation

Return the language at POSITION.

This function assumes that parser ranges are up-to-date. It returns the return value of treesit-language-at-point-function if it's non-nil, otherwise it returns the language of the first parser in treesit-parser-list, or nil if there is no parser.

In a multi-language buffer, make sure
treesit-language-at-point-function is implemented! Otherwise
treesit-language-at wouldn't return the correct result.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-language-at (position)
  "Return the language at POSITION.

This function assumes that parser ranges are up-to-date.  It
returns the return value of `treesit-language-at-point-function'
if it's non-nil, otherwise it returns the language of the first
parser in `treesit-parser-list', or nil if there is no parser.

In a multi-language buffer, make sure
`treesit-language-at-point-function' is implemented!  Otherwise
`treesit-language-at' wouldn't return the correct result."
  (if treesit-language-at-point-function
      (funcall treesit-language-at-point-function position)
    (when-let ((parser (car (treesit-parser-list))))
      (treesit-parser-language parser))))