Subject: [bug#30884] Status: [PATCH 0/6] gnu: Add emacs-epkg.

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 18 Apr 2018 21:09:06 -0400

Hi Oleg,

Oleg Pykhalov <[email-masked]> writes:

> Hello Ludovic,
>
> Thank you for review!
>
> I've applied all your suggestions except ‘set-emacs-load-path’.  First
> of all this procedure is not exported.

Phases are typically not exported individually, but as an alist of all
the phases of the build system, as `%standard-phases'.

> Another pitfall is ‘Invalid
> keyword’ error.
>
> diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
> index 6258dbaed..d290a61b4 100644
> --- a/gnu/packages/emacs.scm
> +++ b/gnu/packages/emacs.scm
> @@ -7733,7 +7733,8 @@ object has been freed.")
>                    ,@%gnu-build-system-modules
>                    (guix build emacs-utils))
>         #:imported-modules (,@%gnu-build-system-modules
> -                           (guix build emacs-utils))
> +                           (guix build emacs-utils)
> +                           (guix build emacs-build-system))
>         #:phases
>         (modify-phases %standard-phases
>           (delete 'configure)
> @@ -7744,22 +7745,8 @@ object has been freed.")
>               #t))
>           (add-after 'patch-elisp-shell-shebangs 'setenv-emacsloadpath
>             (lambda* (#:key inputs #:allow-other-keys)
> -             (define (el-dir store-dir)
> -               (match (find-files store-dir "\\.el$")
> -                 ((f1 f2 ...) (dirname f1))
> -                 (_ "")))
> -             (define emacs-prefix? (cut string-prefix? "emacs-" <>))
> -             (let* ((emacs-load-paths
> -                     (map (match-lambda
> -                            (((? emacs-prefix? name) . dir)
> -                             (string-append (el-dir dir) ":"))
> -                            (_ ""))
> -                          inputs))
> -                    (emacs-load-path-value
> -                     (string-concatenate emacs-load-paths)))
> -               (format #t "environment variable `EMACSLOADPATH' set to ~a\n"
> -                       emacs-load-path-value)
> -               (setenv "EMACSLOADPATH" emacs-load-path-value))
> +             ((@@ (guix build emacs-build-system) set-emacs-load-path)
> +               inputs)

As `set-emacs-load-path' is a phase itself, it expects to be called as
such, with keyworded arguments. It would be simpler to just insert the
phase as in:

--8<---------------cut here---------------start------------->8---
;; Add this to the define-module top level definition:
;; (define-module (gnu packages emacs)
;; ...
;; #:use-module ((guix build emacs-build-system) #:prefix emacs:)
;; ...

(add-after 'patch-elisp-shell-shebangs
           (assoc-ref emacs:%standard-phases 'set-emacs-load-path))
--8<---------------cut here---------------start------------->8---

HTH,

Maxim