bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#59507: 29.0.50; Autoloads generation hangs on Windows and Emacs 29


From: Eli Zaretskii
Subject: bug#59507: 29.0.50; Autoloads generation hangs on Windows and Emacs 29
Date: Sat, 26 Nov 2022 13:01:29 +0200

> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]