git: 0c810e677ac6 - main - editors/emacs: Unbreak build after devel/tree-sitter update

From: Joseph Mingrone <jrm_at_FreeBSD.org>
Date: Mon, 30 Mar 2026 18:08:55 UTC
The branch main has been updated by jrm:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0c810e677ac68d110f85a6fa9258e2c8147a9133

commit 0c810e677ac68d110f85a6fa9258e2c8147a9133
Author:     Joseph Mingrone <jrm@FreeBSD.org>
AuthorDate: 2026-03-30 17:54:30 +0000
Commit:     Joseph Mingrone <jrm@FreeBSD.org>
CommitDate: 2026-03-30 18:08:33 +0000

    editors/emacs: Unbreak build after devel/tree-sitter update
    
    When devel/tree-sitter was updated from version 0.25.10 to 0.26.7 in
    19fa3d59c58, editors/emacs failed to build due to a breaking ABI change
    introduced in tree-sitter 0.26.
    
    Fix the build by patching Emacs to call tree-sitter's new function,
    ts_language_abi_version, rather than the old ts_language_version. Both
    functions have the same signature.
    
    PR:             294144
    Reported by:    russo@bogodyn.org
    Sponsored by:   The FreeBSD Foundation
---
 editors/emacs/Makefile                  |  2 +-
 editors/emacs/files/patch-src_treesit.c | 56 +++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/editors/emacs/Makefile b/editors/emacs/Makefile
index e0f0c0c89999..dbf9a1a64073 100644
--- a/editors/emacs/Makefile
+++ b/editors/emacs/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	emacs
 DISTVERSION=	30.2
-PORTREVISION=	1
+PORTREVISION=	2
 PORTEPOCH=	3
 CATEGORIES=	editors
 MASTER_SITES=	GNU
diff --git a/editors/emacs/files/patch-src_treesit.c b/editors/emacs/files/patch-src_treesit.c
new file mode 100644
index 000000000000..f38b3910424e
--- /dev/null
+++ b/editors/emacs/files/patch-src_treesit.c
@@ -0,0 +1,56 @@
+--- src/treesit.c.orig	2026-03-30 17:46:40 UTC
++++ src/treesit.c
+@@ -34,7 +34,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.or
+ # include "w32common.h"
+ 
+ /* In alphabetical order.  */
+-#undef ts_language_version
++#undef ts_language_abi_version
+ #undef ts_node_child
+ #undef ts_node_child_by_field_name
+ #undef ts_node_child_count
+@@ -89,7 +89,7 @@ along with GNU Emacs.  If not, see <https://www.gnu.or
+ #undef ts_tree_get_changed_ranges
+ #undef ts_tree_root_node
+ 
+-DEF_DLL_FN (uint32_t, ts_language_version, (const TSLanguage *));
++DEF_DLL_FN (uint32_t, ts_language_abi_version, (const TSLanguage *));
+ DEF_DLL_FN (TSNode, ts_node_child, (TSNode, uint32_t));
+ DEF_DLL_FN (TSNode, ts_node_child_by_field_name,
+ 	    (TSNode, const char *, uint32_t));
+@@ -166,7 +166,7 @@ init_treesit_functions (void)
+   if (!library)
+     return false;
+ 
+-  LOAD_DLL_FN (library, ts_language_version);
++  LOAD_DLL_FN (library, ts_language_abi_version);
+   LOAD_DLL_FN (library, ts_node_child);
+   LOAD_DLL_FN (library, ts_node_child_by_field_name);
+   LOAD_DLL_FN (library, ts_node_child_count);
+@@ -224,7 +224,7 @@ init_treesit_functions (void)
+   return true;
+ }
+ 
+-#define ts_language_version fn_ts_language_version
++#define ts_language_abi_version fn_ts_language_abi_version
+ #define ts_node_child fn_ts_node_child
+ #define ts_node_child_by_field_name fn_ts_node_child_by_field_name
+ #define ts_node_child_count fn_ts_node_child_count
+@@ -746,7 +746,7 @@ treesit_load_language (Lisp_Object language_symbol,
+     {
+       *signal_symbol = Qtreesit_load_language_error;
+       *signal_data = list2 (Qversion_mismatch,
+-			    make_fixnum (ts_language_version (lang)));
++			    make_fixnum (ts_language_abi_version (lang)));
+       return NULL;
+     }
+   return lang;
+@@ -817,7 +817,7 @@ Return nil if a grammar library for LANGUAGE is not av
+ 						       &signal_data);
+       if (ts_language == NULL)
+ 	return Qnil;
+-      uint32_t version =  ts_language_version (ts_language);
++      uint32_t version =  ts_language_abi_version (ts_language);
+       return make_fixnum((ptrdiff_t) version);
+     }
+ }