blob: e16239084bf2c553f9438990ff0b81d6840cd580 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
Fix compilation with tree-sitter 0.26
Patch backported from master branch (omitting WINDOWSNT parts)
https://bugs.gentoo.org/970856
commit d587ce8c65a0e22ab0a63ef2873a3dfcfbeba166
Author: Eli Zaretskii <eliz@gnu.org>
Date: Fri Oct 17 14:15:41 2025 +0300
Support Tree-sitter version 0.26 and later
--- emacs-30.2/src/treesit.c
+++ emacs-30.2/src/treesit.c
@@ -632,6 +632,22 @@
}
}
+/* This function is a compatibility shim. Tree-sitter 0.25 introduced
+ ts_language_abi_version as a replacement for ts_language_version, and
+ tree-sitter 0.26 removed ts_language_version. Here we use the fact
+ that 0.25 bumped TREE_SITTER_LANGUAGE_VERSION to 15, to use the new
+ function instead of the old one, when Emacs is compiled against
+ tree-sitter version 0.25 or newer. */
+static uint32_t
+treesit_language_abi_version (const TSLanguage *ts_lang)
+{
+#if TREE_SITTER_LANGUAGE_VERSION >= 15
+ return ts_language_abi_version (ts_lang);
+#else
+ return ts_language_version (ts_lang);
+#endif
+}
+
/* Load the dynamic library of LANGUAGE_SYMBOL and return the pointer
to the language definition.
@@ -746,7 +762,7 @@
{
*signal_symbol = Qtreesit_load_language_error;
*signal_data = list2 (Qversion_mismatch,
- make_fixnum (ts_language_version (lang)));
+ make_fixnum (treesit_language_abi_version (lang)));
return NULL;
}
return lang;
@@ -817,7 +833,7 @@
&signal_data);
if (ts_language == NULL)
return Qnil;
- uint32_t version = ts_language_version (ts_language);
+ uint32_t version = treesit_language_abi_version (ts_language);
return make_fixnum((ptrdiff_t) version);
}
}
|