Subject: Re: bug#45197: Saving customizations makes ~/.config/emacs/init (no .el extension)

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 17 Dec 2020 12:18:15 +0100

tsuucat <[email-masked]> writes:

> 		  (unless init-file-name
> 		    (setq init-file-name alt-file))
> is added
> in https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=4118297ae2fab4886b20d193ba511a229637aea3.
>
> Before this commit, I think ‘.emacs’ is always used  for ‘user-init-file’ value if
> init file is missing.
>
>                  (and (equal (file-name-extension alt-file) "el")
>                       (setq alt-file (file-name-sans-extension alt-file)))
> ...
>                  (load alt-file 'noerror 'nomessage)))
>
> should be also changed in the commit to use “init.el” not “init".

Yes, I think the code here is just confused -- alt-file is "init" by
default, but since it's passed in as a closure, pretty much anything can
be returned, right?  The code does the right thing in stripping the
".el" before passing it to `load', because then `load' will load
init.elc if it exists.

But we can't add back ".el" before setting init-file-name, because the
alt-file may legitimately be ".emacs", and should not then be forced to
".emacs.el".

So I think the "init" in the alt-file closure is the problem: It should
be "init.el", and init-file-name should be set to that verbatim.  (But
the ".el" should still be stripped before doing the `load'.)

I think.  I've now done this change in Emacs 28, but I'm not
super-confident about it -- there's many subtleties here...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no