bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59334: 29.0.50; loading native-compiled init file sets user-init-fil


From: Eli Zaretskii
Subject: bug#59334: 29.0.50; loading native-compiled init file sets user-init-file to .eln
Date: Fri, 18 Nov 2022 09:27:52 +0200

> From: Juanma Barranquero <lekktu@gmail.com>
> Date: Fri, 18 Nov 2022 03:25:34 +0100
> Cc: Andrea Corallo <akrl@sdf.org>, 59334@debbugs.gnu.org
> 
> diff --git i/lisp/startup.el w/lisp/startup.el
> index 70267fc857..62984426e5 100644
> --- i/lisp/startup.el
> +++ w/lisp/startup.el
> @@ -1064,7 +1064,11 @@ startup--load-user-init-file
>              ;; 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))
> +            (when (member (file-name-extension user-init-file)
> +                          '("elc" "eln"))
> +              (let* ((source (file-name-sans-extension
> +                              (or (gethash
> +                                   (file-name-nondirectory user-init-file)
> +                                   comp-eln-to-el-h)
> +                                  user-init-file)))
>                       (alt (concat source ".el")))
>                  (setq source (cond ((file-exists-p alt) alt)

I think the call to gethash should only be done if the file has the
.eln extension, otherwise you might have false positives.

The logic should be something like

  . if the extension is .eln then
    - try to get the corresponding .el file by gethash
    - if that fails, leave user-init-file to be the original .eln
      file name, perhaps with a warning
    - otherwise, set user-init-file to the .el file from gethash
  . else <the original logic which yields .el or .elc>

The file-exists-and-is-newer test is not relevant to the .eln case,
because Emacs will not load a .eln file that is outdated wrt its
source, and will not use a .eln file whose source is not available.
Andrea, please correct me if I'm wrong.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]