Function: treesit-local-parsers-on

treesit-local-parsers-on is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit-local-parsers-on &optional BEG END LANGUAGE WITH-HOST)

Documentation

Return all the local parsers between BEG END.

BEG and END default to the beginning and end of the buffer's accessible portion. Local parsers are those which have an embedded tag, and only parse a limited region marked by an overlay with a non-nil treesit-parser property. If LANGUAGE is non-nil, only return parsers for LANGUAGE.

If WITH-HOST is non-nil, return a list of (PARSER . HOST-PARSER) instead. HOST-PARSER is the host parser which created the local PARSER.

View in manual

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-local-parsers-on (&optional beg end language with-host)
  "Return all the local parsers between BEG END.

BEG and END default to the beginning and end of the buffer's
accessible portion.
Local parsers are those which have an `embedded' tag, and only parse
a limited region marked by an overlay with a non-nil `treesit-parser'
property.  If LANGUAGE is non-nil, only return parsers for LANGUAGE.

If WITH-HOST is non-nil, return a list of (PARSER . HOST-PARSER)
instead.  HOST-PARSER is the host parser which created the local
PARSER."
  (let ((res nil))
    (dolist (ov (overlays-in (or beg (point-min)) (or end (point-max))))
      (when-let ((parser (overlay-get ov 'treesit-parser))
                 (host-parser (overlay-get ov 'treesit-host-parser)))
        (when (or (null language)
                  (eq (treesit-parser-language parser)
                      language))
          (push (if with-host (cons parser host-parser) parser) res))))
    (nreverse res)))