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)
This commit is contained in:
Philip Kaludercic 2026-06-29 20:40:33 +02:00
parent 1ac2f60b53
commit b8f71a6011
No known key found for this signature in database

View file

@ -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))))