GNU bug report logs - #49946
[PATCH 00/31] Tree-sitter, node-gyp addon support and emacs-tree-sitter

Previous Next

Package: guix-patches;

Reported by: Pierre Langlois <pierre.langlois <at> gmx.com>

Date: Sun, 8 Aug 2021 23:27:01 UTC

Severity: normal

Tags: patch

Full log


Message #557 received at 49946 <at> debbugs.gnu.org (full text, mbox):

From: Pierre Langlois <pierre.langlois <at> gmx.com>
To: 49946 <at> debbugs.gnu.org
Cc: Pierre Langlois <pierre.langlois <at> gmx.com>
Subject: Re: [PATCH v5 25/27] gnu: Add emacs-tree-sitter-core.
Date: Sun, 15 May 2022 16:22:31 +0100
[Message part 1 (text/plain, inline)]
Pierre Langlois <pierre.langlois <at> gmx.com> writes:

> * 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(+)
>
> diff --git a/gnu/packages/tree-sitter.scm b/gnu/packages/tree-sitter.scm
> index 5209876431..fb3d13b3c7 100644
> --- a/gnu/packages/tree-sitter.scm
> +++ b/gnu/packages/tree-sitter.scm
> @@ -21,6 +21,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 tree-sitter)
>    #:use-module (guix download)
> @@ -688,3 +689,80 @@ (define-public tree-sitter-typescript
>         "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.18.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
> +                "1sdvz827v436qijs6xafakkfw2d16bvp8frymd818rppjc7a9dif"))))
> +    (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 the version number 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 ,version port)))
> +               (substitute* "tsc-dyn-get.el"
> +                 (("defcustom tsc-dyn-dir tsc--dir")
> +                  (string-append "defcustom tsc-dyn-dir \"" elpa "\"")))

note to self: We can use emacs-subsitute-variables here.
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 2 years and 120 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.