aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2012-06-13 15:33:38 +0800
committerChong Yidong2012-06-13 15:33:38 +0800
commit6005792624e11ee6e4a3b60bc0186b5ef26aaf97 (patch)
treedb1d5b7c5ba6fe685769ecc90ad55a185dc6a269
parentc62ff70691c6c96c1138a485aab402e4f767bdc2 (diff)
downloademacs-6005792624e11ee6e4a3b60bc0186b5ef26aaf97.tar.gz
emacs-6005792624e11ee6e4a3b60bc0186b5ef26aaf97.zip
In the Package Menu, indicate packages that are newly-available.
* lisp/emacs-lisp/package.el (list-packages): Compute a list of packages that are newly-available since the last list-packages invocation. (package-menu--new-package-list): New var. (package-menu--generate, package-menu--print-info) (package-menu--status-predicate, package-menu-mark-install): Handle new status label "new".
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/emacs-lisp/package.el75
3 files changed, 63 insertions, 27 deletions
diff --git a/etc/NEWS b/etc/NEWS
index c5ee62c9256..86c8b695e24 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -299,6 +299,11 @@ details.
299The function `notifications-get-capabilities' returns the supported 299The function `notifications-get-capabilities' returns the supported
300server properties. 300server properties.
301 301
302** Package Menu
303
304*** Newly-available packages are listed in the Package Menu as "new",
305and sorted above the other "available" packages by default.
306
302** Tabulated List and packages derived from it 307** Tabulated List and packages derived from it
303 308
304*** New command `tabulated-list-sort', bound to `S', sorts the column 309*** New command `tabulated-list-sort', bound to `S', sorts the column
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c88f9341964..ba84d59881c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12012-06-13 Chong Yidong <cyd@gnu.org>
2
3 * emacs-lisp/package.el (list-packages): Compute a list of
4 packages that are newly-available since the last list-packages
5 invocation.
6 (package-menu--new-package-list): New var.
7 (package-menu--generate, package-menu--print-info)
8 (package-menu--status-predicate, package-menu-mark-install):
9 Handle new status label "new".
10
12012-06-12 Stefan Monnier <monnier@iro.umontreal.ca> 112012-06-12 Stefan Monnier <monnier@iro.umontreal.ca>
2 12
3 * emacs-lisp/cl-macs.el (cl-remf): Fix error in recent 13 * emacs-lisp/cl-macs.el (cl-remf): Fix error in recent
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 66370c643bf..b01cdbc7b8e 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1362,6 +1362,9 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages."
1362 map) 1362 map)
1363 "Local keymap for `package-menu-mode' buffers.") 1363 "Local keymap for `package-menu-mode' buffers.")
1364 1364
1365(defvar package-menu--new-package-list nil
1366 "List of newly-available packages since `list-packages' was last called.")
1367
1365(define-derived-mode package-menu-mode tabulated-list-mode "Package Menu" 1368(define-derived-mode package-menu-mode tabulated-list-mode "Package Menu"
1366 "Major mode for browsing a list of packages. 1369 "Major mode for browsing a list of packages.
1367Letters do not insert themselves; instead, they are commands. 1370Letters do not insert themselves; instead, they are commands.
@@ -1415,9 +1418,10 @@ or a list of package names (symbols) to display."
1415 (when (or (eq packages t) (memq name packages)) 1418 (when (or (eq packages t) (memq name packages))
1416 (let ((hold (assq name package-load-list))) 1419 (let ((hold (assq name package-load-list)))
1417 (package--push name (cdr elt) 1420 (package--push name (cdr elt)
1418 (if (and hold (null (cadr hold))) 1421 (cond
1419 "disabled" 1422 ((and hold (null (cadr hold))) "disabled")
1420 "available") 1423 ((memq name package-menu--new-package-list) "new")
1424 (t "available"))
1421 info-list)))) 1425 info-list))))
1422 1426
1423 ;; Obsolete packages: 1427 ;; Obsolete packages:
@@ -1442,6 +1446,7 @@ identifier (NAME . VERSION-LIST)."
1442 (face (cond 1446 (face (cond
1443 ((string= status "built-in") 'font-lock-builtin-face) 1447 ((string= status "built-in") 'font-lock-builtin-face)
1444 ((string= status "available") 'default) 1448 ((string= status "available") 'default)
1449 ((string= status "new") 'bold)
1445 ((string= status "held") 'font-lock-constant-face) 1450 ((string= status "held") 'font-lock-constant-face)
1446 ((string= status "disabled") 'font-lock-warning-face) 1451 ((string= status "disabled") 'font-lock-warning-face)
1447 ((string= status "installed") 'font-lock-comment-face) 1452 ((string= status "installed") 'font-lock-comment-face)
@@ -1487,7 +1492,7 @@ If optional arg BUTTON is non-nil, describe its associated package."
1487(defun package-menu-mark-install (&optional _num) 1492(defun package-menu-mark-install (&optional _num)
1488 "Mark a package for installation and move to the next line." 1493 "Mark a package for installation and move to the next line."
1489 (interactive "p") 1494 (interactive "p")
1490 (if (string-equal (package-menu-get-status) "available") 1495 (if (member (package-menu-get-status) '("available" "new"))
1491 (tabulated-list-put-tag "I" t) 1496 (tabulated-list-put-tag "I" t)
1492 (forward-line))) 1497 (forward-line)))
1493 1498
@@ -1536,7 +1541,7 @@ If optional arg BUTTON is non-nil, describe its associated package."
1536 (status (aref (cadr entry) 2))) 1541 (status (aref (cadr entry) 2)))
1537 (cond ((equal status "installed") 1542 (cond ((equal status "installed")
1538 (push pkg installed)) 1543 (push pkg installed))
1539 ((equal status "available") 1544 ((member status '("available" "new"))
1540 (push pkg available))))) 1545 (push pkg available)))))
1541 ;; Loop through list of installed packages, finding upgrades 1546 ;; Loop through list of installed packages, finding upgrades
1542 (dolist (pkg installed) 1547 (dolist (pkg installed)
@@ -1642,16 +1647,18 @@ packages marked for deletion are removed."
1642 (sB (aref (cadr B) 2))) 1647 (sB (aref (cadr B) 2)))
1643 (cond ((string= sA sB) 1648 (cond ((string= sA sB)
1644 (package-menu--name-predicate A B)) 1649 (package-menu--name-predicate A B))
1645 ((string= sA "available") t) 1650 ((string= sA "new") t)
1651 ((string= sB "new") nil)
1652 ((string= sA "available") t)
1646 ((string= sB "available") nil) 1653 ((string= sB "available") nil)
1647 ((string= sA "installed") t) 1654 ((string= sA "installed") t)
1648 ((string= sB "installed") nil) 1655 ((string= sB "installed") nil)
1649 ((string= sA "held") t) 1656 ((string= sA "held") t)
1650 ((string= sB "held") nil) 1657 ((string= sB "held") nil)
1651 ((string= sA "built-in") t) 1658 ((string= sA "built-in") t)
1652 ((string= sB "built-in") nil) 1659 ((string= sB "built-in") nil)
1653 ((string= sA "obsolete") t) 1660 ((string= sA "obsolete") t)
1654 ((string= sB "obsolete") nil) 1661 ((string= sB "obsolete") nil)
1655 (t (string< sA sB))))) 1662 (t (string< sA sB)))))
1656 1663
1657(defun package-menu--description-predicate (A B) 1664(defun package-menu--description-predicate (A B)
@@ -1676,22 +1683,36 @@ The list is displayed in a buffer named `*Packages*'."
1676 ;; Initialize the package system if necessary. 1683 ;; Initialize the package system if necessary.
1677 (unless package--initialized 1684 (unless package--initialized
1678 (package-initialize t)) 1685 (package-initialize t))
1679 (unless no-fetch 1686 (let (old-archives new-packages)
1680 (package-refresh-contents)) 1687 (unless no-fetch
1681 (let ((buf (get-buffer-create "*Packages*"))) 1688 ;; Read the locally-cached archive-contents.
1682 (with-current-buffer buf 1689 (package-read-all-archive-contents)
1683 (package-menu-mode) 1690 (setq old-archives package-archive-contents)
1684 (package-menu--generate nil t)) 1691 ;; Fetch the remote list of packages.
1685 ;; The package menu buffer has keybindings. If the user types 1692 (package-refresh-contents)
1686 ;; `M-x list-packages', that suggests it should become current. 1693 ;; Find which packages are new.
1687 (switch-to-buffer buf)) 1694 (dolist (elt package-archive-contents)
1688 (let ((upgrades (package-menu--find-upgrades))) 1695 (unless (assq (car elt) old-archives)
1689 (if upgrades 1696 (push (car elt) new-packages))))
1690 (message "%d package%s can be upgraded; type `%s' to mark %s for upgrading." 1697
1691 (length upgrades) 1698 ;; Generate the Package Menu.
1692 (if (= (length upgrades) 1) "" "s") 1699 (let ((buf (get-buffer-create "*Packages*")))
1693 (substitute-command-keys "\\[package-menu-mark-upgrades]") 1700 (with-current-buffer buf
1694 (if (= (length upgrades) 1) "it" "them"))))) 1701 (package-menu-mode)
1702 (set (make-local-variable 'package-menu--new-package-list)
1703 new-packages)
1704 (package-menu--generate nil t))
1705 ;; The package menu buffer has keybindings. If the user types
1706 ;; `M-x list-packages', that suggests it should become current.
1707 (switch-to-buffer buf))
1708
1709 (let ((upgrades (package-menu--find-upgrades)))
1710 (if upgrades
1711 (message "%d package%s can be upgraded; type `%s' to mark %s for upgrading."
1712 (length upgrades)
1713 (if (= (length upgrades) 1) "" "s")
1714 (substitute-command-keys "\\[package-menu-mark-upgrades]")
1715 (if (= (length upgrades) 1) "it" "them"))))))
1695 1716
1696;;;###autoload 1717;;;###autoload
1697(defalias 'package-list-packages 'list-packages) 1718(defalias 'package-list-packages 'list-packages)