diff options
author | Juanma Barranquero <lekktu@gmail.com> | 2022-11-18 13:57:00 +0100 |
---|---|---|
committer | Juanma Barranquero <lekktu@gmail.com> | 2022-11-18 13:57:33 +0100 |
commit | c116d9f74c8fc81a7e98b1519fa300998a8a15c3 (patch) | |
tree | d257403481542514e85fc4a55c6a2f33295bf64b /lisp/startup.el | |
parent | f7ee6609ae3b9cbafd48c89bad160b4e17f5b386 (diff) | |
download | emacs-c116d9f74c8fc81a7e98b1519fa300998a8a15c3.tar.gz emacs-c116d9f74c8fc81a7e98b1519fa300998a8a15c3.tar.bz2 emacs-c116d9f74c8fc81a7e98b1519fa300998a8a15c3.zip |
Avoid `user-init-file' being set to an eln file (bug#59334)
* lisp/startup.el (startup--load-user-init-file): If possible,
point `user-init-file' to the source file if the init file was
native-compiled.
Diffstat (limited to 'lisp/startup.el')
-rw-r--r-- | lisp/startup.el | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/lisp/startup.el b/lisp/startup.el index 70267fc857d..d7d87433362 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1063,19 +1063,27 @@ init-file, or to a default value if loading is not possible." ;; If we loaded a compiled file, set `user-init-file' to ;; the source version if that exists. - (when (equal (file-name-extension user-init-file) - "elc") - (let* ((source (file-name-sans-extension user-init-file)) - (alt (concat source ".el"))) - (setq source (cond ((file-exists-p alt) alt) - ((file-exists-p source) source) - (t nil))) - (when source - (when (file-newer-than-file-p source user-init-file) - (message "Warning: %s is newer than %s" - source user-init-file) - (sit-for 1)) - (setq user-init-file source)))) + (if (equal (file-name-extension user-init-file) "elc") + (let* ((source (file-name-sans-extension user-init-file)) + (alt (concat source ".el"))) + (setq source (cond ((file-exists-p alt) alt) + ((file-exists-p source) source) + (t nil))) + (when source + (when (file-newer-than-file-p source user-init-file) + (message "Warning: %s is newer than %s" + source user-init-file) + (sit-for 1)) + (setq user-init-file source))) + ;; Else, perhaps the user init file was compiled + (when (equal (file-name-extension user-init-file) "eln") + (if-let (source (gethash (file-name-nondirectory user-init-file) + comp-eln-to-el-h)) + ;; source exists or the .eln file would not load + (setq user-init-file source) + (message "Warning: unknown source file for init file %S" + user-init-file) + (sit-for 1)))) (when (and load-defaults (not inhibit-default-init)) |