emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 1f7abd0: * lisp/emacs-lisp/package.el: Don't erase


From: Artur Malabarba
Subject: [Emacs-diffs] master 1f7abd0: * lisp/emacs-lisp/package.el: Don't erase tags on refresh
Date: Wed, 27 May 2015 19:42:55 +0000

branch: master
commit 1f7abd04bc695c86dc6b8ee5ad88c7639c2c8868
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    * lisp/emacs-lisp/package.el: Don't erase tags on refresh
    
    (package-menu--post-refresh): Call `tabulated-list-print' with the
    UPDATE argument.  This only affects the refresh action, the revert
    action still erases tags.
    (package-menu-get-status): Change `assq' to `assoc'.
    (package-menu--mark-upgrades-1): New function.
    (package-menu--mark-upgrades-pending): New variable.
    (package-menu-mark-upgrades): Use them to delay marking until
    after refresh is done.
    (package-menu--post-refresh): Call mark-upgrades-1 if
    mark-upgrades-pending is non-nil.
---
 lisp/emacs-lisp/package.el |   41 ++++++++++++++++++++++++++++++-----------
 1 files changed, 30 insertions(+), 11 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index b96518d..3d5afa3 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2811,7 +2811,7 @@ The full list of keys can be viewed with 
\\[describe-mode]."
 
 (defun package-menu-get-status ()
   (let* ((id (tabulated-list-get-id))
-         (entry (and id (assq id tabulated-list-entries))))
+         (entry (and id (assoc id tabulated-list-entries))))
     (if entry
         (aref (cadr entry) 2)
       "")))
@@ -2855,15 +2855,15 @@ consideration."
              (push (cons name avail-pkg) upgrades))))
     upgrades))
 
-(defun package-menu-mark-upgrades ()
+(defvar package-menu--mark-upgrades-pending nil
+  "Whether mark-upgrades is waiting for a refresh to finish.")
+
+(defun package-menu--mark-upgrades-1 ()
   "Mark all upgradable packages in the Package Menu.
-For each installed package with a newer version available, place
-an (I)nstall flag on the available version and a (D)elete flag on
-the installed version.  A subsequent \\[package-menu-execute]
-call will upgrade the package."
-  (interactive)
+Implementation of `package-menu-mark-upgrades'."
   (unless (derived-mode-p 'package-menu-mode)
     (error "The current buffer is not a Package Menu"))
+  (setq package-menu--mark-upgrades-pending nil)
   (let ((upgrades (package-menu--find-upgrades)))
     (if (null upgrades)
         (message "No packages to upgrade.")
@@ -2880,8 +2880,24 @@ call will upgrade the package."
                   (t
                    (package-menu-mark-delete))))))
       (message "%d package%s marked for upgrading."
-               (length upgrades)
-               (if (= (length upgrades) 1) "" "s")))))
+        (length upgrades)
+        (if (= (length upgrades) 1) "" "s")))))
+
+(defun package-menu-mark-upgrades ()
+  "Mark all upgradable packages in the Package Menu.
+For each installed package with a newer version available, place
+an (I)nstall flag on the available version and a (D)elete flag on
+the installed version.  A subsequent \\[package-menu-execute]
+call will upgrade the package.
+
+If there's an async refresh operation in progress, the flags will
+be placed as part of `package-menu--post-refresh' instead of
+immediately."
+  (interactive)
+  (if (not package--downloads-in-progress)
+      (package-menu--mark-upgrades-1)
+    (setq package-menu--mark-upgrades-pending t)
+    (message "Waiting for refresh to finish...")))
 
 (defun package-menu--list-to-prompt (packages)
   "Return a string listing PACKAGES that's usable in a prompt.
@@ -3099,8 +3115,11 @@ after `package-menu--perform-transaction'."
   (let ((buf (get-buffer "*Packages*")))
     (when (buffer-live-p buf)
       (with-current-buffer buf
-        (revert-buffer nil 'noconfirm))))
-  (package-menu--find-and-notify-upgrades))
+        (run-hooks 'tabulated-list-revert-hook)
+        (tabulated-list-print 'remember 'update)
+        (if package-menu--mark-upgrades-pending
+            (package-menu--mark-upgrades-1)
+          (package-menu--find-and-notify-upgrades))))))
 
 ;;;###autoload
 (defun list-packages (&optional no-fetch)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]