From patchwork Fri Feb 10 09:21:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Tropin X-Patchwork-Id: 46779 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 646CC16598; Fri, 10 Feb 2023 09:22:15 +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=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=ham 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 27BDA16559 for ; Fri, 10 Feb 2023 09:22:14 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQPbZ-0003kK-BE; Fri, 10 Feb 2023 04:22:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pQPbW-0003jw-ST for guix-patches@gnu.org; Fri, 10 Feb 2023 04:22:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pQPbW-0007Un-Jz for guix-patches@gnu.org; Fri, 10 Feb 2023 04:22:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pQPbW-0002pG-9A for guix-patches@gnu.org; Fri, 10 Feb 2023 04:22:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#49946] [PATCH 00/31] Tree-sitter, node-gyp addon support and emacs-tree-sitter Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 10 Feb 2023 09:22: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: Pierre Langlois , 49946@debbugs.gnu.org Cc: "\(" , Luis Henrique Gomes Higino , Liliana Marie Prikler , Nicolas Goaziou Received: via spool by 49946-submit@debbugs.gnu.org id=B49946.167602089410826 (code B ref 49946); Fri, 10 Feb 2023 09:22:02 +0000 Received: (at 49946) by debbugs.gnu.org; 10 Feb 2023 09:21:34 +0000 Received: from localhost ([127.0.0.1]:34338 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQPb3-0002oX-VR for submit@debbugs.gnu.org; Fri, 10 Feb 2023 04:21:34 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:65311) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQPb2-0002oK-1o for 49946@debbugs.gnu.org; Fri, 10 Feb 2023 04:21:33 -0500 Received: (Authenticated sender: andrew@trop.in) by mail.gandi.net (Postfix) with ESMTPSA id C13BF4000F; Fri, 10 Feb 2023 09:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop.in; s=gm1; t=1676020885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eOaGVJv5enI2rfT+Cg34JrgtSSTvEThp9JcVlAyaKx8=; b=in+Lu2Pazr8DskMCgcH348KI7+QR2nqI15GIxEAeMvEGyb1sSB6qbCtKWR9mOt8bm2h9He dP0WIHQGCFx5PRPCDbwy+XOL9zj/A1t7IdOIgpWdwqnLtdctnD+gdTeqT1qKfoiRrsHL0h sxSfe6kqBmREPmsU5aufVJie3M3JHyWzAYOz0W478Ekz6YIXwG4hONMg9myEM+bTITw/zv E/MiRfz9WREnNjLQU/zLHwVF6f53zYwhbcUP2T/hWFy2bXGCgriec/MBgNSLpRXJjRxW6p rq8GUW9EXXnVgi9ccUHtakQr65++u1tZyMKpAcmIU1Vi4crTTEvEhs1eenA6TQ== From: Andrew Tropin In-Reply-To: <87h7fztt60.fsf@gmx.com> References: <87h7fztt60.fsf@gmx.com> Date: Fri, 10 Feb 2023 13:21:18 +0400 Message-ID: <87edqxri41.fsf@trop.in> MIME-Version: 1.0 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-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches On 2021-08-08 23:29, Pierre Langlois wrote: > 4. Finally, emacs support! > > emacs-tree-sitter can be used for syntax highlighting, replacing > font-lock. The tree-sitter runtime library is built as a Rust crate > and exposed to emacs using a module thanks to the rust-emacs crate. > > Then emacs-tree-sitter-core provides just the core APIs as exposed by > the rust module, then emacs-tree-sitter integrates it with emacs' > syntax highlighting (and probably other things). > > Finally, we bundle together the various language grammars into a > single emacs-tree-sitter-langs package so that they can get loaded > along with their respective major modes. Note that there are grammars > left to support which I've not yet managed to package, but what we > have already is a good start I think :-). So far I've tested C++, > Rust, Python and JavaScript and JSON. > > * gnu: Add rust-bindgen@0.56. > * gnu: Add rust-tree-sitter. > * gnu: rust-emacs-module: Update to 0.16. > * gnu: rust-emacs-macros: Update to 0.17. > * gnu: rust-emacs: Update to 0.17. > * gnu: Add emacs-tree-sitter-core. > * gnu: Add emacs-tree-sitter. > * gnu: Add emacs-tree-sitter-langs. Hi Pierre! Implemented a loading of tree-sitter grammars in Emacs using guix native-search-paths and built-in treesit package. I did it for emacs package, but it will work only with Emacs 29 and greater (right now it's emacs-next and similiar packages), until emacs package updated to version 29 it won't take any effect on it except providing one more environment variable in guix profile. I tested it with emacs-next-pgtk, the patch is attached below, please let me know what do you think! From b5ecd4e3734e9dd0bc76ebe95cab9c43aa85a3fe Mon Sep 17 00:00:00 2001 From: Andrew Tropin Date: Fri, 10 Feb 2023 12:32:12 +0400 Subject: [PATCH] gnu: emacs: Add TREE_SITTER_GRAMMAR_PATH support. gnu/packages/emacs.scm (emacs)[native-search-paths]: Add a search-path for tree-sitter grammars. gnu/packages/aux-files/emacs/guix-emacs.el: Add directories from TREE_SITTER_GRAMMAR_PATH to treesit-extra-load-path. --- gnu/packages/aux-files/emacs/guix-emacs.el | 7 +++++++ gnu/packages/emacs.scm | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gnu/packages/aux-files/emacs/guix-emacs.el b/gnu/packages/aux-files/emacs/guix-emacs.el index 56dbcb8d67..708093267d 100644 --- a/gnu/packages/aux-files/emacs/guix-emacs.el +++ b/gnu/packages/aux-files/emacs/guix-emacs.el @@ -76,6 +76,13 @@ The files in the list do not have extensions (.el, .elc)." (when (file-directory-p pkg-dir) (package-load-descriptor pkg-dir))))))))))) +;; If emacs built with tree-sitter, read the value of the environment variable +;; to make tree-sitter grammars available in emacs out-of-the-box. +(with-eval-after-load 'treesit + (when-let ((grammar-path (getenv "TREE_SITTER_GRAMMAR_PATH"))) + (mapcar (lambda (x) (add-to-list 'treesit-extra-load-path x)) + (split-string grammar-path ":")))) + (provide 'guix-emacs) ;;; guix-emacs.el ends here diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm index 4ce41deb88..a3cc9d2e22 100644 --- a/gnu/packages/emacs.scm +++ b/gnu/packages/emacs.scm @@ -367,7 +367,15 @@ (define* (emacs-byte-compile-directory dir) (files '("lib/emacs/native-site-lisp"))) (search-path-specification (variable "INFOPATH") - (files '("share/info"))))) + (files '("share/info"))) + ;; tree-sitter support is not yet available in emacs 28, but this + ;; search path won't harm and also will be benifitial for + ;; emacs-next and other emacs-* packages, which have tree-sitter + ;; support enabled. Please, remove this comment, when emacs + ;; package is updated to 29. + (search-path-specification + (variable "TREE_SITTER_GRAMMAR_PATH") + (files '("lib/tree-sitter"))))) (home-page "https://www.gnu.org/software/emacs/") (synopsis "The extensible, customizable, self-documenting text editor") -- 2.39.1