From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cDowORtiQ2LinQAAgWs5BA (envelope-from ) for ; Tue, 29 Mar 2022 21:46:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id KKzMMRtiQ2J/bwEAG6o9tA (envelope-from ) for ; Tue, 29 Mar 2022 21:46:35 +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 66A0529904 for ; Tue, 29 Mar 2022 21:46:35 +0200 (CEST) Received: from localhost ([::1]:39668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZHnW-0007Lt-IU for larch@yhetil.org; Tue, 29 Mar 2022 15:46:34 -0400 Received: from eggs.gnu.org ([209.51.188.92]:57130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZHlD-0003lm-Jl for guix-patches@gnu.org; Tue, 29 Mar 2022 15:44:11 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZHlD-0001Ez-9L for guix-patches@gnu.org; Tue, 29 Mar 2022 15:44:11 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nZHlD-00050D-5G for guix-patches@gnu.org; Tue, 29 Mar 2022 15:44:11 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v5 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: Tue, 29 Mar 2022 19:44:11 +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.164858303919041 (code B ref 49946); Tue, 29 Mar 2022 19:44:11 +0000 Received: (at 49946) by debbugs.gnu.org; 29 Mar 2022 19:43:59 +0000 Received: from localhost ([127.0.0.1]:33626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZHl0-0004wx-If for submit@debbugs.gnu.org; Tue, 29 Mar 2022 15:43:59 -0400 Received: from mout.gmx.net ([212.227.17.22]:55593) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZHkt-0004sl-MI for 49946@debbugs.gnu.org; Tue, 29 Mar 2022 15:43:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1648583026; bh=JbfFiMfn1+z/Ao22UQKuQ4cRrkud/HlSvV5ByczTX08=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=A/AZHxkG9VBPGv8W4hfmjeoEX37AU648OJxZIT8ANbMUg7iA5xv77/32HeTVlRhmu 1PqvWNUurMRYpTfvyAso0Ga8WbGK30oDLA/gDfKo/xMwHLVNP7RsyFbRs5xguqWqDi L5vCFm+RpsOAFVNLH0GOEgitO1tO5taOY+m3auO8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([82.69.64.142]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Ma20q-1nVu4r3cay-00VzC8; Tue, 29 Mar 2022 21:43:46 +0200 From: Pierre Langlois Date: Tue, 29 Mar 2022 20:43:15 +0100 Message-Id: <20220329194318.6106-25-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220329194318.6106-1-pierre.langlois@gmx.com> References: <877d9s2qa9.fsf@gmx.com> <20220329194318.6106-1-pierre.langlois@gmx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:+n+nmHd1AdPjvR5kL/XL2pjPVxz+enURn03IcGKW6O4Tx35qkOu XU5g8vdTVKUsTN3qffu+/5P4FkNOUJNd/2YdToHnAF6uSws5bcyabE7tg17oJv0OSbHQCx/ H+rpMKwCXXPJ3RTRwC52DQYEOISnUv6Bkn1Ypss6bGhaeU7+AprhmnZOG2gqPjEE5ycb/8a 9jTIaITo6U+MPdG0q2Pzw== X-UI-Out-Filterresults: notjunk:1;V03:K0:rGLOKB1Zjhs=:bbWDmmEE7t5XVi6AygrIsm 08LkpmVGfIUv3CaBS6tRb7TYFftLPriucvgq2yd+pMT48OK0OBeHbMOr766Gh9SwNvV/dkYxn iGmIo1CNZOnt1hpGYVE7bnf4eC2P79xiEKuSQJQwhSqrjW400aSAdEj9Yfz4oeQ0hqwr8aL24 VHAzojCjqFaUzK1YRc3tnCc7nFLAb47dgQRfUPj/4P7ncog0FdfFEjttxJ1TQMjewBddT7v5G AFg5qDeDI7vZQlmRPMJBnymr8gE2eM43lj3CYOdn/f8klk3CZQmZWMJOWFc1b3+rfYzVg+nHF vBce1YZPXV38fMcj5bucKumhjWvSLjm96gNdMIBM8HJmFaV7bfHSaWgs0117kQYCd2izYt6Ew ERlop8a4HfZXSYXSWl1ut2ipiMIyLteDYGvqKh0VelBR3rUG63rnv//F2u2j/zXxVOYmru03s 75/ir9XwJQHzcs86f7UrdkViBK8VTDeonceF0EY6eLpgQaqITsvDLMgsGS26KLK7kKs9wJsBQ kGYBs6HIKDgDnxwUnS7UfnuolDYufCnM1//tIhVkGp1N50c9qxopbDTtm47FqiODZi+jILVTf 3aM58L1iTFJwMPPVYfmaP63+R2pEvuBgsZwpu/7p9e85ugVeTwr1PbywbgZyfKgieofrBFMkh e/3txf56JxrA83oRWOSu0dZkcMAVY9v1rdnyeBg96Ld4SdAnC8zWGrprrPdJNOK8+tSZAY7Vd k0dEKaiQDqKDUycCTfX1SzDXaTr2XF2MbOh+XgL6cAX5+5EgNmw4fWBMFOUWnKQT321foNfwG 6tK3iEU0ukDC82AIgj8iglUlr1TYCxP27nMtQtO3+UreB3No4+FWDYnBBiKJXH4EVbdCQ44+G OhC2KdInwtZxhZwe52o4+XSvSPe5GpTsZ80VLsjUTpWJiJOSoh7+1VvbzMGpfkk9Tlli1EsVp pA3UOeRftyh8o/FXB59eIOOmqTMCSmfreaGMFDtZBES1uoq5DvuFSMc2qqhv6kW52HaymUucQ ESjoyIg/djfxXjLLn4hOonVuNZFSCi6StL9cFYnYOmLgZmUI0FUprgziMUIxmIQ4qhLKnx3ND 17RtopmBZpH7Is= 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=1648583195; 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=ai+4vLksEOLsXwsFUFonVExDBlNEActnNUjwre9YC/c=; b=QfdybAyOtU9cp+tsqUn+RXbGLPjLxrhkg710qJW+ImyOTrf0HGsA1r6Uxc5pQeQJNBMnlc BFta3CyLhPmpGAhQRKvVp68i0OM26phSsxfA2uvZ7oV9vTlbVm3fwzETshflSVDlcd/xYW xpxrHIij2Ld00CFrIgfDD8kVcpiLxH/C9PaslE7y+Cr1tu7DoYfUE8iON5zKpGUGNpCh08 f6r+cpAgjrEV2aFIxVj6kaT0fIklQoYAYir9GIfZA8J7tHVBm64IA0Ip4WJmyyuIgu8mFt qP/Y4ehvQGMsm2JVnMyuGe9hRp8rfEOhboAL1pPBFABF1DHcX7IE5XcMZR5fRA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648583195; a=rsa-sha256; cv=none; b=GvWTQF41oTHQvDUYRQJIA0D5PkU5ZoepJRnAovK15o7Q1ebFa/AhHINwNXqoj04vNWqNFQ vOv0yYUQKs79l5L2TGTPrk1+K2zo6ahSuPAxYuk7Q682AoNwWWaC86UQFfV2i4Z0yacbam B6k/m5OeY3nQPnKlZHCYY0mtbLTwgGaCC9LCTWi8d2fCHsuiLjhDyUb9RCEbCDRP9X4Mpo Df7DtD4J7qTeOirtP8BO/GZOsfQcfYNX+DRyO9KrsrZHrTMPrSP9uLRUldGzqzNsWBua+i qL74kq9VAUeRtXsbsjNzRVeEiDEThJR3cRtBNaB5PHGflu/vtdrBxw6mSJgc5g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b="A/AZHxkG"; 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.33 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b="A/AZHxkG"; 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: 66A0529904 X-Spam-Score: 7.33 X-Migadu-Scanner: scn1.migadu.com X-TUID: nWbZZd0c2ami * 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 03972441e6..aa353a6f68 100644 =2D-- a/gnu/local.mk +++ b/gnu/local.mk @@ -1780,6 +1780,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 389cb944b9..5209876431 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.34.0