Commit 1f7abd04 authored by Artur Malabarba's avatar Artur Malabarba

* 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.
parent f9fabb2b
......@@ -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)
......
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