Improve interactive package management support
This commit is contained in:
parent
595109209a
commit
e7a1e0b4a2
1 changed files with 115 additions and 109 deletions
|
@ -335,134 +335,140 @@ package.el as appropriate."
|
||||||
(defun doom//packages-install ()
|
(defun doom//packages-install ()
|
||||||
"Interactive command for installing missing packages."
|
"Interactive command for installing missing packages."
|
||||||
(interactive)
|
(interactive)
|
||||||
(message! "Looking for packages to install...")
|
(if (not noninteractive)
|
||||||
(let ((packages (reverse (doom-get-missing-packages))))
|
(doom-packages--async-run 'doom//packages-install)
|
||||||
(cond ((not packages)
|
(message! "Looking for packages to install...")
|
||||||
(message! (green "No packages to install!")))
|
(let ((packages (reverse (doom-get-missing-packages))))
|
||||||
|
(cond ((not packages)
|
||||||
|
(message! (green "No packages to install!")))
|
||||||
|
|
||||||
((not (or (getenv "YES")
|
((not (or (getenv "YES")
|
||||||
(y-or-n-p
|
(y-or-n-p
|
||||||
(format "%s packages will be installed:\n\n%s\n\nProceed?"
|
(format "%s packages will be installed:\n\n%s\n\nProceed?"
|
||||||
(length packages)
|
(length packages)
|
||||||
(mapconcat
|
(mapconcat
|
||||||
(lambda (pkg)
|
(lambda (pkg)
|
||||||
(format "+ %s (%s)"
|
(format "+ %s (%s)"
|
||||||
(car pkg)
|
(car pkg)
|
||||||
(cond ((doom-package-different-recipe-p (car pkg))
|
(cond ((doom-package-different-recipe-p (car pkg))
|
||||||
"new recipe")
|
"new recipe")
|
||||||
((doom-package-different-backend-p (car pkg))
|
((doom-package-different-backend-p (car pkg))
|
||||||
(if (plist-get (cdr pkg) :recipe)
|
(if (plist-get (cdr pkg) :recipe)
|
||||||
"ELPA -> QUELPA"
|
"ELPA -> QUELPA"
|
||||||
"QUELPA -> ELPA"))
|
"QUELPA -> ELPA"))
|
||||||
((plist-get (cdr pkg) :recipe)
|
((plist-get (cdr pkg) :recipe)
|
||||||
"QUELPA")
|
"QUELPA")
|
||||||
(t
|
(t
|
||||||
"ELPA"))))
|
"ELPA"))))
|
||||||
(sort (cl-copy-list packages) #'doom--sort-alpha)
|
(sort (cl-copy-list packages) #'doom--sort-alpha)
|
||||||
"\n")))))
|
"\n")))))
|
||||||
(message! (yellow "Aborted!")))
|
(message! (yellow "Aborted!")))
|
||||||
|
|
||||||
(t
|
(t
|
||||||
(doom-refresh-packages-maybe doom-debug-mode)
|
(doom-refresh-packages-maybe doom-debug-mode)
|
||||||
(dolist (pkg packages)
|
(dolist (pkg packages)
|
||||||
(message! "Installing %s" (car pkg))
|
(message! "Installing %s" (car pkg))
|
||||||
(doom--condition-case!
|
(doom--condition-case!
|
||||||
(message! "%s%s"
|
(message! "%s%s"
|
||||||
(cond ((and (package-installed-p (car pkg))
|
(cond ((and (package-installed-p (car pkg))
|
||||||
(not (doom-package-different-backend-p (car pkg)))
|
(not (doom-package-different-backend-p (car pkg)))
|
||||||
(not (doom-package-different-recipe-p (car pkg))))
|
(not (doom-package-different-recipe-p (car pkg))))
|
||||||
(dark (white "⚠ ALREADY INSTALLED")))
|
(dark (white "⚠ ALREADY INSTALLED")))
|
||||||
((doom-install-package (car pkg) (cdr pkg))
|
((doom-install-package (car pkg) (cdr pkg))
|
||||||
(green "✓ DONE"))
|
(green "✓ DONE"))
|
||||||
(t
|
(t
|
||||||
(red "✕ FAILED")))
|
(red "✕ FAILED")))
|
||||||
(if (plist-member (cdr pkg) :pin)
|
(if (plist-member (cdr pkg) :pin)
|
||||||
(format " [pinned: %s]" (plist-get (cdr pkg) :pin))
|
(format " [pinned: %s]" (plist-get (cdr pkg) :pin))
|
||||||
""))))
|
""))))
|
||||||
|
|
||||||
(message! (bold (green "Finished!")))
|
(message! (bold (green "Finished!")))
|
||||||
(doom//reload-load-path)))))
|
(doom//reload-load-path))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom//packages-update ()
|
(defun doom//packages-update ()
|
||||||
"Interactive command for updating packages."
|
"Interactive command for updating packages."
|
||||||
(interactive)
|
(interactive)
|
||||||
(message! "Looking for outdated packages...")
|
(if (not noninteractive)
|
||||||
(doom-refresh-packages-maybe doom-debug-mode)
|
(doom-packages--async-run 'doom//packages-update)
|
||||||
(let ((packages (sort (doom-get-outdated-packages) #'doom--sort-alpha)))
|
(message! "Looking for outdated packages...")
|
||||||
(cond ((not packages)
|
(doom-refresh-packages-maybe doom-debug-mode)
|
||||||
(message! (green "Everything is up-to-date")))
|
(let ((packages (sort (doom-get-outdated-packages) #'doom--sort-alpha)))
|
||||||
|
(cond ((not packages)
|
||||||
|
(message! (green "Everything is up-to-date")))
|
||||||
|
|
||||||
((not (or (getenv "YES")
|
((not (or (getenv "YES")
|
||||||
(y-or-n-p
|
(y-or-n-p
|
||||||
(format "%s packages will be updated:\n\n%s\n\nProceed?"
|
(format "%s packages will be updated:\n\n%s\n\nProceed?"
|
||||||
(length packages)
|
(length packages)
|
||||||
(let ((max-len
|
(let ((max-len
|
||||||
(or (car (sort (mapcar (lambda (it) (length (symbol-name (car it)))) packages)
|
(or (car (sort (mapcar (lambda (it) (length (symbol-name (car it)))) packages)
|
||||||
(lambda (it other) (> it other))))
|
(lambda (it other) (> it other))))
|
||||||
10)))
|
10)))
|
||||||
(mapconcat
|
(mapconcat
|
||||||
(lambda (pkg)
|
(lambda (pkg)
|
||||||
(format (format "+ %%-%ds %%-%ds -> %%s" (+ max-len 2) 14)
|
(format (format "+ %%-%ds %%-%ds -> %%s" (+ max-len 2) 14)
|
||||||
(symbol-name (car pkg))
|
(symbol-name (car pkg))
|
||||||
(package-version-join (cadr pkg))
|
(package-version-join (cadr pkg))
|
||||||
(package-version-join (cl-caddr pkg))))
|
(package-version-join (cl-caddr pkg))))
|
||||||
packages
|
packages
|
||||||
"\n"))))))
|
"\n"))))))
|
||||||
(message! (yellow "Aborted!")))
|
(message! (yellow "Aborted!")))
|
||||||
|
|
||||||
(t
|
(t
|
||||||
(dolist (pkg packages)
|
(dolist (pkg packages)
|
||||||
(message! "Updating %s" (car pkg))
|
(message! "Updating %s" (car pkg))
|
||||||
(doom--condition-case!
|
(doom--condition-case!
|
||||||
(message!
|
(message!
|
||||||
(let ((result (doom-update-package (car pkg) t)))
|
(let ((result (doom-update-package (car pkg) t)))
|
||||||
(color (if result 'green 'red)
|
(color (if result 'green 'red)
|
||||||
(if result "✓ DONE" "✕ FAILED"))))))
|
(if result "✓ DONE" "✕ FAILED"))))))
|
||||||
|
|
||||||
(message! (bold (green "Finished!")))
|
(message! (bold (green "Finished!")))
|
||||||
(doom//reload-load-path)))))
|
(doom//reload-load-path))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom//packages-autoremove ()
|
(defun doom//packages-autoremove ()
|
||||||
"Interactive command for auto-removing orphaned packages."
|
"Interactive command for auto-removing orphaned packages."
|
||||||
(interactive)
|
(interactive)
|
||||||
(message! "Looking for orphaned packages...")
|
(if (not noninteractive)
|
||||||
(let ((packages (doom-get-orphaned-packages)))
|
(doom-packages--async-run 'doom//packages-autoremove)
|
||||||
(cond ((not packages)
|
(message! "Looking for orphaned packages...")
|
||||||
(message! (green "No unused packages to remove")))
|
(let ((packages (doom-get-orphaned-packages)))
|
||||||
|
(cond ((not packages)
|
||||||
|
(message! (green "No unused packages to remove")))
|
||||||
|
|
||||||
((not
|
((not
|
||||||
(or (getenv "YES")
|
(or (getenv "YES")
|
||||||
(y-or-n-p
|
(y-or-n-p
|
||||||
(format
|
(format
|
||||||
"%s packages will be deleted:\n\n%s\n\nProceed?"
|
"%s packages will be deleted:\n\n%s\n\nProceed?"
|
||||||
(length packages)
|
(length packages)
|
||||||
(mapconcat
|
(mapconcat
|
||||||
(lambda (sym)
|
(lambda (sym)
|
||||||
(format "+ %s (%s)" sym
|
(format "+ %s (%s)" sym
|
||||||
(let ((backend (doom-package-backend sym)))
|
(let ((backend (doom-package-backend sym)))
|
||||||
(if (doom-package-different-backend-p sym)
|
(if (doom-package-different-backend-p sym)
|
||||||
(if (eq backend 'quelpa)
|
(if (eq backend 'quelpa)
|
||||||
"QUELPA->ELPA"
|
"QUELPA->ELPA"
|
||||||
"ELPA->QUELPA")
|
"ELPA->QUELPA")
|
||||||
(upcase (symbol-name backend))))))
|
(upcase (symbol-name backend))))))
|
||||||
(sort (cl-copy-list packages) #'string-lessp)
|
(sort (cl-copy-list packages) #'string-lessp)
|
||||||
"\n")))))
|
"\n")))))
|
||||||
(message! (yellow "Aborted!")))
|
(message! (yellow "Aborted!")))
|
||||||
|
|
||||||
(t
|
(t
|
||||||
(dolist (pkg packages)
|
(dolist (pkg packages)
|
||||||
(doom--condition-case!
|
(doom--condition-case!
|
||||||
(message!
|
(message!
|
||||||
(let ((result (doom-delete-package pkg t)))
|
(let ((result (doom-delete-package pkg t)))
|
||||||
(color (if result 'green 'red)
|
(color (if result 'green 'red)
|
||||||
"%s %s"
|
"%s %s"
|
||||||
(if result "✓ Removed" "✕ Failed to remove")
|
(if result "✓ Removed" "✕ Failed to remove")
|
||||||
pkg)))))
|
pkg)))))
|
||||||
|
|
||||||
(message! (bold (green "Finished!")))
|
(message! (bold (green "Finished!")))
|
||||||
(doom//reload-load-path)))))
|
(doom//reload-load-path))))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue