Skip to content

pr fix autoload generation recursion error#953

Open
matsl wants to merge 2 commits into
masterfrom
pr_fix_autoload_generation_recursion_error
Open

pr fix autoload generation recursion error#953
matsl wants to merge 2 commits into
masterfrom
pr_fix_autoload_generation_recursion_error

Conversation

@matsl
Copy link
Copy Markdown
Collaborator

@matsl matsl commented May 13, 2026

What

Do not load and generate autoloads from hload-path while in batch
processing (such as byte compiling).

  • Do not load and generate autoloads from hload-path in batch
  • Remove compile dependency on loading autoloads

Why

When generating autoloads in Emacs 31 we get this error below. It does
not occur with older versions.

Eager macro-expansion failure

❯ make clean autoloads
  GEN      kotl/kotl-autoloads.el
  INFO     Scraping 66 files for loaddefs...
hibtypes:0: Warning: Not registering prefix "hy".  Affects: ("hyrolo-stuck-msg" "hyp-manual" "hyp-address" "hyp-source" "hywiki-word" "hywiki-existing-word")
loaddefs-gen: loading file hsys-youtube (for defact)
Loading /home/matsl/src/hyperbole/hsys-youtube.el (source)...
Warning (emacs): loaddefs-gen: load error
	(error "Eager macro-expansion failure: (error \"Eager macro-expansion failure: (error \\\"Recursive load\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/jka-compr.el.gz\\\" \\\"/home/matsl/share/emacs/31.0.50/lisp/emacs-lisp/pcase.el.gz\\\" \\\"/home/matsl/src/hyperbole/set.el\\\" \\\"/home/matsl/src/hyperbole/hact.el\\\" \\\"/home/matsl/src/hyperbole/hsys-youtube.el\\\" \\\"/home/matsl/src/hyperbole/hload-path.el\\\")\")")
  INFO     Scraping 66 files for loaddefs...done
  GEN      hyperbole-autoloads.el
  INFO     Scraping 13 files for loaddefs...
  INFO     Scraping 13 files for loaddefs...done
  GEN      kotl-autoloads.el
Initializing Hyperbole...
Initializing Hyperbole...done
  INFO     Scraping 14 files for loaddefs...
  INFO     Scraping 14 files for loaddefs...done

The recursive load seems to origin from hload-path.el having a call to
check if autoloads are generated and if not generate and load them.

This PR tries to solve this by limiting the generation and loading of
autoloads to an interactive Emacs.

Further, the byte compile errors that occurs due to not loading
autoloads are resolved by adding declare-function and defvar. Each
el-file is by that possible to compile without having to load the
autoloads.

Note

I though this was a good experiment for solving the loaddefs-gen issue
by decoupling byte compilation from autoloads generation.

It also brought my attention to that we generate autoloads from
hload-path which feels a bit odd. I mean for normal use the autoloads
are generated by the package manager or, when running from source, by our
make target. Anyway this PR does not change that. An interactive Emacs
behaves the same.

matsl added 2 commits May 13, 2026 22:27
* hload-path.el: Only generate and load autoloads when interactive
Add declare-function and defvar declarations so each el-file can be
byte compiled without requiring the autoloads to be loaded.
@matsl matsl requested a review from rswgnu May 13, 2026 21:54
@rswgnu
Copy link
Copy Markdown
Owner

rswgnu commented May 14, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants