From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.bugs Subject: bug#59334: 29.0.50; loading native-compiled init file sets user-init-file to .eln Date: Fri, 18 Nov 2022 10:05:50 +0100 Message-ID: References: <8335aheqct.fsf@gnu.org> <83wn7td6l0.fsf@gnu.org> <83fsehcpi2.fsf@gnu.org> <83a64od8nb.fsf@gnu.org> <83tu2wbqgk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000060af2b05edbb052b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12185"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59334@debbugs.gnu.org, akrl@sdf.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 18 10:07:11 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovxL4-0002xU-Ee for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 18 Nov 2022 10:07:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovxKx-0004Y5-QD; Fri, 18 Nov 2022 04:07:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovxKw-0004Xw-C1 for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 04:07:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ovxKw-0003t6-2D for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 04:07:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ovxKv-0006XM-VB for bug-gnu-emacs@gnu.org; Fri, 18 Nov 2022 04:07:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juanma Barranquero Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 18 Nov 2022 09:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59334 X-GNU-PR-Package: emacs Original-Received: via spool by 59334-submit@debbugs.gnu.org id=B59334.166876239725079 (code B ref 59334); Fri, 18 Nov 2022 09:07:01 +0000 Original-Received: (at 59334) by debbugs.gnu.org; 18 Nov 2022 09:06:37 +0000 Original-Received: from localhost ([127.0.0.1]:35251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovxKX-0006WR-5X for submit@debbugs.gnu.org; Fri, 18 Nov 2022 04:06:37 -0500 Original-Received: from mail-pl1-f170.google.com ([209.85.214.170]:39887) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ovxKU-0006WB-Fj for 59334@debbugs.gnu.org; Fri, 18 Nov 2022 04:06:36 -0500 Original-Received: by mail-pl1-f170.google.com with SMTP id k7so4023928pll.6 for <59334@debbugs.gnu.org>; Fri, 18 Nov 2022 01:06:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5x/oR+OBzlym0JS5eMT4RVpEMLGRtAmJ9rA1cvjzZpI=; b=dbQRSPGCPw+Jl7uk+CYnz6aoBw8e6RsVJjvsvUzQkAu5jmu7UWykNucszNugZsM+AM j7Xy5Z5XlOvTQub5DQ+ooy+BW/e46d+kzWjRBDX6u4Q1JSR+ke+ot1rxHlclxA/WXbqC lkJOfxeqQ7HbRjmSzghVCK6x81r+ByAlaLRqb1V7mmaM4RCWK8u9dfhqtpqxq0TEj2wo OyZYnAJv+vA+enrULlGPAPe5SNVjZzMhAK1Nrdm5jwlEMJ0yRuoErfkrysZUF/eqLhnE i7RpWL4RMcYM+rBHhSdoOIhXXa+ol7Zn1LJ/1YQQfeDPRkT+CbKocfptOyiSCyDjSRiS qFBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5x/oR+OBzlym0JS5eMT4RVpEMLGRtAmJ9rA1cvjzZpI=; b=PZ3K2RGU+U8iT8pXa/s9712dmhKUhzzj5dRGHZU/Sh/y2YPgq+ZAjqc6S8vI9Osz1F C34XnYpVQU+rn3AvG8nG2tp9fuZX2+GkXi9nOIhkaM0Sgg6wvS8PGhIE4gTpjkShpTIb 0lbxyurOBuG3md2pw/PNcPCGI39MYLirjTzlhnJLj82/bcHn5inNekHbhofj8TcUIExE 7mF5dbqZq5uzbUzgUEKLHnIzE8X8Kcaaft7A6XA7gqVwyhBy6QpRQgjLXzITBBgeHTch AAujt6HbzFslwjuda1H+vx4xtvQ7pCWnx/7/yna+iJsNHmmQJKoY7X8+kkYF14hi0o4k /tYQ== X-Gm-Message-State: ANoB5pmeFxww0UkycAyqz4u5dT5MYHplk2K4I2u7LH97BLTFv5gQSLv5 MOGgD38WqXqze7w5EJBwbDFqoL1rbe9mjA2fJvU= X-Google-Smtp-Source: AA0mqf6JUeCHMKqJb0Gv9st6xpeuACNtmqnq6IFxeB1ncqSCzno+vnSaKukup30amIPeJI2F7/7QG0j20pPUXMToYio= X-Received: by 2002:a17:902:f313:b0:188:5681:4dc8 with SMTP id c19-20020a170902f31300b0018856814dc8mr6659643ple.23.1668762388441; Fri, 18 Nov 2022 01:06:28 -0800 (PST) In-Reply-To: <83tu2wbqgk.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:248191 Archived-At: --00000000000060af2b05edbb052b Content-Type: text/plain; charset="UTF-8" On Fri, Nov 18, 2022 at 9:46 AM Eli Zaretskii wrote: > I thought about a possibility that the session loaded a .eln file, but > then the user or some Lisp explicitly loaded the .el file by hand. > I'm not sure in this case the hash table is updated. That's a whole another problem, isn't it? On one hand, it would not affect user-init-file, as it's not the usual startup procedure. And, on the other hand, my patch sets user-init-file to the source .el, so after reloading that file it would still have the right value, wouldn't it? Anyway, here's the reworked patch. diff --git i/lisp/startup.el w/lisp/startup.el index 70267fc857..d7d8743336 100644 --- i/lisp/startup.el +++ w/lisp/startup.el @@ -1064,17 +1064,25 @@ 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)) - (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 The original code is untouched, other than changing `when' to `if'; the else part deals with the .eln. I've checked that gethash returns a value, but not for the file's existence because in that case comp already complains: 2022-11-18 10:01:15+0100 Warning (comp): Cannot look up eln file as no source file was found for d:/Home/.emacs.d/init.elc The warning above is only for the unlikely case that user-init-file points to an .eln but the gethash lookup returns nil. --00000000000060af2b05edbb052b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


<= div dir=3D"ltr" class=3D"gmail_attr">On Fri, Nov 18, 2022 at 9:46 AM Eli Za= retskii <eliz@gnu.org> wrote:
=
=
>
I thought about a possibility that the session loaded a .el= n file, but
> then the user or some Lisp explicitly loaded the .el f= ile by hand.
> I'm not sure in this case the hash table is updat= ed.=C2=A0

That's a whole another problem, isn't it?

On o= ne hand, it would not affect user-init-file, as it's not the usual star= tup procedure.=C2=A0And, on the other=C2=A0hand, my patch sets user-init-fi= le to the source .el, so after reloading that file it would still have the = right value, wouldn't it?


diff --git i/lisp/startup.el w/lisp/startup.el
index 70267fc857..d7d8743336 100644
--- i/lisp/startup.el
+++ w/= lisp/startup.el
@@ -1064,17 +1064,25 @@ startup--load-user-init-file
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; If we loaded a compiled = file, set `user-init-file' to
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0;; the source version if that exists.
- =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0(when (equal (file-name-extension user-init-file)
- = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 "elc")
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(let* ((source (file-name-sans-extension user-init-file))
- =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (alt (conca= t source ".el")))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(setq source (cond ((file-exists-p alt) alt)
- =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ((file-exists-p source) source)
- =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (t nil)))
- =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when source
- =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (file-newer-than-file-p = source user-init-file)
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(message "Warning: %s is newer than %s"- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 source user-init-file)
- =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(sit-for 1))
- =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq user-init-= file source))))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(if (equal (f= ile-name-extension user-init-file) "elc")
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let* ((source (file-name-sans-extens= ion user-init-file))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 (alt (concat source ".el")))
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq source (co= nd ((file-exists-p alt) alt)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 ((file-exists-p source) source)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 (t nil)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(when source
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (file-newer-than-file-p sour= ce user-init-file)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(message "Warning: %s is newer than %s"= ;
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 source user-init-file)
+ =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(sit-f= or 1))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(setq user-init-file source)))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0;; Else, perhaps the user init file was compiled
+ =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (equal (file-name-extens= ion user-init-file) "eln")
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(if-let (source (gethash (file-name-nondirectory us= er-init-file)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 comp-eln-to-el-h))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0;; source exists or the .eln file would not = load
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(setq user-init-file source)
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(message "Warning: unknown source file for = init file %S"
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 user-init-file)
+ =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(sit-for 1))))
=C2= =A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (and load-defa= ults


Th= e original code is untouched, other than changing `when' to `if'; t= he else part deals with the .eln.

I've checked that gethash retu= rns a value, but not for the file's existence because in that case comp= already complains:

2022-11-18 10:01= :15+0100 Warning (comp): Cannot look up eln file as no source file was foun= d for d:/Home/.emacs.d/init.elc
=
The warning above is only for the unlikely case that user-init-file poi= nts to an .eln but the gethash lookup returns nil.

--00000000000060af2b05edbb052b--