From: Yuan Fu Date: Tue, 4 Oct 2022 19:16:47 +0000 (-0700) Subject: Add treesit-language-version X-Git-Tag: emacs-29.0.90~1862 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=96d44c4321724556819e2f718f1d94470d753d07;p=emacs.git Add treesit-language-version * doc/lispref/parsing.texi (Language Definitions): Update manual. * src/treesit.c (Ftreesit_language_version): New function --- diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 05f4050b541..0511b85bd77 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -102,6 +102,15 @@ to @code{treesit-load-name-override-list}, where for a language too cool to abide by conventions. +@defun treesit-language-version &optional min-compatible +Tree-sitter library has a @dfn{language version}, a language +definition's version needs to match this version to be compatible. + +This function returns tree-sitter library’s language version. If +@var{min-compatible} is non-nil, it returns the minimal compatible +version. +@end defun + @heading Concrete syntax tree A syntax tree is what a parser generates. In a syntax tree, each node diff --git a/src/treesit.c b/src/treesit.c index d72c99a9747..77b48133ba8 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -316,6 +316,20 @@ DEFUN ("treesit-language-available-p", return Qt; } +DEFUN ("treesit-language-version", + Ftreesit_language_version, + Streesit_language_version, + 0, 1, 0, + doc: /* Return the language version of tree-sitter library. +If MIN-COMPATIBLE non-nil, return the minimal compatible version. */) + (Lisp_Object min_compatible) +{ + if (NILP (min_compatible)) + return make_fixnum (TREE_SITTER_LANGUAGE_VERSION); + else + return make_fixnum (TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION); +} + /*** Parsing functions */ static void