On Wed, Dec 30, 2015 at 5:55 PM, Federico Beffa <be...@ieee.org> wrote:
> On Wed, Dec 30, 2015 at 5:29 PM, Ludovic Courtès <l...@gnu.org> wrote:
>> Federico Beffa <be...@ieee.org> skribis:
>>
>>> If you install guix in the default prefix (/usr/local) you should find a
>>> file called 'guix.el' in /usr/local/share/emacs/site-lisp/.  With that
>>> you can include the following commands in your .emacs file and you
>>> should be all set:
>>>
>>> 1. (setq load-path (append '("/usr/local/share/emacs/site-lisp/") 
>>> load-path))
>>> 2. (require 'guix-init nil t)
>>>
>>> On some host distros step 1. may not even be needed.
>>
>> I don’t see how to make that happen automatically on foreign distros.
>> Any ideas?
>>
>> We still have the option of making it more prominent in the
>> documentation, for example by mentioning specifically Emacs under
>> <https://www.gnu.org/software/guix/manual/html_node/Application-Setup.html>.
>>
>> Thoughts?
>
> If we make an 'emacs-guix' package and make it an input to emacs it should 
> work.

Attached is a proof of concept patch showing one way to do it.

If you don't want to add the full 'guix.el', 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.

Regards,
Fede
From cb2a13f06c80d3b53451d15b5441cdc267666083 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.el functionality.

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

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index 4b23a54..739eed1 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,32 @@
              (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-el
+             (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: configure and byte-compile guix.el before installing
+                   (for-each (cut install-file <> site-lisp)
+                             (find-files "emacs" "\\.el")))
+                 #t))))))
     (inputs
      `(("gnutls" ,gnutls)
        ("ncurses" ,ncurses)
@@ -110,7 +129,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