Subject: Re: [bug#49946] [PATCH v7 30/32] gnu: Add emacs-tree-sitter-core.

From: "(" <[email-masked]>
Date: Fri, 25 Nov 2022 07:22:54 +0000

On Fri Nov 25, 2022 at 1:21 AM GMT, Pierre Langlois wrote:
> * gnu/packages/tree-sitter.scm (tree-sitter-emacs-module): New local variable.
> (emacs-tree-sitter-core): New variable.

Please split these two into separate patches.

> --- a/gnu/packages/tree-sitter.scm
> +++ b/gnu/packages/tree-sitter.scm

> @@ -738,3 +739,86 @@ (define-public tree-sitter-typescript

> +    (arguments
> +     `(#:cargo-inputs

  (list #:cargo-inputs
        ...)

> +       #: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")))
> +               (mkdir-p lib)
> +               (copy-file "target/release/libtsc_dyn.so"
> +                          (string-append lib "/tsc-dyn.so"))))))))

Please use gexps and #$output here:

  (replace 'install
    (lambda _
      (let ((lib (string-append #$output "/lib")))
        (mkdir-p lib)
        (copy-file "target/release/libtsc_dyn.so"
                   (string-append lib "/tsc-dyn.so")))))

> +    (name "emacs-tree-sitter-core")
> +    (version (package-version tree-sitter-emacs-module))
> +    (source (package-source tree-sitter-emacs-module))

This ``version'' and ``source'' are unnecessary.

> +    (arguments
> +     `(#:phases

LIST, please.

> +       (modify-phases %standard-phases

Gexp this, please.

> +             (let ((elpa (elpa-directory (assoc-ref outputs "out")))

Please use #$output.

> +                   (module (search-input-file inputs "/lib/tsc-dyn.so")))

The leading / is redundant; this will do:

  (search-input-file inputs "lib/tsc-dyn.so")

    -- (