Subject: [PATCH] gnu: emacs: Update to 27.1-rc1.

From: Jack Hill <[email-masked]>
Date: Thu, 6 Aug 2020 23:23:02 -0400

* gnu/packages/emacs.scm (emacs): Update to 27.1-rc1.
[arguments]: Add --with-harfbuzz and --with-modules to #configure-flags. Add
restore-emacs-pdump phase.
[inputs]: Add jansson and harfbuzz. Remove imagemagick.
---
 gnu/packages/emacs.scm | 68 ++++++++++++++++++++++++++----------------
 1 file changed, 43 insertions(+), 25 deletions(-)

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index ad8d4b0606..b809e90690 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -58,7 +58,6 @@
   #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages image)
-  #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages linux)     ; alsa-lib
   #:use-module (gnu packages mail)      ; for mailutils
   #:use-module (gnu packages ncurses)
@@ -75,18 +74,18 @@
 (define-public emacs
   (package
     (name "emacs")
-    (version "26.3")
+    (version "27.1")
     (source (origin
-              (method url-fetch)
-              (uri (string-append "mirror://gnu/emacs/emacs-"
-                                  version ".tar.xz"))
-              (sha256
-               (base32
-                "119ldpk7sgn9jlpyngv5y4z3i7bb8q3xp4p0qqi7i5nq39syd42d"))
-              (patches (search-patches "emacs-exec-path.patch"
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://git.savannah.gnu.org/git/emacs.git")
+                    (commit "emacs-27.1-rc1")))
+              (patches (search-patches "emacs27-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
                                        "emacs-ignore-empty-xim-styles.patch"
                                        "emacs-source-date-epoch.patch"))
+              (sha256
+               (base32 "1vyw8bpairxfxim931xg3pwyl3afh2mmjxa2i1igsaiaaxyssbc6"))
               (modules '((guix build utils)))
               (snippet
                '(with-directory-excursion "lisp"
@@ -94,16 +93,7 @@
                   ;; autoloads.
                   (for-each delete-file
                             (append (find-files "." "\\.elc$")
-                                    (find-files "." "loaddefs\\.el$")
-                                    ;; This is the only "autoloads" file that
-                                    ;; does not have "*loaddefs.el" name.
-                                    ;; TODO: Next time changing this package,
-                                    ;; replace the following with a call to
-                                    ;; `find-files', so that `delete-file'
-                                    ;; wouldn't error out when the file is
-                                    ;; missing, making the entire snippet field
-                                    ;; reusable as-is for `emacs-next' below.
-                                    '("eshell/esh-groups.el")))
+                                    (find-files "." "loaddefs\\.el$")))
 
                   ;; Make sure Tramp looks for binaries in the right places on
                   ;; remote Guix System machines, where 'getconf PATH' returns
@@ -129,7 +119,8 @@
     (build-system glib-or-gtk-build-system)
     (arguments
      `(#:tests? #f                      ; no check target
-       #:configure-flags (list "--with-modules"
+       #:configure-flags (list "--with-harfbuzz"
+                               "--with-modules"
                                "--disable-build-details")
        #:phases
        (modify-phases %standard-phases
@@ -180,9 +171,35 @@
                ;; which leads to conflicts.
                (delete-file (string-append lisp-dir "/subdirs.el"))
                ;; Byte compile the site-start files.
-               (emacs-byte-compile-directory lisp-dir)))))))
+               (emacs-byte-compile-directory lisp-dir))))
+         ;; Needed when building from git
+         (add-before
+             'reset-gzip-timestamps
+             'make-compressed-files-writable
+           (lambda _
+             (for-each make-file-writable
+                       (find-files %output ".*\\.t?gz$"))
+             #t))
+         ;; restore the dump file that Emacs installs somewhere in
+         ;; libexec/ to its original state
+         (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
+           (lambda* (#:key outputs target #:allow-other-keys)
+             (let* ((libexec (string-append (assoc-ref outputs "out")
+                                            "/libexec"))
+                    ;; each of these find-files should return one file
+                    (pdmp (find-files libexec "^emacs\\.pdmp$"))
+                    (pdmp-real (find-files libexec
+                                           "^\\.emacs\\.pdmp-real$")))
+               (when (not (null? pdmp-real))
+                 (for-each (lambda (wrapper real)
+                             (delete-file wrapper)
+                             (rename-file real wrapper))
+                           pdmp pdmp-real))
+               #t))))))
     (inputs
      `(("gnutls" ,gnutls)
+       ("jansson" ,jansson)
+       ("harfbuzz" ,harfbuzz)
        ("ncurses" ,ncurses)
 
        ;; Avoid Emacs's limited movemail substitute that retrieves POP3 email
@@ -196,7 +213,6 @@
        ("libtiff" ,libtiff)
        ("giflib" ,giflib)
        ("libjpeg" ,libjpeg-turbo)
-       ("imagemagick" ,imagemagick)
        ("acl" ,acl)
 
        ;; When looking for libpng `configure' links with `-lpng -lz', so we
@@ -218,6 +234,7 @@
     (native-inputs
      `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
        ("pkg-config" ,pkg-config)
+       ("autoconf" ,autoconf) ;Needed when building from git
        ("texinfo" ,texinfo)))
 
     (native-search-paths
@@ -360,7 +377,9 @@ languages.")
      `(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el"))
        ("ncurses" ,ncurses)))
     (native-inputs
-     `(("pkg-config" ,pkg-config)))))
+     `(("pkg-config" ,pkg-config)
+       ("autoconf" ,autoconf) ;Needed when building from git
+       ("texinfo" ,texinfo)))))
 
 (define-public emacs-xwidgets
   (package
@@ -387,8 +406,7 @@ editor (console only)")
     (inputs (fold alist-delete
                   (package-inputs emacs)
                   '("libx11" "gtk+" "libxft" "libtiff" "giflib" "libjpeg"
-                    "imagemagick" "libpng" "librsvg" "libxpm" "libice"
-                    "libsm"
+                    "libpng" "librsvg" "libxpm" "libice" "libsm"
 
                     ;; These depend on libx11, so remove them as well.
                     "libotf" "m17n-lib" "dbus")))))
-- 
2.28.0