;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013-2017, 2019, 2021-2022, 2025 Ludovic Courtès ;;; Copyright © 2013 Andreas Enge ;;; Copyright © 2014 Taylan Ulrich Bayirli/Kammer ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Mark H Weaver ;;; Copyright © 2014, 2015, 2016, 2017 Alex Kost ;;; Copyright © 2016, 2018 Arun Isaac ;;; Copyright © 2016 Federico Beffa ;;; Copyright © 2016 David Thompson ;;; Copyright © 2016 Nikita ;;; Copyright © 2017 Marius Bakke ;;; Copyright © 2017, 2019, 2020, 2023, 2024 Maxim Cournoyer ;;; Copyright © 2017 Alex Vong ;;; Copyright © 2017, 2018 Ricardo Wurmus ;;; Copyright © 2017, 2023, 2024, 2025 Janneke Nieuwenhuizen ;;; Copyright © 2018, 2023 Efraim Flashner ;;; Copyright © 2018 Mathieu Othacehe ;;; Copyright © 2018, 2019, 2021 Tobias Geerinckx-Rice ;;; Copyright © 2019 Jesse John Gildersleve ;;; Copyright © 2019 Valentin Ignatev ;;; Copyright © 2019, 2021 Liliana Marie Prikler ;;; Copyright © 2019 Amin Bandali ;;; Copyright © 2020 Jack Hill ;;; Copyright © 2020 Morgan Smith ;;; Copyright © 2022 Zhu Zihao ;;; Copyright © 2023 Declan Tsien ;;; Copyright © 2023, 2024 Zheng Junjie <873216071@qq.com> ;;; Copyright © 2025 Nicolas Graves ;;; Copyright © 2025 Jake Forster ;;; Copyright © 2025 John Kehayias ;;; Copyright © 2026 Daniel Littlewood ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages emacs) #:use-module (guix deprecation) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix packages) #:use-module (guix gexp) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix build-system) #:use-module (guix build-system gnu) #:use-module (guix build-system glib-or-gtk) #:use-module (gnu packages) #:use-module (gnu packages acl) #:use-module (gnu packages autotools) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages check) #:use-module (gnu packages compression) #:use-module (gnu packages fontutils) #:use-module (gnu packages freedesktop) #:use-module (gnu packages fribidi) #:use-module (gnu packages gawk) #:use-module (gnu packages gcc) #:use-module (gnu packages gd) #:use-module (gnu packages gettext) #:use-module (gnu packages ghostscript) #:use-module (gnu packages glib) #:use-module (gnu packages gnome) ; for librsvg #:use-module (gnu packages gtk) #:use-module (gnu packages guile) #:use-module (gnu packages image) #:use-module (gnu packages imagemagick) #:use-module (gnu packages language) ; m17n-db, m17n-lib #:use-module (gnu packages toolkits) ; motif #:use-module (gnu packages linux) ; alsa-lib, gpm #:use-module (gnu packages mail) ; for mailutils #:use-module (gnu packages multiprecision) #:use-module (gnu packages ncurses) #:use-module (gnu packages pdf) #:use-module (gnu packages pkg-config) #:use-module (gnu packages selinux) #:use-module (gnu packages sqlite) #:use-module (gnu packages texinfo) #:use-module (gnu packages tls) #:use-module (gnu packages tree-sitter) #:use-module (gnu packages web) ; for jansson #:use-module (gnu packages webkit) #:use-module (gnu packages xml) #:use-module (gnu packages xorg) #:use-module (guix utils) #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:export (emacs->emacs-next)) (define (%emacs-modules build-system) (let ((which (build-system-name build-system))) `((guix build ,(symbol-append which '-build-system)) (guix build utils) (srfi srfi-1) (ice-9 ftw)))) (define* (emacs-ert-selector excluded-tests #:key run-nativecomp run-expensive run-unstable) "Create an ERT selector that excludes tests." (string-append "(not (or " (if run-nativecomp "" "(tag :nativecomp) ") (if run-expensive "" "(tag :expensive-test) ") (if run-unstable "" "(tag :unstable) ") (string-join (map (lambda (test) ;; This is a regex (string-append "\\\"^" test "\\$\\\"")) (sort excluded-tests stringemacs-next emacs #:optional name #:key (version (package-version emacs-next-minimal)) (source (package-source emacs-next-minimal))) (package (inherit emacs) (name (or name (and (string-prefix? "emacs" (package-name emacs)) (string-append "emacs-next" (string-drop (package-name emacs) (string-length "emacs")))))) (version version) (source source) (arguments (substitute-keyword-arguments arguments ((#:make-flags flags #~'()) #~(append #$flags (list (string-append "SELECTOR=" #$%emacs-next-selector)))))))) (define-public emacs-next (emacs->emacs-next emacs)) (define-public emacs-next-pgtk (emacs->emacs-next emacs-pgtk)) (define-public emacs-next-lucid (emacs->emacs-next emacs-lucid)) (define-public guile-emacs (let ((upstream-version "31.0.50") (commit "f2d0459d6a4cda8b7c38b6fb12a55f1330ba50fa") (revision "2")) (package (inherit emacs) (name "guile-emacs") (version (git-version upstream-version revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://codeberg.org/lyrra/guilemacs") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "0ry0dn9xrndpz54hs92dnnsw4xa4qn4lz898ldlh2rs47ah1f4wl")))) (native-inputs (modify-inputs native-inputs (prepend autoconf automake guile-for-guile-emacs))) (inputs (modify-inputs inputs (prepend imagemagick))) (home-page "https://guile-emacs.org") (synopsis "Emacs text editor powered by Guile('s elisp implementation)") (description "Guile-Emacs brings Emacs and Guile together by providing a new Elisp implementation based on Guile's compiler technology, serving as the basis for a more expressive and extensible version of Elisp. Started in 2014 as a GSOC project, Guile-Emacs was resurrected in 2024.") (arguments (substitute-keyword-arguments `(#:strip-binaries? #f ,@(package-arguments emacs)) ((#:configure-flags flags ''()) #~`(#$(string-append "CFLAGS=-Og -ggdb3" " -Wno-error=implicit-function-declaration" " -Wno-error=implicit-int" " -Wno-error=incompatible-pointer-types" " -Wno-error=int-conversion" " -Wno-error=shift-count-negative") "--with-native-compilation=no" "--without-modules" "--without-threads" "--with-jpeg=no" "--without-cairo" "--without-tree-sitter" "--with-imagemagick" ,@(fold delete #$flags '("CFLAGS=-g -O2 -Wno-error=incompatible-pointer-types" "--with-cairo" "--with-modules" "--with-native-compilation=aot")))) ((#:make-flags flags #~'()) #~(list "V=1")) ((#:phases phases) #~(modify-phases #$phases (add-after 'unpack 'autogen (lambda _ (invoke "sh" "autogen.sh"))) (delete 'patch-compilation-driver) (delete 'set-libgccjit-path) (delete 'validate-comp-integrity) (delete 'restore-emacs-pdmp) (delete 'build-trampolines) (delete 'install-site-start) (replace 'wrap-emacs-paths ;; Restrict EMACSLOADPATH to builtin packages. (lambda _ (let ((lisp-dirs (list (string-append #$output "/share/emacs/" #$upstream-version "/lisp"))) (inputs '#$(map (match-lambda ((name directory) #~(#$name . #$directory))) (package-inputs this-package)))) (for-each (lambda (prog) (wrap-program prog ;; Some variants rely on uname being in PATH for Tramp. ;; Tramp paths can't be hardcoded, because they need to ;; be portable. `("PATH" suffix ,(map dirname (list (search-input-file inputs "/bin/gzip") ;; for coreutils (search-input-file inputs "/bin/yes")))) ;; We use "=" because loading non-builtin packages is ;; currently not supported and prevents guile-emacs ;; from running. `("EMACSLOADPATH" = ,lisp-dirs))) (find-files (string-append #$output "/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]+)*)?$"))))) (add-after 'configure 'touch-lisp/finder-inf.el (lambda _ (call-with-output-file "lisp/finder-inf.el" (lambda (port) (display port))))))))))))