summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Streit <simon@netpanic.org>2022-11-01 20:54:45 +0100
committerSimon Streit <simon@netpanic.org>2023-06-19 21:36:36 +0200
commit0efabb89da2d521900c7ed613955b1a3c6d6b0d8 (patch)
treef85335861b992b03e88040dfd67c46090f8d3c72
parent7bbf0164f0515d5f89c8755434355a4ba0abd049 (diff)
siguix: emacs-lucid: Code clean-up.
* siguix/packages/emacs.scm (emacs-lucid): Make use of substitute-keyword-arguments.
-rw-r--r--siguix/packages/emacs.scm132
1 files changed, 6 insertions, 126 deletions
diff --git a/siguix/packages/emacs.scm b/siguix/packages/emacs.scm
index 628363d..98fcac7 100644
--- a/siguix/packages/emacs.scm
+++ b/siguix/packages/emacs.scm
@@ -84,133 +84,13 @@
(define-public emacs-lucid
(package/inherit emacs
(name "emacs-lucid")
-
(arguments
- `(#:tests? #f ; no check target
- #:configure-flags (list "--with-modules"
- ;; "--with-cairo"
- ;; "--disable-build-details"
- "--with-x-toolkit=lucid"
- "--without-gconf"
- "--without-gsettings")
- #:phases
- (modify-phases %standard-phases
- (add-after 'unpack 'patch-program-file-names
- (lambda* (#:key inputs #:allow-other-keys)
- (substitute* '("src/callproc.c"
- "lisp/term.el"
- "lisp/htmlfontify.el"
- "lisp/textmodes/artist.el"
- "lisp/progmodes/sh-script.el")
- (("\"/bin/sh\"")
- (format #f "~s" (which "sh"))))
- (substitute* "lisp/doc-view.el"
- (("\"(gs|dvipdf|ps2pdf)\"" all what)
- (let ((ghostscript (assoc-ref inputs "ghostscript")))
- (if ghostscript
- (string-append "\"" ghostscript "/bin/" what "\"")
- all)))
- (("\"(pdftotext)\"" all what)
- (let ((poppler (assoc-ref inputs "poppler")))
- (if poppler
- (string-append "\"" poppler "/bin/" what "\"")
- all))))
- ;; match ".gvfs-fuse-daemon-real" and ".gvfsd-fuse-real"
- ;; respectively when looking for GVFS processes.
- (substitute* "lisp/net/tramp-gvfs.el"
- (("\\(tramp-compat-process-running-p \"(.*)\"\\)" all process)
- (format #f "(or ~a (tramp-compat-process-running-p ~s))"
- all (string-append "." process "-real"))))
- #t))
- (add-before 'configure 'fix-/bin/pwd
- (lambda _
- ;; Use `pwd', not `/bin/pwd'.
- (substitute* (find-files "." "^Makefile\\.in$")
- (("/bin/pwd")
- "pwd"))
- #t))
- (add-after 'install 'install-site-start
- ;; Use 'guix-emacs' in "site-start.el", which is used autoload the
- ;; Elisp packages found in EMACSLOADPATH.
- (lambda* (#:key inputs outputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out"))
- (lisp-dir (string-append out "/share/emacs/site-lisp"))
- (emacs (string-append out "/bin/emacs")))
-
- ;; This is duplicated from emacs-utils to prevent coupling.
- (define* (emacs-byte-compile-directory dir)
- (let ((expr `(progn
- (setq byte-compile-debug t)
- (byte-recompile-directory
- (file-name-as-directory ,dir) 0 1))))
- (invoke emacs "--quick" "--batch"
- (format #f "--eval=~s" expr))))
-
- (copy-file (assoc-ref inputs "guix-emacs.el")
- (string-append lisp-dir "/guix-emacs.el"))
- (with-output-to-file (string-append lisp-dir "/site-start.el")
- (lambda ()
- (display
- (string-append
- "(when (require 'guix-emacs nil t)\n"
- " (guix-emacs-autoload-packages)\n"
- " (advice-add 'package-load-all-descriptors"
- " :after #'guix-emacs-load-package-descriptors))"))))
- ;; Remove the extraneous subdirs.el file, as it causes Emacs to
- ;; add recursively all the the sub-directories of a profile's
- ;; share/emacs/site-lisp union when added to EMACSLOADPATH,
- ;; which leads to conflicts.
- (delete-file (string-append lisp-dir "/subdirs.el"))
- ;; Byte compile the site-start files.
- (emacs-byte-compile-directory lisp-dir))
- #t))
- (add-after 'glib-or-gtk-wrap 'restore-emacs-pdmp
- ;; restore the dump file that Emacs installs somewhere in
- ;; libexec/ to its original state
- (lambda* (#:key outputs target #:allow-other-keys)
- (let* ((libexec (string-append (assoc-ref outputs "out")
- "/libexec"))
- ;; each of these ought to only match a single file,
- ;; but even if not (find-files) sorts by string<,
- ;; so the Nth element in one maps to the Nth element of
- ;; the other
- (pdmp (find-files libexec "\\.pdmp$"))
- (pdmp-real (find-files libexec "\\.pdmp-real$")))
- (for-each rename-file pdmp-real pdmp))))
- (add-after 'glib-or-gtk-wrap 'strip-double-wrap
- (lambda* (#:key outputs #:allow-other-keys)
- ;; Directly copy emacs-X.Y to emacs, so that it is not wrapped
- ;; twice. This also fixes a minor issue, where WMs would not be
- ;; able to track emacs back to emacs.desktop.
- (with-directory-excursion (assoc-ref outputs "out")
- (copy-file
- (car (find-files "bin" "^emacs-([0-9]+\\.)+[0-9]+$"))
- "bin/emacs")
- #t)))
- (add-after 'strip-double-wrap 'wrap-emacs-paths
- (lambda* (#:key inputs outputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out"))
- (lisp-dirs (find-files (string-append out "/share/emacs")
- "^lisp$"
- #:directories? #t)))
- (for-each
- (lambda (prog)
- (wrap-program prog
- ;; emacs-next and variants rely on uname being in PATH for
- ;; Tramp. Tramp paths can't be hardcoded, because they
- ;; need to be portable.
- `("PATH" suffix
- ,(map (lambda (in) (string-append in "/bin"))
- (list (assoc-ref inputs "gzip")
- (assoc-ref inputs "coreutils"))))
- `("EMACSLOADPATH" suffix ,lisp-dirs)))
- (find-files (string-append out "/bin")
- ;; Matches versioned and unversioned emacs binaries.
- ;; We don't patch emacsclient, because it takes its
- ;; environment variables from emacs.
- ;; Likewise, we don't need to patch helper binaries
- ;; like etags, ctags or ebrowse.
- "^emacs(-[0-9]+(\\.[0-9]+)*)?$"))))))))
+ (substitute-keyword-arguments (package-arguments emacs)
+ ((#:configure-flags flags #~'())
+ #~(cons* "--with-x-toolkit=lucid"
+ "--without-gconf"
+ "--without-gsettings"
+ #$flags))))
(inputs (modify-inputs (package-inputs emacs)
(append libxaw)))))