gnu: emacs: Use new package style.

* gnu/packages/emacs.scm (emacs)[source]<snippet>: Drop trailing ‘#t’.
[arguments]: Convert to list of G-Expressions.
Use ‘search-input-file’ where possible.
Inline references to auxiliary files.
Drop trailing ‘#t’s.
[inputs, native-inputs]: Drop labels.
This commit is contained in:
Liliana Marie Prikler 2022-04-10 13:28:05 +02:00
parent b65a1e4a21
commit 64557bc695
No known key found for this signature in database
GPG key ID: 442A84B8C70E2F87

View file

@ -41,6 +41,7 @@
(define-module (gnu packages emacs) (define-module (gnu packages emacs)
#:use-module ((guix licenses) #:prefix license:) #:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (guix gexp)
#:use-module (guix download) #:use-module (guix download)
#:use-module (guix git-download) #:use-module (guix git-download)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
@ -51,6 +52,7 @@ (define-module (gnu packages emacs)
#:use-module (gnu packages base) #:use-module (gnu packages base)
#:use-module (gnu packages compression) #:use-module (gnu packages compression)
#:use-module (gnu packages fontutils) #:use-module (gnu packages fontutils)
#:use-module (gnu packages freedesktop)
#:use-module (gnu packages fribidi) #:use-module (gnu packages fribidi)
#:use-module (gnu packages gd) #:use-module (gnu packages gd)
#:use-module (gnu packages gettext) #:use-module (gnu packages gettext)
@ -119,16 +121,16 @@ (define-public emacs
(list line (list line
"\"~/.guix-profile/include\"" "\"~/.guix-profile/include\""
"\"/var/guix/profiles/system/profile/include\"") "\"/var/guix/profiles/system/profile/include\"")
" "))) " ")))))))
#t))))
(build-system glib-or-gtk-build-system) (build-system glib-or-gtk-build-system)
(arguments (arguments
`(#:tests? #f ; no check target (list
#:configure-flags (list "--with-modules" #:tests? #f ; no check target
#:configure-flags #~(list "--with-modules"
"--with-cairo" "--with-cairo"
"--disable-build-details") "--disable-build-details")
#:phases #:phases
(modify-phases %standard-phases #~(modify-phases %standard-phases
(add-after 'unpack 'patch-program-file-names (add-after 'unpack 'patch-program-file-names
(lambda* (#:key inputs #:allow-other-keys) (lambda* (#:key inputs #:allow-other-keys)
(substitute* '("src/callproc.c" (substitute* '("src/callproc.c"
@ -137,32 +139,27 @@ (define-public emacs
"lisp/textmodes/artist.el" "lisp/textmodes/artist.el"
"lisp/progmodes/sh-script.el") "lisp/progmodes/sh-script.el")
(("\"/bin/sh\"") (("\"/bin/sh\"")
(format #f "~s" (which "sh")))) (format #f "~s" (search-input-file inputs "/bin/sh"))))
(substitute* "lisp/doc-view.el" (substitute* "lisp/doc-view.el"
(("\"(gs|dvipdf|ps2pdf)\"" all what) (("\"(gs|dvipdf|ps2pdf|pdftotext)\"" all what)
(let ((ghostscript (assoc-ref inputs "ghostscript"))) (let ((replacement (search-input-file
(if ghostscript inputs
(string-append "\"" ghostscript "/bin/" what "\"") (string-append "/bin/" what))))
all))) (if replacement
(("\"(pdftotext)\"" all what) (string-append "\"" replacement "\"")
(let ((poppler (assoc-ref inputs "poppler")))
(if poppler
(string-append "\"" poppler "/bin/" what "\"")
all)))) all))))
;; match ".gvfs-fuse-daemon-real" and ".gvfsd-fuse-real" ;; match ".gvfs-fuse-daemon-real" and ".gvfsd-fuse-real"
;; respectively when looking for GVFS processes. ;; respectively when looking for GVFS processes.
(substitute* "lisp/net/tramp-gvfs.el" (substitute* "lisp/net/tramp-gvfs.el"
(("\\(tramp-compat-process-running-p \"(.*)\"\\)" all process) (("\\(tramp-compat-process-running-p \"(.*)\"\\)" all process)
(format #f "(or ~a (tramp-compat-process-running-p ~s))" (format #f "(or ~a (tramp-compat-process-running-p ~s))"
all (string-append "." process "-real")))) all (string-append "." process "-real"))))))
#t))
(add-before 'configure 'fix-/bin/pwd (add-before 'configure 'fix-/bin/pwd
(lambda _ (lambda _
;; Use `pwd', not `/bin/pwd'. ;; Use `pwd', not `/bin/pwd'.
(substitute* (find-files "." "^Makefile\\.in$") (substitute* (find-files "." "^Makefile\\.in$")
(("/bin/pwd") (("/bin/pwd")
"pwd")) "pwd"))))
#t))
(add-after 'install 'install-site-start (add-after 'install 'install-site-start
;; Use 'guix-emacs' in "site-start.el", which is used autoload the ;; Use 'guix-emacs' in "site-start.el", which is used autoload the
;; Elisp packages found in EMACSLOADPATH. ;; Elisp packages found in EMACSLOADPATH.
@ -180,7 +177,8 @@ (define* (emacs-byte-compile-directory dir)
(invoke emacs "--quick" "--batch" (invoke emacs "--quick" "--batch"
(format #f "--eval=~s" expr)))) (format #f "--eval=~s" expr))))
(copy-file (assoc-ref inputs "guix-emacs.el") (copy-file #$(local-file
(search-auxiliary-file "emacs/guix-emacs.el"))
(string-append lisp-dir "/guix-emacs.el")) (string-append lisp-dir "/guix-emacs.el"))
(with-output-to-file (string-append lisp-dir "/site-start.el") (with-output-to-file (string-append lisp-dir "/site-start.el")
(lambda () (lambda ()
@ -196,8 +194,7 @@ (define* (emacs-byte-compile-directory dir)
;; which leads to conflicts. ;; which leads to conflicts.
(delete-file (string-append lisp-dir "/subdirs.el")) (delete-file (string-append lisp-dir "/subdirs.el"))
;; Byte compile the site-start files. ;; Byte compile the site-start files.
(emacs-byte-compile-directory lisp-dir)) (emacs-byte-compile-directory lisp-dir))))
#t))
(add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
;; restore the dump file that Emacs installs somewhere in ;; restore the dump file that Emacs installs somewhere in
;; libexec/ to its original state ;; libexec/ to its original state
@ -219,8 +216,7 @@ (define* (emacs-byte-compile-directory dir)
(with-directory-excursion (assoc-ref outputs "out") (with-directory-excursion (assoc-ref outputs "out")
(copy-file (copy-file
(car (find-files "bin" "^emacs-([0-9]+\\.)+[0-9]+$")) (car (find-files "bin" "^emacs-([0-9]+\\.)+[0-9]+$"))
"bin/emacs") "bin/emacs"))))
#t)))
(add-after 'strip-double-wrap 'wrap-emacs-paths (add-after 'strip-double-wrap 'wrap-emacs-paths
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
@ -234,9 +230,10 @@ (define* (emacs-byte-compile-directory dir)
;; Tramp. Tramp paths can't be hardcoded, because they ;; Tramp. Tramp paths can't be hardcoded, because they
;; need to be portable. ;; need to be portable.
`("PATH" suffix `("PATH" suffix
,(map (lambda (in) (string-append in "/bin")) ,(map dirname
(list (assoc-ref inputs "gzip") (list (search-input-file inputs "/bin/gzip")
(assoc-ref inputs "coreutils")))) ;; for coreutils
(search-input-file inputs "/bin/yes"))))
`("EMACSLOADPATH" suffix ,lisp-dirs))) `("EMACSLOADPATH" suffix ,lisp-dirs)))
(find-files (string-append out "/bin") (find-files (string-append out "/bin")
;; Matches versioned and unversioned emacs binaries. ;; Matches versioned and unversioned emacs binaries.
@ -246,56 +243,54 @@ (define* (emacs-byte-compile-directory dir)
;; like etags, ctags or ebrowse. ;; like etags, ctags or ebrowse.
"^emacs(-[0-9]+(\\.[0-9]+)*)?$")))))))) "^emacs(-[0-9]+(\\.[0-9]+)*)?$"))))))))
(inputs (inputs
`(("gnutls" ,gnutls) (list gnutls
("ncurses" ,ncurses) ncurses
;; Required for "core" functionality, such as dired and compression. ;; Required for "core" functionality, such as dired and compression.
("coreutils" ,coreutils) coreutils
("gzip" ,gzip) gzip
;; Avoid Emacs's limited movemail substitute that retrieves POP3 email ;; Avoid Emacs's limited movemail substitute that retrieves POP3
;; only via insecure channels. This is not needed for (modern) IMAP. ;; email only via insecure channels.
("mailutils" ,mailutils) ;; This is not needed for (modern) IMAP.
mailutils
;; TODO: Add the optional dependencies. ;; TODO: Add the optional dependencies.
("gpm" ,gpm) gpm
("libx11" ,libx11) libx11
("gtk+" ,gtk+) gtk+
("cairo" ,cairo) cairo
("pango" ,pango) pango
("harfbuzz" ,harfbuzz) harfbuzz
("libxft" ,libxft) libxft
("libtiff" ,libtiff) libtiff
("giflib" ,giflib) giflib
("libjpeg" ,libjpeg-turbo) libjpeg-turbo
("acl" ,acl) acl
("jansson" ,jansson) jansson
("gmp" ,gmp) gmp
("ghostscript" ,ghostscript) ghostscript
("poppler" ,poppler) poppler
;; When looking for libpng `configure' links with `-lpng -lz', so we ;; When looking for libpng `configure' links with `-lpng -lz', so we
;; must also provide zlib as an input. ;; must also provide zlib as an input.
("libpng" ,libpng) libpng
("zlib" ,zlib) zlib
("librsvg" ,@(if (target-x86-64?) (if (target-x86-64?)
(list librsvg-bootstrap) librsvg-bootstrap
(list librsvg-2.40))) librsvg-2.40)
("libxpm" ,libxpm) libxpm
("libxml2" ,libxml2) libxml2
("libice" ,libice) libice
("libsm" ,libsm) libsm
("alsa-lib" ,alsa-lib) alsa-lib
("dbus" ,dbus) dbus
;; multilingualization support ;; multilingualization support
("libotf" ,libotf) libotf
("m17n-lib" ,m17n-lib))) m17n-lib))
(native-inputs (native-inputs
`(("guix-emacs.el" ,(search-auxiliary-file "emacs/guix-emacs.el")) (list pkg-config texinfo))
("pkg-config" ,pkg-config)
("texinfo" ,texinfo)))
(native-search-paths (native-search-paths
(list (search-path-specification (list (search-path-specification
(variable "EMACSLOADPATH") (variable "EMACSLOADPATH")