emacs-31 b8f71a60119: Compile User Lisp files after adjusting 'load-path'

Philip Kaludercic <[email protected]> Mon, 29 Jun 2026 15:08:32 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit b8f71a601193e3fa11aa54aa963203b8c313741a
Author: Philip Kaludercic <[email protected]>
Commit: Philip Kaludercic <[email protected]>

    Compile User Lisp files after adjusting 'load-path'
    
    * lisp/startup.el (prepare-user-lisp): Collect Lisp files in a
    list and process these after traversing the file system.  This
    is necessary to prevent the compiler from failing to
    byte-compile files that depend on other files in the User Lisp
    directory because their neighboring dependencies cannot be
    located.  (Bug#81304)
---
 lisp/startup.el | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index e6f2087604f..24cb3fc2582 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1263,22 +1263,23 @@ unconditionally."
             (not (string-match-p ignored (file-name-nondirectory dir)))))
          (dir (expand-file-name user-lisp-directory))
          (backup-inhibited t)
-         (dirs (list dir)))
+         (dirs (list dir)) (files '()))
     (add-to-list 'load-path (directory-file-name dir))
     (dolist (file (directory-files-recursively dir "" t pred t))
       (cond
        ((and (file-regular-p file) (string-suffix-p ".el" file))
-        (unless just-activate
-          (with-demoted-errors "Error while compiling: %S"
-            (byte-recompile-file file force 0)
-            (when (native-comp-available-p)
-              (native-compile-async file)))))
+        (push file files))
        ((and (file-directory-p file)
              (not (string-match-p ignored (file-name-nondirectory file))))
         (add-to-list 'load-path (directory-file-name file))
         (push file dirs))))
     (unless just-activate
-      (loaddefs-generate dirs autoload-file nil nil nil force))
+      (loaddefs-generate dirs autoload-file nil nil nil force)
+      (dolist (file files)
+        (with-demoted-errors "Error while compiling: %S"
+          (byte-recompile-file file force 0)
+          (when (native-comp-available-p)
+            (native-compile-async file)))))
     (when (file-exists-p autoload-file)
       (load autoload-file nil t))))