From patchwork Sun May 15 12:20:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Pierre Langlois X-Patchwork-Id: 39374 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 7A60427BBE9; Sun, 15 May 2022 14:11:13 +0100 (BST) 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 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 28CA327BBEA for ; Sun, 15 May 2022 14:11:10 +0100 (BST) Received: from localhost ([::1]:34570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqE1d-0006HX-C5 for patchwork@mira.cbaines.net; Sun, 15 May 2022 09:11:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqE1W-0006H9-6M for guix-patches@gnu.org; Sun, 15 May 2022 09:11:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:54865) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nqE1V-0005NH-U3 for guix-patches@gnu.org; Sun, 15 May 2022 09:11:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nqE1V-00021H-MH for guix-patches@gnu.org; Sun, 15 May 2022 09:11:01 -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: Sun, 15 May 2022 13:11:01 +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: Maxime Devos Cc: Pierre Langlois , 49946@debbugs.gnu.org Received: via spool by 49946-submit@debbugs.gnu.org id=B49946.16526202367718 (code B ref 49946); Sun, 15 May 2022 13:11:01 +0000 Received: (at 49946) by debbugs.gnu.org; 15 May 2022 13:10:36 +0000 Received: from localhost ([127.0.0.1]:48762 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nqE16-00020Q-9y for submit@debbugs.gnu.org; Sun, 15 May 2022 09:10:36 -0400 Received: from mout.gmx.net ([212.227.17.20]:58023) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nqE14-00020B-5L for 49946@debbugs.gnu.org; Sun, 15 May 2022 09:10:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1652620227; bh=B0Y4DSELNuHC5ocT64+KrCKinq/bMnNrb4ecpo1bFBo=; h=X-UI-Sender-Class:References:From:To:Cc:Subject:Date:In-reply-to; b=ZxrQBzyJn+hYTVF8Y607ga4EEHoTxQ237x2kT6mo6a85ksGOJhUpx3qamjQE5pE4B F2wlpiuv19FirexVe8sNu9cP/d9vFCRFFX31Ivcyx6E4JJh7vZ2HF0criTvIxi4A94 NO5I/AfrU4KCGAW9ayLEbHYxjd4l5hhm7qTIdCzY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from labiere ([82.69.64.142]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MkHQX-1nS7Tu2IUj-00keC7; Sun, 15 May 2022 15:10:27 +0200 References: <877d9s2qa9.fsf@gmx.com> <20220329194318.6106-1-pierre.langlois@gmx.com> <20220329194318.6106-28-pierre.langlois@gmx.com> <0fa9d98cb9038a24e8596858a8d37d63071937a2.camel@telenet.be> User-agent: mu4e 1.6.10; emacs 28.1 From: Pierre Langlois Date: Sun, 15 May 2022 13:20:48 +0100 In-reply-to: <0fa9d98cb9038a24e8596858a8d37d63071937a2.camel@telenet.be> Message-ID: <87bkvz54cg.fsf@gmx.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:BpoOQTGXsAkVZd6dUuGnI2V6jdwAUAuIONhiRgwSsOBoXvLWge0 1zT3XzrO2SpXOTgFfPnbMBO230Rhm6OITt4KZnJ35QuSbvV4TMqRjbuigbKpsSVBFs3WjE8 CUA7Ht+XXQyuVcf313HG0tkaFQoxyK4KDkTGwVR/HeAAyMGWYx+h3L8MAUND05T3LfHKtbw YRqP7rJSvk++xfVmCA60g== X-UI-Out-Filterresults: notjunk:1;V03:K0:8cssDhiFE2c=:qMlVbvj/evXtBlrf4DiFHa KjiAzJ2KPspRvKgnWZib2CAHbxDXUJBJit39fb5ZZPCAUs4BcTHs1s6obZMX2EgYiA50tO08I DHEG2m5AzKu2BVePAWseHvhQAUqwp5T9orSkg5pYX14KrlILcYNpd11kdro0478pppQXpimql xTrJ1kC8JA5qrCk+DB6w9mH1GyAKoA6CD/vzNJ0VJUhKfybm8XyrZB57LpWEKYBHrXPOn2dhs 3t21oa8+LdDkWW4r4dtE0lZcMnVTeYfUeQ4kUjk2Fq93jxRihJhZiOjaUoOx7Or1xGdjvgZLf rpXAq3kbzdkFYLrw+RV0bU82llVFyHN18hXpLck76Z0jCk8CxXb++41I+XNVkbiXshQ1DtU0l uDw+IadkrZmLxac6W8G16+tr8veV1RTJpC1dpAOxMJQ5WY6TeGWGkSgJrFcd+Vl9aUgz2z245 k+oNPyRixsN8YaYzey8y0/xhNwXDrJFXFFVoGcj3hpvQ1VxpvxJ+WCz6yp0kpNnGsZOkMO1pM 2TQU3oSLBvHSz6V6P1ZJbQfr770YMHsVwxmfA6n151RXWINkVKYgPOzpYOrLE9f1GUsJgyhk0 EBsMBmGpweZ3O4chYh9wx6ghNAXfbR7yyCQuNj1tQ0+icab+L2ofojwrXQtqQird1+mljMG2k NbfUN8lDwctxP4njO+GT/BR34VbRaqUXSV5GgCBUVn5qhnfmPl0PjUOI3IbpvZbgCgOmL8rGJ t4FXNlGH5bMC1tdcz5leRL2f2eKivbPOHgy/WqwgREp0JM/N74lxB3Z/+VY/GdEOkQrSAFtO5 N0HcNfFxuB5cCvpn9FH+EaiK8SVD//+L5HXYtAE33he0lqk542yMszp6/Qy3bKTZ3LrDl8KLA 3pH2H0ukzfALKIFQ/E6wB8jJxKdJiWuE9xfbk0QtiI9VEk6LPyIBwMzUlHAgtt8eWFznnUadx P87AHrPsnIpjVdXwmeXizWtXGgvUsxyg5h//BdfJPiOHNEMlFhfwZ6koec+mWEzWporA+EGJk iXnCwFVtsN7SbEzqYUePWzydN+ReAQFYnPxepRtc64UkKEk+TyKkfsrym2RWLxMziZEN52I3A 2F7RPzuk8/vhmT4tdawzrMLgfXMnoL5h7rbG3wEnlXtSVB+OUkhVwQCMQ== 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 Hi Maxime, sorry for the late reply! Maxime Devos writes: > [[PGP Signed Part:Undecided]] > Pierre Langlois schreef op di 29-03-2022 om 20:43 [+0100]: >> +                  ;; The BUNDLE-VERSION file prevents emacs-tree-sitter-langs >> +                  ;; from downloading libraries at load time. > > WDYT of patching emacs-tree-sitter-langs to not download, such that it > doesn't download and run non-Guix libraries behind the user's back? The way the current patchset works, by providing a compatible bundle, we already prevent emacs-tree-sitter-langs from downloading binaries by default. I agree we could go further though, and entirely remove the code that downloads binaries. However I'm not sure about it. Essentially, there is a tree-sitter-langs-build.el file [0] that can either download binaries or fetch sources and compile locally. So a user could decide to opt-out of using Guix binaries and instead use an alternative method. I 100% agree that by default we should make the package use Guix libraries, this way it also /just works/. However, if somebody wants to do things differently, I'm not sure we want to get in the way. In the end, this isn't so different from letting people use an alternative package manager if they like. We'd rather people used Guix of course :-). I don't have a really strong opinion about this though, so if you still prefer to delete the downloading code, I've attached an example patch that entirely replace it with a bare-bones implementation as an example. Let me know what you think! [0]: https://github.com/emacs-tree-sitter/tree-sitter-langs/blob/master/tree-sitter-langs-build.el > Also, why do we need a bundle at all, would simply installing emacs- > tree-sitter, and, e.g., tree-sitter-java, just work? Yeah, having a bundle is fundamentally how this package works AFAICT. I think the main reason is that in order to do highlighting effectively in emacs, it's not enough to install the tree-sitter runtime and a tree-sitter- grammar. You also want to "configure" how the highlighting is done by providing custom "queries" expressions. And this package provides queries for every language that it supports: https://github.com/emacs-tree-sitter/tree-sitter-langs/tree/master/queries All that being said, I believe that long-term the idea is that upstream language-specific packages would eventually gain support for tree-sitter and then this bundle "glue" package will no longer be necessary. Especially if one day emacs proper gains native support for tree-sitter (I think I saw some discussions about that on emacs-devel last year). But given this package is quite useful though, I'd be surprised if it goes away soon. Hope this makes sense! Thanks, Pierre > > Greetings, > Maxime. > > [[End of PGP Signed Part]] From 7ad62ccef2446011dfbdfb2dbe8cc58f46fb05d8 Mon Sep 17 00:00:00 2001 From: Pierre Langlois Date: Sat, 2 Apr 2022 19:22:52 +0100 Subject: [PATCH] wip --- gnu/packages/tree-sitter.scm | 49 ++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm index 7e14ebd1e3..d6892db6e3 100644 --- a/gnu/packages/tree-sitter.scm +++ b/gnu/packages/tree-sitter.scm @@ -795,11 +795,11 @@ (define-public emacs-tree-sitter @end enumerate") (license license:expat))) -(define (make-emacs-tree-sitter-langs-grammar-bundle version) +(define emacs-tree-sitter-langs-grammar-bundle (package (name "emacs-tree-sitter-langs-grammar-bundle") (source #f) - (version version) + (version (package-version tree-sitter)) (build-system trivial-build-system) (inputs ;; FIXME: Support for some languages is still left to package. @@ -836,11 +836,7 @@ (define (make-emacs-tree-sitter-langs-grammar-bundle version) (map (match-lambda ((name directory) (string-append directory "/lib/tree-sitter"))) - '#$(package-inputs this-package)))) - ;; The BUNDLE-VERSION file prevents emacs-tree-sitter-langs - ;; from downloading libraries at load time. - (call-with-output-file (string-append #$output "/BUNDLE-VERSION") - (lambda (port) (display #$version port))))))) + '#$(package-inputs this-package)))))))) (synopsis #f) (description #f) (home-page #f) @@ -861,7 +857,7 @@ (define-public emacs-tree-sitter-langs "1p2zbb6ac7wi6x6zpbczcmpkb2p45md2csd2bj43d8s56ckzw5mp")))) (build-system emacs-build-system) (inputs - (list (make-emacs-tree-sitter-langs-grammar-bundle version))) + (list emacs-tree-sitter-langs-grammar-bundle)) (propagated-inputs (list emacs-tree-sitter)) (arguments @@ -870,15 +866,36 @@ (define-public emacs-tree-sitter-langs #:test-command ''("script/test") #:phases #~(modify-phases %standard-phases + (add-after 'unpack 'disable-downloader + (lambda _ + (call-with-output-file "tree-sitter-langs-build.el" + (lambda (port) + (let ((on-load-message + (string-append + "tree-sitter-langs: Grammar bundle already installed " + "via Guix. Installing external grammars via this " + "function isn't supported, if a language you need is " + "missing please report a bug at bug-guix@gnu.org."))) + (format + port + ";;;###autoload + (defun tree-sitter-langs-install-grammars + (&optional skip-if-installed version os + keep-bundle) + (interactive) + (message \"~a\")) + (defconst tree-sitter-langs--queries-dir + (file-name-as-directory + (concat (file-name-directory (locate-library \"tree-sitter-langs.el\")) + \"queries\"))) + (defun tree-sitter-langs--bin-dir () \"~a\") + (provide 'tree-sitter-langs-build)" + on-load-message + #$emacs-tree-sitter-langs-grammar-bundle)))))) (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 version) - "bin"))) (add-before 'check 'patch-tree-sitter-require-test (lambda _ (use-modules (ice-9 regex)) @@ -906,12 +923,6 @@ (define-public emacs-tree-sitter-langs (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 version) - (string-append elpa "/bin"))))) (add-after 'install 'install-queries (lambda* (#:key outputs #:allow-other-keys) (let ((elpa (elpa-directory (assoc-ref outputs "out")))) -- 2.36.0