Skip to content

Commit 6bc41e5

Browse files
committed
fix: color and output
1 parent f5a4a3d commit 6bc41e5

File tree

1 file changed

+38
-31
lines changed

1 file changed

+38
-31
lines changed

lisp/_prepare.el

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ You can pass BUFFER-OR-NAME to replace current buffer."
502502
;;
503503
;;; Archive
504504

505+
(defconst eask-package-archives-url-format
506+
"https://raw.githubusercontent.com/emacs-eask/archives/master/%s/"
507+
"The backup package archives url.")
508+
505509
(defun eask--locate-archive-contents (archive)
506510
"Locate ARCHIVE's contents file."
507511
(let* ((name (cond ((consp archive) (car archive))
@@ -535,38 +539,40 @@ Arguments FNC and ARGS are used for advice `:around'."
535539

536540
(defun eask--download-archives ()
537541
"If archives download failed; download it manually."
538-
(dolist (archive package-archives)
539-
(cl-incf eask--action-index)
540-
(let* ((name (car archive))
541-
(local-file (eask--locate-archive-contents archive))
542-
(dir (file-name-directory local-file)) ; ~/.emacs.d/elpa/archives/{name}
543-
(file (file-name-nondirectory local-file)) ; archive-contents
544-
(url (format "https://raw.githubusercontent.com/emacs-eask/archives/master/%s/" name))
545-
(url-file (concat url file))
546-
(download-p)
547-
;; exclude local elpa
548-
(local-archive-p (string= name eask--local-archive-name))
549-
(fmt (eask--action-format (length package-archives))))
550-
(unless (file-exists-p local-file)
551-
(eask-with-verbosity-override 'log
552-
(when (= 1 eask--action-index) (eask-msg ""))
553-
(eask-with-progress
554-
(format " - %sDownloading %s (%s) manually... "
555-
(format fmt eask--action-index)
556-
(ansi-green name)
557-
(ansi-yellow url))
558-
(eask-with-verbosity 'debug
559-
(unless local-archive-p
542+
(let ((archives (cl-remove-if (lambda (archive)
543+
;; First, exclude the `local' archive.
544+
(equal (car archive) eask--local-archive-name))
545+
package-archives))
546+
(one-download-p))
547+
(dolist (archive archives)
548+
(cl-incf eask--action-index)
549+
(let* ((name (car archive))
550+
(local-file (eask--locate-archive-contents archive))
551+
(dir (file-name-directory local-file)) ; ~/.emacs.d/elpa/archives/{name}/
552+
(contents (file-name-nondirectory local-file)) ; archive-contents
553+
(url (format eask-package-archives-url-format name))
554+
(url-file (concat url contents))
555+
(download-p)
556+
(fmt (eask--action-format (length archives))))
557+
(unless (file-exists-p local-file)
558+
(eask-with-verbosity-override 'log
559+
(when (= 1 eask--action-index) (eask-println ""))
560+
(eask-with-progress
561+
(format " - %sDownloading %s (%s) manually... "
562+
(format fmt eask--action-index)
563+
(ansi-green name)
564+
(ansi-yellow url))
565+
(eask-with-verbosity 'debug
560566
(if (url-file-exists-p url-file)
561567
(progn
562568
(ignore-errors (make-directory dir t))
563569
(url-copy-file url-file local-file t)
564-
(setq download-p t))
565-
(eask-debug "No archive-contents found in `%s'" (ansi-green name)))))
566-
(cond (download-p "done ✓")
567-
(local-archive-p "skipped ✗")
568-
(t "failed ✗")))))
569-
(when download-p (eask-pkg-init t)))))
570+
(setq download-p t
571+
one-download-p t))
572+
(eask-debug "No archive-contents found in `%s'" (ansi-green name))))
573+
(cond (download-p "done ✓")
574+
(t "failed ✗")))))))
575+
(when one-download-p (eask-pkg-init t))))
570576

571577
;;
572578
;;; Package
@@ -1639,8 +1645,9 @@ argument COMMAND."
16391645
;; On recipe
16401646
(when eask-depends-on-recipe-p
16411647
(eask-with-progress
1642-
(format "✓ Checking local archives %s... "
1643-
(ansi-magenta eask--local-archive-name))
1648+
(concat (ansi-green "✓ Checking local archives ")
1649+
(ansi-magenta eask--local-archive-name)
1650+
(ansi-green "... "))
16441651
(eask-with-verbosity 'debug
16451652
;; Make sure can be customized by `source'
16461653
(unless (assoc eask--local-archive-name package-archives)
@@ -1652,7 +1659,7 @@ argument COMMAND."
16521659
;; high number so user we always use the specified dependencies!
16531660
(add-to-list 'package-archive-priorities
16541661
`(,eask--local-archive-name . 90) t)))
1655-
"done!")))
1662+
(ansi-green "done!"))))
16561663

16571664
(add-hook 'eask-file-loaded-hook #'eask--setup-dependencies)
16581665

0 commit comments

Comments
 (0)