Subject: [bug#66624] [PATCH emacs-team 05/15] gnu: emacs-mew: Adjust to changes in emacs-build-system.

From: Liliana Marie Prikler <[email-masked]>
Date: Thu, 19 Oct 2023 06:53:11 +0200

* gnu/packages/mail.scm (emacs-mew)[arguments]: Only let-bind icon-dir.
<#:modules>: Add (guix build emacs-build-system).
<#:imported-modules>: Use %emacs-build-system-modules.
<#:configure-flags>: Set elispdir with emacs:elpa-directory.
<#:phases>: Move ‘generate-autoloads’ after ‘unpack’.
Generate the autoloads locally.
Also enable compilation.
---
 gnu/packages/mail.scm | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index be458a2d92..84c7275ef6 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -1165,17 +1165,17 @@ (define-public emacs-mew
            "0xazygwdc328m5l31rxjazq9giv2xrygp2p2q455lf3jhdxwq1km"))))
       (build-system gnu-build-system)
       (arguments
-       (let ((elisp-dir #~(string-append #$output "/share/emacs/site-lisp"))
-             (icon-dir  #~(string-append #$output "/share/mew")))
+       (let ((icon-dir  #~(string-append #$output "/share/mew")))
          (list
           #:modules '((guix build gnu-build-system)
                       (guix build utils)
+                      ((guix build emacs-build-system) #:prefix emacs:)
                       (guix build emacs-utils))
-          #:imported-modules `(,@%gnu-build-system-modules
-                               (guix build emacs-utils))
+          #:imported-modules %emacs-build-system-modules
           #:tests? #f
           #:configure-flags
-          #~(list (string-append "--with-elispdir=" #$elisp-dir)
+          #~(list (string-append "--with-elispdir="
+                                 (emacs:elpa-directory #$output))
                   (string-append "--with-etcdir=" #$icon-dir))
           #:phases
           #~(modify-phases %standard-phases
@@ -1186,9 +1186,15 @@ (define-public emacs-mew
                      `(progn
                        (add-to-list 'image-load-path 'mew-icon-directory)
                        ,#$icon-dir)))))
-              (add-after 'install 'generate-autoloads
+              (add-after 'unpack 'generate-autoloads
                 (lambda _
-                  (emacs-generate-autoloads "mew" #$elisp-dir)))))))
+                  (emacs-generate-autoloads "mew" "elisp")
+                  (substitute* "elisp/mew-autoloads.el"
+                    ((";; no-byte-compile.*") ""))
+                  ;; Add generated autoloads to Makefile, so they get compiled
+                  (substitute* "elisp/Makefile"
+                    (("OBJS =") "OBJS = mew-autoloads.elc")
+                    (("SRCS =") "SRCS = mew-autoloads.el"))))))))
       (native-inputs
        (list emacs))
       (propagated-inputs
-- 
2.41.0