Refactor how we indent straight's progress output

More work up front, less work in the trenches.
This commit is contained in:
Henrik Lissner 2020-01-01 14:29:40 -05:00
parent 4f676bd218
commit 7a348f8784
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 43 additions and 29 deletions

View file

@ -74,9 +74,7 @@ declaration) or dependency thereof that hasn't already been."
(package local-repo)
(let ((existed-p (file-directory-p (straight--repos-dir package))))
(condition-case-unless-debug e
(and (straight-use-package
(intern package) nil nil
(make-string (1- (or doom-format-indent 1)) 32))
(and (straight-use-package (intern package))
(not existed-p)
(file-directory-p (straight--repos-dir package))
(if-let (commit (cdr (assoc package versions-alist)))
@ -103,29 +101,23 @@ declaration) or dependency thereof that hasn't already been."
(print! (start "(Re)building %spackages...") (if force-p "all " ""))
(straight--transaction-finalize)
(print-group!
(let ((straight-check-for-modifications
(when (file-directory-p (straight--modified-dir))
'(find-when-checking)))
(straight--allow-find (and straight-check-for-modifications t))
(straight--packages-not-to-rebuild
(or straight--packages-not-to-rebuild (make-hash-table :test #'equal)))
(straight-use-package-pre-build-functions
straight-use-package-pre-build-functions)
(n 0))
(add-hook! 'straight-use-package-pre-build-functions (cl-incf n))
(if force-p
(let ((straight--packages-to-rebuild :all))
(dolist (package (hash-table-keys straight--recipe-cache))
(straight-use-package
(intern package) nil nil
(make-string (1- (or doom-format-indent 1)) 32))))
(straight--make-package-modifications-available)
(dolist (recipe (hash-table-values straight--recipe-cache))
(straight--with-plist recipe (package local-repo no-build)
(unless (or no-build (null local-repo))
(straight-use-package
(intern package) nil nil
(make-string (or doom-format-indent 0) 32))))))
(let* ((n 0)
(straight-check-for-modifications
(when (file-directory-p (straight--modified-dir))
'(find-when-checking)))
(straight--allow-find (and straight-check-for-modifications t))
(straight--packages-not-to-rebuild
(or straight--packages-not-to-rebuild (make-hash-table :test #'equal)))
(straight--packages-to-rebuild
(or (if force-p :all straight--packages-to-rebuild)
(make-hash-table :test #'equal)))
(straight-use-package-pre-build-functions
(cons (lambda (&rest _) (cl-incf n))
straight-use-package-pre-build-functions)))
(unless force-p
(straight--make-package-modifications-available))
(dolist (package (hash-table-keys straight--recipe-cache))
(straight-use-package (intern package)))
(if (= n 0)
(ignore (print! (success "No packages need rebuilding")))
(print! (success "Rebuilt %d package(s)" n))