Better feedback while updating packages with `Update Spacemacs` link
This commit is contained in:
parent
b8bfa7e1a3
commit
4581515c73
|
@ -377,9 +377,7 @@ If PRE is non nil then `layer-pre-extensions' is read instead of
|
||||||
(spacemacs/replace-last-line-of-buffer
|
(spacemacs/replace-last-line-of-buffer
|
||||||
(format "--> installing %s:%s... [%s/%s]"
|
(format "--> installing %s:%s... [%s/%s]"
|
||||||
(ht-get configuration-layer-all-packages pkg)
|
(ht-get configuration-layer-all-packages pkg)
|
||||||
pkg
|
pkg installed-count not-installed-count) t)
|
||||||
installed-count
|
|
||||||
not-installed-count) t)
|
|
||||||
(unless (package-installed-p pkg)
|
(unless (package-installed-p pkg)
|
||||||
(if (not (assq pkg package-archive-contents))
|
(if (not (assq pkg package-archive-contents))
|
||||||
(spacemacs/append-to-buffer
|
(spacemacs/append-to-buffer
|
||||||
|
@ -392,6 +390,22 @@ If PRE is non nil then `layer-pre-extensions' is read instead of
|
||||||
(redisplay))
|
(redisplay))
|
||||||
(spacemacs/append-to-buffer "\n")))))
|
(spacemacs/append-to-buffer "\n")))))
|
||||||
|
|
||||||
|
(defun configuration-layer//get-packages-to-update (packages)
|
||||||
|
"Return a list of packages to update given a list of PACKAGES."
|
||||||
|
(let (result)
|
||||||
|
(dolist (pkg packages)
|
||||||
|
;; do not stop with errors on builtins and compilation fails
|
||||||
|
(let ((installed-version (configuration-layer//get-package-version pkg))
|
||||||
|
(newest-version (configuration-layer//get-latest-package-version
|
||||||
|
pkg)))
|
||||||
|
;; (message "package - %s" pkg)
|
||||||
|
;; (message "installed - %s" installed-version)
|
||||||
|
;; (message "latest - %s" newest-version)
|
||||||
|
(unless (or (null installed-version)
|
||||||
|
(version<= newest-version installed-version))
|
||||||
|
(push pkg result))))
|
||||||
|
(reverse result)))
|
||||||
|
|
||||||
(defun configuration-layer/update-packages ()
|
(defun configuration-layer/update-packages ()
|
||||||
"Upgrade elpa packages"
|
"Upgrade elpa packages"
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -401,33 +415,29 @@ If PRE is non nil then `layer-pre-extensions' is read instead of
|
||||||
"--> fetching new package repository indexes...\n")
|
"--> fetching new package repository indexes...\n")
|
||||||
(redisplay)
|
(redisplay)
|
||||||
(package-refresh-contents)
|
(package-refresh-contents)
|
||||||
(setq upgraded-count 0)
|
(let* ((pkgs-to-update (configuration-layer//get-packages-to-update
|
||||||
(dolist (pkg configuration-layer-all-packages-sorted)
|
configuration-layer-all-packages-sorted))
|
||||||
;; do not stop with errors on builtins and compilation fails
|
(upgrade-count (length pkgs-to-update))
|
||||||
(ignore-errors
|
(upgraded-count 0))
|
||||||
(let ((installed-version (configuration-layer//get-package-version pkg))
|
(if (> upgrade-count 0)
|
||||||
(newest-version (configuration-layer//get-latest-package-version pkg)))
|
(progn
|
||||||
;; (message "package - %s" pkg)
|
(ignore-errors
|
||||||
;; (message "installed - %s" installed-version)
|
(spacemacs/append-to-buffer
|
||||||
;; (message "latest - %s" newest-version)
|
(format "Found %s package(s) to update...\n" upgrade-count))
|
||||||
(unless (version<= newest-version installed-version)
|
(dolist (pkg pkgs-to-update)
|
||||||
(progn
|
(setq upgraded-count (1+ upgraded-count))
|
||||||
(setq upgraded-count (1+ upgraded-count))
|
(spacemacs/replace-last-line-of-buffer
|
||||||
(spacemacs/replace-last-line-of-buffer
|
(format "--> updating package %s:%s... [%s/%s]"
|
||||||
(format "--> updating packge %s:%s (%s)..."
|
(ht-get configuration-layer-all-packages pkg)
|
||||||
(ht-get configuration-layer-all-packages pkg)
|
pkg upgraded-count upgrade-count) t)
|
||||||
pkg
|
(redisplay)
|
||||||
upgraded-count
|
(configuration-layer//package-delete pkg)
|
||||||
))
|
(package-install pkg))
|
||||||
(redisplay)
|
(spacemacs/append-to-buffer
|
||||||
(configuration-layer//package-delete pkg)
|
(format "\n--> %s packages updated.\n" upgraded-count))
|
||||||
(package-install pkg)
|
(redisplay)))
|
||||||
)))))
|
(spacemacs/append-to-buffer "--> All packages are up to date.\n"))
|
||||||
(spacemacs/append-to-buffer
|
(redisplay)))
|
||||||
(format (concat (if (> upgraded-count 0) "\n" "")
|
|
||||||
"--> %s packages updated.\n")
|
|
||||||
upgraded-count))
|
|
||||||
(redisplay))
|
|
||||||
|
|
||||||
(defun configuration-layer//initialize-packages ()
|
(defun configuration-layer//initialize-packages ()
|
||||||
"Initialize all the declared packages."
|
"Initialize all the declared packages."
|
||||||
|
|
Loading…
Reference in New Issue