Commit 7ac84a25 authored by Artur Malabarba's avatar Artur Malabarba

* lisp/emacs-lisp/package.el: Always update selected-packages

(package--update-selected-packages): New function.
(package-menu-execute): Use it before starting the transaction,
this way the list of selected packages is updated even when the
transaction fails.
(package-menu--perform-transaction): Don't edit selected-packages.
parent 1f83c3e5
......@@ -2954,9 +2954,24 @@ objects removed."
(dolist (elt (package--sort-by-dependence delete-list))
(condition-case-unless-debug err
(let ((inhibit-message t))
(package-delete elt))
(package-delete elt nil 'nosave))
(error (message (cadr err))))))))
(defun package--update-selected-packages (add remove)
"Update the `package-selected-packages' list according to ADD and REMOVE.
ADD and REMOVE must be disjoint lists of package names (or
`package-desc' objects) to be added and removed to the selected
packages list, respectively."
(dolist (p add)
(cl-pushnew (if (package-desc-p p) (package-desc-name p) p)
(dolist (p remove)
(setq package-selected-packages
(remove (if (package-desc-p p) (package-desc-name p) p)
(when (or add remove)
(package--save-selected-packages package-selected-packages)))
(defun package-menu-execute (&optional noquery)
"Perform marked Package Menu actions.
Packages marked for installation are downloaded and installed;
......@@ -2993,10 +3008,7 @@ Optional argument NOQUERY non-nil means do not ask the user to confirm."
(message (replace-regexp-in-string "__" "ing" message-template) "started")
;; Packages being upgraded are not marked as selected.
(when .install
(dolist (p .install)
(cl-pushnew (package-desc-name p) package-selected-packages))
(package--save-selected-packages package-selected-packages))
(package--update-selected-packages .install .delete)
(package-menu--perform-transaction install-list delete-list)
(when package-selected-packages
(if-let ((removable (package--removable-packages)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment