summary refs log tree commit diff
path: root/gnu
diff options
context:
space:
mode:
Diffstat (limited to 'gnu')
-rw-r--r--gnu/local.mk6
-rw-r--r--gnu/packages/aux-files/emacs/guix-emacs.el80
-rw-r--r--gnu/packages/emacs-xyz.scm159
-rw-r--r--gnu/packages/emacs.scm498
-rw-r--r--gnu/packages/mail.scm6
-rw-r--r--gnu/packages/patches/emacs-all-the-icons-remove-duplicate-rs.patch21
-rw-r--r--gnu/packages/patches/emacs-haskell-mode-no-redefine-builtin.patch75
-rw-r--r--gnu/packages/patches/emacs-helpful-fix-tests.patch28
-rw-r--r--gnu/packages/patches/emacs-source-date-epoch.patch20
-rw-r--r--gnu/packages/patches/emacs-yasnippet-fix-empty-snippet-next.patch59
-rw-r--r--gnu/packages/patches/emacs-yasnippet-fix-tests.patch14
-rw-r--r--gnu/packages/patches/notmuch-emacs-test-output.patch89
12 files changed, 662 insertions, 393 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index be155d6004..ee9a509f1b 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1095,21 +1095,24 @@ dist_patch_DATA =						\
   %D%/packages/patches/elm-offline-package-registry.patch	\
   %D%/packages/patches/elm-reactor-static-files.patch		\
   %D%/packages/patches/elogind-fix-rpath.patch			\
+  %D%/packages/patches/emacs-all-the-icons-remove-duplicate-rs.patch	\
   %D%/packages/patches/emacs-deferred-fix-number-of-arguments.patch	\
   %D%/packages/patches/emacs-exec-path.patch			\
   %D%/packages/patches/emacs-ess-fix-obsolete-function-alias.patch	\
   %D%/packages/patches/emacs-git-email-missing-parens.patch	\
   %D%/packages/patches/emacs-fix-scheme-indent-function.patch	\
   %D%/packages/patches/emacs-json-reformat-fix-tests.patch	\
+  %D%/packages/patches/emacs-haskell-mode-no-redefine-builtin.patch	\
+  %D%/packages/patches/emacs-helpful-fix-tests.patch	\
   %D%/packages/patches/emacs-highlight-stages-add-gexp.patch	\
   %D%/packages/patches/emacs-lispy-fix-thread-last-test.patch   \
   %D%/packages/patches/emacs-native-comp-driver-options.patch   \
   %D%/packages/patches/emacs-pasp-mode-quote-file-names.patch  \
   %D%/packages/patches/emacs-polymode-fix-lexical-variable-error.patch  \
-  %D%/packages/patches/emacs-source-date-epoch.patch		\
   %D%/packages/patches/emacs-telega-path-placeholder.patch	\
   %D%/packages/patches/emacs-telega-test-env.patch		\
   %D%/packages/patches/emacs-wordnut-require-adaptive-wrap.patch	\
+  %D%/packages/patches/emacs-yasnippet-fix-empty-snippet-next.patch	\
   %D%/packages/patches/emacs-yasnippet-fix-tests.patch	\
   %D%/packages/patches/emacs-kv-fix-tests.patch	\
   %D%/packages/patches/emacs-pgtk-super-key-fix.patch	\
@@ -1661,6 +1664,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/network-manager-meson.patch		\
   %D%/packages/patches/nginx-socket-cloexec.patch		\
   %D%/packages/patches/nnpack-system-libraries.patch		\
+  %D%/packages/patches/notmuch-emacs-test-output.patch		\
   %D%/packages/patches/nsis-env-passthru.patch			\
   %D%/packages/patches/nss-getcwd-nonnull.patch			\
   %D%/packages/patches/nss-increase-test-timeout.patch		\
diff --git a/gnu/packages/aux-files/emacs/guix-emacs.el b/gnu/packages/aux-files/emacs/guix-emacs.el
index 708093267d..265c8bde16 100644
--- a/gnu/packages/aux-files/emacs/guix-emacs.el
+++ b/gnu/packages/aux-files/emacs/guix-emacs.el
@@ -1,8 +1,9 @@
+;;; -*- lexical-binding: t; -*-
 ;;; guix-emacs.el --- Emacs packages installed with Guix
 
 ;; Copyright © 2014, 2015, 2016, 2017 Alex Kost <alezost@gmail.com>
 ;; Copyright © 2017 Kyle Meyer <kyle@kyleam.com>
-;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;; Copyright © 2019, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 
 ;; This file is part of GNU Guix.
 
@@ -21,8 +22,9 @@
 
 ;;; Commentary:
 
-;; This file provides auxiliary code to autoload Emacs packages
-;; installed with Guix.
+;; This file provides auxiliary code to autoload Emacs packages installed with
+;; Guix.  To produce verbose messages useful while debugging, set the
+;; GUIX-EMACS-VERBOSE variable to true.
 
 ;;; Code:
 (require 'seq)
@@ -30,51 +32,77 @@
 
 (defvar guix-emacs-autoloads-regexp
   (rx (* any) "-autoloads.el" (zero-or-one "c") string-end)
-  "Regexp to match Emacs 'autoloads' file.")
+  "Regexp to match files containing autoload definitions.
+
+Historically, this used to be the package name followed by \"-autoloads.el\".
+As of Emacs 29, the term \"loaddefs\" is preferred over \"autoloads\",
+but they function much in the same manner.")
 
 (defun guix-emacs-find-autoloads (directory)
-  "Return a list of Emacs 'autoloads' files in DIRECTORY.
+  "Return a list of files containing autoload definitions in DIRECTORY.
 The files in the list do not have extensions (.el, .elc)."
   ;; `directory-files' doesn't honor group in regexp.
   (delete-dups (mapcar #'file-name-sans-extension
                        (directory-files directory 'full-name
                                         guix-emacs-autoloads-regexp))))
 
+(defcustom guix-emacs-verbose nil
+  "Set to true to provide verbose messages, such as when loading packages."
+  :type 'boolean
+  :group 'guix-emacs)
+
+(defun guix-emacs--load-file-no-error (file)
+  "Load FILE, ignoring any errors"
+  (load file 'noerror (not guix-emacs-verbose)))
+
 (defun guix-emacs--non-core-load-path ()
   ;; Filter out core Elisp directories, which are already handled by Emacs.
   (seq-filter (lambda (dir)
                 (string-match-p "/share/emacs/site-lisp" dir))
               load-path))
 
+(defun guix-emacs--subdirs-files ()
+  "Return the Guix subdirs.el files found on the (non-core) load path."
+  (seq-filter #'file-exists-p
+              (mapcar (lambda (dir)
+                        (expand-file-name "subdirs.el" dir))
+                      (guix-emacs--non-core-load-path))))
+
 ;;;###autoload
-(defun guix-emacs-autoload-packages ()
-  "Autoload Emacs packages found in EMACSLOADPATH.
+(defun guix-emacs-autoload-packages (&optional no-reload)
+  "Load autoload definitions for packages in `load-path'.
+
+Autoload definitions are contained within files matching
+`guix-emacs-autoload-regexp'; load each file matching that regexp.
+When NO-RELOAD is nil (the default), also evaluate any subdirs.el files
+found in `load-path' to discover newly installed packages."
+  (interactive "P")
+  ;; Reload the subdirs.el files such as the one generated by the Guix profile
+  ;; hook, so that newly installed Emacs packages located under
+  ;; sub-directories are put on the load-path without having to restart Emacs.
+  (unless no-reload
+    (mapc #'guix-emacs--load-file-no-error (guix-emacs--subdirs-files))
+    (setq load-path (delete-dups load-path)))
 
-'Autoload' means to load the 'autoloads' files matching
-`guix-emacs-autoloads-regexp'."
-  (interactive)
   (let ((autoloads (mapcan #'guix-emacs-find-autoloads
                            (guix-emacs--non-core-load-path))))
-    (mapc (lambda (f)
-            (load f 'noerror t))
-          autoloads)))
+    (mapc #'guix-emacs--load-file-no-error autoloads)))
 
 ;;;###autoload
 (defun guix-emacs-load-package-descriptors ()
   "Load descriptors for packages found in EMACSLOADPATH via subdirs.el."
-  (dolist (dir (guix-emacs--non-core-load-path))
-    (let ((subdirs-file (expand-file-name "subdirs.el" dir)))
-     (when (file-exists-p subdirs-file)
-      (with-temp-buffer
-        (insert-file-contents subdirs-file)
-        (goto-char (point-min))
-        (let ((subdirs (read (current-buffer))))
-          (and (equal (car-safe subdirs) 'normal-top-level-add-to-load-path)
-               (equal (car-safe (cadr subdirs)) 'list)
-               (dolist (subdir (cdadr subdirs))
-                 (let ((pkg-dir (expand-file-name subdir dir)))
-                   (when (file-directory-p pkg-dir)
-                     (package-load-descriptor pkg-dir)))))))))))
+  (dolist (subdirs-file (guix-emacs--subdirs-files))
+    (with-temp-buffer
+      (insert-file-contents subdirs-file)
+      (goto-char (point-min))
+      (let ((subdirs (read (current-buffer))))
+        (and (equal (car-safe subdirs) 'normal-top-level-add-to-load-path)
+             (equal (car-safe (cadr subdirs)) 'list)
+             (dolist (subdir (cdadr subdirs))
+               (let ((pkg-dir (expand-file-name
+                               subdir (file-name-directory subdirs-file))))
+                 (when (file-directory-p pkg-dir)
+                   (package-load-descriptor pkg-dir)))))))))
 
 ;; If emacs built with tree-sitter, read the value of the environment variable
 ;; to make tree-sitter grammars available in emacs out-of-the-box.
diff --git a/gnu/packages/emacs-xyz.scm b/gnu/packages/emacs-xyz.scm
index c4de0e1d1f..2575a833ab 100644
--- a/gnu/packages/emacs-xyz.scm
+++ b/gnu/packages/emacs-xyz.scm
@@ -1430,6 +1430,10 @@ on stdout instead of using a socket as the Emacsclient does.")
                 (substitute* "test/submodule-test.el"
                   (("\\(ert-deftest (status|ids) .*" all)
                    (string-append all " (skip-unless nil)")))))
+            (add-after 'unpack 'ert-number-tests
+              (lambda _
+                (ert-number-tests "test/repository-test.el"
+                                  "repository-head-for-worktree")))
             (add-before 'install 'prepare-for-install
               (lambda _
                 (let ((s "../source"))
@@ -2324,7 +2328,9 @@ replacement.")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "03j94fgw1bljbjqmikbn9mnrfifxf7g9zrb727zmnnrjwyi0wd4n"))))
+        (base32 "03j94fgw1bljbjqmikbn9mnrfifxf7g9zrb727zmnnrjwyi0wd4n"))
+       (patches
+        (search-patches "emacs-haskell-mode-no-redefine-builtin.patch"))))
     (propagated-inputs
      (list emacs-dash))
     (native-inputs
@@ -4888,7 +4894,9 @@ current match, total matches and exit status.
                   (make-file-writable test-file)
                   (substitute* test-file
                     (("testdata/indentation_tests/" all)
-                     (string-append "test/" all)))))))))
+                     (string-append "test/" all)))
+                  (ert-number-tests "test/go-fill-paragraph-test.el"
+                                    "go--fill-paragraph-block-region")))))))
       (build-system emacs-build-system)
       (native-inputs (list emacs-ert-runner))
       (home-page "https://github.com/dominikh/go-mode.el")
@@ -7450,7 +7458,14 @@ blocks with @code{org-babel} in @code{org-mode}.")
         #:test-command #~(list "emacs" "--batch" "-L" "."
                                "--eval=(require 'ob-go)"
                                "-l" "test-ob-go.el"
-                               "-f" "ert-run-tests-batch-and-exit")))
+                               "-f" "ert-run-tests-batch-and-exit")
+        #:phases #~(modify-phases %standard-phases
+                     (add-after 'unpack 'ert-number-tests
+                       (lambda _
+                         (ert-number-tests "test-ob-go.el"
+                                           "ob-go/string-variables")
+                         (ert-number-tests "test-ob-go.el"
+                                           "ob-go/imports"))))))
       (home-page "https://github.com/pope/ob-go")
       (synopsis "Org Babel support for evaluating Go code")
       (description "@code{ob-go} enables Org Babel support for evaluating Go
@@ -12823,11 +12838,16 @@ navigate code in a tree-like fashion.")
             (add-before 'check 'make-test-writable
               (lambda _
                 (make-file-writable "lispy-test.el")))
-            (add-before 'check 'remove-failing-test
+            (add-before 'check 'fix-tests
               (lambda _
+                (ert-number-tests "lispy-test.el" "lispy-outline-add")
+                (ert-number-tests "lispy-test.el" "lispy-ace-subword")
                 (emacs-batch-edit-file "lispy-test.el"
                   `(progn
-                    (dolist (test '("lispy-eval-python-str" "lispy--clojure-dot-object"))
+                    (dolist (test '("lispy-eval-python-str"
+                                    "lispy-outline-add-0"
+                                    "lispy--clojure-dot-object"
+                                    "lispy--pretty-args"))
                             (goto-char (point-min))
                             (re-search-forward
                              (concat "ert-deftest " test))
@@ -13905,7 +13925,22 @@ A function to toggle the @code{*elfeed-log*} buffer in a popup window.
          (modify-phases %standard-phases
            (add-before 'check 'chmod
              (lambda _
-               (chmod "test/fixture-mark-feed-ignore.org" #o644))))))
+               (chmod "test/fixture-mark-feed-ignore.org" #o644)))
+           (add-before 'check 'xt-number-tests
+             (lambda _
+               ((lambda (file test-name)     ; variant of ert-number-tests
+                  (emacs-batch-edit-file file
+                    `(let ((i 0))
+                       (while (re-search-forward ,(string-append "xt-deftest "
+                                                                 test-name)
+                                                 nil t)
+                         (goto-char (match-beginning 0))
+                         (kill-region (match-beginning 0) (match-end 0))
+                         (insert (format "xt-deftest %s-%d" ,test-name i))
+                         (setq i (+ i 1)))
+                       (basic-save-buffer))))
+                "test/elfeed-org-test.el"
+                "rmh-elfeed-org-convert-headline-to-tagger-params"))))))
       (propagated-inputs
        (list emacs-elfeed emacs-org emacs-dash emacs-s))
       (native-inputs
@@ -14167,7 +14202,11 @@ another window.")
        (modify-phases %standard-phases
          ;; This phase incorrectly attempts to substitute "activate" and fails
          ;; doing so.
-         (delete 'patch-el-files))
+         (delete 'patch-el-files)
+         (add-after 'unpack 'ert-number-tests
+             (lambda _
+               (ert-number-tests "test/pyvenv-hook-dir-test.el"
+                                 "pyvenv-hook-dir"))))
        #:tests? #t
        #:test-command '("ert-runner")))
     (native-inputs
@@ -14377,6 +14416,12 @@ completion, interactive development and more.")
                     (url "https://github.com/Fanael/rainbow-delimiters")
                     (commit version)))
               (file-name (git-file-name name version))
+              ;; Fix tests for Emacs 29
+              ;; https://github.com/Fanael/rainbow-delimiters/pull/78
+              (modules '((guix build utils)))
+              (snippet '(substitute* "rainbow-delimiters-test.el"
+                          (("category c-type " all)
+                           (string-append all "c-<>-c-types-set "))))
               (sha256
                (base32
                 "179mzsd8nvlr0ym9zf9fgdngsgxj3kdgbjblynliirsyk05ssrwc"))))
@@ -17323,7 +17368,8 @@ the Emacs TempEl package.")
        (sha256
         (base32 "0via9dzw8m5lzymg1h78xkwjssh39zr3g6ccyamlf1rjzjsyxknv"))
        (patches
-        (search-patches "emacs-yasnippet-fix-tests.patch"))))
+        (search-patches "emacs-yasnippet-fix-empty-snippet-next.patch"
+                        "emacs-yasnippet-fix-tests.patch"))))
     (build-system emacs-build-system)
     (arguments
      `(#:tests? #t
@@ -22110,8 +22156,8 @@ object has been freed.")
   (license license:unlicense)))
 
 (define-public emacs-emacsql
-  (let ((commit "e1baaf2f874df7f9259a8ecca978e03d3ddae5b5")
-        (revision "0"))
+  (let ((commit "29194a63ede3ee24c7457c2fde03b0f1320ca4b1")
+        (revision "1"))
     (package
       (name "emacs-emacsql")
       (version (git-version "3.1.1" revision commit))
@@ -22123,7 +22169,7 @@ object has been freed.")
                (commit commit)))
          (file-name (git-file-name name version))
          (sha256
-          (base32 "0dvqs1jg5zqn0i3r67sn1a40h5rm961q9vxvmqxbgvdhkjvip8fn"))))
+          (base32 "14yj53xxqi3009bdj39k2fqwyc896yp2m7gdkgyv47wlkh1xwzxh"))))
       (build-system emacs-build-system)
       (arguments
        (list
@@ -22139,12 +22185,6 @@ object has been freed.")
                     (srfi srfi-26))
         #:phases
         #~(modify-phases %standard-phases
-            (add-before 'install 'remove-sqlite-builtin
-              ;; Current emacs 28.2 doesn't have sqlite feature and compilation
-              ;; of this file fails.  This phase should be removed, when emacs
-              ;; package is updated to 29.
-              (lambda _
-                (delete-file "emacsql-sqlite-builtin.el")))
             (add-before 'install 'patch-elisp-shell-shebangs
               (lambda _
                 (substitute* (find-files "." "\\.el")
@@ -22182,47 +22222,6 @@ has no concept of @code{TEXT} values; it's all just Lisp objects.  The Lisp
 object @code{nil} corresponds 1:1 with @code{NULL} in the database.")
       (license license:gpl3+))))
 
-(define-public emacs-emacsql-sqlite3
-  ;; This commit contains changes necessary for Sqlite 3.38+.
-  (let ((commit "2113618732665f2112cb932a66c0e89c404d8777")
-        (revision "1"))
-    (package
-      (name "emacs-emacsql-sqlite3")
-      (version (git-version "1.0.2" revision commit))
-      (source
-       (origin
-         (method git-fetch)
-         (uri (git-reference
-               (url "https://github.com/cireu/emacsql-sqlite3")
-               (commit commit)))
-         (file-name (git-file-name name version))
-         (sha256
-          (base32 "0r8svrd0d4cflx8a8gkynnhafcpv3ksn9rds8dhyx5yibximbzsw"))))
-      (build-system emacs-build-system)
-      (arguments
-       `(#:tests? #t
-         #:test-command '("emacs" "-Q" "--batch" "-L" "."
-                          "--load" "emacsql-sqlite3-test.el"
-                          "-f" "ert-run-tests-batch-and-exit")
-         #:phases
-         (modify-phases %standard-phases
-           (add-after 'unpack 'embed-path-to-sqlite3
-             (lambda _
-               (substitute* "emacsql-sqlite3.el"
-                 (("\\(executable-find \"sqlite3\"\\)")
-                  (string-append "\"" (which "sqlite3") "\""))))))))
-      (native-inputs
-       (list emacs-ert-runner))
-      (inputs
-       (list sqlite))
-      (propagated-inputs
-       (list emacs-emacsql))
-      (home-page "https://github.com/cireu/emacsql-sqlite3")
-      (synopsis "EmacSQL backend for SQLite")
-      (description "This is yet another EmacSQL backend for SQLite which uses
-official @command{sqlite3} executable to access SQL database.")
-      (license license:gpl3+))))
-
 (define-public emacs-closql
   (package
     (name "emacs-closql")
@@ -24648,7 +24647,8 @@ downloading manager for Emacs.")
              (commit version)))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "03afgdbs5nmhw833svrqky7fmfs1zlvqzcj7j5g29sakivs60xqc"))))
+        (base32 "03afgdbs5nmhw833svrqky7fmfs1zlvqzcj7j5g29sakivs60xqc"))
+       (patches (search-patches "emacs-helpful-fix-tests.patch"))))
     (build-system emacs-build-system)
     (propagated-inputs
      (list emacs-dash emacs-elisp-refs emacs-f emacs-s))
@@ -28058,6 +28058,8 @@ files are easily readable and they work nicely with version control systems.")
              (url "https://github.com/domtronn/all-the-icons.el")
              (commit version)))
        (file-name (git-file-name name version))
+       (patches
+        (search-patches "emacs-all-the-icons-remove-duplicate-rs.patch"))
        (sha256
         (base32 "0lwgvgnqf7vihglm0c5bwsxbl4x7f641289cji5s7jwy2dbsqk7g"))))
     (build-system emacs-build-system)
@@ -28078,10 +28080,12 @@ files are easily readable and they work nicely with version control systems.")
                  (install-file "octicons.ttf" fonts)
                  (install-file "weathericons.ttf" fonts)))))
          (replace 'check
-           (lambda* (#:key outputs #:allow-other-keys)
-             (apply invoke "ert-runner" "-l"
-                    (append (find-files "data" "\\.el")
-                            '("all-the-icons-faces.el"))))))))
+           (lambda* (#:key tests? outputs #:allow-other-keys)
+             (if tests?
+                 (apply invoke "ert-runner" "-l"
+                        (append (find-files "data" "\\.el")
+                                '("all-the-icons-faces.el")))
+                 (format #t "test suite not run~%")))))))
     (native-inputs
      (list emacs-f emacs-ert-runner))
     (propagated-inputs
@@ -30454,10 +30458,10 @@ comfort of Magit and the rest of Emacs.")
      (license license:gpl3+)))
 
 (define-public emacs-matcha
-  (let ((commit "c7df5cf5cdac9ae369e241342389ccda0205eab9"))
+  (let ((commit "dc4a940b3360aadeb2d9eaab7bd0c85e1e85ab76"))
     (package
       (name "emacs-matcha")
-      (version (git-version "0.0.1" "1" commit)) ;no upstream release
+      (version (git-version "0.0.1" "2" commit)) ;no upstream release
       (source (origin
                 (method git-fetch)
                 (uri (git-reference
@@ -30466,7 +30470,7 @@ comfort of Magit and the rest of Emacs.")
                 (file-name (git-file-name name version))
                 (sha256
                  (base32
-                  "1lfnh1glg6al677m7ci0x8g5wjdhjxlfl3nv1f1ppsw4dpnwsj9b"))))
+                  "1bljnv5z289hxn73y7krbd0wya6acnwphabxwfajilpc118qz3lp"))))
       (propagated-inputs (list emacs-hydra))
       (build-system emacs-build-system)
       (home-page "https://github.com/jojojames/matcha/")
@@ -30645,7 +30649,6 @@ JavaScript.")
           (base32 "0cbchri4117wjcnlk3npi4x1sfx248vck1q61cis8drrrz4c8jyp"))
          (file-name (git-file-name name version))))
       (build-system emacs-build-system)
-      (arguments (list #:emacs emacs-next))
       (propagated-inputs
        (list emacs-dash
              emacs-s
@@ -31137,7 +31140,25 @@ definition-jumping and type-checking on demand.")
      (list emacs-js2-mode))
     (arguments
      `(#:tests? #t
-       #:test-command '("make" "test")))
+       #:test-command '("make" "test")
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'js2-number-tests
+           (lambda _
+             ((lambda (file test-name)     ; variant of ert-number-tests
+                (emacs-batch-edit-file file
+                  `(let ((i 0))
+                     (while (re-search-forward
+                             ,(string-append "js2-deftest-parse "
+                                             test-name)
+                             nil t)
+                       (goto-char (match-beginning 0))
+                       (kill-region (match-beginning 0) (match-end 0))
+                       (insert (format "xt-deftest %s-%d" ,test-name i))
+                       (setq i (+ i 1)))
+                     (basic-save-buffer))))
+                "rjsx-tests.el.el"
+                "no-attr-no-children-self-closing"))))))
     (home-page "https://github.com/felipeochoa/rjsx-mode")
     (synopsis "Major mode for JSX files")
     (description "This package extends the parser of @code{js2-mode} to
@@ -35603,7 +35624,7 @@ go directly to where they belong.")
        (list texinfo))
       (propagated-inputs
        (list emacs-dash
-             emacs-emacsql-sqlite3
+             emacs-emacsql
              emacs-f
              emacs-magit
              emacs-org
diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index d3689c2474..72b2c7795e 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -54,6 +54,7 @@
   #:use-module (gnu packages acl)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages freedesktop)
@@ -85,7 +86,8 @@
   #:use-module (gnu packages xorg)
   #:use-module (guix utils)
   #:use-module (ice-9 match)
-  #:use-module (srfi srfi-1))
+  #:use-module (srfi srfi-1)
+  #:export (emacs->emacs-next))
 
 (define (%emacs-modules build-system)
   (let ((which (build-system-name build-system)))
@@ -94,20 +96,21 @@
       (srfi srfi-1)
       (ice-9 ftw))))
 
-(define-public emacs
+(define-public emacs-minimal
   (package
-    (name "emacs")
-    (version "28.2")
+    (name "emacs-minimal")
+    (version "29.1")
     (source (origin
               (method url-fetch)
               (uri (string-append "mirror://gnu/emacs/emacs-"
                                   version ".tar.xz"))
               (sha256
                (base32
-                "12144dcaihv2ymfm7g2vnvdl4h71hqnsz1mljzf34cpg6ci1h8gf"))
+                "009f7q08vg919b90k2jrsznq73s3n224avz80dd2y7i3rjjq3y6j"))
               (patches (search-patches "emacs-exec-path.patch"
                                        "emacs-fix-scheme-indent-function.patch"
-                                       "emacs-source-date-epoch.patch"))
+                                       "emacs-native-comp-driver-options.patch"
+                                       "emacs-pgtk-super-key-fix.patch"))
               (modules '((guix build utils)))
               (snippet
                '(with-directory-excursion "lisp"
@@ -138,37 +141,14 @@
                             "\"~/.guix-profile/include\""
                             "\"/var/guix/profiles/system/profile/include\"")
                       " ")))))))
-    (build-system glib-or-gtk-build-system)
+    (build-system gnu-build-system)
     (arguments
      (list
-      #:tests? #f                      ; no check target
+      #:tests? #f                       ; no check target
       #:modules (%emacs-modules build-system)
-      #:configure-flags #~(list "--with-modules"
-                                "--with-cairo"
-                                "--with-native-compilation"
-                                "--disable-build-details")
-      #:make-flags #~(list "NATIVE_FULL_AOT=1")
+      #:configure-flags #~(list "--with-gnutls=no" "--disable-build-details")
       #:phases
       #~(modify-phases %standard-phases
-          (add-after 'set-paths 'set-libgccjit-path
-            (lambda* (#:key inputs #:allow-other-keys)
-              (define (first-subdirectory/absolute directory)
-                (let ((files (scandir
-                              directory
-                              (lambda (file)
-                                (and (not (member file '("." "..")))
-                                     (file-is-directory? (string-append
-                                                          directory "/"
-                                                          file)))))))
-                  (and (not (null? files))
-                       (string-append directory "/" (car files)))))
-              (let* ((libgccjit-libdir
-                      (first-subdirectory/absolute ;; version
-                       (first-subdirectory/absolute ;; host type
-                        (search-input-directory inputs "lib/gcc")))))
-                (setenv "LIBRARY_PATH"
-                        (string-append (getenv "LIBRARY_PATH")
-                                       ":" libgccjit-libdir)))))
           (add-after 'unpack 'enable-elogind
             (lambda _
               (substitute* "configure.ac"
@@ -199,20 +179,6 @@
                 (("\\(tramp-compat-process-running-p \"(.*)\"\\)" all process)
                  (format #f "(or ~a (tramp-compat-process-running-p ~s))"
                          all (string-append "." process "-real"))))))
-          (add-after 'unpack 'patch-compilation-driver
-            (lambda _
-              (substitute* "lisp/emacs-lisp/comp.el"
-                (("\\(defcustom native-comp-driver-options nil")
-                 (format
-                  #f "(defcustom native-comp-driver-options '(~@{~s~^ ~})"
-                  (string-append
-                   "-B" #$(this-package-input "binutils") "/bin/")
-                  (string-append
-                   "-B" #$(this-package-input "glibc") "/lib/")
-                  (string-append
-                   "-B" #$(this-package-input "libgccjit") "/lib/")
-                  (string-append
-                   "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))
           (add-before 'configure 'fix-/bin/pwd
             (lambda _
               ;; Use `pwd', not `/bin/pwd'.
@@ -244,7 +210,7 @@
                     (display
                      (string-append
                       "(when (require 'guix-emacs nil t)\n"
-                      "  (guix-emacs-autoload-packages)\n"
+                      "  (guix-emacs-autoload-packages 'no-reload)\n"
                       "  (advice-add 'package-load-all-descriptors"
                       " :after #'guix-emacs-load-package-descriptors))"))))
                 ;; Remove the extraneous subdirs.el file, as it causes Emacs to
@@ -254,29 +220,7 @@
                 (delete-file (string-append lisp-dir "/subdirs.el"))
                 ;; Byte compile the site-start files.
                 (emacs-byte-compile-directory lisp-dir))))
-          (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"))))
-          (add-after 'strip-double-wrap 'wrap-emacs-paths
+          (add-after 'install '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")
@@ -285,9 +229,9 @@
                 (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.
+                     ;; 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")
@@ -300,64 +244,30 @@
                              ;; environment variables from emacs.
                              ;; Likewise, we don't need to patch helper binaries
                              ;; like etags, ctags or ebrowse.
-                             "^emacs(-[0-9]+(\\.[0-9]+)*)?$"))))))))
-    (inputs
-     (list gnutls
-           ncurses
-
-           ;; To "unshadow" ld-wrapper in native builds
-           (make-ld-wrapper "ld-wrapper" #:binutils binutils)
-
-           ;; For native compilation
-           binutils
-           (libc-for-target)
-           libgccjit
-
-           ;; Required for "core" functionality, such as dired and compression.
-           coreutils
-           gzip
-
-           ;; Avoid Emacs's limited movemail substitute that retrieves POP3
-           ;; email only via insecure channels.
-           ;; This is not needed for (modern) IMAP.
-           mailutils
-
-           gpm
-           libx11
-           gtk+
-           cairo
-           pango
-           harfbuzz
-           libxft
-           libtiff
-           giflib
-           lcms
-           libjpeg-turbo
-           libselinux
-           acl
-           jansson
-           gmp
-           ghostscript
-           poppler
-           elogind
-
-           ;; When looking for libpng `configure' links with `-lpng -lz', so we
-           ;; must also provide zlib as an input.
-           libpng
-           zlib
-           (librsvg-for-system)
-           libxpm
-           libxml2
-           libice
-           libsm
-           alsa-lib
-           dbus
-
-           ;; multilingualization support
-           libotf
-           m17n-lib))
-    (native-inputs
-     (list autoconf pkg-config texinfo))
+                             "^emacs(-[0-9]+(\\.[0-9]+)*)?$")))))
+          (add-after 'wrap-emacs-paths 'undo-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")))))))
+    (inputs (list bash-minimal coreutils gzip ncurses))
+    (native-inputs (list autoconf pkg-config texinfo))
+    (home-page "https://www.gnu.org/software/emacs/")
+    (synopsis "The extensible text editor (minimal build for byte-compilation)")
+    (description
+     "GNU Emacs is an extensible and highly customizable text editor.  It is
+based on an Emacs Lisp interpreter with extensions for text editing.  Emacs
+has been extended in essentially all areas of computing, giving rise to a
+vast array of packages supporting, e.g., email, IRC and XMPP messaging,
+spreadsheets, remote server editing, and much more.  Emacs includes extensive
+documentation on all aspects of the system, from basic editing to writing
+large Lisp programs.  It has full Unicode support for nearly all human
+languages.")
+    (license license:gpl3+)
     (native-search-paths
      (list (search-path-specification
             (variable "EMACSLOADPATH")
@@ -368,200 +278,200 @@
            (search-path-specification
             (variable "INFOPATH")
             (files '("share/info")))
-           ;; tree-sitter support is not yet available in emacs 28, but this
-           ;; search path won't harm and also will be beneficial for
-           ;; emacs-next and other emacs-* packages, which have tree-sitter
-           ;; support enabled.  Please, remove this comment, when emacs
-           ;; package is updated to 29.
+           ;; Most variants support tree-sitter, so let's include it here.
            (search-path-specification
             (variable "TREE_SITTER_GRAMMAR_PATH")
-            (files '("lib/tree-sitter")))))
+            (files '("lib/tree-sitter")))))))
 
-    (home-page "https://www.gnu.org/software/emacs/")
-    (synopsis "The extensible, customizable, self-documenting text editor")
-    (description
-     "GNU Emacs is an extensible and highly customizable text editor.  It is
-based on an Emacs Lisp interpreter with extensions for text editing.  Emacs
-has been extended in essentially all areas of computing, giving rise to a
-vast array of packages supporting, e.g., email, IRC and XMPP messaging,
-spreadsheets, remote server editing, and much more.  Emacs includes extensive
-documentation on all aspects of the system, from basic editing to writing
-large Lisp programs.  It has full Unicode support for nearly all human
-languages.")
-    (license license:gpl3+)))
-
-(define-public emacs-next
-  (package
-    (inherit emacs)
-    (name "emacs-next")
-    (version "29.0.92")
-    (source
-     (origin
-       (inherit (package-source emacs))
-       (method git-fetch)
-       (uri (git-reference
-             (url "https://git.savannah.gnu.org/git/emacs.git/")
-             (commit (string-append "emacs-" version))))
-       (file-name (git-file-name name version))
-       ;; emacs-source-date-epoch.patch is no longer necessary
-       (patches (search-patches "emacs-exec-path.patch"
-                                "emacs-fix-scheme-indent-function.patch"
-                                "emacs-native-comp-driver-options.patch"))
-       (sha256
-        (base32
-         "1h3p325859svcy43iv7wr27dp68049j9d44jq5akcynqdkxz4jjn"))))
+(define-public emacs-no-x
+  (package/inherit emacs-minimal
+    (name "emacs-no-x")
+    (synopsis "The extensible, customizable, self-documenting text
+editor (console only)")
+    (arguments
+     (substitute-keyword-arguments (package-arguments emacs-minimal)
+       ((#:configure-flags flags #~'())
+        #~(cons* "--with-modules" "--with-native-compilation=aot"
+                 (delete "--with-gnutls=no" #$flags)))
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (add-after 'set-paths 'set-libgccjit-path
+              (lambda* (#:key inputs #:allow-other-keys)
+                (define (first-subdirectory/absolute directory)
+                  (let ((files (scandir
+                                directory
+                                (lambda (file)
+                                  (and (not (member file '("." "..")))
+                                       (file-is-directory? (string-append
+                                                            directory "/"
+                                                            file)))))))
+                    (and (not (null? files))
+                         (string-append directory "/" (car files)))))
+                (let* ((libgccjit-libdir
+                        (first-subdirectory/absolute ;; version
+                         (first-subdirectory/absolute ;; host type
+                          (search-input-directory inputs "lib/gcc")))))
+                  (setenv "LIBRARY_PATH"
+                          (string-append (getenv "LIBRARY_PATH")
+                                         ":" libgccjit-libdir)))))
+            (add-after 'unpack 'patch-compilation-driver
+              (lambda _
+                (substitute* "lisp/emacs-lisp/comp.el"
+                  (("\\(defcustom native-comp-driver-options nil")
+                   (format
+                    #f "(defcustom native-comp-driver-options '(~@{~s~^ ~})"
+                    (string-append
+                     "-B" #$(this-package-input "binutils") "/bin/")
+                    (string-append
+                     "-B" #$(this-package-input "glibc") "/lib/")
+                    (string-append
+                     "-B" #$(this-package-input "libgccjit") "/lib/")
+                    (string-append
+                     "-B" #$(this-package-input "libgccjit") "/lib/gcc/"))))))))))
     (inputs
-     (modify-inputs (package-inputs emacs)
-       (prepend sqlite)))
-    (native-inputs
-     (modify-inputs (package-native-inputs emacs)
-       (prepend autoconf)))))
+     (modify-inputs (package-inputs emacs-minimal)
+       (prepend gnutls
+                ;; To "unshadow" ld-wrapper in native builds
+                (make-ld-wrapper "ld-wrapper" #:binutils binutils)
+                ;; For native compilation
+                binutils
+                (libc-for-target)
+                libgccjit
 
-(define-public emacs-next-tree-sitter
-  (package
-    (inherit emacs-next)
-    (name "emacs-next-tree-sitter")
-    (inputs
-     (modify-inputs (package-inputs emacs-next)
-       (prepend sqlite tree-sitter)))
-    (synopsis "Emacs text editor with @code{tree-sitter} support")
-    (description "This Emacs build supports tree-sitter.")))
+                ;; Avoid Emacs's limited movemail substitute that retrieves POP3
+                ;; email only via insecure channels.
+                ;; This is not needed for (modern) IMAP.
+                mailutils
 
-(define-public emacs-next-pgtk
-  (package
-    (inherit emacs-next-tree-sitter)
-    (name "emacs-next-pgtk")
-    (source
-     (origin
-       (inherit (package-source emacs-next-tree-sitter))
-       (patches
-        (append (search-patches "emacs-pgtk-super-key-fix.patch")
-                (origin-patches (package-source emacs-next-tree-sitter))))))
-    (arguments
-     (substitute-keyword-arguments (package-arguments emacs-next-tree-sitter)
-       ((#:configure-flags flags #~'())
-        #~(cons* "--with-pgtk" #$flags))))
-    (synopsis "Emacs text editor with @code{pgtk} and @code{tree-sitter} support")
-    (description "This Emacs build implements graphical UI purely in terms
-of GTK and supports tree-sitter.")))
+                acl
+                alsa-lib
+                elogind
+                ghostscript
+                gpm
+                jansson
+                lcms
+                libice
+                libselinux
+                libsm
+                libxml2
+                m17n-lib
+                sqlite
+                tree-sitter
+                zlib)))))
 
-(define-public emacs-next-pgtk-xwidgets
-  (package
-    (inherit emacs-next-pgtk)
-    (name "emacs-next-pgtk-xwidgets")
-    (synopsis "Emacs text editor with @code{xwidgets} and @code{pgtk} support")
+(define-public emacs
+  (package/inherit emacs-no-x
+    (name "emacs")
+    (synopsis "The extensible, customizable, self-documenting text editor")
+    (build-system glib-or-gtk-build-system)
     (arguments
-     (substitute-keyword-arguments (package-arguments emacs-next-pgtk)
+     (substitute-keyword-arguments (package-arguments emacs-no-x)
+       ((#:modules _) (%emacs-modules build-system))
        ((#:configure-flags flags #~'())
-        #~(cons "--with-xwidgets" #$flags))))
-    (inputs
-     (modify-inputs (package-inputs emacs-next-pgtk)
-       (prepend gsettings-desktop-schemas webkitgtk-with-libsoup2)))))
+        #~(cons* "--with-cairo" #$flags))
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            ;; Note: due to the changed #:modules, %standard-phases in #$phases
+            ;; refers to glib-or-gtk:%standard-phases, so we don't need to add
+            ;; them ourselves.
+            (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))))))))
+    (inputs (modify-inputs (package-inputs emacs-no-x)
+              (prepend
+               cairo
+               dbus
+               gtk+
+               giflib
+               harfbuzz
+               libjpeg-turbo
+               libotf
+               libpng
+               (librsvg-for-system)
+               libtiff
+               libx11
+               libxft
+               libxpm
+               pango
+               poppler)))))
 
-(define-public emacs-minimal
-  ;; This is the version that you should use as an input to packages that just
-  ;; need to byte-compile .el files.
+(define-public emacs-pgtk
   (package/inherit emacs
-    (name "emacs-minimal")
-    (synopsis "The extensible text editor (used only for byte-compilation)")
-    (build-system gnu-build-system)
+    (name "emacs-pgtk")
     (arguments
      (substitute-keyword-arguments (package-arguments emacs)
        ((#:configure-flags flags #~'())
-        #~(list "--with-gnutls=no" "--disable-build-details"))
-       ((#:modules _) (%emacs-modules build-system))
-       ((#:phases phases)
-        #~(modify-phases #$phases
-            (delete 'set-libgccjit-path)
-            (delete 'patch-compilation-driver)
-            (delete 'restore-emacs-pdmp)
-            (delete 'strip-double-wrap)))))
-    (inputs (list ncurses coreutils gzip))
-    (native-inputs (list autoconf pkg-config))))
+        #~(cons* "--with-pgtk" #$flags))))
+    (synopsis "Emacs text editor with @code{pgtk} frames")
+    (description "This Emacs build implements graphical UI purely in terms
+of GTK.")))
 
 (define-public emacs-xwidgets
   (package/inherit emacs
     (name "emacs-xwidgets")
     (synopsis "The extensible, customizable, self-documenting text
 editor (with xwidgets support)")
-    (build-system gnu-build-system)
     (arguments
      (substitute-keyword-arguments (package-arguments emacs)
        ((#:configure-flags flags #~'())
-        #~(cons "--with-xwidgets" #$flags))
-       ((#:modules _) (%emacs-modules build-system))
-       ((#:phases phases)
-        #~(modify-phases #$phases
-            (delete 'restore-emacs-pdmp)
-            (delete 'strip-double-wrap)))))
+        #~(cons "--with-xwidgets" #$flags))))
     (inputs
      (modify-inputs (package-inputs emacs)
        (prepend webkitgtk-with-libsoup2 libxcomposite)))))
 
+(define-public emacs-pgtk-xwidgets
+  (package
+    (inherit emacs-pgtk)
+    (name "emacs-pgtk-xwidgets")
+    (synopsis "Emacs text editor with @code{xwidgets} and @code{pgtk} support")
+    (arguments
+     (substitute-keyword-arguments (package-arguments emacs-pgtk)
+       ((#:configure-flags flags #~'())
+        #~(cons "--with-xwidgets" #$flags))))
+    (inputs
+     (modify-inputs (package-inputs emacs-pgtk)
+       (prepend gsettings-desktop-schemas webkitgtk-with-libsoup2)))))
+
 (define-public emacs-motif
-  (package/inherit emacs
+  (package/inherit emacs-no-x
     (name "emacs-motif")
     (synopsis
      "The extensible, customizable, self-documenting text editor (with Motif
 toolkit)")
-    (build-system gnu-build-system)
+    ;; Using emacs' inputs as base, since it has all the graphical stuff
     (inputs (modify-inputs (package-inputs emacs)
               (delete "gtk+")
               (prepend inotify-tools motif)))
     (arguments
      (substitute-keyword-arguments
-         (package-arguments
-          emacs)
+         (package-arguments emacs-no-x)
        ((#:configure-flags flags #~'())
         #~(cons "--with-x-toolkit=motif"
-                #$flags))
-       ((#:modules _)
-        (%emacs-modules build-system))
-       ((#:phases phases)
-        #~(modify-phases #$phases
-            (delete 'restore-emacs-pdmp)
-            (delete 'strip-double-wrap)))))))
-
-(define-public emacs-no-x
-  (package/inherit emacs
-    (name "emacs-no-x")
-    (synopsis "The extensible, customizable, self-documenting text
-editor (console only)")
-    (build-system gnu-build-system)
-    (inputs (modify-inputs (package-inputs emacs)
-              (delete "libx11" "gtk+" "libxft" "libtiff" "giflib" "libjpeg"
-                      "imagemagick" "libpng" "librsvg" "libxpm" "libice"
-                      "libsm" "cairo" "pango" "harfbuzz"
-                      ;; These depend on libx11, so remove them as well.
-                      "libotf" "m17n-lib" "dbus")))
-    (arguments
-     (substitute-keyword-arguments (package-arguments emacs)
-       ((#:configure-flags flags #~'())
-        #~(delete "--with-cairo" #$flags))
-       ((#:modules _) (%emacs-modules build-system))
-       ((#:phases phases)
-        #~(modify-phases #$phases
-            (delete 'restore-emacs-pdmp)
-            (delete 'strip-double-wrap)))))))
+                #$flags))))))
 
 (define-public emacs-no-x-toolkit
-  (package/inherit emacs
+  (package/inherit emacs-no-x
     (name "emacs-no-x-toolkit")
     (synopsis "The extensible, customizable, self-documenting text
 editor (without an X toolkit)" )
-    (build-system gnu-build-system)
+    ;; Using emacs' inputs as base, since it has all the graphical stuff
     (inputs (modify-inputs (package-inputs emacs)
               (delete "gtk+")
               (prepend inotify-tools)))
     (arguments
-     (substitute-keyword-arguments (package-arguments emacs)
+     (substitute-keyword-arguments (package-arguments emacs-no-x)
        ((#:configure-flags flags #~'())
-        #~(cons "--with-x-toolkit=no" #$flags))
-       ((#:modules _) (%emacs-modules build-system))
-       ((#:phases phases)
-        #~(modify-phases #$phases
-           (delete 'restore-emacs-pdmp)
-           (delete 'strip-double-wrap)))))))
+        #~(cons "--with-x-toolkit=no" #$flags))))))
 
 (define-public emacs-wide-int
   (package/inherit emacs
@@ -573,6 +483,42 @@ editor (with wide ints)" )
        ((#:configure-flags flags)
         #~(cons "--with-wide-int" #$flags))))))
 
+(define-public emacs-next-minimal
+  (let ((commit "9d27b95b263473fb41a30e3f6ea5607c99e93a61")
+        (revision "1"))
+   (package
+    (inherit emacs-minimal)
+    (name "emacs-next-minimal")
+    (version (git-version "30.0.50" revision commit))
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.savannah.gnu.org/git/emacs.git")
+             (commit commit)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "00mwpq1msr3jij281w5piqmbwq968xr8dn9hqbf4r947ck754kn9")))))))
+
+(define* (emacs->emacs-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)))
+
+(define-public emacs-next (emacs->emacs-next emacs))
+(define-public emacs-next-pgtk (emacs->emacs-next emacs-pgtk))
+(define-public emacs-next-pgtk-xwidgets (emacs->emacs-next emacs-pgtk-xwidgets))
+(define-public emacs-next-tree-sitter
+  (deprecated-package "emacs-next-tree-sitter" emacs-next))
+
 (define-public guile-emacs
   (let ((commit "41120e0f595b16387eebfbf731fff70481de1b4b")
         (revision "0"))
diff --git a/gnu/packages/mail.scm b/gnu/packages/mail.scm
index e0c185ceb5..93cd801a95 100644
--- a/gnu/packages/mail.scm
+++ b/gnu/packages/mail.scm
@@ -52,6 +52,7 @@
 ;;; Copyright © 2022 jgart <jgart@dismail.de>
 ;;; Copyright © 2022 ( <paren@disroot.org>
 ;;; Copyright © 2023 Timo Wilken <guix@twilken.net>
+;;; Copyright © 2023 Arjan Adriaanse <arjan@adriaan.se>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1368,7 +1369,10 @@ invoking @command{notifymuch} from the post-new hook.")
        (uri (string-append "https://notmuchmail.org/releases/notmuch-"
                            version ".tar.xz"))
        (sha256
-        (base32 "1xl64xh0ijfkx265lcj9cqv1wkzha8gsn9jn4fw4xgvqigr6sxhf"))))
+        (base32 "1xl64xh0ijfkx265lcj9cqv1wkzha8gsn9jn4fw4xgvqigr6sxhf"))
+       (patches
+        ;; Output for some tests varies slightly in Emacs 29.
+        (search-patches "notmuch-emacs-test-output.patch"))))
     (build-system gnu-build-system)
     (arguments
      (list
diff --git a/gnu/packages/patches/emacs-all-the-icons-remove-duplicate-rs.patch b/gnu/packages/patches/emacs-all-the-icons-remove-duplicate-rs.patch
new file mode 100644
index 0000000000..2c6b14e0aa
--- /dev/null
+++ b/gnu/packages/patches/emacs-all-the-icons-remove-duplicate-rs.patch
@@ -0,0 +1,21 @@
+From 24b8d5b63e347bd4cdcf79bf897fc0097fa20fc7 Mon Sep 17 00:00:00 2001
+From: Michael Wernthaler <michael.wernthaler@posteo.de>
+Date: Thu, 22 Jul 2021 11:27:31 +0200
+Subject: [PATCH] Fixed icon for .rs-files
+
+---
+ all-the-icons.el | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/all-the-icons.el b/all-the-icons.el
+index e1f4cb7695..3399906cfb 100644
+--- a/all-the-icons.el
++++ b/all-the-icons.el
+@@ -194,7 +194,6 @@
+     ("r"            all-the-icons-fileicon "R"                :face all-the-icons-lblue)
+     ("rd"           all-the-icons-fileicon "R"                :face all-the-icons-lblue)
+     ("rdx"          all-the-icons-fileicon "R"                :face all-the-icons-lblue)
+-    ("rs"           all-the-icons-fileicon "R"                :face all-the-icons-lblue)
+     ("rsx"          all-the-icons-fileicon "R"                :face all-the-icons-lblue)
+     ;; There seems to be a a bug with this font icon which does not
+     ;; let you propertise it without it reverting to being a lower
diff --git a/gnu/packages/patches/emacs-haskell-mode-no-redefine-builtin.patch b/gnu/packages/patches/emacs-haskell-mode-no-redefine-builtin.patch
new file mode 100644
index 0000000000..65ace2ee5e
--- /dev/null
+++ b/gnu/packages/patches/emacs-haskell-mode-no-redefine-builtin.patch
@@ -0,0 +1,75 @@
+From faa95a784d2c74c72e70367a5d531df6dd61aeab Mon Sep 17 00:00:00 2001
+From: Steve Purcell <steve@sanityinc.com>
+Date: Sun, 6 Aug 2023 16:41:48 +0200
+Subject: [PATCH] Don't redefine built-in function
+
+Fixes #1817
+---
+ tests/haskell-indent-tests.el      | 14 ++++++++------
+ tests/haskell-indentation-tests.el | 14 ++++++++------
+ 2 files changed, 16 insertions(+), 12 deletions(-)
+
+diff --git a/tests/haskell-indent-tests.el b/tests/haskell-indent-tests.el
+index 7196405b8..9a3de4ad3 100644
+--- a/tests/haskell-indent-tests.el
++++ b/tests/haskell-indent-tests.el
+@@ -40,11 +40,13 @@
+ ;;                    (haskell-indent-put-region-in-literate (point-min) (point-max) -1)
+ ;;                    (buffer-substring-no-properties (point-min) (point-max))))))
+ 
+-(defsubst string-trim-left (string)
+-  "Remove leading whitespace from STRING."
+-  (if (string-match "\\`[ \t\n\r]+" string)
+-      (replace-match "" t t string)
+-    string))
++(if (fboundp 'string-trim-left)
++    (defalias 'haskell--string-trim-left 'string-trim-left)
++  (defun haskell--string-trim-left (string &optional regexp)
++    "Remove leading whitespace from STRING."
++    (if (string-match (concat "\\`\\(?:" (or regexp "[ \t\n\r]+") "\\)") string)
++        (substring string (match-end 0))
++      string)))
+ 
+ (defun haskell-indent-format-info (info)
+   (if (cdr info)
+@@ -128,7 +130,7 @@ macro quotes them for you."
+          :expected-result
+          ,(if allow-failure :failed :passed)
+          (haskell-indent-check
+-          ,(string-trim-left source)
++          ,(haskell--string-trim-left source)
+           ,@(mapcar (lambda (x)
+                       (list 'quote x))
+                     test-cases))))))
+diff --git a/tests/haskell-indentation-tests.el b/tests/haskell-indentation-tests.el
+index 4889b76a7..cd783a4f4 100644
+--- a/tests/haskell-indentation-tests.el
++++ b/tests/haskell-indentation-tests.el
+@@ -33,11 +33,13 @@
+ 
+ ;;; Code:
+ 
+-(defsubst string-trim-left (string)
+-  "Remove leading whitespace from STRING."
+-  (if (string-match "\\`[ \t\n\r]+" string)
+-      (replace-match "" t t string)
+-    string))
++(if (fboundp 'string-trim-left)
++    (defalias 'haskell--string-trim-left 'string-trim-left)
++  (defun haskell--string-trim-left (string &optional regexp)
++    "Remove leading whitespace from STRING."
++    (if (string-match (concat "\\`\\(?:" (or regexp "[ \t\n\r]+") "\\)") string)
++        (substring string (match-end 0))
++      string)))
+ 
+ (defun haskell-indentation-check (source &rest test-cases)
+   "Check if `haskell-indentation-find-indentations' returns expected results.
+@@ -115,7 +117,7 @@ macro quotes them for you."
+          :expected-result
+          ,(if allow-failure :failed :passed)
+          (haskell-indentation-check
+-          ,(string-trim-left source)
++          ,(haskell--string-trim-left source)
+           ,@(mapcar (lambda (x)
+                       (list 'quote x))
+                     test-cases))))))
diff --git a/gnu/packages/patches/emacs-helpful-fix-tests.patch b/gnu/packages/patches/emacs-helpful-fix-tests.patch
new file mode 100644
index 0000000000..61ed0671a4
--- /dev/null
+++ b/gnu/packages/patches/emacs-helpful-fix-tests.patch
@@ -0,0 +1,28 @@
+From 233e254bbe44f70ca899a506b3706af489228fda Mon Sep 17 00:00:00 2001
+From: aagon <aymeric.agon@hotmail.fr>
+Date: Thu, 10 Aug 2023 20:03:52 +0200
+Subject: [PATCH] Repair helpful--display-implementations test for emacs 29.1
+
+---
+ test/helpful-unit-test.el | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/test/helpful-unit-test.el b/test/helpful-unit-test.el
+index 0f5177b..0716b0d 100644
+--- a/test/helpful-unit-test.el
++++ b/test/helpful-unit-test.el
+@@ -1089,8 +1089,12 @@ find the source code."
+   (require 'xref)
+   (helpful-function 'xref-location-marker)
+   (should (s-contains-p "Implementations" (buffer-string)))
+-  (should (s-contains-p "((l xref-file-location))" (buffer-string)))
+-  (should (s-contains-p "((l xref-buffer-location))" (buffer-string))))
++  (should (if (version< emacs-version "29.1")
++	      (s-contains-p "((l xref-file-location))" (buffer-string))
++	    (s-contains-p "(xref-location-marker (L xref-file-location))" (buffer-string))))
++  (should (if (version< emacs-version "29.1")
++	      (s-contains-p "((l xref-buffer-location))" (buffer-string))
++	    (s-contains-p "(xref-location-marker (L xref-buffer-location))" (buffer-string)))))
+ 
+ (defun helpful--boring-advice (orig-fn &rest args)
+   (apply orig-fn args))
diff --git a/gnu/packages/patches/emacs-source-date-epoch.patch b/gnu/packages/patches/emacs-source-date-epoch.patch
deleted file mode 100644
index 77ea7ac15c..0000000000
--- a/gnu/packages/patches/emacs-source-date-epoch.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-Honor SOURCE_DATE_EPOCH variable to avoid non-determinism in generated
-"autoloads" files.
-
---- a/lisp/emacs-lisp/autoload.el
-+++ b/lisp/emacs-lisp/autoload.el
-@@ -419,8 +419,12 @@
-   ;;              nil t))
-   ;;        (match-end 2))))
-   (insert generate-autoload-section-header)
--  (prin1 `(autoloads ,autoloads ,load-name ,file ,time)
--	 outbuf)
-+  (let* ((env  (getenv "SOURCE_DATE_EPOCH"))
-+         (time (if env
-+                   (seconds-to-time (string-to-number env))
-+                 time)))
-+    (prin1 `(autoloads ,autoloads ,load-name ,file ,time)
-+           outbuf))
-   (terpri outbuf)
-   ;; Break that line at spaces, to avoid very long lines.
-   ;; Make each sub-line into a comment.
diff --git a/gnu/packages/patches/emacs-yasnippet-fix-empty-snippet-next.patch b/gnu/packages/patches/emacs-yasnippet-fix-empty-snippet-next.patch
new file mode 100644
index 0000000000..1faea2b456
--- /dev/null
+++ b/gnu/packages/patches/emacs-yasnippet-fix-empty-snippet-next.patch
@@ -0,0 +1,59 @@
+From 925292484162bc35c4258e72c36462bb13a5c69a Mon Sep 17 00:00:00 2001
+From: Liliana Marie Prikler <liliana.prikler@gmail.com>
+Date: Sat, 19 Aug 2023 08:38:17 +0200
+Subject: [PATCH] Guard against empty snippet in yas-next-field.
+
+---
+ yasnippet.el | 29 +++++++++++++++--------------
+ 1 file changed, 15 insertions(+), 14 deletions(-)
+
+diff --git a/yasnippet.el b/yasnippet.el
+index e0b5537..41d86dd 100644
+--- a/yasnippet.el
++++ b/yasnippet.el
+@@ -136,6 +136,7 @@
+ (declare-function cl-progv-after "cl-extra") ; Needed for 23.4.
+ (require 'easymenu)
+ (require 'help-mode)
++(require 'subr-x)
+ 
+ (defvar yas--editing-template)
+ (defvar yas--guessed-modes)
+@@ -3386,20 +3387,20 @@ Otherwise delegate to `yas-next-field'."
+ If there's none, exit the snippet."
+   (interactive)
+   (unless arg (setq arg 1))
+-  (let* ((active-field (overlay-get yas--active-field-overlay 'yas--field))
+-         (snippet (car (yas-active-snippets (yas--field-start active-field)
+-                                            (yas--field-end active-field))))
+-         (target-field (yas--find-next-field arg snippet active-field)))
+-    (yas--letenv (yas--snippet-expand-env snippet)
+-      ;; Apply transform to active field.
+-      (when active-field
+-        (let ((yas-moving-away-p t))
+-          (when (yas--field-update-display active-field)
+-            (yas--update-mirrors snippet))))
+-      ;; Now actually move...
+-      (if target-field
+-          (yas--move-to-field snippet target-field)
+-        (yas-exit-snippet snippet)))))
++  (and-let* ((active-field (overlay-get yas--active-field-overlay 'yas--field))
++             (snippet (car (yas-active-snippets (yas--field-start active-field)
++                                                (yas--field-end active-field)))))
++    (let ((target-field (yas--find-next-field arg snippet active-field)))
++      (yas--letenv (yas--snippet-expand-env snippet)
++        ;; Apply transform to active field.
++        (when active-field
++          (let ((yas-moving-away-p t))
++            (when (yas--field-update-display active-field)
++              (yas--update-mirrors snippet))))
++        ;; Now actually move...
++        (if target-field
++            (yas--move-to-field snippet target-field)
++          (yas-exit-snippet snippet))))))
+ 
+ (defun yas--place-overlays (snippet field)
+   "Correctly place overlays for SNIPPET's FIELD."
+-- 
+2.41.0
+
diff --git a/gnu/packages/patches/emacs-yasnippet-fix-tests.patch b/gnu/packages/patches/emacs-yasnippet-fix-tests.patch
index c70cc75d92..5995b0afa4 100644
--- a/gnu/packages/patches/emacs-yasnippet-fix-tests.patch
+++ b/gnu/packages/patches/emacs-yasnippet-fix-tests.patch
@@ -10,6 +10,11 @@ Content-Transfer-Encoding: 8bit
 - A test that was temporarily broken passes again.
 - The default for ‘org-adapt-indentation’ has changed.
 - buffer-list may be called with arguments when native-comp is enabled.
+
+2023-08-19 Liliana Marie Prikler <liliana.prikler@gmail.com>
+
+	* delete-numberless-inner-snippet-issue-562: Correct value in
+        looking-at.
 ---
  yasnippet-tests.el | 45 ++++++++++++++++++++++++++++-----------------
  1 file changed, 28 insertions(+), 17 deletions(-)
@@ -26,6 +31,15 @@ index f7ca2bb..7618ab7 100644
  
  ;; Author: João Távora <joaot@siscog.pt>
  ;; Keywords: emulations, convenience
+@@ -289,7 +289,7 @@ attention to case differences."
+     (should (looking-at "testblable"))
+     (ert-simulate-command '(yas-next-field-or-maybe-expand))
+     (ert-simulate-command '(yas-skip-and-clear-field))
+-    (should (looking-at "ble"))
++    (should (looking-at "blable"))
+     (should (null (yas-active-snippets)))))
+ 
+ (ert-deftest delete-nested-simple-field-issue-824 ()
 @@ -556,16 +556,19 @@ XXXXX   ------------------------"))))
      (yas-mock-insert "foo bar")
      (ert-simulate-command '(yas-next-field))
diff --git a/gnu/packages/patches/notmuch-emacs-test-output.patch b/gnu/packages/patches/notmuch-emacs-test-output.patch
new file mode 100644
index 0000000000..3c6d472d6b
--- /dev/null
+++ b/gnu/packages/patches/notmuch-emacs-test-output.patch
@@ -0,0 +1,89 @@
+From e9e779ead4d703ad423e46c23abd0c9afd7d5ed2 Mon Sep 17 00:00:00 2001
+From: Arjan Adriaanse <arjan@adriaan.se>
+Date: Tue, 15 Aug 2023 00:00:05 +0200
+Subject: [PATCH] test: fix expected output for Emacs 29
+
+---
+ test/T453-emacs-reply.sh                                 | 1 -
+ test/T454-emacs-dont-reply-names.sh                      | 9 +++------
+ .../notmuch-reply-duplicate-4                            | 1 -
+ 3 files changed, 3 insertions(+), 8 deletions(-)
+
+diff --git a/test/T453-emacs-reply.sh b/test/T453-emacs-reply.sh
+index 0a27d066..de400b85 100755
+--- a/test/T453-emacs-reply.sh
++++ b/test/T453-emacs-reply.sh
+@@ -17,7 +17,6 @@ cat <<EOF > EXPECTED
+ From: Notmuch Test Suite <test_suite@notmuchmail.org>
+ To: Antoine Beaupré <anarcat@orangeseeds.org>
+ Subject: Re: bug: "no top level messages" crash on Zen email loops
+-In-Reply-To: <874llc2bkp.fsf@curie.anarc.at>
+ Fcc: MAIL_DIR/sent
+ --text follows this line--
+ Antoine Beaupré <anarcat@orangeseeds.org> writes:
+diff --git a/test/T454-emacs-dont-reply-names.sh b/test/T454-emacs-dont-reply-names.sh
+index 3a770177..9ed4f18b 100755
+--- a/test/T454-emacs-dont-reply-names.sh
++++ b/test/T454-emacs-dont-reply-names.sh
+@@ -17,13 +17,12 @@ test_emacs '(let ((message-dont-reply-to-names "notmuchmail\\|noreply\\|harvard"
+ 	      (test-visible-output "OUTPUT-FULL.raw"))'
+ 
+ notmuch_dir_sanitize < OUTPUT-FULL.raw > OUTPUT-FULL
+-head -6 OUTPUT-FULL > OUTPUT
++head -5 OUTPUT-FULL > OUTPUT
+ 
+ cat <<EOF > EXPECTED
+ From: Notmuch Test Suite <test_suite@notmuchmail.org>
+ To: Mikhail Gusarov <dottedmag@dottedmag.net>
+ Subject: Re: [notmuch] Working with Maildir storage?
+-In-Reply-To: <20091117203301.GV3165@dottiness.seas.harvard.edu>
+ Fcc: MAIL_DIR/sent
+ --text follows this line--
+ EOF
+@@ -38,14 +37,13 @@ test_emacs '(let ((message-dont-reply-to-names
+ 	      (test-visible-output "OUTPUT-FULL-PRED.raw"))'
+ 
+ notmuch_dir_sanitize < OUTPUT-FULL-PRED.raw > OUTPUT-FULL-PRED
+-head -7 OUTPUT-FULL-PRED > OUTPUT-PRED
++head -6 OUTPUT-FULL-PRED > OUTPUT-PRED
+ 
+ cat <<EOF > EXPECTED-PRED
+ From: Notmuch Test Suite <test_suite@notmuchmail.org>
+ To: Lars Kellogg-Stedman <lars@seas.harvard.edu>
+ Cc: notmuch@notmuchmail.org
+ Subject: Re: [notmuch] Working with Maildir storage?
+-In-Reply-To: <20091117203301.GV3165@dottiness.seas.harvard.edu>
+ Fcc: MAIL_DIR/sent
+ --text follows this line--
+ EOF
+@@ -59,14 +57,13 @@ test_emacs '(let ((message-dont-reply-to-names nil))
+ 	      (test-visible-output "OUTPUT-FULL-NIL.raw"))'
+ 
+ notmuch_dir_sanitize < OUTPUT-FULL-NIL.raw > OUTPUT-FULL-NIL
+-head -7 OUTPUT-FULL-NIL > OUTPUT-NIL
++head -6 OUTPUT-FULL-NIL > OUTPUT-NIL
+ 
+ cat <<EOF > EXPECTED-NIL
+ From: Notmuch Test Suite <test_suite@notmuchmail.org>
+ To: Lars Kellogg-Stedman <lars@seas.harvard.edu>, Mikhail Gusarov <dottedmag@dottedmag.net>
+ Cc: notmuch@notmuchmail.org
+ Subject: Re: [notmuch] Working with Maildir storage?
+-In-Reply-To: <20091117203301.GV3165@dottiness.seas.harvard.edu>
+ Fcc: MAIL_DIR/sent
+ --text follows this line--
+ EOF
+diff --git a/test/emacs-reply.expected-output/notmuch-reply-duplicate-4 b/test/emacs-reply.expected-output/notmuch-reply-duplicate-4
+index 836f77b1..44b8c7a6 100644
+--- a/test/emacs-reply.expected-output/notmuch-reply-duplicate-4
++++ b/test/emacs-reply.expected-output/notmuch-reply-duplicate-4
+@@ -1,7 +1,6 @@
+ From: Notmuch Test Suite <test_suite@notmuchmail.org>
+ To: Sean Whitton <spwhitton@spwhitton.name>, 916811@bugs.debian.org, 916805@bugs.debian.org, 916807@bugs.debian.org, 916808@bugs.debian.org, 916809@bugs.debian.org, 916811@bugs.debian.org, 916867@bugs.debian.org, 916869@bugs.debian.org, 916872@bugs.debian.org, 916875@bugs.debian.org, 916876@bugs.debian.org
+ Subject: Re: [Pkg-emacsen-addons] Bug#916811: Increase severity to 'serious'
+-In-Reply-To: <87r2ecrr6x.fsf@zephyr.silentflame.com>
+ Fcc: MAIL_DIR/sent
+ --text follows this line--
+ Sean Whitton <spwhitton@spwhitton.name> writes:
+-- 
+2.41.0
+