Skip to content

Commit b3cf318

Browse files
committed
emacs: revbump for tree-sitter-0.26
1 parent 7d148fa commit b3cf318

File tree

2 files changed

+102
-2
lines changed

2 files changed

+102
-2
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
Based on the following patch:
2+
From d587ce8c65a0e22ab0a63ef2873a3dfcfbeba166 Mon Sep 17 00:00:00 2001
3+
From: Eli Zaretskii <eliz@gnu.org>
4+
Date: Fri, 17 Oct 2025 14:15:41 +0300
5+
Subject: [PATCH] Support Tree-sitter version 0.26 and later
6+
7+
diff --git a/src/treesit.c b/src/treesit.c
8+
index bf982de580bd..69751b5ea106 100644
9+
--- a/emacs-30.2/src/treesit.c
10+
+++ b/emacs-30.2/src/treesit.c
11+
@@ -34,7 +34,11 @@ along with GNU Emacs. If not, see <http
12+
# include "w32common.h"
13+
14+
/* In alphabetical order. */
15+
+#if TREE_SITTER_LANGUAGE_VERSION >= 15
16+
+#undef ts_language_abi_version
17+
+#else
18+
#undef ts_language_version
19+
+#endif
20+
#undef ts_node_child
21+
#undef ts_node_child_by_field_name
22+
#undef ts_node_child_count
23+
@@ -89,7 +93,11 @@ along with GNU Emacs. If not, see <http
24+
#undef ts_tree_get_changed_ranges
25+
#undef ts_tree_root_node
26+
27+
+#if TREE_SITTER_LANGUAGE_VERSION >= 15
28+
+DEF_DLL_FN (uint32_t, ts_language_abi_version, (const TSLanguage *));
29+
+#else
30+
DEF_DLL_FN (uint32_t, ts_language_version, (const TSLanguage *));
31+
+#endif
32+
DEF_DLL_FN (TSNode, ts_node_child, (TSNode, uint32_t));
33+
DEF_DLL_FN (TSNode, ts_node_child_by_field_name,
34+
(TSNode, const char *, uint32_t));
35+
@@ -166,7 +174,11 @@ init_treesit_functions (void)
36+
if (!library)
37+
return false;
38+
39+
+#if TREE_SITTER_LANGUAGE_VERSION >= 15
40+
+ LOAD_DLL_FN (library, ts_language_abi_version);
41+
+#else
42+
LOAD_DLL_FN (library, ts_language_version);
43+
+#endif
44+
LOAD_DLL_FN (library, ts_node_child);
45+
LOAD_DLL_FN (library, ts_node_child_by_field_name);
46+
LOAD_DLL_FN (library, ts_node_child_count);
47+
@@ -224,7 +236,11 @@ init_treesit_functions (void)
48+
return true;
49+
}
50+
51+
+#if TREE_SITTER_LANGUAGE_VERSION >= 15
52+
+#define ts_language_abi_version fn_ts_language_abi_version
53+
+#else
54+
#define ts_language_version fn_ts_language_version
55+
+#endif
56+
#define ts_node_child fn_ts_node_child
57+
#define ts_node_child_by_field_name fn_ts_node_child_by_field_name
58+
#define ts_node_child_count fn_ts_node_child_count
59+
@@ -632,6 +648,22 @@ treesit_load_language_push_for_each_suff
60+
}
61+
}
62+
63+
+/* This function is a compatibility shim. Tree-sitter 0.25 introduced
64+
+ ts_language_abi_version as a replacement for ts_language_version, and
65+
+ tree-sitter 0.26 removed ts_language_version. Here we use the fact
66+
+ that 0.25 bumped TREE_SITTER_LANGUAGE_VERSION to 15, to use the new
67+
+ function instead of the old one, when Emacs is compiled against
68+
+ tree-sitter version 0.25 or newer. */
69+
+static uint32_t
70+
+treesit_language_abi_version (const TSLanguage *ts_lang)
71+
+{
72+
+#if TREE_SITTER_LANGUAGE_VERSION >= 15
73+
+ return ts_language_abi_version (ts_lang);
74+
+#else
75+
+ return ts_language_version (ts_lang);
76+
+#endif
77+
+}
78+
+
79+
/* Load the dynamic library of LANGUAGE_SYMBOL and return the pointer
80+
to the language definition.
81+
82+
@@ -746,7 +778,7 @@ treesit_load_language (Lisp_Object langu
83+
{
84+
*signal_symbol = Qtreesit_load_language_error;
85+
*signal_data = list2 (Qversion_mismatch,
86+
- make_fixnum (ts_language_version (lang)));
87+
+ make_fixnum (treesit_language_abi_version (lang)));
88+
return NULL;
89+
}
90+
return lang;
91+
@@ -817,7 +849,7 @@ Return nil if a grammar library for LANG
92+
&signal_data);
93+
if (ts_language == NULL)
94+
return Qnil;
95+
- uint32_t version = ts_language_version (ts_language);
96+
+ uint32_t version = treesit_language_abi_version (ts_language);
97+
return make_fixnum((ptrdiff_t) version);
98+
}
99+
}
100+

srcpkgs/emacs/template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Template file for 'emacs'
22
pkgname=emacs
33
version=30.2
4-
revision=1
4+
revision=2
55
create_wrksrc=required
66
build_style=gnu-configure
77
configure_args="--with-file-notification=inotify --with-modules
@@ -50,7 +50,7 @@ desc_option_xpm="Enable support for XPM images"
5050
build_options_default="cairo gif gmp gnutls harfbuzz jpeg m17n nativecomp
5151
png sound sqlite svg tiff treesitter webp xml xpm"
5252

53-
post_extract() {
53+
post_patch() {
5454
# Just configuring in different directories results in
5555
# spurious emacs rebuilds with incompatible build numbers.
5656
cp -a emacs-* nox

0 commit comments

Comments
 (0)