Function: treesit-parser-list
treesit-parser-list is a function defined in treesit.c.
Signature
(treesit-parser-list &optional BUFFER LANGUAGE TAG)
Documentation
Return BUFFER's parser list, filtered by LANGUAGE and TAG.
BUFFER defaults to the current buffer. If that buffer is an indirect buffer, its base buffer is used instead. That is, indirect buffers use their base buffer's parsers.
If LANGUAGE is non-nil, only return parsers for that language.
The returned list only contain parsers with TAG. TAG defaults to nil. If TAG is t, include parsers in the returned list regardless of their tag.
Other relevant functions are documented in the treesit group.
Probably introduced at or before Emacs version 30.1.
Shortdoc
;; treesit
(treesit-parser-list)
e.g. => (#<treesit-parser for c>)
Source Code
// Defined in /usr/src/emacs/src/treesit.c
{
struct buffer *buf;
Lisp_Object buf_orig;
if (NILP (buffer))
{
buf = current_buffer;
XSETBUFFER (buf_orig, current_buffer);
}
else
{
CHECK_BUFFER (buffer);
buf = XBUFFER (buffer);
buf_orig = buffer;
}
if (buf->base_buffer)
buf = buf->base_buffer;
/* Return a fresh list so messing with that list doesn't affect our
internal data. */
Lisp_Object return_list = Qnil;
Lisp_Object tail;
tail = BVAR (buf, ts_parser_list);
FOR_EACH_TAIL (tail)
{
struct Lisp_TS_Parser *parser = XTS_PARSER (XCAR (tail));
if ((NILP (language) || EQ (language, parser->language_symbol))
&& (EQ (tag, Qt) || EQ (tag, parser->tag))
/* Indirect buffers and base buffer shares the same parser
* list, so we need the filtering here. */
&& (EQ (parser->buffer, buf_orig)))
return_list = Fcons (XCAR (tail), return_list);
}
return Freverse (return_list);
}