Re: [PATCH 0/4] Allow specifying alternate names for addresses in other_email
[notmuch-archives.git] / a9 / efe5e7cecadab8354c8727b79ae35db512c537
1 Return-Path: <sit@abydos.emilsit.net>\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 B7592404955\r
6         for <notmuch@notmuchmail.org>; Wed, 17 Mar 2010 20:06:02 -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: -0.251\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.251 tagged_above=-999 required=5\r
12         tests=[AWL=-0.748, BAYES_50=0.001, NO_DNS_FOR_FROM=1.496,\r
13         RCVD_IN_DNSWL_LOW=-1] autolearn=no\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id d9tv7qda0c1b for <notmuch@notmuchmail.org>;\r
17         Wed, 17 Mar 2010 20:06:02 -0700 (PDT)\r
18 X-Greylist: delayed 414 seconds by postgrey-1.32 at olra;\r
19         Wed, 17 Mar 2010 20:06:02 PDT\r
20 Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com\r
21         [66.111.4.27])\r
22         by olra.theworths.org (Postfix) with ESMTP id 15499404952\r
23         for <notmuch@notmuchmail.org>; Wed, 17 Mar 2010 20:06:02 -0700 (PDT)\r
24 Received: from compute1.internal (compute1.internal [10.202.2.41])\r
25         by gateway1.messagingengine.com (Postfix) with ESMTP id E3DB1E65FF;\r
26         Wed, 17 Mar 2010 22:59:07 -0400 (EDT)\r
27 Received: from heartbeat2.messagingengine.com ([10.202.2.161])\r
28         by compute1.internal (MEProxy); Wed, 17 Mar 2010 22:59:07 -0400\r
29 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com;\r
30         h=from:to:subject:date:message-id; s=smtpout;\r
31         bh=2ZOysouhYydwa4Qi8MDzSosK/l0=;\r
32         b=PjmKDFo735peRtjLPaTHCqy70uBxD0HIKZM2L1glZPbI0QpbvnMcGyp8OOcO5jRbIBcIQN8i0s9cC0WQgzl6CZDU/qb1XE0r4bloRFQP8UX9xalk1eMZopzGen9c6JGue+mnZG0WLrKPUBaLmGk0ItwgO6qP5UUS91exw0Iz26M=\r
33 X-Sasl-enc: YxhkXx6fv9iX3bREd/PgmWH5EItJzkrEpfGm6Fm4/VHkHa/JkUSyFqc 1268881147\r
34 Received: from abydos.emilsit.net (c-76-24-28-147.hsd1.ma.comcast.net\r
35         [76.24.28.147])\r
36         by mail.messagingengine.com (Postfix) with ESMTPSA id AD0968EB8\r
37         for <notmuch@notmuchmail.org>; Wed, 17 Mar 2010 22:59:07 -0400 (EDT)\r
38 Received: by abydos.emilsit.net (Postfix, from userid 1000)\r
39         id 336EF21E89; Wed, 17 Mar 2010 22:59:07 -0400 (EDT)\r
40 From: Emil Sit <sit@emilsit.net>\r
41 To: notmuch@notmuchmail.org\r
42 Date: Wed, 17 Mar 2010 22:59:07 -0400\r
43 Message-Id: <1268881147-32503-1-git-send-email-sit@emilsit.net>\r
44 X-Mailer: git-send-email 1.6.3.3\r
45 X-Mailman-Approved-At: Mon, 22 Mar 2010 12:17:24 -0700\r
46 Subject: [notmuch] [PATCH] notmuch-new: Parse some maildir flags for labels\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Thu, 18 Mar 2010 03:06:02 -0000\r
60 \r
61 Instead of blanket applying tag:inbox and tag:unread to\r
62 all messages, when parsing a Maildir file, attempt to\r
63 parse the flags encoded in the filename to determine whether\r
64 to mark something as unread (and inbox).  Also, parse user\r
65 flagged messages and trash messages.\r
66 \r
67 Signed-off-by: Emil Sit <sit@emilsit.net>\r
68 ---\r
69 I confess that I'm not actively following the mailing list or actively using\r
70 notmuch to read mail (the vim client seems not to work well for me on Ubuntu\r
71 Hardy and not a huge emacs fan and don't have emacs23; still using mutt/mairix)\r
72 so I apologize if something like this has been discussed/rejected before.  I've\r
73 been playing with this patch locally and it definitely helped with the initial\r
74 import.  It's a nice complement to notmuchsync.\r
75 \r
76 Hope someone finds it useful.\r
77 \r
78  notmuch-new.c |   32 ++++++++++++++++++++++++++++----\r
79  1 files changed, 28 insertions(+), 4 deletions(-)\r
80 \r
81 diff --git a/notmuch-new.c b/notmuch-new.c\r
82 index 44b50aa..f937e85 100644\r
83 --- a/notmuch-new.c\r
84 +++ b/notmuch-new.c\r
85 @@ -94,10 +94,34 @@ _filename_list_add (_filename_list_t *list,\r
86  }\r
87  \r
88  static void\r
89 -tag_inbox_and_unread (notmuch_message_t *message)\r
90 +tag_maildir_message (const char *filename, notmuch_message_t *message)\r
91  {\r
92 -    notmuch_message_add_tag (message, "inbox");\r
93 -    notmuch_message_add_tag (message, "unread");\r
94 +    notmuch_bool_t is_read = FALSE;\r
95 +\r
96 +    const char *p = strrchr (filename, ':');\r
97 +    if (p != NULL && strncmp(p + 1, "2,", 2) == 0) {\r
98 +        /* This appears to be a valid Maildir filename.\r
99 +         * Interpret some basic semantics */\r
100 +        while (*p) {\r
101 +            switch (*p) {\r
102 +                case 'S': /* seen */\r
103 +                    is_read = TRUE;\r
104 +                    break;\r
105 +                case 'T': /* trashed */\r
106 +                    notmuch_message_add_tag (message, "trash");\r
107 +                    break;\r
108 +                case 'F': /* flagged */\r
109 +                    notmuch_message_add_tag (message, "flagged");\r
110 +                    break;\r
111 +            }\r
112 +            p++;\r
113 +        }\r
114 +    }\r
115 +\r
116 +    if (!is_read) {\r
117 +        notmuch_message_add_tag (message, "inbox");\r
118 +        notmuch_message_add_tag (message, "unread");\r
119 +    }\r
120  }\r
121  \r
122  static void\r
123 @@ -412,7 +436,7 @@ add_files_recursive (notmuch_database_t *notmuch,\r
124         /* success */\r
125         case NOTMUCH_STATUS_SUCCESS:\r
126             state->added_messages++;\r
127 -           tag_inbox_and_unread (message);\r
128 +           tag_maildir_message (next, message);\r
129             break;\r
130         /* Non-fatal issues (go on to next file) */\r
131         case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
132 -- \r
133 1.6.3.3\r
134 \r