Subject: [bug#39877] [PATCH] Cleanup remaining guix.d/ Emacs packages, update doc

From: Maxim Cournoyer <[email-masked]>
Date: Mon, 02 Mar 2020 20:43:04 -0500

Hello,

The attached patches correct the last Emacs packages that were still
using the previous guix.d/ installation prefix, as well as the
documentation.

Thank you!

Maxim
From 3a9677dd027fac4403c318a722d9dbe383722e26 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Fri, 28 Feb 2020 23:42:59 -0500
Subject: [PATCH 1/8] gnu: emacs-magit: Remove obsolete make flags.

* gnu/packages/emacs-xyz.scm (emacs-magit): Remove make flags that were jadis
required to reference external Elisp libraries.  These are now made available
through EMACSLOADPATH.
---
 gnu/packages/emacs-xyz.scm | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index a9b36dd882..2ddf3c0645 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -291,7 +291,7 @@ on stdout instead of using a socket as the Emacsclient does.")
   (let ((commit "c761d28d49e5238037512b898db0ec9b40d85770"))
     (package
       (name "emacs-magit")
-      (version (git-version "2.90.1" "2" commit))
+      (version (git-version "2.90.1" "3" commit))
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
@@ -331,24 +331,10 @@ on stdout instead of using a socket as the Emacsclient does.")
                              (guix build emacs-utils))
          #:test-target "test"
          #:tests? #f                   ; tests are not included in the release
-
          #:make-flags
          (list (string-append "PREFIX=" %output)
                ;; Don't put .el files in a sub-directory.
-               (string-append "lispdir=" %output "/share/emacs/site-lisp")
-               (string-append "DASH_DIR="
-                              (assoc-ref %build-inputs "dash")
-                              "/share/emacs/site-lisp/guix.d/dash-"
-                              ,(package-version emacs-dash))
-               (string-append "WITH_EDITOR_DIR="
-                              (assoc-ref %build-inputs "with-editor")
-                              "/share/emacs/site-lisp/guix.d/with-editor-"
-                              ,(package-version emacs-with-editor))
-               (string-append "TRANSIENT_DIR="
-                              (assoc-ref %build-inputs "transient")
-                              "/share/emacs/site-lisp/guix.d/transient-"
-                              ,(package-version emacs-transient)))
-
+               (string-append "lispdir=" %output "/share/emacs/site-lisp"))
          #:phases
          (modify-phases %standard-phases
            (add-after 'unpack 'patch
-- 
2.25.0

From 1c03eca0b46a91cfe2944772cad9bb0c046de442 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sat, 29 Feb 2020 09:34:40 -0500
Subject: [PATCH 2/8] gnu: emacs-magit-svn: Use the emacs-build-system.

* gnu/packages/emacs-xyz.scm (emacs-magit-svn)[build-system]: Use the
emacs-build-system.
[arguments]: Remove.
---
 gnu/packages/emacs-xyz.scm | 41 ++------------------------------------
 1 file changed, 2 insertions(+), 39 deletions(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 2ddf3c0645..781259ee7e 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -396,7 +396,7 @@ operations.")
   (let ((commit "9e33ceee32f665db59909e1c00a667ccdd04178f"))
     (package
       (name "emacs-magit-svn")
-      (version (git-version "2.2.1" "1" commit))
+      (version (git-version "2.2.1" "2" commit))
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
@@ -406,48 +406,11 @@ operations.")
                 (sha256
                  (base32
                   "1mlqz8dh6jy5rv72lgkxv253dgh73fmbaidskicypapvbl3lr6xy"))))
-      (build-system trivial-build-system)
-      (native-inputs `(("emacs" ,emacs-minimal)))
+      (build-system emacs-build-system)
       (propagated-inputs `(("dash" ,emacs-dash)
                            ("with-editor" ,emacs-with-editor)
                            ("magit" ,emacs-magit)
                            ("transient" ,emacs-transient)))
-      (arguments
-       `(#:modules ((guix build utils)
-                    (guix build emacs-utils))
-
-         #:builder
-         (begin
-           (use-modules (guix build utils)
-                        (guix build emacs-utils))
-
-           (let ((emacs    (string-append (assoc-ref %build-inputs "emacs")
-                                          "/bin/emacs"))
-                 (magit    (string-append (assoc-ref %build-inputs "magit")
-                                          "/share/emacs/site-lisp"))
-                 (transient (string-append (assoc-ref %build-inputs "transient")
-                                           "/share/emacs/site-lisp/guix.d/transient-"
-                                           ,(package-version emacs-transient)))
-                 (dash     (string-append (assoc-ref %build-inputs "dash")
-                                          "/share/emacs/site-lisp/guix.d/dash-"
-                                          ,(package-version emacs-dash)))
-                 (with-editor (string-append (assoc-ref %build-inputs "with-editor")
-                                             "/share/emacs/site-lisp/guix.d/with-editor-"
-                                             ,(package-version emacs-with-editor)))
-                 (source   (assoc-ref %build-inputs "source"))
-                 (lisp-dir (string-append %output "/share/emacs/site-lisp")))
-
-             (install-file (string-append source "/magit-svn.el")
-                           lisp-dir)
-
-             (with-directory-excursion lisp-dir
-               (parameterize ((%emacs emacs))
-                 (emacs-generate-autoloads ,name lisp-dir)
-                 (setenv "EMACSLOADPATH"
-                         (string-append ":" magit ":" transient
-                                        ":" dash ":" with-editor))
-                 (emacs-batch-eval '(byte-compile-file "magit-svn.el"))))
-             #t))))
       (home-page "https://github.com/magit/magit-svn")
       (synopsis "Git-SVN extension to Magit")
       (description
-- 
2.25.0

From afd77eb4dbefa9ef5988de1e63c04def2404cd8c Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sat, 29 Feb 2020 09:48:55 -0500
Subject: [PATCH 3/8] gnu: emacs-guix: Remove unnecessary configure flags.

* gnu/packages/emacs-xyz.scm (emacs-guix)[arguments]: Remove.
---
 gnu/packages/emacs-xyz.scm | 41 --------------------------------------
 1 file changed, 41 deletions(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index 781259ee7e..dd54bbeaca 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -2094,47 +2094,6 @@ type, for example: packages, buffers, files, etc.")
                (base32
                 "0yz64c0z4ygi2k4af18k4r1ncgys18jb8icywkp2g5pgmpn5l7ps"))))
     (build-system gnu-build-system)
-    (arguments
-     `(#:configure-flags
-       (let ((guix        (assoc-ref %build-inputs "guix"))
-             (gcrypt      (assoc-ref %build-inputs "guile-gcrypt"))
-             (geiser      (assoc-ref %build-inputs "geiser"))
-             (dash        (assoc-ref %build-inputs "dash"))
-             (bui         (assoc-ref %build-inputs "bui"))
-             (magit-popup (assoc-ref %build-inputs "magit-popup"))
-             (edit-indirect (assoc-ref %build-inputs "edit-indirect"))
-             (site-lisp   "/share/emacs/site-lisp")
-             (site-scm    "/share/guile/site")
-             (site-go     "/lib/guile")
-             (guile-dir (lambda (dir)
-                          (car (find-files dir
-                                           (lambda (file stat)
-                                             (string-prefix?
-                                              "2." (basename file)))
-                                           #:directories? #t)))))
-         (list (string-append "--with-guix-site-dir="
-                              (guile-dir (string-append guix site-scm)))
-               (string-append "--with-guix-site-ccache-dir="
-                              (guile-dir (string-append guix site-go))
-                              "/site-ccache")
-               (string-append "--with-guile-gcrypt-site-dir="
-                              (guile-dir (string-append gcrypt site-scm)))
-               (string-append "--with-guile-gcrypt-site-ccache-dir="
-                              (guile-dir (string-append gcrypt site-go))
-                              "/site-ccache")
-               (string-append "--with-geiser-lispdir=" geiser site-lisp)
-               (string-append "--with-dash-lispdir="
-                              dash site-lisp "/guix.d/dash-"
-                              ,(package-version emacs-dash))
-               (string-append "--with-bui-lispdir="
-                              bui site-lisp "/guix.d/bui-"
-                              ,(package-version emacs-bui))
-               (string-append "--with-editindirect-lispdir="
-                              edit-indirect site-lisp "/guix.d/edit-indirect-"
-                              ,(package-version emacs-edit-indirect))
-               (string-append "--with-popup-lispdir="
-                              magit-popup site-lisp "/guix.d/magit-popup-"
-                              ,(package-version emacs-magit-popup))))))
     (native-inputs
      `(("pkg-config" ,pkg-config)
        ("emacs" ,emacs-minimal)))
-- 
2.25.0

From 77e78f7ea47f130bbcc135bad5001fae90ad5103 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sat, 29 Feb 2020 12:38:33 -0500
Subject: [PATCH 4/8] gnu: emacs-forge: Use the emacs-build-system.

This streamlines the package definition nicely and bring benefits, such as
having the Elisp files scanned for potential /bin/ programs and patched,
compressing the info manual, being able to compile the autoload file, and
installing the byte compiled files to the correct location (under site-lisp/).

* gnu/packages/emacs-xyz.scm (emacs-forge)[build-system]: Switch from the
gnu-build-system to the emacs-build-system.
[arguments]: Remove the #:modules and #:imported-modules arguments.  Delete
all the custom phases except the 'chdir-lisp one, and add a new
'build-info-manual phase.
---
 gnu/packages/emacs-xyz.scm | 53 +++++++++-----------------------------
 1 file changed, 12 insertions(+), 41 deletions(-)

diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index dd54bbeaca..cc72c4861d 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -18267,7 +18267,7 @@ a suffix) we prefer to call it just a \"transient\".")
   (let ((commit "63cbf81f166fc71861d8e3d246df8e5ccedcb9bb"))
     (package
       (name "emacs-forge")
-      (version (git-version "0.1.0" "2" commit))
+      (version (git-version "0.1.0" "3" commit))
       (source
        (origin
          (method git-fetch)
@@ -18278,7 +18278,7 @@ a suffix) we prefer to call it just a \"transient\".")
          (sha256
           (base32
            "1yf2xjx3459py6rji740jm8bmh2pv66ghnbjxsvjd4jf9kcdav83"))))
-      (build-system gnu-build-system)
+      (build-system emacs-build-system)
       (native-inputs
        `(("texinfo" ,texinfo)
          ("emacs" ,emacs-minimal)))
@@ -18293,51 +18293,22 @@ a suffix) we prefer to call it just a \"transient\".")
          ("emacs-transient" ,emacs-transient)))
       (arguments
        `(#:tests? #f ;no tests
-         #:modules ((srfi srfi-26)
-                    (guix build gnu-build-system)
-                    ((guix build emacs-build-system) #:prefix emacs:)
-                    (guix build utils)
-                    (guix build emacs-utils))
-         #:imported-modules (,@%gnu-build-system-modules
-                             (guix build emacs-build-system)
-                             (guix build emacs-utils))
          #:phases
          (modify-phases %standard-phases
-           (delete 'configure)
-           (delete 'install)
-           (add-after 'unpack 'delete-doc-targets
+           (add-after 'unpack 'build-info-manual
              (lambda _
-               (substitute* "./Makefile"
-                 (("lisp docs") "lisp"))))
-           (add-after 'delete-doc-targets 'chdir-lisp
+               (invoke "make" "info")
+               ;; Move the info file to lisp so that it gets installed by the
+               ;; emacs-build-system.
+               (rename-file "docs/forge.info" "lisp/forge.info")))
+           (add-after 'build-info-manual 'chdir-lisp
              (lambda _
-               (chdir "lisp")))
-           (add-after 'chdir-lisp 'emacs-install
-             (assoc-ref emacs:%standard-phases 'install))
-           (add-after 'emacs-install 'emacs-make-autoloads
-             (assoc-ref emacs:%standard-phases 'make-autoloads))
-           (add-after 'build 'install-elc
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (el-dir (string-append
-                               out "/share/emacs/site-lisp/guix.d/forge-"
-                               ,version)))
-                 (for-each (cut install-file <> el-dir)
-                           (find-files "." "\\.elc"))
-                 #t)))
-           (add-after 'install-elc 'install-doc
-             (lambda* (#:key outputs #:allow-other-keys)
-               (let* ((out (assoc-ref outputs "out"))
-                      (info (string-append out "/share/info")))
-                 (with-directory-excursion "../docs"
-                   (invoke "makeinfo" "forge.texi")
-                   (install-file "forge.info" info)
-                   #t)))))))
+               (chdir "lisp")
+               #t)))))
       (home-page "https://github.com/magit/forge/")
       (synopsis "Access Git forges from Magit")
-      (description
-       "Work with Git forges, such as Github and Gitlab, from the comfort of
-Magit and the rest of Emacs.")
+      (description "Work with Git forges, such as Github and Gitlab, from the
+comfort of Magit and the rest of Emacs.")
       (license license:gpl3+))))
 
 (define-public emacs-matcha
-- 
2.25.0

From e1422326a0d8b97f52b9b068bcb573710999dad4 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 1 Mar 2020 21:52:37 -0500
Subject: [PATCH 5/8] gnu: ghc-hindent: Remove guix.d from the Elisp
 installation directory.

* gnu/packages/haskell-xyz.scm (ghc-hindent)[phases]{emacs-install}: Update
the installation prefix directory.
---
 gnu/packages/haskell-xyz.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/haskell-xyz.scm b/gnu/packages/haskell-xyz.scm
index e368082c03..dd02c11ae6 100644
--- a/gnu/packages/haskell-xyz.scm
+++ b/gnu/packages/haskell-xyz.scm
@@ -5285,8 +5285,7 @@ descriptions.")
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let* ((out   (assoc-ref outputs "out"))
                     (elisp-file "elisp/hindent.el")
-                    (dest  (string-append out "/share/emacs/site-lisp"
-                                          "/guix.d/hindent-" ,version))
+                    (dest  (string-append out "/share/emacs/site-lisp"))
                     (emacs (string-append (assoc-ref inputs "emacs")
                                           "/bin/emacs")))
                (make-file-writable elisp-file)
-- 
2.25.0

From 3c7c0dc194f1070990bc4da8549cf51186ab82df Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 1 Mar 2020 22:11:47 -0500
Subject: [PATCH 6/8] gnu: cedille: Remove guix.d from the Elisp installation
 directory.

* gnu/packages/cedille.scm (cedille)[phases]{patch-cedille-path-el}: Update
the Elisp installation prefix used.
{copy-cedille-mode}: Likewise.
---
 gnu/packages/cedille.scm | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/cedille.scm b/gnu/packages/cedille.scm
index d3a6850f9f..d9cf66c501 100644
--- a/gnu/packages/cedille.scm
+++ b/gnu/packages/cedille.scm
@@ -56,17 +56,12 @@
              (let ((out (assoc-ref outputs "out")))
                (substitute* "cedille-mode.el"
                  (("/usr/share/emacs/site-lisp/cedille-mode")
-                  (string-append
-                   out "/share/emacs/site-lisp/guix.d/cedille-"
-                   ,version)))
+                  (string-append out "/share/emacs/site-lisp")))
                #t)))
          (add-after 'unpack 'copy-cedille-mode
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
-                    (lisp
-                     (string-append
-                      out "/share/emacs/site-lisp/guix.d/cedille-"
-                      ,version "/")))
+                    (lisp (string-append out "/share/emacs/site-lisp")))
                (mkdir-p (string-append lisp "cedille-mode"))
                (copy-recursively
                 "cedille-mode"
-- 
2.25.0

From 154d0470a659ed32f3c008d7c1fcb0d55f13c6ca Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 1 Mar 2020 22:34:41 -0500
Subject: [PATCH 7/8] gnu: emacs-mew: Remove guix.d from the Elisp installation
 directory.

* gnu/packages/mail.scm (emacs-mew)[arguments]: Update the Elisp installation
prefix.
---
 gnu/packages/mail.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index a2e8503ccd..9211ab34d6 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -673,7 +673,7 @@ repository and Maildir/IMAP as LOCAL repository.")
        ("ruby" ,ruby))) ; to set GEM_PATH so ruby-sqlite3 is found at runtime
     (build-system gnu-build-system)
     (arguments
-     (let ((elisp-dir "/share/emacs/site-lisp/guix.d/mew")
+     (let ((elisp-dir "/share/emacs/site-lisp")
            (icon-dir  "/share/mew"))
        `(#:modules ((guix build gnu-build-system)
                     (guix build utils)
-- 
2.25.0

From ca4a4d0effeca9046523b568ed79dd115e982fa9 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Sun, 1 Mar 2020 23:04:00 -0500
Subject: [PATCH 8/8] doc: Update to reflect the current installation prefix of
 Emacs packages.

* doc/guix.texi (Application Setup)[Emacs Packages]: No longer mention the
guix.d Elisp installation prefix.  Do not treat the user profile specially, as
it is not special anymore.
(Build Systems): Document the correct Elisp installation prefix.
---
 doc/guix.texi | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a66bb3d646..4371fbe0e1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -1737,22 +1737,18 @@ information.
 @subsection Emacs Packages
 
 @cindex @code{emacs}
-When you install Emacs packages with Guix, the elisp files may be placed
-either in @file{$HOME/.guix-profile/share/emacs/site-lisp/} or in
-sub-directories of
-@file{$HOME/.guix-profile/share/emacs/site-lisp/guix.d/}.  The latter
-directory exists because potentially there may exist thousands of Emacs
-packages and storing all their files in a single directory may not be
-reliable (because of name conflicts).  So we think using a separate
-directory for each package is a good idea.  It is very similar to how
-the Emacs package system organizes the file structure (@pxref{Package
-Files,,, emacs, The GNU Emacs Manual}).
-
-By default, Emacs (installed with Guix) ``knows'' where these packages
-are placed, so you do not need to perform any configuration.  If, for
-some reason, you want to avoid auto-loading Emacs packages installed
-with Guix, you can do so by running Emacs with @code{--no-site-file}
-option (@pxref{Init File,,, emacs, The GNU Emacs Manual}).
+When you install Emacs packages with Guix, the Elisp files are placed
+under the @file{share/emacs/site-lisp/} directory of the profile in
+which they are installed.  The Elisp libraries are made available to
+Emacs through the @code{EMACSLOADPATH} environment variable, which is
+set when installing Emacs itself.
+
+Additionally, autoload definitions are automatically evaluated at the
+initialization of Emacs, by the Guix-specific
+@code{guix-emacs-autoload-packages} procedure.  If, for some reason, you
+want to avoid auto-loading the Emacs packages installed with Guix, you
+can do so by running Emacs with the @code{--no-site-file} option
+(@pxref{Init File,,, emacs, The GNU Emacs Manual}).
 
 @subsection The GCC toolchain
 
@@ -6680,9 +6676,8 @@ of Emacs itself (@pxref{Packages,,, emacs, The GNU Emacs Manual}).
 It first creates the @code{@code{package}-autoloads.el} file, then it
 byte compiles all Emacs Lisp files.  Differently from the Emacs
 packaging system, the Info documentation files are moved to the standard
-documentation directory and the @file{dir} file is deleted.  Each
-package is installed in its own directory under
-@file{share/emacs/site-lisp/guix.d}.
+documentation directory and the @file{dir} file is deleted.  The Elisp
+package files are installed directly under @file{share/emacs/site-lisp}.
 @end defvr
 
 @defvr {Scheme Variable} font-build-system
-- 
2.25.0