From 8b29276fa445791438b2952bbd88debd4d5d94f4 Mon Sep 17 00:00:00 2001 From: Mats Lidell Date: Fri, 15 May 2026 23:41:04 +0200 Subject: [PATCH] Make autoloads in synchronous subprocess Avoid loading files within current Emacs when generating autoloads while Hyperbole is being loaded. * hload-path.el (hload-path--make-directory-autoloads-in-sync-subprocess): Run autoload generation in a synchronous subprocess. (hyperb:generate-autoloads): Use hload-path--make-directory-autoloads-in-sync-subprocess. --- ChangeLog | 7 +++++++ hload-path.el | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 014e6cf7..1c3d8c34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2026-05-16 Mats Lidell + +* hload-path.el (hload-path--make-directory-autoloads-in-sync-subprocess): + Run autoload generation in a synchronous subprocess. + (hyperb:generate-autoloads): Use + hload-path--make-directory-autoloads-in-sync-subprocess. + 2026-05-15 Mats Lidell * Add declare-function and defvar that replaces the autoload definitions diff --git a/hload-path.el b/hload-path.el index 4e2fc48f..17759331 100644 --- a/hload-path.el +++ b/hload-path.el @@ -95,6 +95,21 @@ directory separator character.") "Use `loaddefs-generate' if available or fallback to `make-directory-autoloads'. `make-directory-autoloads' is defined since Emacs 28.") +(defun hload-path--make-directory-autoloads-in-sync-subprocess (dirs output-file) + "Make autoloads in a synchronous subprocess for directories DIRS. +The autoloads will be written to OUTPUT-FILE. Use `loaddefs-generate' +if available or fallback to `make-directory-autoloads', defined since +Emacs 28." + (call-process (expand-file-name invocation-name invocation-directory) + nil nil nil + "--batch" + "--eval" (format "(%S '%S %S)" + (cond ((fboundp 'loaddefs-generate) + #'loaddefs-generate) + (t + #'make-directory-autoloads)) + dirs output-file))) + ;; Menu items could call this function before Info is loaded. (autoload 'Info-goto-node "info" "Jump to specific Info node." t) @@ -119,12 +134,12 @@ This is used only when running from git source and not a package release." (al-buf (find-file-noselect al-file))) ;; (make-local-variable 'generated-autoload-file) (with-current-buffer al-buf - (hload-path--make-directory-autoloads "." al-file)) + (hload-path--make-directory-autoloads-in-sync-subprocess "." al-file)) (kill-buffer al-buf) (setq al-file (expand-file-name "kotl/kotl-autoloads.el") al-buf (find-file-noselect al-file)) (with-current-buffer al-buf - (hload-path--make-directory-autoloads "." al-file)) + (hload-path--make-directory-autoloads-in-sync-subprocess "." al-file)) (kill-buffer al-buf)) (unless (hyperb:autoloads-exist-p) (error "Hyperbole failed to generate autoload files; try running 'make src' in a shell in %s" hyperb:dir)))