[PATCH 1/3] Initial support for maildir flags.
authorMike Kelly <pioto@pioto.org>
Thu, 8 Apr 2010 19:45:29 +0000 (15:45 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:32 +0000 (09:36 -0800)
95/f2f5e5bd35cf946b9f8ea746fdce9e0f270adc [new file with mode: 0644]

diff --git a/95/f2f5e5bd35cf946b9f8ea746fdce9e0f270adc b/95/f2f5e5bd35cf946b9f8ea746fdce9e0f270adc
new file mode 100644 (file)
index 0000000..a5c0a2c
--- /dev/null
@@ -0,0 +1,122 @@
+Return-Path: <pioto@pioto.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 7005F4196F0\r
+       for <notmuch@notmuchmail.org>; Thu,  8 Apr 2010 12:44:44 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id eA-OOBdtaIO4 for <notmuch@notmuchmail.org>;\r
+       Thu,  8 Apr 2010 12:44:43 -0700 (PDT)\r
+Received: from everglades.pioto.org (everglades.pioto.org [207.192.69.249])\r
+       by olra.theworths.org (Postfix) with ESMTP id A0B61431FC1\r
+       for <notmuch@notmuchmail.org>; Thu,  8 Apr 2010 12:44:43 -0700 (PDT)\r
+Received: from aether.pioto.org (pool-96-236-149-110.pitbpa.fios.verizon.net\r
+       [96.236.149.110]) (Authenticated sender: pioto)\r
+       by everglades.pioto.org (Postfix) with ESMTPA id 26E4F160E00;\r
+       Thu,  8 Apr 2010 15:44:43 -0400 (EDT)\r
+Received: by aether.pioto.org (Postfix, from userid 1000)\r
+       id 5B5176B08C; Thu,  8 Apr 2010 15:45:47 -0400 (EDT)\r
+From: Mike Kelly <pioto@pioto.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/3] Initial support for maildir flags.\r
+Date: Thu,  8 Apr 2010 15:45:29 -0400\r
+Message-Id: <1270755931-24290-1-git-send-email-pioto@pioto.org>\r
+X-Mailer: git-send-email 1.7.0.4\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 08 Apr 2010 19:44:44 -0000\r
+\r
+When adding new messages, if they have the 'S' (seen) flag, do not add\r
+them to the 'unread' tag.\r
+---\r
+ lib/message.cc |   25 +++++++++++++++++++++++++\r
+ lib/notmuch.h  |    5 +++++\r
+ notmuch-new.c  |    3 ++-\r
+ 3 files changed, 32 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/lib/message.cc b/lib/message.cc\r
+index 721c9a6..2ca1562 100644\r
+--- a/lib/message.cc\r
++++ b/lib/message.cc\r
+@@ -509,6 +509,31 @@ notmuch_message_set_flag (notmuch_message_t *message,\r
+       message->flags &= ~(1 << flag);\r
+ }\r
\r
++notmuch_bool_t\r
++notmuch_message_md_flag (notmuch_message_t *message,\r
++                       const char flag)\r
++{\r
++    const char *filename;\r
++    const char *p;\r
++\r
++    filename = notmuch_message_get_filename (message);\r
++\r
++    p = strstr (filename, ":2,");\r
++    if (p == NULL) {\r
++        /* Not a valid maildir filename */\r
++        return FALSE;\r
++    }\r
++\r
++    for (p += 3; *p != '\0'; p++) {\r
++        if (*p == flag) {\r
++            return TRUE;\r
++        }\r
++    }\r
++\r
++    return FALSE;\r
++}\r
++\r
++\r
+ time_t\r
+ notmuch_message_get_date (notmuch_message_t *message)\r
+ {\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index 88da078..018c002 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -763,6 +763,11 @@ void\r
+ notmuch_message_set_flag (notmuch_message_t *message,\r
+                         notmuch_message_flag_t flag, notmuch_bool_t value);\r
\r
++/* See if a given maildir flag is set, based on the message's filename. */\r
++notmuch_bool_t\r
++notmuch_message_md_flag (notmuch_message_t *message,\r
++                       const char flag);\r
++\r
+ /* Get the date of 'message' as a time_t value.\r
+  *\r
+  * For the original textual representation of the Date header from the\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index 44b50aa..511347d 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -97,7 +97,8 @@ static void\r
+ tag_inbox_and_unread (notmuch_message_t *message)\r
+ {\r
+     notmuch_message_add_tag (message, "inbox");\r
+-    notmuch_message_add_tag (message, "unread");\r
++    if (! notmuch_message_md_flag(message, 'S'))\r
++        notmuch_message_add_tag (message, "unread");\r
+ }\r
\r
+ static void\r
+-- \r
+1.7.0.4\r
+\r