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

From: Lars Ingebrigtsen <[email-masked]>
Date: Tue, 15 Dec 2020 07:14:58 +0100

Eli Zaretskii <[email-masked]> writes:

>> I did not read those 150 messages, and this code is uncommented in
>> startup.el:
>> 
>>      (lambda ()
>>        (expand-file-name
>>         "init"
>>         startup-init-directory))
>> 
>> Does anybody know whether this is just a typo?
>
> It isn't: the code later tries appending .el to the name.

The code flow isn't trivial to follow here, but this is the code:

         (when (and (eq user-init-file t) alternate-filename-function)
                (let ((alt-file (funcall alternate-filename-function)))
                  (and (equal (file-name-extension alt-file) "el")
                       (setq alt-file (file-name-sans-extension alt-file)))
		  (unless init-file-name
		    (setq init-file-name alt-file))
                  (load alt-file 'noerror 'nomessage)))

              ;; If we did not find the user's init file, set
              ;; user-init-file conclusively.  Don't let it be
              ;; set from default.el.
              (when (eq user-init-file t)
                (setq user-init-file init-file-name)))

alternate-filename-function is the lambda up there, so it's
"/tmp/test-home/.config/emacs/init".  So this always sets user-init-file
to the .el-less file name.  (Well, it would have even if the alternate
file name had ended in ".el".)

That makes sense for making a file name for `load' (so that it'll load
the .elc file, if it exists), but setting `user-init-file' to that
.el-less name sounds like the problem here?

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