emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

feature/tree-sitter 96d44c4321 06/12: Add treesit-language-version


From: Yuan Fu
Subject: feature/tree-sitter 96d44c4321 06/12: Add treesit-language-version
Date: Wed, 5 Oct 2022 22:52:20 -0400 (EDT)

branch: feature/tree-sitter
commit 96d44c4321724556819e2f718f1d94470d753d07
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Add treesit-language-version
    
    * doc/lispref/parsing.texi (Language Definitions): Update manual.
    * src/treesit.c (Ftreesit_language_version): New function
---
 doc/lispref/parsing.texi |  9 +++++++++
 src/treesit.c            | 14 ++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 05f4050b54..0511b85bd7 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 d72c99a974..77b48133ba 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]