From aef68eb8043b68a308d35da97ed7fee7024fa212 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 14 Feb 2014 00:38:20 +0100 Subject: [PATCH] Sort and group headlines Even though sorting by feed id is completely meaningless, it is easy. --- avandu.el | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/avandu.el b/avandu.el index ec10823..a4401f3 100644 --- a/avandu.el +++ b/avandu.el @@ -687,14 +687,27 @@ This screen shows the contents of an article. \\{avandu-overview-map} \\") +(defsubst avandu--feed-id (alist) + "Get a feed_id from ALIST." + (cdr (assoc 'feed_id alist))) + +(defun avandu--order-feed (feed1 feed2) + "Return t if FEED1 should be sorted before FEED2." + (string< (avandu--feed-id feed1) (avandu--feed-id feed2))) + ;;;###autoload (defun avandu-overview () - "Request the headlines of unread articles and list them grouped -by feed." + "Request the headlines of unread articles and list them. + +The list is grouped and sorted by feed ID. Sorting by feed ID is +meaningless, but it's easy." (interactive) (avandu--check-login) (let ((buffer (get-buffer-create "*avandu-overview*")) - (result (avandu-headlines -4 :show-excerpt t :view-mode "unread")) + (result (sort (cl-coerce (avandu-headlines -4 :show-excerpt t + :view-mode "unread") + 'list) + #'avandu--order-feed)) feed-id) (with-current-buffer buffer (setq buffer-read-only nil)