From patchwork Thu Feb 10 22:55:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 37201 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C34F727BBEA; Thu, 10 Feb 2022 23:02:03 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4A83827BBE9 for ; Thu, 10 Feb 2022 23:02:03 +0000 (GMT) Received: from localhost ([::1]:47250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIIRu-0005h0-F3 for patchwork@mira.cbaines.net; Thu, 10 Feb 2022 18:02:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36048) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIIMG-0007p0-HB for guix-patches@gnu.org; Thu, 10 Feb 2022 17:56:12 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35445) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIIMG-0006LJ-5u for guix-patches@gnu.org; Thu, 10 Feb 2022 17:56:12 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nIIMG-0000zy-4R for guix-patches@gnu.org; Thu, 10 Feb 2022 17:56:12 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [WIP PATCH v3 24/26] gnu: Add emacs-tree-sitter-core. Resent-From: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 10 Feb 2022 22:56:12 +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.16445337703802 (code B ref 49946); Thu, 10 Feb 2022 22:56:12 +0000 Received: (at 49946) by debbugs.gnu.org; 10 Feb 2022 22:56:10 +0000 Received: from localhost ([127.0.0.1]:57569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIIMD-0000z4-Bj for submit@debbugs.gnu.org; Thu, 10 Feb 2022 17:56:09 -0500 Received: from mout.gmx.net ([212.227.17.20]:36391) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nIILo-0000sm-9d for 49946@debbugs.gnu.org; Thu, 10 Feb 2022 17:55:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1644533738; bh=xJrPTZj+G8//0+zgeJuM7aKOhRsT8ZW8FTEXRvSsEd4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=Ruqwq5rQ6c5eCg28GwOr731f4zVPCo35UeYADTJGfAbiM+sufELGWEuMJibvYizL/ JUI7hpAC3lT1vMs8SfsGE1ZiLRpe9BXtm5a+BB/r6otTWdqJABYw986CAHvmQ0YF98 jbZlQj2Z76gMlJQX3Iq209V+GaKPDki/++EigfSo= 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 1MwQTF-1o7dqp1Uov-00sPDv; Thu, 10 Feb 2022 23:55:38 +0100 From: Pierre Langlois Date: Thu, 10 Feb 2022 22:55:25 +0000 Message-Id: <20220210225527.25189-24-pierre.langlois@gmx.com> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220210225527.25189-1-pierre.langlois@gmx.com> References: <87leyinxly.fsf@gmx.com> <20220210225527.25189-1-pierre.langlois@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:qbPZ3B03tvR7p7wUEooFBc4FMg7enTfkIyzKnepMtwEYfNOPLzj Zb6c3WiFr3U3WupS8KKo7UUV2Jbr0qD3RQnIQhuSu9eXgoxR7zcMKlXQcOQ9olr3TB8Va+r DGctNN7gp0VVftsj+Wdalu2N0TAipIk6NM+YVRf5WNENoO5peKmGNDkpPiZ502XN6/qpSva jteTZ21hWFlkmtjOLeoow== X-UI-Out-Filterresults: notjunk:1;V03:K0:YCgDpXohdrU=:bAfxUYkDY+iGjFyG2aCfRC EGGSOEWnzm7YvP/dEQVB//u9tbmcM1WRLk69vuysVfAh3gCtsh/Yaqs1gOU3FiI9qS4PUUGD0 eX8WidPctw26xpBrqEPfY1/wJZIixrcpV3cSReAgIzF1OOzXsYYlqczQ3H+w16fxUtUwJk7qe mLkR2UIauXkPiD6XctgLOc28vhDZ+QW9G0Yjsjd5YQrAmqUtrqJQDwiQoeu/rytqEaTRyOBak OgOV9T6DNkqLALlvHGdkMnAbH7f0O6QcZvQTvV2HAu6gc2VWeumdF5pZuQK8aoEn1rPa5j9fp FU5U3zpkYzZBxnTV8nBPJwomw6KpGjczqDOSFhI8UuJqrL3zw+M0zvf7SL1S8Nsco584zI+Bz bgc9bBFS+WZSGHwma9uCjylpnu88gEwHe5ofsnK8HF2VjSA0uTiN39++itv8Wi3l7LFquzTWx /N4xsASdozzXID7YybZ7eo/0wWZwLs9a4bD5pQBm7O53dJF7ZrVtCVVxw+wf9I3O114OajjXw RbQC7YGv3gBmrHb6l4dnsqfYNINprfBjAYu91JclhFaAQKHfrVDL8hBpyOlAI4XA06AhYSLpE F6haqS30TNNrCeTJf43GWrw7+5JcS4fC16yfU2li0ZmzB4jjwJMCQ5oKMFUGVzQt0b89Qo8MJ rTGD7NCcyz/D1fz2IGi/ust9xtn2leXgXvLxTLDSqJDFJ+PpGvobvj8i945tQVZ6NRIyC/I/R MzrVRU9aPIny+43o8rGz8SaDbCy47nV4/nxCMhNAIGl6TzaPnFYCAGC5sGb9O6tmnlPho4Ylw L23n4XzbOEC6xdqYCoviwevV6cbsJSiiZw9MUmwJWLaRF/+SsgaGP/6NRivBB7DaR4mJw5JCL djaJbNkZ0Xue3JB9HxzymNDXg6UmHYHhY5jSWQjA6Q4UyIj45xzsNqdKKSYwCsmHjvHXJDkD4 CHDgXPaOaRo02A0aKOiEP4PiegTA3p9CyxslddRD0CYaydVtQF7J1NmZEaRygcZDKhjeg94YJ UJeoV45V8MGnpJWZq60M0YoHm+IeubrTbn8Wy6rgWQvBH/VWReNXyq/snDoI9Aj6gShKth7y5 xLKgGKwJ+wFMl8= 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/tree-sitter.scm (tree-sitter-emacs-module): New local variable. (emacs-tree-sitter-core): New variable. --- gnu/packages/tree-sitter.scm | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) -- 2.34.0 diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index c86244a300..893c02824d 100644 --- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -20,6 +20,7 @@ (define-module (gnu packages tree-sitter) #:use-module (guix gexp) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix build-system cargo) + #:use-module (guix build-system emacs) #:use-module (guix build-system gnu) #:use-module (guix build-system node) #:use-module (guix gexp) @@ -620,3 +621,80 @@ (define (source-file? basename) "This package provides Typescript and TSX grammars for the Tree-sitter library.") (license license:expat)))) + +;; Local package definition solely for building the native emacs module +;; written in Rust. +(define tree-sitter-emacs-module + (package + (name "tree-sitter-emacs-module") + (version "0.17.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/emacs-tree-sitter/elisp-tree-sitter") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0bl7709r4mhb5nmfcsiqj09ja8wn53x9nf5jrr5lq3n1lwz7qq66")))) + (build-system cargo-build-system) + (inputs + (list tree-sitter)) + (arguments + `(#:cargo-inputs + (("rust-anyhow" ,rust-anyhow-1) + ("rust-emacs" ,rust-emacs-0.18) + ("rust-libloading" ,rust-libloading-0.7) + ("rust-once-cell" ,rust-once-cell-1) + ("rust-tree-sitter" ,rust-tree-sitter-for-emacs)) + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'chdir + (lambda _ (chdir "core"))) + (add-after 'chdir 'delete-cargo.lock + (lambda _ (delete-file "Cargo.lock"))) + (add-after 'delete-cargo.lock 'do-not-fetch-from-github + (lambda _ + (substitute* "Cargo.toml" + (("\\[patch.*") "") + (("git = .*") "")))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let ((lib (string-append (assoc-ref outputs "out") "/lib"))) + (install-file "target/release/libtsc_dyn.so" lib))))))) + (home-page #f) + (synopsis #f) + (description #f) + (license license:expat))) + +(define-public emacs-tree-sitter-core + (package + (name "emacs-tree-sitter-core") + (version (package-version tree-sitter-emacs-module)) + (source (package-source tree-sitter-emacs-module)) + (build-system emacs-build-system) + (native-inputs + (list tree-sitter-emacs-module)) + (arguments + `(#:phases + (modify-phases %standard-phases + (add-after 'unpack 'chdir + (lambda _ (chdir "core"))) + (add-after 'install 'install-module + (lambda* (#:key inputs outputs #:allow-other-keys) + (let ((elpa (elpa-directory (assoc-ref outputs "out"))) + (module (string-append (assoc-ref inputs "tree-sitter-emacs-module") + "/lib/libtsc_dyn.so"))) + ;; Writing "LOCAL" in this file prevents the package from + ;; trying to download the module from the internet. + (call-with-output-file (string-append elpa "/DYN-VERSION") + (lambda (port) (display "LOCAL" port))) + (substitute* "tsc-dyn-get.el" + (("defcustom tsc-dyn-dir tsc--dir") + (string-append "defcustom tsc-dyn-dir \"" elpa "\""))) + (copy-file module (string-append elpa "/tsc-dyn.so")))))))) + (home-page "https://github.com/emacs-tree-sitter/elisp-tree-sitter") + (synopsis "Tree-sitter bindings for Emacs Lisp, core library") + (description "This package provides core APIs of the Emacs binding for +Tree-sitter, an incremental parsing system.") + (license license:expat)))