conventions.
@cindex language grammar version, compatibility
-@defun treesit-language-version &optional min-compatible
+@defun treesit-library-abi-version &optional min-compatible
This function returns the version of the language grammar
Application Binary Interface (@acronym{ABI}) supported by the
tree-sitter library. By default, it returns the latest ABI version
them.
@end defun
+@defun treesit-language-abi-version language
+This function returns the language grammar @acronym{ABI} version of
+language grammar for @var{language} loaded by Emacs. If
+@var{language} is unavailable, this function returns @code{nil}.
+@end defun
+
@heading Concrete syntax tree
@cindex syntax tree, concrete
}
}
-DEFUN ("treesit-language-version",
- Ftreesit_language_version,
- Streesit_language_version,
+DEFUN ("treesit-library-abi-version", Ftreesit_library_abi_version,
+ Streesit_library_abi_version,
0, 1, 0,
doc: /* Return the language ABI version of the tree-sitter library.
return make_fixnum (TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION);
}
+DEFUN ("treesit-language-version", Ftreesit_language_abi_version,
+ Streesit_language_abi_version,
+ 0, 1, 0,
+ doc: /* Return the language ABI version of the tree-sitter LANGUAGE.
+Return nil if LANGUAGE is not available. */)
+ (Lisp_Object language)
+{
+ if (NILP (Ftreesit_langauge_available_p (language, Qnil)))
+ return Qnil;
+ else
+ {
+ Lisp_Object signal_symbol = Qnil;
+ Lisp_Object signal_data = Qnil;
+ TSLanguage *ts_language = treesit_load_language (language,
+ &signal_symbol,
+ &signal_data);
+ if (ts_language == NULL)
+ return Qnil;
+ uint32_t version = ts_language_version (ts_language);
+ return make_fixnum((ptrdiff_t) version);
+ }
+}
+
/*** Parsing functions */
static void
Vtreesit_extra_load_path = Qnil;
defsubr (&Streesit_language_available_p);
- defsubr (&Streesit_language_version);
+ defsubr (&Streesit_library_abi_version);
+ defsubr (&Streesit_language_abi_version);
defsubr (&Streesit_parser_p);
defsubr (&Streesit_node_p);