On Sat, Jan 2, 2016 at 3:13 PM, Alex Kost <alez...@gmail.com> wrote:
> Federico Beffa (2016-01-01 19:53 +0300) wrote:
>
>> On Fri, Jan 1, 2016 at 5:28 PM, Alex Kost <alez...@gmail.com> wrote:
>>> Ludovic Courtès (2016-01-01 18:22 +0300) wrote:
>>>
>>>>> then we should definitely add code in a similar way to instruct emacs
>>>>> to look in the right places (".../guix.d") for our emacs packages out
>>>>> of the box.  As Dmitry rightfully points out, having emacs packages
>>>>> which do not work out of the box is just a bug.
>>>>
>>>> Yeah.  Alex, any idea how to add the guix.d subdirectories to the search
>>>> path without duplicating all of guix.el in the ‘emacs’ package?
>>>
>>> Yeah, no need to duplicate all of the guix elisp files.  Only
>>> "guix-emacs.el" (and its dependencies: "guix-profiles.el" and
>>> "guix-config.el") is needed.  And instead of (require 'guix-init) the
>>> following code should be used to "activate" our .guix.d directories:
>>
>> there's no 'guix-config.el', but only 'guix-config.el.in'. It would be
>> great if you could provide a working patch.
>
> Hm, OK, so your "proof of concept patch" will have the same problem.
> Could you please answer
> <http://lists.gnu.org/archive/html/guix-devel/2016-01/msg00021.html>, as
> I still don't understand how your suggestion can help Emacs to find
> packages in "guix.d" dirs of user profile.

That's the easy part. Once we know how to load a minimal version of
your code, we add it to 'site-start.el'. Emacs automatically loads it.

> Returning to 'guix-config' problem, we can make a "soft" dependency on
> 'guix-profiles' (see the attached patch), so the only file needed for
> finding emacs packages in "guix.d" will be "guix-emacs.el".  And the
> code that should be loaded by Emacs to find guix emacs packages will be:
>
> (when (require 'guix-emacs nil t)
>   (add-to-list 'load-path (guix-emacs-directory))
>   (guix-emacs-load-autoloads))
>

I've done this, but it doesn't load as 'guix-config' is missing. I
guess it needs your patch which I didn't try.

Fede
From 5d1ada998bdb8755845914d28757d142ed8de8bf Mon Sep 17 00:00:00 2001
From: Federico Beffa <be...@fbengineering.ch>
Date: Fri, 1 Jan 2016 15:12:40 +0100
Subject: [PATCH] gnu: emacs: Add 'guix.d' directories to 'load-path'.

* gnu/packages/emacs.scm (emacs): Convert to 'modify-phases' syntax.  Add
  'guix-src' input and 'install-guix-emacs phase.
---
 gnu/packages/emacs.scm | 48 +++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 39 insertions(+), 9 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index eb50b52..9b8b7cf 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -56,6 +56,7 @@
   #:use-module (gnu packages xml)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages acl)
+  #:use-module (gnu packages package-management)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pdf)
   #:use-module (gnu packages scheme)
@@ -78,14 +79,42 @@
              (patches (list (search-patch "emacs-exec-path.patch")))))
     (build-system glib-or-gtk-build-system)
     (arguments
-     '(#:phases (alist-cons-before
-                 'configure 'fix-/bin/pwd
-                 (lambda _
-                   ;; Use `pwd', not `/bin/pwd'.
-                   (substitute* (find-files "." "^Makefile\\.in$")
-                     (("/bin/pwd")
-                      "pwd")))
-                 %standard-phases)))
+     `(#:modules ((guix build glib-or-gtk-build-system)
+                  (guix build utils)
+                  (srfi srfi-26))
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'configure 'fix-/bin/pwd
+           (lambda _
+             ;; Use `pwd', not `/bin/pwd'.
+             (substitute* (find-files "." "^Makefile\\.in$")
+               (("/bin/pwd")
+                "pwd"))))
+         (add-after 'install 'install-guix-emacs
+             (lambda* (#:key inputs outputs #:allow-other-keys)
+               (let* ((guix-src (assoc-ref inputs "guix-src"))
+                      (out (assoc-ref outputs "out"))
+                      (site-lisp (string-append out "/share/emacs/"
+                                                ,(version-major+minor version)
+                                                "/site-lisp"))
+                      (unpack (assoc-ref %standard-phases 'unpack)))
+                 (mkdir "guix")
+                 (with-directory-excursion "guix"
+                   (apply unpack (list #:source guix-src))
+                   ;; FIXME: miss cl-lib
+                   (install-file "emacs/guix-emacs.el" site-lisp))
+                 (with-directory-excursion site-lisp
+                   (with-output-to-file "site-start.el"
+                     (lambda ()
+                       (display "(when (require 'guix-emacs nil t)
+  (add-to-list 'load-path (guix-emacs-directory))
+  (guix-emacs-load-autoloads))"))))
+                 (zero?
+                  (let ((expr `(byte-recompile-directory
+                                (file-name-as-directory ,site-lisp) 0)))
+                    (system*
+                     (string-append out "/bin/emacs") "--quick" "--batch"
+                     (format #f "--eval=~S" expr))))))))))
     (inputs
      `(("gnutls" ,gnutls)
        ("ncurses" ,ncurses)
@@ -110,7 +139,8 @@
        ("libice" ,libice)
        ("libsm" ,libsm)
        ("alsa-lib" ,alsa-lib)
-       ("dbus" ,dbus)))
+       ("dbus" ,dbus)
+       ("guix-src" ,(package-source guix))))
     (native-inputs
      `(("pkg-config" ,pkg-config)
        ("texinfo" ,texinfo)))
-- 
2.6.3

Reply via email to