diff --git a/core/cli/autoloads.el b/core/cli/autoloads.el index 279b3e870..33b0261eb 100644 --- a/core/cli/autoloads.el +++ b/core/cli/autoloads.el @@ -18,58 +18,51 @@ one wants that.") (defvar autoload-timestamps) (defvar generated-autoload-load-name) -(defun doom-cli-reload-autoloads (&optional type) - "Reloads FILE (an autoload file), if it needs reloading. +(defun doom-cli-reload-autoloads () + "Reloads `doom-autoload-file' and `doom-package-autoload-file' files." + (doom-cli-reload-core-autoloads) + (doom-cli-reload-package-autoloads)) -FILE should be one of `doom-autoload-file' or `doom-package-autoload-file'. If -it is nil, it will try to reload both." - (if type - (cond ((eq type 'core) - (doom-cli-reload-core-autoloads doom-autoload-file)) - ((eq type 'package) - (doom-cli-reload-package-autoloads doom-package-autoload-file)) - ((error "Invalid autoloads file: %s" type))) - (doom-cli-reload-autoloads 'core) - (doom-cli-reload-autoloads 'package))) - -(defun doom-cli-reload-core-autoloads (file) - (cl-check-type file string) +(defun doom-cli-reload-core-autoloads (&optional file) (print! (start "(Re)generating core autoloads...")) (print-group! - (and (print! (start "Generating core autoloads...")) - (doom-cli--write-autoloads - file (doom-cli--generate-autoloads - (cl-loop for dir in (append (list doom-core-dir) - (cdr (doom-module-load-path 'all-p)) - (list doom-private-dir)) - if (doom-glob dir "autoload.el") collect it - if (doom-glob dir "autoload/*.el") append it) - 'scan)) - (print! (start "Byte-compiling core autoloads file...")) - (doom-cli--byte-compile-file file) - (print! (success "Generated %s") - (relpath (byte-compile-dest-file file) - doom-emacs-dir))))) + (let ((file (or file doom-autoload-file))) + (cl-check-type file string) + (and (print! (start "Generating core autoloads...")) + (doom-cli--write-autoloads + file (doom-cli--generate-autoloads + (cl-loop for dir in (append (list doom-core-dir) + (cdr (doom-module-load-path 'all-p)) + (list doom-private-dir)) + if (doom-glob dir "autoload.el") collect it + if (doom-glob dir "autoload/*.el") append it) + 'scan)) + (print! (start "Byte-compiling core autoloads file...")) + (doom-cli--byte-compile-file file) + (print! (success "Generated %s") + (relpath (byte-compile-dest-file file) + doom-emacs-dir)))))) -(defun doom-cli-reload-package-autoloads (file) - (cl-check-type file string) +(defun doom-cli-reload-package-autoloads (&optional file) (print! (start "(Re)generating package autoloads...")) (print-group! (doom-initialize-packages) - (and (print! (start "Generating package autoloads...")) - (doom-cli--write-autoloads - file - (doom-cli--generate-var-cache doom-autoload-cached-vars) - (doom-cli--generate-autoloads - (mapcar #'straight--autoloads-file - (cl-set-difference (hash-table-keys straight--build-cache) - doom-autoload-excluded-packages - :test #'string=)))) - (print! (start "Byte-compiling package autoloads file...")) - (doom-cli--byte-compile-file file) - (print! (success "Generated %s") - (relpath (byte-compile-dest-file file) - doom-emacs-dir))))) + (let ((file (or file doom-package-autoload-file))) + (cl-check-type file string) + (and (print! (start "Generating package autoloads...")) + (doom-cli--write-autoloads + file + (doom-cli--generate-var-cache doom-autoload-cached-vars) + (doom-cli--generate-autoloads + (mapcar #'straight--autoloads-file + (cl-set-difference (hash-table-keys straight--build-cache) + doom-autoload-excluded-packages + :test #'string=)))) + (print! (start "Byte-compiling package autoloads file...")) + (doom-cli--byte-compile-file file) + (print! (success "Generated %s") + (relpath (byte-compile-dest-file file) + doom-emacs-dir)))))) ;; @@ -223,6 +216,7 @@ it is nil, it will try to reload both." (cl-remove-if-not #'file-readable-p files) (nreverse (delq nil autoloads))) (with-temp-buffer + (print! (debug "- Scanning %s") (relpath file doom-emacs-dir)) (if scan (doom-cli--generate-autoloads-buffer file) (insert-file-contents file)) diff --git a/core/cli/packages.el b/core/cli/packages.el index 66ad5886a..931a2da5d 100644 --- a/core/cli/packages.el +++ b/core/cli/packages.el @@ -10,9 +10,9 @@ between HEAD and FETCH_HEAD. This can take a while. This excludes packages whose `package!' declaration contains a non-nil :freeze or :ignore property." (straight-check-all) - (doom-cli-reload-autoloads 'core) + (doom-cli-reload-core-autoloads) (when (doom-cli-packages-update) - (doom-cli-reload-autoloads 'package)) + (doom-cli-reload-package-autoloads)) t) (defcli! (build b) @@ -23,7 +23,7 @@ This ensures that all needed files are symlinked from their package repo and their elisp files are byte-compiled. This is especially necessary if you upgrade Emacs (as byte-code is generally not forward-compatible)." (when (doom-cli-packages-build (not rebuild-p)) - (doom-cli-reload-autoloads 'package)) + (doom-cli-reload-package-autoloads)) t) (defcli! (purge p) @@ -46,7 +46,7 @@ list remains lean." (not norepos-p) (not nobuilds-p) regraft-p) - (doom-cli-reload-autoloads 'package)) + (doom-cli-reload-package-autoloads)) t) ;; (defcli! rollback () ; TODO doom rollback diff --git a/core/cli/test.el b/core/cli/test.el index 44db855ea..1defcf063 100644 --- a/core/cli/test.el +++ b/core/cli/test.el @@ -50,9 +50,9 @@ (require 'core-cli) (doom-initialize 'force 'noerror) (doom-initialize-modules) - (doom-cli-reload-autoloads 'core) + (doom-cli-reload-core-autoloads) (when (doom-cli-packages-install) - (doom-cli-reload-autoloads 'package))))) + (doom-cli-reload-package-autoloads))))) (unless (zerop status) (error "Failed to bootstrap unit tests")))) (with-temp-buffer diff --git a/core/cli/upgrade.el b/core/cli/upgrade.el index 66c6482b9..003f737de 100644 --- a/core/cli/upgrade.el +++ b/core/cli/upgrade.el @@ -18,7 +18,7 @@ following shell commands: (doom-cli-upgrade doom-auto-accept force-p) (doom-cli-execute "refresh") (when (doom-cli-packages-update) - (doom-cli-reload-autoloads 'package) + (doom-cli-reload-package-autoloads) t))) (print! (success "Done! Restart Emacs for changes to take effect.")) (print! "Nothing to do. Doom is up-to-date!"))) diff --git a/core/core-cli.el b/core/core-cli.el index 6d6c10bb7..23304d01b 100644 --- a/core/core-cli.el +++ b/core/core-cli.el @@ -246,16 +246,7 @@ stale." (file-exists-p doom-env-file)) (doom-cli-reload-env-file 'force)) - ;; Ensures that no pre-existing state pollutes the generation of the new - ;; autoloads files. - (dolist (file (list doom-autoload-file doom-package-autoload-file)) - (delete-file file) - (delete-file (byte-compile-dest-file file))) - - (doom-initialize 'force 'noerror) - (doom-initialize-modules) - - (doom-cli-reload-autoloads 'core) + (doom-cli-reload-core-autoloads) (unwind-protect (progn (and (doom-cli-packages-install) @@ -264,7 +255,7 @@ stale." (setq success t)) (and (doom-cli-packages-purge prune-p 'builds-p prune-p prune-p) (setq success t))) - (doom-cli-reload-autoloads 'package) + (doom-cli-reload-package-autoloads) (doom-cli-byte-compile nil 'recompile)) t)))