[notmuch] [PATCH 2/2] notmuch-new: Tag mails not as unread when the seen flag in...
[notmuch-archives.git] / 53 / 0592e2a5d7036894768f101481101229be3761
1 Return-Path: <stefan@datenfreihafen.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 055BC431FBF\r
6         for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 16:11:31 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id Vz+mNzdau2Gh for <notmuch@notmuchmail.org>;\r
11         Sat, 21 Nov 2009 16:11:30 -0800 (PST)\r
12 Received: from sirius.lasnet.de (sirius.lasnet.de [78.47.116.19])\r
13         by olra.theworths.org (Postfix) with ESMTP id CFD61431FAE\r
14         for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 16:11:29 -0800 (PST)\r
15 Received: from p5b034af6.dip.t-dialin.net ([91.3.74.246] helo=excalibur)\r
16         by sirius.lasnet.de with esmtpsa \r
17         (Cipher TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63 #1)\r
18         id 1NC032-0000td-2v by authid <stefan@sostec.de> with cram_md5;\r
19         Sun, 22 Nov 2009 01:11:28 +0100\r
20 Received: from stefan by excalibur with local (Exim 4.69)\r
21         (envelope-from <stefan@excalibur.local>)\r
22         id 1NC031-0001Dm-H7; Sun, 22 Nov 2009 01:11:23 +0100\r
23 From: Stefan Schmidt <stefan@datenfreihafen.org>\r
24 To: notmuch@notmuchmail.org\r
25 Date: Sun, 22 Nov 2009 01:11:01 +0100\r
26 Message-Id: <1258848661-4660-2-git-send-email-stefan@datenfreihafen.org>\r
27 X-Mailer: git-send-email 1.6.5.3\r
28 In-Reply-To: <1258848661-4660-1-git-send-email-stefan@datenfreihafen.org>\r
29 References: <yes> <1258848661-4660-1-git-send-email-stefan@datenfreihafen.org>\r
30 Subject: [notmuch] [PATCH 2/2] notmuch-new: Tag mails not as unread when the\r
31         seen flag in the maildir is set.\r
32 X-BeenThere: notmuch@notmuchmail.org\r
33 X-Mailman-Version: 2.1.12\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: Sun, 22 Nov 2009 00:11:31 -0000\r
45 \r
46 With the new notmuch_message_get_flags() function we can get the information if\r
47 a message was already flagged as seen in maildir by another mailer or tool. This\r
48 gives a more realistic picture instead of flagging all as unread.\r
49 \r
50 Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>\r
51 ---\r
52  Makefile      |    2 +-\r
53  notmuch-new.c |   16 +++++++++++++++-\r
54  2 files changed, 16 insertions(+), 2 deletions(-)\r
55 \r
56 diff --git a/Makefile b/Makefile\r
57 index 3fedcf1..dfcfc70 100644\r
58 --- a/Makefile\r
59 +++ b/Makefile\r
60 @@ -1,6 +1,6 @@\r
61  # Default FLAGS, (can be overridden by user such as "make CFLAGS=-O2")\r
62  WARN_FLAGS=-Wall -Wextra -Wmissing-declarations -Wwrite-strings -Wswitch-enum\r
63 -CFLAGS=-O2\r
64 +CFLAGS=-O0 -ggdb3\r
65  \r
66  # Additional flags that we will append to whatever the user set.\r
67  # These aren't intended for the user to manipulate.\r
68 diff --git a/notmuch-new.c b/notmuch-new.c\r
69 index bc35b4e..ef4429d 100644\r
70 --- a/notmuch-new.c\r
71 +++ b/notmuch-new.c\r
72 @@ -41,8 +41,22 @@ handle_sigint (unused (int sig))\r
73  static void\r
74  tag_inbox_and_unread (notmuch_message_t *message)\r
75  {\r
76 -    notmuch_message_add_tag (message, "inbox");\r
77 +    char *buf;\r
78 +    int i;\r
79 +\r
80 +    buf = notmuch_message_get_flags (message);\r
81 +    for (i = 0; i < strlen (buf); i++) {\r
82 +        /* If the S flag is set the message can be tagged as read */\r
83 +        if (buf[i] == 'S') {\r
84 +            notmuch_message_add_tag (message, "read");\r
85 +            goto inbox;\r
86 +        }\r
87 +    }\r
88 +\r
89      notmuch_message_add_tag (message, "unread");\r
90 +\r
91 +inbox:\r
92 +    notmuch_message_add_tag (message, "inbox");\r
93  }\r
94  \r
95  static void\r
96 -- \r
97 1.6.5.3\r
98 \r