Comments
Patch
@@ -516,6 +516,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)
{
@@ -753,6 +753,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
@@ -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