Subject: [PATCH v3 4/4] gnu: quilt: Build emacs package.

From: Morgan Smith <[email-masked]>
Date: Sun, 13 Apr 2025 13:39:46 -0400

* gnu/packages/patchutils.scm (quilt): Build emacs package.

Change-Id: I4d70ad1c137a377f71cd9d3f1b69f5ed95e4debd
---

Look at this absolute abomination!  I'm so proud of this!

Please tell me all the reasons why this a terrible idea because I know it is
but the specific reasons elude me.

 gnu/packages/patchutils.scm | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/patchutils.scm b/gnu/packages/patchutils.scm
index 3da1e7b3b4..64283d4ac1 100644
--- a/gnu/packages/patchutils.scm
+++ b/gnu/packages/patchutils.scm
@@ -44,6 +44,7 @@ (define-module (gnu packages patchutils)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages django)
+  #:use-module (gnu packages emacs)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages file)
   #:use-module (gnu packages gawk)
@@ -179,7 +180,7 @@ (define-public quilt
         (base32 "09l4nf6qb8y8l62z8ypdg5mraz0lvqxg1j1p6xdyh1n10gg0k37y"))))
     (build-system gnu-build-system)
     (native-inputs
-     (list gettext-minimal))
+     (list emacs-minimal gettext-minimal))
     (inputs
      (list bash-minimal perl less file gzip ed
            diffutils diffstat findutils tar
@@ -187,8 +188,31 @@ (define-public quilt
            guile-3.0))
     (arguments
      (list
+      #:imported-modules `(,@%default-gnu-imported-modules
+                           (guix build emacs-build-system)
+                           (guix build emacs-utils))
+      #:modules `(,@%default-gnu-modules
+                  ((guix build emacs-build-system) #:prefix emacs:)
+                  (guix build emacs-utils))
       #:phases
       #~(modify-phases %standard-phases
+          (add-after 'unpack 'emacs-build
+            (lambda* (#:rest args)
+              ;; Don't build using makefile
+              (substitute* "Makefile.in"
+                ((".*lib/quilt.el.*") ""))
+              (with-directory-excursion "lib"
+                ;; Run the `emacs-build-system' phases that aren't 'unpack' or
+                ;; duplicated in %standard-phases
+                (for-each
+                 (lambda (phase)
+                   (apply (cdr phase)
+                          ;; No tests
+                          (append args '(#:tests? #f))))
+                 (filter (lambda (phase)
+                           (not (or (eq? 'unpack (car phase))
+                                    (memq phase %standard-phases))))
+                         emacs:%standard-phases)))))
           (delete 'check)
           (add-after 'install 'wrap-script
             ;; quilt's configure checks for the absolute path to the utilities it
-- 
2.49.0