From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4NM4OwpKgWIwLAAAbAwnHQ (envelope-from ) for ; Sun, 15 May 2022 20:44:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id 4BYZOwpKgWJE0AAAauVa8A (envelope-from ) for ; Sun, 15 May 2022 20:44:26 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9D4B1A85C for ; Sun, 15 May 2022 20:44:26 +0200 (CEST) Received: from localhost ([::1]:48196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqJE9-0006M0-S8 for larch@yhetil.org; Sun, 15 May 2022 14:44:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqJDn-0006KU-5z for guix-patches@gnu.org; Sun, 15 May 2022 14:44:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nqJDm-0001I4-Tp for guix-patches@gnu.org; Sun, 15 May 2022 14:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nqJDm-0006oS-SN for guix-patches@gnu.org; Sun, 15 May 2022 14:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v6 24/27] gnu: Add rust-tree-sitter-for-emacs. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 15 May 2022 18:44:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49946 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49946@debbugs.gnu.org Cc: Pierre Langlois Received: via spool by 49946-submit@debbugs.gnu.org id=B49946.165264023726162 (code B ref 49946); Sun, 15 May 2022 18:44:02 +0000 Received: (at 49946) by debbugs.gnu.org; 15 May 2022 18:43:57 +0000 Received: from localhost ([127.0.0.1]:50743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nqJDg-0006nm-8u for submit@debbugs.gnu.org; Sun, 15 May 2022 14:43:57 -0400 Received: from mout.gmx.net ([212.227.17.20]:44473) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nqJDZ-0006nM-S6 for 49946@debbugs.gnu.org; Sun, 15 May 2022 14:43:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652640224; bh=y/ECVwaHOny3TmX/UyPrdkgjwEF4tIZfluzAOATGwr0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=HSIr0qLh9R6/mdDlqWGrFlIVgbY+mb7Q18V/Fvb38cssj/1L30L3RO7720sE2ZISg 5Jx8cIom68czDzPoB8xX8wAne17KRnq6/gA8EgFCq4YT6NgW7dFerH89p+5V8sH2H3 /+LkdqNgguX9nX9Uoc5VGeUTHFd1ZtvzxT252rMA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MOiDX-1oFpRE2yER-00QAbd; Sun, 15 May 2022 20:38:43 +0200 From: Pierre Langlois Date: Sun, 15 May 2022 19:38:31 +0100 Message-Id: <20220515183834.18771-24-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220515183834.18771-1-pierre.langlois@gmx.com> References: <87mtfi63ut.fsf@gmx.com> <20220515183834.18771-1-pierre.langlois@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:6+sS+4eXz3wBz+G7eJ2I5PG5bZzluuXc89cugbHLuewkB+vDr0Q 0OvhgsHL8u6q1aWLhhcnQqd5syU3uXPPtDjKLGa6zXc48M5wuQ35Dlr/2x26GsDlxS+IUbz +fLweWwy+pSrTf/oSx4OC+Na3zvHmr1S5rwagLjAVr962WVCmxF8Ru0xHesGs28QDG1EXff Vco6a8S/mOQJskcnih3FA== X-UI-Out-Filterresults: notjunk:1;V03:K0:cAdn0MrGAIg=:IYqsPnPArKd1ye8QsJ/WjL ymVqh+S3MEASI3XL804bXkoqY0WyNZE3Q7sy7YEblgK1cSOgI1xqKAyRwTtgzJTI6se7cFhLG K2Ljip4gDTqExec0jGN3nEejG30XfDT7AumksVXTaDoiloP0VOXuwpb51sKSBGqOoqJrLwK8L pMRQqiwNeRljrlQ/bjrjdALq0Ma9lG4b4UM/UHO4mPugyZwPnLQf/FaFNAxTZgE7jWrIWnQ3U yI3MAAftCzTdNlQehtmXp9emjDQx/hKVChfEA6IMusgsyz/edWe5brRNYmZvZFR7UEf+IAcT3 kGqWNLImhVyG5PswkbdxNf4lC4z3zOSIL+LarfQF1u9l18WKBzwDO6XrcVuShi1J1Sx9GidAx x1mVw1AW+DsPXvEg+QO+GjuuVDhOOiZsYe88RC4rWqWFJPp/8gWpd+uFT42FfNJg8CtUrG6/0 6EcBIpqpfVkeZ3tD2UjMl2mUojE9yEClomJIyK5+o5keSXwnPDGwI40b97sB8M/1syYxcXYdG KclmdQb1YC7s7LMckbTr4gwXxy0hKn4Ku+DXERtpl1qZDd+nwLnRXJCRFjHyjs/ooN0O0CsXy U1Df7PfdEGVcf6Urg7OJH1uX1Wa03/SOEYWeWOEPQwENCj0OvJxqPk+a19mWirQ+6GaMKIbQE def88QOOyG+jqlaXeb5TEx2OCRmBAqEklK7drgvQdykG69zOLag16txli6I41XAGkHL8mxz6x XiPIghB/oHcndTEkM6RMv4ApFEO6D3togNXtSp2rVQh1g6WAaHoLeVDBWLZWoDgWykMyuQuNx U3DCIIvGcXcI1nm8PE7wFyEtE5gZA98LsSIPnnWcfJDZXYYGsxZbpHbyT1In8wuq4FpQy2IM3 cQiPasw+k88aFjMZGHeUhgjYN4wx/D94XwqvKiXmj1KPgDeY6LA8oTiHEet38WEoP7VUxzk2a VY11cnmh6m0lHsjnH9DMi5SP5kX5ya3Q9vZXlF+sQqulnoqXxtUF438rP/aDg66DuU3YPXzZF 88bZCynZhg0zfxWWW4UOw9JWuaXhgqxlgPbSU+OK5wPK1X5p14qoBlAg5JlrmYIpZ9L8LqKgK o82QKTdCn+w5SI= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1652640266; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=UqD/eK7VTOP08+Nd0I7IqH7hGhnWPARxALhQ5BzPnZ0=; b=XnnwZIwJVZVd5ik7BP2axHGUvRNWhiwmhGy7BIjTRlb7T4DouODkodMa56sZ84HN2geERb PLe5YFY+PA2lOM2FpK8lZeapaBy/jgqNZmbCguqADbqohfp/YRHucZbtxUeFE5b4FNSaz6 xmFeWLOFlh4OdtezqGJEyny3OHtQVR/R4K0JT7KH20OjF39a3AE3Ryz9uRNLFrDh1hEZyA +SC80I7ozOaDeO7QlZNmHR+dISOq5e4Lgl7N8rvf1ctGxsYRtpCM5IrPg59XfauTDbqOwP oHer6xyQxALGrPifBgC7fRmPkEWRUHlgS4RyB1G3zMvlgkRV071zlqZ1pPbNCw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1652640266; a=rsa-sha256; cv=none; b=i+zaGfy6xTL578MWyC5sj77LahNR+O+XTDDTcc/uDipiNKL5ruS9k48KcbU7f8MclKFO+6 sPzdQDkTRPmf0+F+jo7s7Im+FeUW5wiuMljgL74yttxBbTCQ8MeCkUhYztLGqEvwhmBM/E yvdesgnXARXp7tVBSQsVGNbhp0T9eEFWGtmch/Ie/3eY2ewLLNYA+kzoS02urFBhS+E1rX 4EUyjyFVJCCGtQqXu2fml2WEGhEtaHDEgVWUi1ShWJgUx9RaUJ2JiqUJqljAELuVVueivR k3tHAyWgkOamvOPob6BixhBZ5QtzWNlA5sEBPURKh2ZEpINxDXsMnFJnGAGqWQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=HSIr0qLh; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 7.37 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=HSIr0qLh; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmx.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9D4B1A85C X-Spam-Score: 7.37 X-Migadu-Scanner: scn1.migadu.com X-TUID: TUDzaHKxJvHi * gnu/packages/tree-sitter.scm (rust-tree-sitter-for-emacs): New variable. * gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. =2D-- gnu/local.mk | 1 + .../rust-tree-sitter-text-provider-fix.patch | 98 +++++++++++++++++++ gnu/packages/tree-sitter.scm | 14 +++ 3 files changed, 113 insertions(+) create mode 100644 gnu/packages/patches/rust-tree-sitter-text-provider-fi= x.patch diff --git a/gnu/local.mk b/gnu/local.mk index 429a0b577b..7681eda58d 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -1787,6 +1787,7 @@ dist_patch_DATA =3D \ %D%/packages/patches/rust-nettle-sys-disable-vendor.patch \ %D%/packages/patches/rust-openssl-sys-no-vendor.patch \ %D%/packages/patches/rust-shell2batch-lint-fix.patch \ + %D%/packages/patches/rust-tree-sitter-text-provider-fix.patch \ %D%/packages/patches/rust-wl-clipboard-rs-newer-wl.patch \ %D%/packages/patches/sbc-fix-build-non-x86.patch \ %D%/packages/patches/sbcl-aserve-add-HTML-5-elements.patch \ diff --git a/gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch= b/gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch new file mode 100644 index 0000000000..215e7fc18b =2D-- /dev/null +++ b/gnu/packages/patches/rust-tree-sitter-text-provider-fix.patch @@ -0,0 +1,98 @@ +From e3576b180488b8231e1fc0ca130748577579d129 Mon Sep 17 00:00:00 2001 +From: =3D?UTF-8?q?Tu=3DE1=3DBA=3DA5n-Anh=3D20Nguy=3DE1=3DBB=3D85n?=3D +Date: Sun, 25 Jul 2021 13:11:52 +0700 +Subject: [PATCH] Allow TextProvider's iterators to generate owned text + +--- + binding_rust/lib.rs | 33 ++++++++++++++++++--------------- + 1 file changed, 18 insertions(+), 15 deletions(-) + +diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs +index e88a411c..cf214d92 100644 +--- a/binding_rust/lib.rs ++++ b/binding_rust/lib.rs +@@ -5,6 +5,7 @@ mod util; + use std::os::unix::io::AsRawFd; + + use std::{ ++ borrow::Cow, + char, error, + ffi::CStr, + fmt, hash, iter, +@@ -183,7 +184,8 @@ pub struct QueryCaptures<'a, 'tree: 'a, T: TextProvid= er<'a>> { + } + + pub trait TextProvider<'a> { +- type I: Iterator + 'a; ++ type I: Iterator>; ++ + fn text(&mut self, node: Node) -> Self::I; + } + +@@ -1840,19 +1842,19 @@ impl<'a, 'tree> QueryMatch<'a, 'tree> { + buffer2: &mut Vec, + text_provider: &mut impl TextProvider<'a>, + ) -> bool { +- fn get_text<'a, 'b: 'a, I: Iterator>( ++ fn get_text<'a, 'b: 'a, I: Iterator>>( + buffer: &'a mut Vec, + mut chunks: I, +- ) -> &'a [u8] { +- let first_chunk =3D chunks.next().unwrap_or(&[]); ++ ) -> Cow<'a, [u8]> { ++ let first_chunk =3D chunks.next().unwrap_or(Cow::Owned(vec![= 0u8; 0])); + if let Some(next_chunk) =3D chunks.next() { + buffer.clear(); +- buffer.extend_from_slice(first_chunk); +- buffer.extend_from_slice(next_chunk); ++ buffer.extend_from_slice(&first_chunk); ++ buffer.extend_from_slice(&next_chunk); + for chunk in chunks { +- buffer.extend_from_slice(chunk); ++ buffer.extend_from_slice(&chunk); + } +- buffer.as_slice() ++ Cow::Borrowed(buffer.as_slice()) + } else { + first_chunk + } +@@ -1888,7 +1890,7 @@ impl<'a, 'tree> QueryMatch<'a, 'tree> { + match node { + Some(node) =3D> { + let text =3D get_text(buffer1, text_provider= .text(node)); +- r.is_match(text) =3D=3D *is_positive ++ r.is_match(&text) =3D=3D *is_positive + } + None =3D> true, + } +@@ -2002,23 +2004,24 @@ impl<'cursor, 'tree> fmt::Debug for QueryMatch<'c= ursor, 'tree> { + } + } + +-impl<'a, F, I> TextProvider<'a> for F ++impl<'a, F, I, T> TextProvider<'a> for F + where + F: FnMut(Node) -> I, +- I: Iterator + 'a, ++ T: Into>, ++ I: Iterator, + { +- type I =3D I; ++ type I =3D iter::Map Cow<'a, [u8]>>; + + fn text(&mut self, node: Node) -> Self::I { +- (self)(node) ++ (self)(node).map(T::into) + } + } + + impl<'a> TextProvider<'a> for &'a [u8] { +- type I =3D iter::Once<&'a [u8]>; ++ type I =3D iter::Once>; + + fn text(&mut self, node: Node) -> Self::I { +- iter::once(&self[node.byte_range()]) ++ iter::once(Cow::Borrowed(&self[node.byte_range()])) + } + } + diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index 58ecc445a6..4d1d3b2177 100644 =2D-- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -27,6 +27,7 @@ (define-module (gnu packages tree-sitter) #:use-module (guix git-download) #:use-module (guix packages) #:use-module (guix utils) + #:use-module (gnu packages) #:use-module (gnu packages crates-graphics) #:use-module (gnu packages crates-io) #:use-module (gnu packages icu4c)) @@ -196,6 +197,19 @@ (define-public rust-tree-sitter parsing library.") (license license:expat))) +;; We need to apply a patch in order to compile the rust bindings against= the +;; emacs tree-sitter module. +;; See https://github.com/tree-sitter/tree-sitter/pull/1294 +(define-public rust-tree-sitter-for-emacs + (package (inherit rust-tree-sitter) + (source (origin + (inherit (package-source rust-tree-sitter)) + (patches (search-patches + "rust-tree-sitter-text-provider-fix.patch")))) + ;; Do not show this package in the UI as it's only meant to be used f= or + ;; emacs's tree-sitter module. + (properties '((hidden? . #t))))) + (define tree-sitter-delete-generated-files '(begin (delete-file "binding.gyp") =2D- 2.36.0