Subject: Re: [bug#28832] [PATCH 1/3] gnu: Add emacs-json-reformat.

From: Oleg Pykhalov <[email-masked]>
Date: Tue, 19 Dec 2017 13:46:56 +0300

Hello Ludovic,

Thank you for refactoring notes!

[email-masked] (Ludovic Courtès) writes:

> I think it would have been better to open a separate issue for this.
> Here are some superficial comments.  I hope someone more knowledgeable
> about Emacs can comment.

OK, I CC [email-masked] in this message.

Previos discussion: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28832#17

> Oleg Pykhalov <[email-masked]> skribis:

[...]

> Please see ‘C-x v l’ in that file for the syntax of commit logs.  :-)

Oh, nice tip.  Thanks!

[...]

> Did you try rebuilding Emacs packages, and to simplify those that
> explicitly pass -L flags?

I tried it on emacs-json-reformat which wants many -L flags and
succeeded build a manifest with following packages and patch:

  emacs-aggressive-indent emacs-company emacs-company-quickhelp
  emacs-debbugs emacs-elfeed emacs-erc-hl-nicks emacs-default-encrypt
  emacs-god-mode emacs-ggtags emacs-git-gutter emacs-gitpatch emacs-guix
  emacs-helm emacs-helm-make emacs-helm-projectile
  emacs-highlight-stages emacs-ivy emacs-markdown-mode
  emacs-multiple-cursors emacs-nix-mode emacs-org emacs-projectile
  emacs-rainbow-delimiters emacs-rainbow-mode emacs-slime
  emacs-smartparens emacs-transmission emacs-transpose-frame
  emacs-use-package emacs-w3m emacs-which-key emacs-yasnippet
  emacs-yasnippet-snippets flycheck geiser magit

From c66f03c09517571a03fdf97b86bc571a71e969bf Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <[email-masked]>
Date: Wed, 13 Dec 2017 08:10:21 +0300
Subject: [PATCH] emacs-build-system: Handle EMACSLOADPATH environment
 variable.

Define the 'EMACSLOADPATH' environment variable to carry all inputs in tests.

* guix/build/emacs-build-system.scm (setup-environment): New procedure.
  (%standard-phases): Use the new setup-environment procedure.
---
 guix/build/emacs-build-system.scm | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/guix/build/emacs-build-system.scm b/guix/build/emacs-build-system.scm
index bd0d2e026..9897abf9e 100644
--- a/guix/build/emacs-build-system.scm
+++ b/guix/build/emacs-build-system.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2015 Federico Beffa <[email-masked]>
 ;;; Copyright © 2016 David Thompson <[email-masked]>
 ;;; Copyright © 2016 Alex Kost <[email-masked]>
+;;; Copyright © 2017 Oleg Pykhalov <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -222,6 +223,37 @@ second hyphen.  This corresponds to 'name-version' as used in ELPA packages."
             strip-store-file-name)
    store-dir))
 
+(define* (setup-environment #:key inputs #:allow-other-keys)
+  "Export the variable EMACSLOADPATH, which are based on INPUTS respectively."
+  (define (name+version input)
+    (package-name->name+version (strip-store-file-name input)))
+  (match (assoc "emacs" inputs)
+    ((name . input)
+     (setenv "EMACSLOADPATH"
+             (string-join (list input "share" name
+                                ((compose (lambda (_ version) version)
+                                          name+version)
+                                 input)
+                                "lisp")
+                          "/"))))
+  (for-each (match-lambda
+              ((name . input)
+               (setenv "EMACSLOADPATH"
+                       (string-append
+                        (or (getenv "EMACSLOADPATH") "")
+                        ":" input %install-suffix "/"
+                        ((compose (lambda (name version)
+                                    (string-append
+                                     (string-drop name
+                                                  (string-length "emacs-"))
+                                     "-" version))
+                                  name+version)
+                         input)))))
+            (fold alist-delete (emacs-inputs inputs) '("emacs" "source")))
+  (format #t "environment variable EMACSLOADPATH set to `~a'~%"
+          (getenv "EMACSLOADPATH"))
+  #t)
+
 (define %standard-phases
   (modify-phases gnu:%standard-phases
     (replace 'unpack unpack)
@@ -229,6 +261,7 @@ second hyphen.  This corresponds to 'name-version' as used in ELPA packages."
     (delete 'check)
     (delete 'install)
     (replace 'build build)
+    (add-before 'build 'setup-environment setup-environment)
     (add-before 'build 'install install)
     (add-after 'install 'make-autoloads make-autoloads)
     (add-after 'make-autoloads 'patch-el-files patch-el-files)
-- 
2.15.1

Oleg.