Subject: [bug#77225] [PATCH v2 1/2] gnu: emacs-next: Update to 31.0.50-0.467aba6.

From: Gabriel Santos <[email-masked]>
Date: Fri, 28 Mar 2025 06:43:06 -0300

From: Gabriel Santos <[email-masked]>

* gnu/packages/emacs.scm (emacs-next-minimal): Update to 31.0.50-0.467aba6.
* gnu/packages/patches/emacs-next-disable-jit-compilation.patch: New patch.
* gnu/packages/patches/emacs-disable-jit-compilation.patch: Fix typo.
* gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch: Regenerate.

Change-Id: I529eb49208c319692c19bb1057a069cb856e1426
---
 gnu/packages/emacs.scm                        |  7 ++-
 .../emacs-disable-jit-compilation.patch       |  2 +-
 .../emacs-next-disable-jit-compilation.patch  | 19 +++++++
 ...emacs-next-native-comp-fix-filenames.patch | 56 +++++++++----------
 4 files changed, 52 insertions(+), 32 deletions(-)
 create mode 100644 gnu/packages/patches/emacs-next-disable-jit-compilation.patch

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index deebb7282d..7d15ddb732 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -25,6 +25,7 @@
 ;;; Copyright © 2022 Zhu Zihao <[email-masked]>
 ;;; Copyright © 2023 Declan Tsien <[email-masked]>
 ;;; Copyright © 2023, 2024 Zheng Junjie <[email-masked]>
+;;; Copyright © 2025 Gabriel Santos <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -572,7 +573,7 @@ (define-public emacs-wide-int
         #~(cons "--with-wide-int" #$flags))))))
 
 (define-public emacs-next-minimal
-  (let ((commit "60232a30e360c00fb303cb033d4aec15a9e41342")
+  (let ((commit "467aba67db407e930fc5de6d4a4ae0cd6fc106df")
         (revision "0"))
   (package
     (inherit emacs-minimal)
@@ -586,9 +587,9 @@ (define-public emacs-next-minimal
              (commit commit)))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1n1i20j92a8sqv224yzvyzk804h9x0lgyp3jlny3b6g08ka91034"))
+        (base32 "05gnavcy1zv1ab4zglqyxfrqym4mq778rwnidqfmafwfk0rzmnn8"))
        (patches
-        (search-patches "emacs-disable-jit-compilation.patch"
+        (search-patches "emacs-next-disable-jit-compilation.patch"
                         "emacs-next-exec-path.patch"
                         "emacs-fix-scheme-indent-function.patch"
                         "emacs-native-comp-driver-options.patch"
diff --git a/gnu/packages/patches/emacs-disable-jit-compilation.patch b/gnu/packages/patches/emacs-disable-jit-compilation.patch
index 8b1ac5a9df..f04b8a3cb7 100644
--- a/gnu/packages/patches/emacs-disable-jit-compilation.patch
+++ b/gnu/packages/patches/emacs-disable-jit-compilation.patch
@@ -11,7 +11,7 @@ Index: emacs-29.2/src/comp.c
 +natively-compiled one.  This variable is enabled by default upstream,
 +but disabled in Guix to better make use of precompiled packages.
 +Notably, Guix removes the hashes that prevent inadvertent shadowing
-+frm the file names of compiled libraries in order to facilitate grafts.
++from the file names of compiled libraries in order to facilitate grafts.
 +Enable at your own risk!  */);
 +  native_comp_jit_compilation = false;
  
diff --git a/gnu/packages/patches/emacs-next-disable-jit-compilation.patch b/gnu/packages/patches/emacs-next-disable-jit-compilation.patch
new file mode 100644
index 0000000000..04145dda17
--- /dev/null
+++ b/gnu/packages/patches/emacs-next-disable-jit-compilation.patch
@@ -0,0 +1,19 @@
+Index: emacs-29.2/src/comp.c
+===================================================================
+--- emacs-29.2.orig/src/comp.c
++++ emacs-29.2/src/comp.c
+@@ -5556,7 +5556,11 @@ syms_of_comp (void)
+     doc: /* If non-nil, compile loaded .elc files asynchronously.
+ 
+ After compilation, each function definition is updated to use the
+-natively compiled one.  */);
+-  native_comp_jit_compilation = true;
++natively compiled one.  This variable is enabled by default upstream,
++but disabled in Guix to better make use of precompiled packages.
++Notably, Guix removes the hashes that prevent inadvertent shadowing
++from the file names of compiled libraries in order to facilitate grafts.
++Enable at your own risk!  */);
++  native_comp_jit_compilation = false;
+ 
+   DEFSYM (Qnative_comp_speed, "native-comp-speed");
+   DEFSYM (Qnative_comp_debug, "native-comp-debug");
\ No newline at end of file
diff --git a/gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch b/gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch
index 54670218ed..016cf4cc42 100644
--- a/gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch
+++ b/gnu/packages/patches/emacs-next-native-comp-fix-filenames.patch
@@ -16,7 +16,7 @@ Index: emacs/src/comp.c
 ===================================================================
 --- emacs.orig/src/comp.c
 +++ emacs/src/comp.c
-@@ -4279,26 +4279,17 @@ DEFUN ("comp-el-to-eln-rel-filename", Fc
+@@ -4390,26 +4390,17 @@ DEFUN ("comp-el-to-eln-rel-filename", Fc
         Scomp_el_to_eln_rel_filename, 1, 1, 0,
         doc: /* Return the relative name of the .eln file for FILENAME.
  FILENAME must exist, and if it's a symlink, the target must exist.
@@ -32,7 +32,7 @@ Index: emacs/src/comp.c
    (Lisp_Object filename)
  {
    CHECK_STRING (filename);
-
+ 
 -  /* Resolve possible symlinks in FILENAME, so that path_hash below
 -     always compares equal. (Bug#44701).  */
 -  filename = Fexpand_file_name (filename, Qnil);
@@ -44,15 +44,15 @@ Index: emacs/src/comp.c
 -      xfree (file_normalized);
 -    }
 +  Lisp_Object rel_name = filename;
-
+ 
 +  filename = Fexpand_file_name (filename, Qnil);
    if (NILP (Ffile_exists_p (filename)))
      xsignal1 (Qfile_missing, filename);
-
-@@ -4306,64 +4297,55 @@ one for the file name and another for it
+ 
+@@ -4417,64 +4408,55 @@ one for the file name and another for it
    filename = Fw32_long_file_name (filename);
  #endif
-
+ 
 -  Lisp_Object content_hash = comp_hash_source_file (filename);
 -
 -  if (suffix_p (filename, ".gz"))
@@ -93,7 +93,7 @@ Index: emacs/src/comp.c
 -    }
 +  Lisp_Object tail = Vload_path;
 +  Lisp_Object name_len = Flength (filename);
-
+ 
 -  Lisp_Object lds_re_tail = loadsearch_re_list;
 -  FOR_EACH_TAIL (lds_re_tail)
 +  FOR_EACH_TAIL_SAFE (tail)
@@ -155,9 +155,9 @@ Index: emacs/src/comp.c
 +  return concat2(Fsubstring (filename, Qnil, make_fixnum (-3)),
 +		 build_string (NATIVE_ELISP_SUFFIX));
  }
-
+ 
  DEFUN ("comp-el-to-eln-filename", Fcomp_el_to_eln_filename,
-@@ -4377,13 +4359,7 @@ If BASE-DIR is non-nil, use it as the di
+@@ -4488,13 +4470,7 @@ If BASE-DIR is non-nil, use it as the di
  non-absolute BASE-DIR is interpreted as relative to `invocation-directory'.
  If BASE-DIR is omitted or nil, look for the first writable directory
  in `native-comp-eln-load-path', and use as BASE-DIR its subdirectory
@@ -172,7 +172,7 @@ Index: emacs/src/comp.c
    (Lisp_Object filename, Lisp_Object base_dir)
  {
    Lisp_Object source_filename = filename;
-@@ -4431,10 +4407,11 @@ the latter is supposed to be used by the
+@@ -4542,10 +4518,11 @@ the latter is supposed to be used by the
    Lisp_Object lisp_preloaded =
      Fgetenv_internal (build_string ("LISP_PRELOADED"), Qnil);
    base_dir = Fexpand_file_name (Vcomp_native_version_dir, base_dir);
@@ -185,34 +185,34 @@ Index: emacs/src/comp.c
 +			     Fmapcar (intern_c_string ("file-name-sans-extension"),
  				      CALLNI (split-string, lisp_preloaded))))))
      base_dir = Fexpand_file_name (build_string ("preloaded"), base_dir);
-
-@@ -5741,10 +5718,7 @@ The last directory of this list is assum
+ 
+@@ -5866,10 +5843,7 @@ The last directory of this list is assum
  the system *.eln files, which are the files produced when building
  Emacs.  */);
-
+ 
 -  /* Temporary value in use for bootstrap.  We can't do better as
 -     `invocation-directory' is still unset, will be fixed up during
 -     dump reload.  */
 -  Vnative_comp_eln_load_path = Fcons (build_string ("../native-lisp/"), Qnil);
 +  Vnative_comp_eln_load_path = Qnil;
-
+ 
    DEFVAR_LISP ("native-comp-enable-subr-trampolines",
  	       Vnative_comp_enable_subr_trampolines,
 Index: emacs/lisp/startup.el
 ===================================================================
 --- emacs.orig/lisp/startup.el
 +++ emacs/lisp/startup.el
-@@ -520,9 +520,6 @@ DIRS are relative."
+@@ -527,9 +527,6 @@ DIRS are relative."
  (defvar native-comp-jit-compilation)
  (defvar native-comp-enable-subr-trampolines)
-
+ 
 -(defvar startup--original-eln-load-path nil
 -  "Original value of `native-comp-eln-load-path'.")
 -
  (defun startup-redirect-eln-cache (cache-directory)
    "Redirect the user's eln-cache directory to CACHE-DIRECTORY.
  CACHE-DIRECTORY must be a single directory, a string.
-@@ -533,22 +530,10 @@ to `user-emacs-directory'.
+@@ -540,22 +537,10 @@ to `user-emacs-directory'.
  For best results, call this function in your early-init file,
  so that the rest of initialization and package loading uses
  the updated value."
@@ -222,7 +222,7 @@ Index: emacs/lisp/startup.el
    (push (expand-file-name (file-name-as-directory cache-directory)
                            user-emacs-directory)
          native-comp-eln-load-path))
-
+ 
 -(defun startup--update-eln-cache ()
 -  "Update the user eln-cache directory due to user customizations."
 -  ;; Don't override user customizations!
@@ -235,20 +235,20 @@ Index: emacs/lisp/startup.el
  (defun startup--rescale-elt-match-p (font-pattern font-object)
    "Test whether FONT-OBJECT matches an element of `face-font-rescale-alist'.
  FONT-OBJECT is a font-object that specifies a font to test.
-@@ -771,9 +756,6 @@ It is the default value of the variable
+@@ -778,9 +763,6 @@ It is the default value of the variable `top-level'."
        (unwind-protect
  	  (command-line)
-
+ 
 -        (when (featurep 'native-compile)
 -          (startup--update-eln-cache))
 -
  	;; Do this again, in case .emacs defined more abbreviations.
  	(if default-directory
  	    (setq default-directory (abbreviate-file-name default-directory)))
-@@ -1385,12 +1367,6 @@ please check its value")
+@@ -1392,12 +1374,6 @@ please check its value")
        startup-init-directory)))
    (setq early-init-file user-init-file)
-
+ 
 -  ;; Amend `native-comp-eln-load-path', since the early-init file may
 -  ;; have altered `user-emacs-directory' and/or changed the eln-cache
 -  ;; directory.
@@ -258,10 +258,10 @@ Index: emacs/lisp/startup.el
    ;; If any package directory exists, initialize the package system.
    (and user-init-file
         package-enable-at-startup
-@@ -1525,12 +1501,6 @@ please check its value")
+@@ -1532,12 +1508,6 @@ please check its value")
          startup-init-directory))
       t)
-
+ 
 -    ;; Amend `native-comp-eln-load-path' again, since the early-init
 -    ;; file may have altered `user-emacs-directory' and/or changed the
 -    ;; eln-cache directory.
@@ -290,7 +290,7 @@ Index: emacs/lisp/loadup.el
  
  ;; Add subdirectories to the load-path for files that might get
  ;; autoloaded when bootstrapping or running Emacs normally.
-@@ -522,27 +530,25 @@ This to have it working when installed o
+@@ -538,27 +546,25 @@ This to have it working when installed o
  directory got moved.  This is set to be a pair in the form of:
  \(rel-filename-from-install-bin . rel-filename-from-local-bin)."
    (when (and load--bin-dest-dir load--eln-dest-dir)
@@ -330,7 +330,7 @@ Index: emacs/lisp/loadup.el
                       ;; Relative filename from the built uninstalled binary.
                       (file-relative-name file invocation-directory))))))
  	     comp-loaded-comp-units-h)))
-@@ -609,7 +615,9 @@ directory got moved.  This is set to be
+@@ -643,7 +649,9 @@ directory got moved.  This is set to be
                     (equal dump-mode "pdump"))
            ;; Don't enable this before bootstrap is completed, as the
            ;; compiler infrastructure may not be usable yet.
@@ -345,11 +345,11 @@ Index: emacs/src/Makefile.in
 ===================================================================
 --- emacs.orig/src/Makefile.in
 +++ emacs/src/Makefile.in
-@@ -567,6 +567,7 @@ shortlisp := $(filter-out ${shortlisp_fi
+@@ -592,6 +592,7 @@ shortlisp := $(filter-out ${shortlisp_fi
  ## We don't really need to sort, but may as well use it to remove duplicates.
  shortlisp := loaddefs.el loadup.el $(sort ${shortlisp})
  export LISP_PRELOADED = ${shortlisp}
 +export NATIVE_COMP_BOGUS_DIRS =
  lisp = $(addprefix ${lispsource}/,${shortlisp})
  
- ## Construct full set of libraries to be linked.
+ ## Construct full set of libraries to be linked.
\ No newline at end of file
-- 
2.49.0