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 ms5.migadu.com with LMTPS id mMrsOcYM5mMbRwEAbAwnHQ (envelope-from ) for ; Fri, 10 Feb 2023 10:22:15 +0100 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 ADwdOMYM5mN4QQAAG6o9tA (envelope-from ) for ; Fri, 10 Feb 2023 10:22:14 +0100 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 5E4356CD5 for ; Fri, 10 Feb 2023 10:22:14 +0100 (CET) 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 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676020934; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: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=eOaGVJv5enI2rfT+Cg34JrgtSSTvEThp9JcVlAyaKx8=; b=GHOhnBtupXJa+gCIjq9KdgIkRDXwrWmhIBi7D+OpL2SqC8bipYrvx4EQOHxVXjYSX73QcD 6dqVNaa7AsDSenjLVFDqAwW+DN8yB8e7APuIg1o9QQ9dVC5fNeJ3H9BCd3oZkevXrcy+a1 XndY8I7ffRb3jLZI5bydv+88emafhUOVRm9xcdH4LIRSdINVNRgSj6blM4DlW5AbCT3zeo 0HCJzDKkl1Eio6cYrcAD6rRn7c7Jr+pguck9XlYTDXnhWJw8iDzUiv1jnBjaJKvTFDhzZm s/croCPvTcyZjw4JdQbo6WHvbU4FxZufUQTOceHh0gkYtI4HL+WUKYMUt/K5Yw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=in+Lu2Pa; 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"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1676020934; a=rsa-sha256; cv=none; b=gaDItKfxYmp2/0ozlhQyGcZ9LWqkJwHDVlnCKeCfBKm39ZQ9VMedegOVA5oA+QiX2/X3ye Z63r6Rtq77b+hT5RDEmuGjTgSohawuB+zsihMxeh50CNG9IHyS/mN6sDpEVl95/2AZp85f pOtJhRmRW2vk3HGoMRYy1l4XKW+j6Nx8JxDy8nf/TYX8NXuECCWljw740GIBCPzulUgyfD MiakdpI0rKNfttluZnSmeEHSgQLkr7qZ9RxGg6FXzy+4PFVfx8me+5qP0Ba1yKDeF1qQ19 Zi3g+CCAPGi9sgYpmy3snH4cyWUdVTjIF4xHBBgws2DMjjfeoAVGzqwPAlo7kw== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -2.80 X-Spam-Score: -2.80 X-Migadu-Queue-Id: 5E4356CD5 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=trop.in header.s=gm1 header.b=in+Lu2Pa; 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"; dmarc=none X-TUID: n2VvxTA8EcwB --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain 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! --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-gnu-emacs-Add-TREE_SITTER_GRAMMAR_PATH-support.patch Content-Transfer-Encoding: quoted-printable From=20b5ecd4e3734e9dd0bc76ebe95cab9c43aa85a3fe 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. =2D-- 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 =2D-- 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))))))))))) =20 +;; If emacs built with tree-sitter, read the value of the environment vari= able +;; 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) =20 ;;; guix-emacs.el ends here diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm index 4ce41deb88..a3cc9d2e22 100644 =2D-- 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") =2D (files '("share/info"))))) + (files '("share/info"))) + ;; tree-sitter support is not yet available in emacs 28, but th= is + ;; 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"))))) =20 (home-page "https://www.gnu.org/software/emacs/") (synopsis "The extensible, customizable, self-documenting text editor") =2D-=20 2.39.1 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable =2D-=20 Best regards, Andrew Tropin --=-=-=-- --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEKEGaxlA4dEDH6S/6IgjSCVjB3rAFAmPmDI4ACgkQIgjSCVjB 3rAqMw/9EEOnkMMcWqA2434QvKazGX6eiN+bTLNcPz+5IZuVuKqbbU2k2F0tATEC Vy05t+XPVvhELzizGJRk/gxYwsuMpULNqu6YIuO2+asP45iw4tnH5Vdvf6RLOHKW WH+Fr+Fo6wDaEGztDCEY4ud/j1bsdtgrxxWgUmE6VgzBt7UJl1Y6LVJh0tSn/gNl tseYkXcYHn1bQUCHBIA03w45WNZ8bQMxRXGzvmiNUEPWJhGbkluk3TQuGXXezKKn O3tLuKwERxG4gRTC9Oj3uPWcv4RCxbQ2binNamT1KGFVpq1VdwA8WbDu41gp4Nk+ TIEw+G2JcbaxC3Om/p8oJsVsbYUaHtZlzysLhSjeg1mSQdqh6WanwuYif2cVFWQo uUEt7+rcfZyiLeDqlgiUZO5gv86k+LyB3q4/wf4W0B0Ij8AblLMMNgAeUukamq5p KfhuTRdAawL7ZijPCQ3QuDRJJ/x9OsK9s+WTNV2tITxfWwm6uQgtizwrpGwnUaPW 3gb/hwdhgdNjlsrICod9+8X++akY2bXcCJTfWKebeKsgzTj4fR5MIxIjeYDInd2E asuVGsep6y5lxCsz4gN4bMEQcDjpj5B1Y6zsi6FiiMylkuqWeHvWZZet3/LAQJXD ZxZRufLGz/zSpsW4W4nXKnr9LCgiY1HxthOYJHduveVpWIGFOz8= =ohCg -----END PGP SIGNATURE----- --==-=-=--