[PATCH 1/3] Initial support for maildir flags.
Mike Kelly
pioto at pioto.org
Thu Apr 8 12:45:29 PDT 2010
When adding new messages, if they have the 'S' (seen) flag, do not add
them to the 'unread' tag.
---
lib/message.cc | 25 +++++++++++++++++++++++++
lib/notmuch.h | 5 +++++
notmuch-new.c | 3 ++-
3 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/lib/message.cc b/lib/message.cc
index 721c9a6..2ca1562 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -509,6 +509,31 @@ notmuch_message_set_flag (notmuch_message_t *message,
message->flags &= ~(1 << flag);
}
+notmuch_bool_t
+notmuch_message_md_flag (notmuch_message_t *message,
+ const char flag)
+{
+ const char *filename;
+ const char *p;
+
+ filename = notmuch_message_get_filename (message);
+
+ p = strstr (filename, ":2,");
+ if (p == NULL) {
+ /* Not a valid maildir filename */
+ return FALSE;
+ }
+
+ for (p += 3; *p != '\0'; p++) {
+ if (*p == flag) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
time_t
notmuch_message_get_date (notmuch_message_t *message)
{
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 88da078..018c002 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -763,6 +763,11 @@ void
notmuch_message_set_flag (notmuch_message_t *message,
notmuch_message_flag_t flag, notmuch_bool_t value);
+/* See if a given maildir flag is set, based on the message's filename. */
+notmuch_bool_t
+notmuch_message_md_flag (notmuch_message_t *message,
+ const char flag);
+
/* Get the date of 'message' as a time_t value.
*
* For the original textual representation of the Date header from the
diff --git a/notmuch-new.c b/notmuch-new.c
index 44b50aa..511347d 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -97,7 +97,8 @@ static void
tag_inbox_and_unread (notmuch_message_t *message)
{
notmuch_message_add_tag (message, "inbox");
- notmuch_message_add_tag (message, "unread");
+ if (! notmuch_message_md_flag(message, 'S'))
+ notmuch_message_add_tag (message, "unread");
}
static void
--
1.7.0.4
More information about the notmuch
mailing list