[PATCH v2 03/14] cli/reply: reuse show_reply_headers() in headers-only format
[notmuch-archives.git] / 95 / f2f5e5bd35cf946b9f8ea746fdce9e0f270adc
1 Return-Path: <pioto@pioto.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 7005F4196F0\r
6         for <notmuch@notmuchmail.org>; Thu,  8 Apr 2010 12:44:44 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.9\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9] autolearn=ham\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id eA-OOBdtaIO4 for <notmuch@notmuchmail.org>;\r
16         Thu,  8 Apr 2010 12:44:43 -0700 (PDT)\r
17 Received: from everglades.pioto.org (everglades.pioto.org [207.192.69.249])\r
18         by olra.theworths.org (Postfix) with ESMTP id A0B61431FC1\r
19         for <notmuch@notmuchmail.org>; Thu,  8 Apr 2010 12:44:43 -0700 (PDT)\r
20 Received: from aether.pioto.org (pool-96-236-149-110.pitbpa.fios.verizon.net\r
21         [96.236.149.110]) (Authenticated sender: pioto)\r
22         by everglades.pioto.org (Postfix) with ESMTPA id 26E4F160E00;\r
23         Thu,  8 Apr 2010 15:44:43 -0400 (EDT)\r
24 Received: by aether.pioto.org (Postfix, from userid 1000)\r
25         id 5B5176B08C; Thu,  8 Apr 2010 15:45:47 -0400 (EDT)\r
26 From: Mike Kelly <pioto@pioto.org>\r
27 To: notmuch@notmuchmail.org\r
28 Subject: [PATCH 1/3] Initial support for maildir flags.\r
29 Date: Thu,  8 Apr 2010 15:45:29 -0400\r
30 Message-Id: <1270755931-24290-1-git-send-email-pioto@pioto.org>\r
31 X-Mailer: git-send-email 1.7.0.4\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.13\r
34 Precedence: list\r
35 List-Id: "Use and development of the notmuch mail system."\r
36         <notmuch.notmuchmail.org>\r
37 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
38         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
39 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
40 List-Post: <mailto:notmuch@notmuchmail.org>\r
41 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
42 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
44 X-List-Received-Date: Thu, 08 Apr 2010 19:44:44 -0000\r
45 \r
46 When adding new messages, if they have the 'S' (seen) flag, do not add\r
47 them to the 'unread' tag.\r
48 ---\r
49  lib/message.cc |   25 +++++++++++++++++++++++++\r
50  lib/notmuch.h  |    5 +++++\r
51  notmuch-new.c  |    3 ++-\r
52  3 files changed, 32 insertions(+), 1 deletions(-)\r
53 \r
54 diff --git a/lib/message.cc b/lib/message.cc\r
55 index 721c9a6..2ca1562 100644\r
56 --- a/lib/message.cc\r
57 +++ b/lib/message.cc\r
58 @@ -509,6 +509,31 @@ notmuch_message_set_flag (notmuch_message_t *message,\r
59         message->flags &= ~(1 << flag);\r
60  }\r
61  \r
62 +notmuch_bool_t\r
63 +notmuch_message_md_flag (notmuch_message_t *message,\r
64 +                        const char flag)\r
65 +{\r
66 +    const char *filename;\r
67 +    const char *p;\r
68 +\r
69 +    filename = notmuch_message_get_filename (message);\r
70 +\r
71 +    p = strstr (filename, ":2,");\r
72 +    if (p == NULL) {\r
73 +        /* Not a valid maildir filename */\r
74 +        return FALSE;\r
75 +    }\r
76 +\r
77 +    for (p += 3; *p != '\0'; p++) {\r
78 +        if (*p == flag) {\r
79 +            return TRUE;\r
80 +        }\r
81 +    }\r
82 +\r
83 +    return FALSE;\r
84 +}\r
85 +\r
86 +\r
87  time_t\r
88  notmuch_message_get_date (notmuch_message_t *message)\r
89  {\r
90 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
91 index 88da078..018c002 100644\r
92 --- a/lib/notmuch.h\r
93 +++ b/lib/notmuch.h\r
94 @@ -763,6 +763,11 @@ void\r
95  notmuch_message_set_flag (notmuch_message_t *message,\r
96                           notmuch_message_flag_t flag, notmuch_bool_t value);\r
97  \r
98 +/* See if a given maildir flag is set, based on the message's filename. */\r
99 +notmuch_bool_t\r
100 +notmuch_message_md_flag (notmuch_message_t *message,\r
101 +                        const char flag);\r
102 +\r
103  /* Get the date of 'message' as a time_t value.\r
104   *\r
105   * For the original textual representation of the Date header from the\r
106 diff --git a/notmuch-new.c b/notmuch-new.c\r
107 index 44b50aa..511347d 100644\r
108 --- a/notmuch-new.c\r
109 +++ b/notmuch-new.c\r
110 @@ -97,7 +97,8 @@ static void\r
111  tag_inbox_and_unread (notmuch_message_t *message)\r
112  {\r
113      notmuch_message_add_tag (message, "inbox");\r
114 -    notmuch_message_add_tag (message, "unread");\r
115 +    if (! notmuch_message_md_flag(message, 'S'))\r
116 +        notmuch_message_add_tag (message, "unread");\r
117  }\r
118  \r
119  static void\r
120 -- \r
121 1.7.0.4\r
122 \r