diff --git a/core/cli/autoloads.el b/core/cli/autoloads.el index 09193c565..11641ff5f 100644 --- a/core/cli/autoloads.el +++ b/core/cli/autoloads.el @@ -7,6 +7,10 @@ These packages have silly or destructive autoload files that try to load everyone in the universe and their dog, causing errors that make babies cry. No one wants that.") +(defvar doom-autoloads-excluded-files + '("/bufler/bufler-workspaces-tabs\\.el$") + "List of regexps whose matching files won't be indexed for autoloads.") + (defvar doom-autoloads-cached-vars '(doom-modules doom-disabled-packages @@ -49,11 +53,13 @@ one wants that.") (list doom-private-dir)) if (doom-glob dir "autoload.el") collect it if (doom-glob dir "autoload/*.el") append it) - (mapcan #'doom-glob doom-autoloads-files))) + (mapcan #'doom-glob doom-autoloads-files)) + nil) (doom-autoloads--scan (mapcar #'straight--autoloads-file (seq-difference (hash-table-keys straight--build-cache) doom-autoloads-excluded-packages)) + doom-autoloads-excluded-files 'literal)) (print! (start "Byte-compiling autoloads file...")) (doom-autoloads--compile-file file) @@ -189,35 +195,38 @@ one wants that.") (doom-autoloads--scan-autodefs file target-buffer module module-enabled-p)))) -(defun doom-autoloads--scan (files &optional literal) +(defun doom-autoloads--scan (files &optional exclude literal) (require 'autoload) - (let (autoloads) - (dolist (file - (seq-filter #'file-readable-p files) - (nreverse (delq nil autoloads))) - (with-temp-buffer - (print! (debug "- Scanning %s") (relpath file doom-emacs-dir)) - (if literal - (insert-file-contents file) - (doom-autoloads--scan-file file)) - (save-excursion - (let ((filestr (prin1-to-string file))) - (while (re-search-forward "\\_" nil t) - ;; `load-file-name' is meaningless in a concatenated - ;; mega-autoloads file, 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 filestr t t)))))) - (let ((load-file-name file) - (load-path - (append (list doom-private-dir) - doom-modules-dirs - load-path))) - (condition-case _ - (while t - (push (doom-autoloads--cleanup-form (read (current-buffer)) - (not literal)) - autoloads)) - (end-of-file))))))) + (let (case-fold-search ; case-sensitive regexp from here on + autoloads) + (dolist (file files (nreverse (delq nil autoloads))) + (when (and (or (null exclude) + (seq-remove (doom-rpartial #'string-match-p file) + exclude)) + (file-readable-p file)) + (doom-log "Scanning %s" file) + (with-temp-buffer + (if literal + (insert-file-contents file) + (doom-autoloads--scan-file file)) + (save-excursion + (let ((filestr (prin1-to-string file))) + (while (re-search-forward "\\_" nil t) + ;; `load-file-name' is meaningless in a concatenated + ;; mega-autoloads file, 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 filestr t t)))))) + (let ((load-file-name file) + (load-path + (append (list doom-private-dir) + doom-modules-dirs + load-path))) + (condition-case _ + (while t + (push (doom-autoloads--cleanup-form (read (current-buffer)) + (not literal)) + autoloads)) + (end-of-file))))))))