[PATCH WIP v2 1/6] emacs: show: add a function to test for unread

Mark Walters markwalters1009 at gmail.com
Sun Dec 1 02:02:22 PST 2013


This adds a function which tests for unread. A message is deemed
unread if applying `notmuch-show-mark-read-tags' would change the
message's tags.
---
 emacs/notmuch-show.el |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 784644c..a135e79 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1510,6 +1510,17 @@ current thread."
   "Are the headers of the current message visible?"
   (notmuch-show-get-prop :headers-visible))
 
+(defun notmuch-show-unread-p ()
+  "Return t if current message is unread.
+
+Returns t unless applying `notmuch-show-mark-read-tags' would be
+a no-op"
+  (when notmuch-show-mark-read-tags
+    (let* ((current-tags (notmuch-show-get-tags))
+	   (tag-changes (notmuch-tag-change-list notmuch-show-mark-read-tags))
+	   (new-tags (notmuch-update-tags current-tags tag-changes)))
+      (not (equal current-tags new-tags)))))
+
 (put 'notmuch-show-mark-read 'notmuch-prefix-doc
      "Mark the current message as unread.")
 (defun notmuch-show-mark-read (&optional unread)
-- 
1.7.9.1



More information about the notmuch mailing list