[notmuch] [PATCH 2/2] notmuch-new: Tag mails not as unread when the seen flag in the maildir is set.

Stefan Schmidt stefan at datenfreihafen.org
Sat Nov 21 16:11:01 PST 2009


With the new notmuch_message_get_flags() function we can get the information if
a message was already flagged as seen in maildir by another mailer or tool. This
gives a more realistic picture instead of flagging all as unread.

Signed-off-by: Stefan Schmidt <stefan at datenfreihafen.org>
---
 Makefile      |    2 +-
 notmuch-new.c |   16 +++++++++++++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 3fedcf1..dfcfc70 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Default FLAGS, (can be overridden by user such as "make CFLAGS=-O2")
 WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum
-CFLAGS=-O2
+CFLAGS=-O0 -ggdb3
 
 # Additional flags that we will append to whatever the user set.
 # These aren't intended for the user to manipulate.
diff --git a/notmuch-new.c b/notmuch-new.c
index bc35b4e..ef4429d 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -41,8 +41,22 @@ handle_sigint (unused (int sig))
 static void
 tag_inbox_and_unread (notmuch_message_t *message)
 {
-    notmuch_message_add_tag (message, "inbox");
+    char *buf;
+    int i;
+
+    buf = notmuch_message_get_flags (message);
+    for (i = 0; i < strlen (buf); i++) {
+        /* If the S flag is set the message can be tagged as read */
+        if (buf[i] == 'S') {
+            notmuch_message_add_tag (message, "read");
+            goto inbox;
+        }
+    }
+
     notmuch_message_add_tag (message, "unread");
+
+inbox:
+    notmuch_message_add_tag (message, "inbox");
 }
 
 static void
-- 
1.6.5.3



More information about the notmuch mailing list