> 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")

  autoload-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")

  autoload-generate-file-autoloads("c:/Users/d/AppData/Roaming/.emacs.d/straig..." nil "d:/dotfiles/.emacs.d/straight/build/bind-key/bind-...")

  make-directory-autoloads("c:/Users/d/AppData/Roaming/.emacs.d/straight/build/bind-key/" "c:/Users/d/AppData/Roaming/.emacs.d/straight/build/bind-key/bind-key-autoloads.el")

  straight--build-autoloads((:flavor melpa :files ("bind-key.el" "bind-key-pkg.el") :package "bind-key" :local-repo "use-package" :type git :repo "jwiegley/use-package" :host github))

  run-hook-with-args(straight--build-autoloads (:flavor melpa :files ("bind-key.el" "bind-key-pkg.el") :package "bind-key" :local-repo "use-package" :type git :repo "jwiegley/use-package" :host github))

  straight--build-package((:flavor melpa :files ("bind-key.el" "bind-key-pkg.el") :package "bind-key" :local-repo "use-package" :type git :repo "jwiegley/use-package" :host github) "Building use-package")

  #f(compiled-function () #<bytecode -0x1fce4a710bdd24dd>)()

  straight--transaction-exec(use-package-\"81e6ef700f88dfe7131843f7ca08439c\"-nil-nil :now #f(compiled-function () #<bytecode -0x1fce4a710bdd24dd>))

  straight-use-package(bind-key nil nil "Building use-package")

 

And then it hangs in the loop mentioned in my original message.

 

A recipe for “emacs -Q” might be this (not smallest thing so, but a real life one):

 

Paste this to the *scratch*:

 

(defvar bootstrap-version)

(let ((bootstrap-file

       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))

      (bootstrap-version 5))

  (unless (file-exists-p bootstrap-file)

    (with-current-buffer

        (url-retrieve-synchronously

        "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"

        'silent 'inhibit-cookies)

      (goto-char (point-max))

      (eval-print-last-sexp))

    (load bootstrap-file nil 'nomessage)))

(setq straight-vc-git-default-clone-depth '(1 single-branch))

 

aand M-x eval-buffer :) Warning: it will download the straight.el from its GitHub official repo.

Note, that I do this on Windows, so user-emacs-directory isn’t a "~/.emacs.d", but an absolute path,

starting from "c:/".

 

Hope this helps!