Refactor doom-cli--generate-autoloads

This commit is contained in:
Henrik Lissner 2019-12-30 17:06:49 -05:00
parent 497a6a206e
commit 0b1ab39a00
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -219,29 +219,29 @@ it is nil, it will try to reload both."
(defun doom-cli--generate-autoloads (files &optional scan) (defun doom-cli--generate-autoloads (files &optional scan)
(require 'autoload) (require 'autoload)
(let (autoloads) (let (autoloads)
(dolist (file files (delq nil (nreverse autoloads))) (dolist (file
(and (file-readable-p file) (cl-remove-if-not #'file-readable-p files)
(with-temp-buffer (nreverse (delq nil autoloads)))
(save-excursion (with-temp-buffer
(if scan (if scan
(doom-cli--generate-autoloads-buffer file) (doom-cli--generate-autoloads-buffer file)
(insert-file-contents-literally file))) (insert-file-contents-literally file))
(save-excursion (save-excursion
(let ((filestr (prin1-to-string file))) (let ((filestr (prin1-to-string file)))
(while (re-search-forward "\\_<load-file-name\\_>" nil t) (while (re-search-forward "\\_<load-file-name\\_>" nil t)
;; `load-file-name' is meaningless in a concatenated ;; `load-file-name' is meaningless in a concatenated
;; mega-autoloads file, so we replace references to it with the ;; mega-autoloads file, so we replace references to it with the
;; file they came from. ;; file they came from.
(unless (doom-point-in-string-or-comment-p) (unless (doom-point-in-string-or-comment-p)
(replace-match filestr t t))))) (replace-match filestr t t)))))
(let ((load-file-name file) (let ((load-file-name file)
(load-path (load-path
(append (list doom-private-dir) (append (list doom-private-dir)
doom-modules-dirs doom-modules-dirs
load-path))) load-path)))
(condition-case _ (condition-case _
(while t (while t
(push (doom-cli--filter-form (read (current-buffer)) (push (doom-cli--filter-form (read (current-buffer))
scan) scan)
autoloads)) autoloads))
(end-of-file)))))))) (end-of-file)))))))