[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master c116d9f74c: Avoid `user-init-file' being set to an eln file (bug#
From: |
Juanma Barranquero |
Subject: |
master c116d9f74c: Avoid `user-init-file' being set to an eln file (bug#59334) |
Date: |
Fri, 18 Nov 2022 07:58:13 -0500 (EST) |
branch: master
commit c116d9f74c8fc81a7e98b1519fa300998a8a15c3
Author: Juanma Barranquero <lekktu@gmail.com>
Commit: Juanma Barranquero <lekktu@gmail.com>
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.
---
lisp/startup.el | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/lisp/startup.el b/lisp/startup.el
index 70267fc857..d7d8743336 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))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master c116d9f74c: Avoid `user-init-file' being set to an eln file (bug#59334),
Juanma Barranquero <=