]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/package.el: Always update selected-packages
authorArtur Malabarba <bruce.connor.am@gmail.com>
Sat, 23 May 2015 09:13:02 +0000 (10:13 +0100)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Sat, 23 May 2015 09:21:27 +0000 (10:21 +0100)
(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.

lisp/emacs-lisp/package.el

index 7e09b1f48154cc5c9f4e7c9095317f25a276b255..b96518df502b9ef92d7a46a0035b29e038a56a89 100644 (file)
@@ -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)
+                package-selected-packages))
+  (dolist (p remove)
+    (setq package-selected-packages
+          (remove (if (package-desc-p p) (package-desc-name p) p)
+                  package-selected-packages)))
+  (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)))