diff --git a/lisp/lib/autoloads.el b/lisp/lib/autoloads.el index 13b65de9c..ef3e93ce3 100644 --- a/lisp/lib/autoloads.el +++ b/lisp/lib/autoloads.el @@ -174,29 +174,29 @@ non-nil, treat FILES as pre-generated autoload files instead." (file-readable-p file)) (doom-log "loaddefs:scan: %s" file) (with-temp-buffer - (if literal - (insert-file-contents file) - (doom-autoloads--scan-file file)) - (save-excursion - (while (re-search-forward "\\_" nil t) - ;; `load-file-name' is meaningless in a concatenated - ;; mega-autoloads file, but also essential in isolation, so we - ;; replace references to it with the file they came from. - (let ((ppss (save-excursion (syntax-ppss)))) - (or (nth 3 ppss) - (nth 4 ppss) - (replace-match (prin1-to-string (abbreviate-file-name file)) t t))))) - (let ((load-file-name file) - (load-path - (append (list doom-user-dir) - doom-module-load-path - load-path))) - (condition-case _ - (while t - (push (doom-autoloads--cleanup-form (read (current-buffer)) - (not literal)) - autoloads)) - (end-of-file)))))))) + (let (subautoloads) + (if literal + (insert-file-contents file) + (doom-autoloads--scan-file file)) + (save-excursion + ;; Fixup the special #$ reader form and throw away comments. + (while (re-search-forward "#\\$\\|^;\\(.*\n\\)" nil 'move) + (unless (ppss-string-terminator (save-match-data (syntax-ppss))) + (replace-match (if (match-end 1) "" pfile) t t)))) + (let ((load-file-name file) + (load-path + (append (list doom-user-dir) + doom-module-load-path + load-path))) + (condition-case _ + (while t + (push (doom-autoloads--cleanup-form (read (current-buffer)) + (not literal)) + subautoloads)) + (end-of-file))) + (push `(let* ((load-file-name ,file) (load-true-file-name load-file-name)) + ,@(delq nil subautoloads)) + autoloads))))))) (provide 'doom-lib '(autoloads)) ;;; autoloads.el end here diff --git a/lisp/lib/profiles.el b/lisp/lib/profiles.el index e6349b2e1..a1f6b668a 100644 --- a/lisp/lib/profiles.el +++ b/lisp/lib/profiles.el @@ -397,24 +397,26 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache." (defun doom-profile--generate-doom-autoloads () `((defun doom--startup-module-autoloads () - ,@(doom-autoloads--scan - (append (doom-glob doom-core-dir "lib/*.el") - (cl-loop for dir - in (append (doom-module-load-path) - (list doom-user-dir)) - if (doom-glob dir "autoload.el") collect (car it) - if (doom-glob dir "autoload/*.el") append it) - (mapcan #'doom-glob doom-autoloads-files)) - nil)))) + (let ((load-in-progress t)) + ,@(doom-autoloads--scan + (append (doom-glob doom-core-dir "lib/*.el") + (cl-loop for dir + in (append (doom-module-load-path) + (list doom-user-dir)) + if (doom-glob dir "autoload.el") collect (car it) + if (doom-glob dir "autoload/*.el") append it) + (mapcan #'doom-glob doom-autoloads-files)) + nil))))) (defun doom-profile--generate-package-autoloads () `((defun doom--startup-package-autoloads () - ,@(doom-autoloads--scan - (mapcar #'straight--autoloads-file - (nreverse (seq-difference (hash-table-keys straight--build-cache) - doom-autoloads-excluded-packages))) - doom-autoloads-excluded-files - 'literal)))) + (let ((load-in-progress t)) + ,@(doom-autoloads--scan + (mapcar #'straight--autoloads-file + (nreverse (seq-difference (hash-table-keys straight--build-cache) + doom-autoloads-excluded-packages))) + doom-autoloads-excluded-files + 'literal))))) (provide 'doom-lib '(profiles)) ;;; profiles.el ends here