From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 8CZ6KMxiQ2KHnwAAgWs5BA (envelope-from ) for ; Tue, 29 Mar 2022 21:49:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id gF0aIcxiQ2I80QAAG6o9tA (envelope-from ) for ; Tue, 29 Mar 2022 21:49:32 +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 1D3B93CB09 for ; Tue, 29 Mar 2022 21:49:32 +0200 (CEST) Received: from localhost ([::1]:41074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nZHqN-0000C7-9p for larch@yhetil.org; Tue, 29 Mar 2022 15:49:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nZHpw-00008H-Ie for guix-patches@gnu.org; Tue, 29 Mar 2022 15:49:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nZHpv-0002gP-7H for guix-patches@gnu.org; Tue, 29 Mar 2022 15:49:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nZHpv-0005An-5Z for guix-patches@gnu.org; Tue, 29 Mar 2022 15:49:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH v5 27/27] gnu: Add emacs-tree-sitter-langs. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 29 Mar 2022 19:49:03 +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.164858333719860 (code B ref 49946); Tue, 29 Mar 2022 19:49:03 +0000 Received: (at 49946) by debbugs.gnu.org; 29 Mar 2022 19:48:57 +0000 Received: from localhost ([127.0.0.1]:33665 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZHpp-0005AA-7d for submit@debbugs.gnu.org; Tue, 29 Mar 2022 15:48:57 -0400 Received: from mout.gmx.net ([212.227.17.21]:43783) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nZHpl-00059c-4q for 49946@debbugs.gnu.org; Tue, 29 Mar 2022 15:48:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1648583327; bh=RUQptR1PMxktgV8LmeLsFRD+Yyr1rDH8v0IhlqzHmsw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=F+a8nqzX6KB3nS5rfeOBtaeaSj9Z8uU5cXacfGsPUp4ULGGVfTF8h+0xicvEQV45z HyDz6QS094TIvObuaWawsOvbbuGSvE0+dY8ZBfeKM8r5808hUxJkz5ovFTuMhE/fne UNf9K0nYtW4/pRtsKbuEB9PjI8+UnHzB0BT9Tesc= 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 1MsYux-1nsL0b38iR-00u4jT; Tue, 29 Mar 2022 21:43:46 +0200 From: Pierre Langlois Date: Tue, 29 Mar 2022 20:43:18 +0100 Message-Id: <20220329194318.6106-28-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:TKOWDBj4sZ8WPGww2uvraQmodtxgS3Lkzt4At/97WoMlF8nk6rH 2WB6oVAlApXZTELfx2ED6w13QvUBypnknL/jRoEREGB0K2UAtJLmE3NpZPtzHiOhZnNfgoX jj4rHePcXnSSgvfQ8dyxV39zU07NMPRvCv98XbmyWqPOMbugmcTLDCCYgqb9wYRAUQ2jFtM LL0hBV/qwzk9B0P98plpA== X-UI-Out-Filterresults: notjunk:1;V03:K0:gNqn6A98Xhs=:aztWNbT1DdxXCYQyiyCwWR YJxY3o2g5hanDKZb6MH6YkYGQeXSgHpgrLl6zgzFG6beW1wmOpgAaVV7izrL9dhK7AsL9XxTg vUesbDk/842VmTwkKMPdyfA6kwMFbNBCAbL9ii9z6sSr6VYyCaX0Sokd4qo/Ns65iehPtdLnF 8DWBeU8jE6+UUZ2wB3KsUEHUo1RjMiM0n49qwc8tRg9RVmmiTdj4R0pLKGuPI5pb5FVUSbrGU 7BfL3NF1siyPCkCISciZvfe7Lc1Ivqah7Tmzz12kybXcQ4TM3vC2kF9JMCSm1hVOp6C/kFmWO EjwTWq/wuYxLqEFgwF7Xa75XiS4yCLiVRIeHUbf3B6xE9jnAURhyNGOhhOtjer6c2etWC4DLf Nn7n6tjdUU1t8nmWbDfg0ISIBWZ8M3gk+0ZVlRbTtb3J2O1OtKznnKcTNjcpGai+Nn90ba6DI 2Ff19mQgCv02qO6U1QD5kCR2NzNcvYCjdvGeF8rN+PU/6lRREKYkJB6wjwRnMfIyqX/hiLyH6 c6AvRSc72Nm5VmdffSLDp0K3uXQEQhkcDhleWuVihm28lhw3JCKzoW/TvomKdssnrOAA2yYli /GZxEGfGwNnbniF87+Fq3Fwh3o03GhiHX75syHAzzpNb5AOmPTa23UVdCfaNBoYxixs6JfpzH HxvhBDs4HQ6A1TyF6xsPmPMtXW76vzLZrWZrI8jqQ6aLR2Nttv6ot1Z8xjGADpgbejkGTYIuE rfz5cPCGg/BkGbw0nEGbFeCoEaS6j9c/L29RT0q2sHqBUK9xIW5+4Gb+cbR23P2kpgnMWJD/E apY3a8z1hKh4HaFmyrGo7Op885Gv/kacHl+haHn1ODnj5JiEaj9V5UuZ0G4626xU89kJV8zhb FTOMyH5gk4lwuqnpEOnprlVTzHgpOS3nPXp5f4XojTOlvPSb9UZhMnl+qr+5bOzc49rcGAD7r qk/NJa4xmztbhxaSNyxgyeJEX9g4AjVVwHXajWUUqHmkFB8K67s7hpcokU/e5K53Lyde/88B8 hRcvgtOzJ4LTpFUxpQiJXUtKMxm9ijfzRsFlPbLYLpkPcqr5HnN703bp2JaMyvwa2uVeTt8h4 wEyDj4ILrWKvoU= 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=1648583372; 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=yG57yo59GAaVbArdTd4Kphrc9/XV6SHsXBqKEM15FIw=; b=sdtyrF4hCODO+QeMNvfZXxDYFeX310u88n5Ls5evHsRWyYbHvUSlNBDjqn9DJcPQ4BgC7M TWICMieZO7f11MI/+SRJzdJbg0WAvH0j3/LbA0i+dStD95Dj6iza4EgarJ9VIvuwoFy9br 2/oGUG5A9lQE2iCftIFYHdtbc1LxdZcZ+/faT292ByVWNm582/9zNYNvONF37giVGLrHuS mf9FXgKYZFlSp0F1Fqwi/tM1bAENC6n2HBaw/hbS4/ey0sCuuu1w5c0N78Hkd2PGoVTjIT hj1qUZZFjrGUpAjDXFZB4zvuaUBcmRrmp2GLh0RRw6UOXyCVl8weKTyjKsW3DA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1648583372; a=rsa-sha256; cv=none; b=IDTkP+ePyjM6Wvg2OGWy1pmcJ/902lxtpSlFkt/3BHxPXmkJCPidHWaM5ROG3vXyEacF1P QGAuSd+wyj6CfcufPKWhSECOKCQqxBcSWiYnk0XYPgafKDfBtJ9p0L8nP2UpsfNI5mLd5i a6xjp4/OGDknvzIFtAcuyY3rMG2yaLwxrGR1h54qhjW/rSJHedVEp91CpxmJ2EPs5htH3t 459cA23ZNuqkOOKjXc/COCJUatM+uCnCuFXh3ld7Yy+LtZN+oSs0Ie4JV10npLa+L+74L9 rxvETp9WRN7e3pN5HLAolNfMZfaGFK0OVEe1ZMgebbXJktOkUAb1yFj6imfZ6g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmx.net header.s=badeba3b8450 header.b=F+a8nqzX; 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=F+a8nqzX; 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: 1D3B93CB09 X-Spam-Score: 7.33 X-Migadu-Scanner: scn1.migadu.com X-TUID: 52wXAlfsCuvi * gnu/packages/tree-sitter.scm (make-emacs-tree-sitter-langs-grammar-bundl= e): New procedure. (emacs-tree-sitter-langs): New variable. =2D-- gnu/packages/tree-sitter.scm | 137 +++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index 97a20494ec..ae0478c3e4 100644 =2D-- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -24,6 +24,7 @@ (define-module (gnu packages tree-sitter) #:use-module (guix build-system emacs) #:use-module (guix build-system gnu) #:use-module (guix build-system tree-sitter) + #:use-module (guix build-system trivial) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix packages) @@ -793,3 +794,139 @@ (define-public emacs-tree-sitter @item More informative indexing for imenu. @end enumerate") (license license:expat))) + +(define (make-emacs-tree-sitter-langs-grammar-bundle version) + (package + (name "emacs-tree-sitter-langs-grammar-bundle") + (source #f) + (version version) + (build-system trivial-build-system) + (inputs + ;; FIXME: Support for some languages is still left to package. + (list tree-sitter-bash + tree-sitter-c + tree-sitter-c-sharp + tree-sitter-cpp + tree-sitter-css + tree-sitter-elixir + tree-sitter-elm + tree-sitter-go + tree-sitter-html + tree-sitter-java + tree-sitter-javascript + tree-sitter-json + tree-sitter-julia + tree-sitter-ocaml + tree-sitter-php + tree-sitter-python + tree-sitter-rust + tree-sitter-ruby + tree-sitter-typescript)) + (arguments + (list #:builder + (with-imported-modules '((guix build union) + (guix build utils)) + #~(begin + (use-modules (ice-9 match) + (guix build union) + (guix build utils)) + (union-build + #$output + (filter directory-exists? + (map (match-lambda + ((name directory) + (string-append directory "/lib/tree-sit= ter"))) + '#$(package-inputs this-package)))) + ;; The BUNDLE-VERSION file prevents emacs-tree-sitter-l= angs + ;; from downloading libraries at load time. + (call-with-output-file (string-append #$output "/BUNDLE= -VERSION") + (lambda (port) (display #$version port))))))) + (synopsis #f) + (description #f) + (home-page #f) + (license #f))) + +(define-public emacs-tree-sitter-langs + (package + (name "emacs-tree-sitter-langs") + (version "0.11.6") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/emacs-tree-sitter/tree-sitte= r-langs") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0jyzpiyl3b88vwfzkda7ak77kl0b2nybvsz0j9cndl3pf95d62g0")))= ) + (build-system emacs-build-system) + (inputs + (list (make-emacs-tree-sitter-langs-grammar-bundle version))) + (propagated-inputs + (list emacs-tree-sitter)) + (arguments + (list + #:tests? #t + #:test-command ''("script/test") + #:phases + #~(modify-phases %standard-phases + (add-after 'unpack 'remove-cask + (lambda _ + (substitute* "script/test" + (("cask") "")))) + (add-before 'check 'bundle-for-testing + (lambda* (#:key inputs #:allow-other-keys) + (delete-file-recursively "bin") + (symlink #$(make-emacs-tree-sitter-langs-grammar-bundle ver= sion) + "bin"))) + (add-before 'check 'patch-tree-sitter-require-test + (lambda _ + (use-modules (ice-9 regex)) + ;; This test needs a git repositories with submodules for + ;; each languages in order to map all repositories. We pat= ch + ;; the mapping function with one that invokes the tests for= each + ;; packaged language. + (let ((supported-languages + (map (lambda (lib) + (match:substring + (string-match "(.*)\\.so$" (basename lib)) + 1)) + (find-files "bin" "\\.so$")))) + (substitute* "tree-sitter-langs-tests.el" + (("tree-sitter-langs--map-repos") + (call-with-output-string + (lambda (port) + (write `(lambda (fn) + (dolist (lang ',supported-languages) + (funcall fn lang))) + port)))))))) + ;; Tests for queries will fail given those languages are not + ;; packages yet. + (add-before 'check 'remove-unused-highlight-queries + (lambda _ + (delete-file-recursively "queries/hcl") + (delete-file-recursively "queries/pgn"))) + (add-before 'install 'install-bundle + (lambda _ + (let ((elpa (elpa-directory #$output))) + (mkdir-p elpa) + (symlink #$(make-emacs-tree-sitter-langs-grammar-bundle v= ersion) + (string-append elpa "/bin"))))) + (add-after 'install 'install-queries + (lambda* (#:key outputs #:allow-other-keys) + (let ((elpa (elpa-directory (assoc-ref outputs "out")))) + (copy-recursively "queries" (string-append elpa "/queries= ")))))))) + (home-page "https://ubolonton.github.io/emacs-tree-sitter/languages/"= ) + (synopsis "Language support bundle for Tree-sitter") + (description "This package is a convenient language bundle for +Tree-sitter. For each supported language, this package provides: + +@enumerate +@item Pre-compiled grammar binaries. +@item An optional highlights.scm file that provides highlighting patterns= . +This is mainly intended for major modes that are not aware of tree-sitter= . +@item Optional query patterns for other minor modes that provide high-lev= el +functionalities on top of tree-sitter, such as code folding, evil text +objects, ...etc. +@end enumerate") + (license license:expat))) =2D- 2.34.0