]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/package.el: Mode-line progress report
authorArtur Malabarba <bruce.connor.am@gmail.com>
Thu, 21 May 2015 08:58:45 +0000 (09:58 +0100)
committerArtur Malabarba <bruce.connor.am@gmail.com>
Thu, 21 May 2015 08:59:45 +0000 (09:59 +0100)
(package-menu--transaction-status): New variable.
(package-menu-mode, package-menu--perform-transaction): Use it.

lisp/emacs-lisp/package.el

index 95882ee3069b406e9db361a120c30cba257cf9a2..444adf0d127b41dcade0ffbfecd047fed123c1c8 100644 (file)
@@ -2400,12 +2400,17 @@ will be deleted."
 (defvar package-menu--new-package-list nil
   "List of newly-available packages since `list-packages' was last called.")
 
+(defvar package-menu--transaction-status nil
+  "Mode-line status of ongoing package transaction.")
+
 (define-derived-mode package-menu-mode tabulated-list-mode "Package Menu"
   "Major mode for browsing a list of packages.
 Letters do not insert themselves; instead, they are commands.
 \\<package-menu-mode-map>
 \\{package-menu-mode-map}"
-  (setq mode-line-process '(package--downloads-in-progress ":Loading"))
+  (setq mode-line-process '((package--downloads-in-progress ":Loading")
+                            (package-menu--transaction-status
+                             package-menu--transaction-status)))
   (setq tabulated-list-format
         `[("Package" 18 package-menu--name-predicate)
           ("Version" 13 nil)
@@ -2929,20 +2934,31 @@ objects removed."
 (defun package-menu--perform-transaction (install-list delete-list)
   "Install packages in INSTALL-LIST and delete DELETE-LIST."
   (if install-list
-      (dolist (pkg install-list)
-        (package-install
-         ;; Don't mark as selected if it's a new version of an
-         ;; installed package.
-         pkg (and (not (package-installed-p pkg))
-                  (package-installed-p
-                   (package-desc-name pkg)))))
+      (let ((status-format (format ":Installing %%d/%d"
+                             (length install-list)))
+            (i 0)
+            (package-menu--transaction-status))
+        (dolist (pkg install-list)
+          (setq package-menu--transaction-status
+                (format status-format (cl-incf i)))
+          (force-mode-line-update)
+          (redisplay 'force)
+          (package-install
+           ;; Don't mark as selected if it's a new version of an
+           ;; installed package.
+           pkg (and (not (package-installed-p pkg))
+                    (package-installed-p
+                     (package-desc-name pkg))))))
     ;; Once there are no more packages to install, proceed to
     ;; deletion.
-    (dolist (elt (package--sort-by-dependence delete-list))
-      (condition-case-unless-debug err
-          (let ((inhibit-message t))
-            (package-delete elt))
-        (error (message (cadr err)))))))
+    (let ((package-menu--transaction-status ":Deleting"))
+      (force-mode-line-update)
+      (redisplay 'force)
+      (dolist (elt (package--sort-by-dependence delete-list))
+        (condition-case-unless-debug err
+            (let ((inhibit-message t))
+              (package-delete elt))
+          (error (message (cadr err))))))))
 
 (defun package-menu-execute (&optional noquery)
   "Perform marked Package Menu actions.