unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Denys Mentiei <Denys.Mentiei@tobii.com>
Cc: 59507@debbugs.gnu.org
Subject: bug#59507: 29.0.50; Autoloads generation hangs on Windows and Emacs 29
Date: Sat, 26 Nov 2022 13:01:29 +0200	[thread overview]
Message-ID: <83bkout1x2.fsf@gnu.org> (raw)
In-Reply-To: <HE1PR0302MB2603368DBC24E458E29EB488F00C9@HE1PR0302MB2603.eurprd03.prod.outlook.com> (message from Denys Mentiei on Wed, 23 Nov 2022 19:36:12 +0000)

> From: Denys Mentiei <Denys.Mentiei@tobii.com>
> CC: "59507@debbugs.gnu.org" <59507@debbugs.gnu.org>
> Date: Wed, 23 Nov 2022 19:36:12 +0000
> 
> > I may be missing something, but I fail to see the difference between a
> > Windows file name starting with "C:/" and a Unix file name starting with
> > "/", as far as that function is concerned.  Either they both work or they
> > both fail in the same way, because (file-name-directory "/") returns "/".
> 
> Indeed! That is just the use case I describe further was caught on Windows.
> 
> > So do you have a real-life recipe where loaddefs-generate--file-load-name is
> > called and infloops?  Can you show such a recipe, preferably in "emacs -Q"?
> 
> So, this happened for me when installing a package via Straight.el.
> Under the hood it invokes autoloads generation, which can be seen in the
> following backtrace:
>  
>   loaddefs-generate--file-load-name
> ("c:/Users/d/AppData/Roaming/.emacs.d/straight/build/bind-key/bind-key.el"
> "d:/dotfiles/.emacs.d/straight/build/bind-key/bind-key-autoloads.el")

Thanks, I think I see the problem now.  Please try the patch below, which I
just installed on the master branch of the Emacs Git repository:

diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el
index ecc5f7e..2dd0417 100644
--- a/lisp/emacs-lisp/loaddefs-gen.el
+++ b/lisp/emacs-lisp/loaddefs-gen.el
@@ -108,21 +108,26 @@ loaddefs-generate--file-load-name
   (let* ((name (file-relative-name file (file-name-directory outfile)))
          (names '())
          (dir (file-name-directory outfile)))
-    ;; If `name' has directory components, only keep the
-    ;; last few that are really needed.
-    (while name
-      (setq name (directory-file-name name))
-      (push (file-name-nondirectory name) names)
-      (setq name (file-name-directory name)))
-    (while (not name)
-      (cond
-       ((null (cdr names)) (setq name (car names)))
-       ((file-exists-p (expand-file-name "subdirs.el" dir))
-        ;; FIXME: here we only check the existence of subdirs.el,
-        ;; without checking its content.  This makes it generate wrong load
-        ;; names for cases like lisp/term which is not added to load-path.
-        (setq dir (expand-file-name (pop names) dir)))
-       (t (setq name (mapconcat #'identity names "/")))))
+    ;; If `name' lives inside an ancestor directory of OUTFILE, only
+    ;; keep the last few leading directories that are really needed.
+    ;; (It will always live in an ancestor directory of OUTFILE on
+    ;; Posix systems, but on DOS/Windows it could not be, if FILE and
+    ;; OUTFILE are on different drives.)
+    (when (not (file-name-absolute-p name))
+      (while name
+        (setq name (directory-file-name name))
+        (push (file-name-nondirectory name) names)
+        (setq name (file-name-directory name)))
+      (while (not name)
+        (cond
+         ((null (cdr names)) (setq name (car names)))
+         ((file-exists-p (expand-file-name "subdirs.el" dir))
+          ;; FIXME: here we only check the existence of subdirs.el,
+          ;; without checking its content.  This makes it generate
+          ;; wrong load names for cases like lisp/term which is not
+          ;; added to load-path.
+          (setq dir (expand-file-name (pop names) dir)))
+         (t (setq name (mapconcat #'identity names "/"))))))
     (if (string-match "\\.elc?\\(\\.\\|\\'\\)" name)
         (substring name 0 (match-beginning 0))
       name)))





  reply	other threads:[~2022-11-26 11:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-22 20:13 bug#59507: 29.0.50; Autoloads generation hangs on Windows and Emacs 29 Denys Mentiei via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-23 14:33 ` Eli Zaretskii
2022-11-23 19:36   ` Denys Mentiei via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-26 11:01     ` Eli Zaretskii [this message]
2022-11-29  8:58       ` Denys Mentiei via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-29 13:10         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83bkout1x2.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=59507@debbugs.gnu.org \
    --cc=Denys.Mentiei@tobii.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).