[PATCH 6/7] emacs: hello: add highlight newly arrived messages option

Mark Walters markwalters1009 at gmail.com
Sun May 11 01:34:41 PDT 2014


This adds a function that highlights searches which have newly arrived
messages (ones which arrived since the previous refresh of
notmuch-hello). It does that by getting a full list of matching
message ids and checking whether any new messages have appeared. Thus
it will be slow on large saved searches.
---
 emacs/notmuch-hello.el |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 28e16be..265b879 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -96,6 +96,8 @@ (define-widget 'notmuch-saved-search-plist 'list
 				    (const :tag "Default (messages)" nil)
 				    (function-item :tag "messages/threads"
 						   notmuch-hello-display-count-threads-and-messages)
+				    (function-item :tag "highlight newly arrived messages"
+						   notmuch-hello-display-new-messages)
 				    function)))))
 
 (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")
@@ -507,6 +509,25 @@ (defun notmuch-hello-display-count-threads-and-messages (&rest args)
 			  (notmuch-hello-nice-number threads))))
     (plist-put current :count display)))
 
+(defun notmuch-hello-display-new-messages (&rest args)
+  "Highlight saved searches which have new messages.
+
+New messages are ones which have appeared since the last time
+notmuch hello was refreshed. This will be slow on large queries."
+  (let* ((current (plist-get args :current))
+	 (old (plist-get args :old))
+	 (query (plist-get current :query))
+	 (name (plist-get current :name))
+	 (new-list (notmuch-call-notmuch-sexp "search"
+					      "--output=messages"
+					      "--format=sexp"
+					      query))
+	 (old-list (plist-get old :message-list)))
+    (unless (subsetp new-list old-list :test 'equal)
+      (plist-put current :name (propertize name 'face '(:foreground "red"))))
+    (plist-put current :count (notmuch-hello-nice-number (length new-list)))
+    (plist-put current :message-list new-list)))
+
 (defun notmuch-hello-batch-message-count (elem-plist options)
   "Update the message count for a saved search.
 
-- 
1.7.10.4



More information about the notmuch mailing list