Subject: bug#59424: bug#59358: 29.0.50; failing to load .eln for init file sets user-init-file to warnings.el

From: Eli Zaretskii <[email-masked]>
Date: Sun, 27 Nov 2022 21:26:11 +0200

> From: Juanma Barranquero <[email-masked]>
> Date: Sun, 27 Nov 2022 20:01:25 +0100
> Cc: [email-masked]
> 
> On Fri, Nov 18, 2022 at 3:24 PM Eli Zaretskii <[email-masked]> wrote:
>  
>  I think the solution to that is to special-case ".emacs", in
>  maybe_swap_for_eln, as a file name that doesn't have to have the .el
>  extension for this purpose.
> 
> I've been fiddling with maybe_swap_for_eln for a while to try to special-case .emacs and make comp
> native-compile it, but I reached a point where it was getting a bit out of hand in the kludgey department.
> 
> I think that's better implemented by someone more knowledgeable with the native-compiler machinery.

I'm probably missing something, because it looks like this is the place to
do it:

  /* Search eln in the eln-cache directories.  */
  Lisp_Object eln_path_tail = Vnative_comp_eln_load_path;
  Lisp_Object src_name =
    Fsubstring (*filename, Qnil, make_fixnum (-1));  <<<<<<<<<<<<<<<<

The idea is to use

    Fsubstring (*filename, Qnil, make_fixnum (-3))

instead of the above if '*filename' ends in ".emacs.elc" (which you can
establish by using the same suffix_p that is used above this code to verify
the ".elc" extension).

But since you say there's more here than meets the eye, I'm wondering what
did I miss?