From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 8PUZKDpz5mNvrgAAbAwnHQ (envelope-from ) for ; Fri, 10 Feb 2023 17:39:22 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 2Jv/Jzpz5mMoRAEA9RJhRA (envelope-from ) for ; Fri, 10 Feb 2023 17:39:22 +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 33B212E584 for ; Fri, 10 Feb 2023 17:39:22 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pQWQS-00032H-5u; Fri, 10 Feb 2023 11:39:04 -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 1pQWQQ-0002mp-Ot for guix-patches@gnu.org; Fri, 10 Feb 2023 11:39:02 -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 1pQWQQ-0000Pq-5U for guix-patches@gnu.org; Fri, 10 Feb 2023 11:39:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pQWQP-0000vS-Ow for guix-patches@gnu.org; Fri, 10 Feb 2023 11:39:01 -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: Pierre Langlois Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 10 Feb 2023 16:39: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: Andrew Tropin Cc: "\(" , Pierre Langlois , Liliana Marie Prikler , Nicolas Goaziou , Luis Henrique Gomes Higino , 49946@debbugs.gnu.org Received: via spool by 49946-submit@debbugs.gnu.org id=B49946.16760471223532 (code B ref 49946); Fri, 10 Feb 2023 16:39:01 +0000 Received: (at 49946) by debbugs.gnu.org; 10 Feb 2023 16:38:42 +0000 Received: from localhost ([127.0.0.1]:37970 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQWQ5-0000ut-IR for submit@debbugs.gnu.org; Fri, 10 Feb 2023 11:38:42 -0500 Received: from mout.gmx.net ([212.227.17.21]:55727) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pQWQ3-0000ue-9A for 49946@debbugs.gnu.org; Fri, 10 Feb 2023 11:38:39 -0500 Received: from labiere ([82.69.64.142]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N79yG-1oWSMr0Cmi-017YO0; Fri, 10 Feb 2023 17:38:29 +0100 References: <87h7fztt60.fsf@gmx.com> <87edqxri41.fsf@trop.in> User-agent: mu4e 1.8.13; emacs 28.2 From: Pierre Langlois Date: Fri, 10 Feb 2023 16:22:07 +0000 In-reply-to: <87edqxri41.fsf@trop.in> Message-ID: <87zg9lo4qq.fsf@gmx.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Provags-ID: V03:K1:JIkHk2Iu9ykxbCuxmfJzy+acW4FH57WLf/Lm56K4p0v+R9ToaVM 3rRaye8LHGnUToN2GbRe6fq5/oQ5ht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w26oEOhqUl0QEeZ 6asi98Cb5eUPkP9xyXc/9Z5OU9+WQ4Tc2L4Fbw9sH21HtsDc9CE6Qymwepd1fX93jy1cx1wfY Bs3uu2s/polfxhSoAObBHkVwpmM= 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-Seal: i=1; s=key1; d=yhetil.org; t=1676047162; a=rsa-sha256; cv=none; b=YebAfHm3dFieZZeuSRJiG7Hld3sRRs+AECkirygVuLnkiDxqC74ImHm/HGbWOaxYakAeh4 oY8tjDYsB/oqLvRUF7BhLmBAhavy8pjFSz5MHXJ8XOtps125aBFbd6jfRa8xlOjrFgEC2J BJqwvUE7TENf+V4JVEn/Us7RwIzcGAse2om1iHMOgmLUYfRwPhfWgFYSdPAIlfn828PYk8 uLWxCkLmd+xAqhXPy/fU2hvwsKo1drsvnD3mSWSy8493mSb8zxvWnS9Vbt3xoxlJm/ZYeP f11i2JL+GIL3zcADoPNV1F3myX5uvtFyOqsXQkIEVnjlps9xWw9qk1H+3zKmKQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=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"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmx.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1676047162; 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; bh=Wk9o8ztzhokk6MzPBpSNcSyCfMOjgSsStvs0rIEzPXY=; b=orgilUkEs30xM8Zwwwp9qxTLLXBi4+2qLGxXm9eoX+O25H0yp9VVN3vcB519VCEb1zt9NQ Qi1wCt1uWcbEADy9tmhzm7hK37y4pUg8o3CifPq3dEN4YcIPAm0MBL9l/A49//cwVas7qi loESlsutAN3S+LcEMOhrEX5SSOCplJOrdzYs5DUXFU4JOjsH+nwYU9xYaaf4Nrs4wFqUFL dGVQiWLCJS4RWwyMKmdKpofWAFy+VAx7XIoVOCxm9tqvlBFIROsXFoVygVIToNFxonF+Dc 6m/eanPUMj7Pb4aadtmtHbQnbaPUCBfDYHLwbvKdDDRWQxwAwfaJ1SXcm9RjIA== X-Migadu-Scanner: scn0.migadu.com X-Spam-Score: -2.51 X-Migadu-Queue-Id: 33B212E584 X-Migadu-Spam-Score: -2.51 Authentication-Results: aspmx1.migadu.com; dkim=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"; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmx.com (policy=none) X-TUID: BMnMsV4Pge4j --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Hi, Andrew Tropin writes: > [[PGP Signed Part:Undecided]] > 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! This is cool, thanks! I'm not familiar with how upstream emacs loads grammars so I can't comment too much on the details. That being said, I think it'd be good to get it to work with emacs 28 as well, I've been using it for the past 6 months and it's working nicely. I'm happy to take care of that part of the work though and let others focus on emacs-next. We have the following packages for emacs 28 support: >> * 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. Most of those would eventually go away I think, except probably emacs-tree-sitter-langs, which is really useful to provide basic tree-sitter syntax highlighint support to many language modes that may not need to be changed themselves. For instance, there is a PR to eventually move over to using the core emacs 29 treesit module: https://github.com/emacs-tree-sitter/tree-sitter-l= angs/pull/157 > > 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/au= x-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, .el= c)." > (when (file-directory-p pkg-dir) > (package-load-descriptor pkg-dir))))))))))) >=20=20 > +;; If emacs built with tree-sitter, read the value of the environment va= riable > +;; 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=20 > ;;; 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-sit= ter > + ;; 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=20 > (home-page "https://www.gnu.org/software/emacs/") > (synopsis "The extensible, customizable, self-documenting text edito= r") > --=20 > 2.39.1 LGTM! Thanks, Pierre --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQFMBAEBCgA2FiEEctU9gYy29KFyWDdMqPyeRH9PfVQFAmPmcv4YHHBpZXJyZS5s YW5nbG9pc0BnbXguY29tAAoJEKj8nkR/T31UMH4H/0Ax9b3V09Wzp5u2bNaEMwNf LIRZO79oReySOCO8+TRQdtpIZrPXIbK+XbyTsgw48luezLOOEf7sE32tap05SiFj ZyfpPuEbxDglw8vHNx/vo72DpklF0RdCNEWRSk4MbswALWXb301XroeOy6/GUMJq 170hVM9zjkrtt1cNbiO7+cFUQK+eK2Z3z646Wv/dOYVMlOW1LBLDqcj3rEA1vn/m koLZthidyeAIT4Inm0ze7rSyqyGLjjocpkT5VzL81El5B/Riqqrh3vuD6tCFB5uQ /58Zu7PjhnVCcUskr/gwUNYFuIPggHWSIn4yOmI5wCuVB+sU9+6IDYyHjGvfkyI= =nLvU -----END PGP SIGNATURE----- --=-=-=--