1 Return-Path: <lrilling@gmail.com>
\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 AB0C2429E25
\r
6 for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 15:42:42 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.699 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001,
\r
13 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 6SxtJhQYZa2s for <notmuch@notmuchmail.org>;
\r
17 Mon, 11 Jul 2011 15:42:41 -0700 (PDT)
\r
18 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com
\r
19 [209.85.161.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 9C6B3431FB6
\r
22 for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 15:42:41 -0700 (PDT)
\r
23 Received: by fxh19 with SMTP id 19so4428696fxh.19
\r
24 for <notmuch@notmuchmail.org>; Mon, 11 Jul 2011 15:42:40 -0700 (PDT)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
\r
26 h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to
\r
27 :references; bh=QL0kWUiIQNN2Nji8qmuXge4j9lSGjDUFuv5AyttDpCY=;
\r
28 b=SgyMzlopqr/gsckdWCSDq2Z9z8md8LE/D3xudthnzovg3V1rOCNq5yUncvh4PR2GUa
\r
29 po5Ft/ZkTkyYxqdZW1BA1QbcqTfSSvy618QYAmBrQOfVJg0ofer0YzyvuSp6iH+Pp69v
\r
30 gMBtGOyPLclHUftvOsNjLMyvju1TnU6wyBrJ4=
\r
31 Received: by 10.223.52.155 with SMTP id i27mr8133337fag.139.1310424160452;
\r
32 Mon, 11 Jul 2011 15:42:40 -0700 (PDT)
\r
33 Received: from osdor.le-roi-du-couscous.fr ([78.222.14.116])
\r
34 by mx.google.com with ESMTPS id b13sm9532048fab.12.2011.07.11.15.42.39
\r
35 (version=SSLv3 cipher=OTHER); Mon, 11 Jul 2011 15:42:39 -0700 (PDT)
\r
36 Sender: Louis Rilling <lrilling@gmail.com>
\r
37 From: Louis Rilling <l.rilling@av7.net>
\r
38 To: Austin Clements <amdragon@MIT.EDU>
\r
39 Subject: [PATCH v2] tags_to_maildir_flags: Don't rename if no flags change
\r
40 Date: Tue, 12 Jul 2011 00:41:55 +0200
\r
41 Message-Id: <1310424115-18850-1-git-send-email-l.rilling@av7.net>
\r
42 X-Mailer: git-send-email 1.7.2.5
\r
43 In-Reply-To: <20110711223805.GC3583@localdomain>
\r
44 References: <20110711223805.GC3583@localdomain>
\r
45 Cc: notmuch@notmuchmail.org
\r
46 X-BeenThere: notmuch@notmuchmail.org
\r
47 X-Mailman-Version: 2.1.13
\r
49 List-Id: "Use and development of the notmuch mail system."
\r
50 <notmuch.notmuchmail.org>
\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
54 List-Post: <mailto:notmuch@notmuchmail.org>
\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
58 X-List-Received-Date: Mon, 11 Jul 2011 22:42:42 -0000
\r
60 notmuch_message_tags_to_maildir_flags() unconditionally moves messages from
\r
61 maildir directory "new/" to maildir directory "cur/", which makes messages lose
\r
62 their "new" status in the MUA. However some users want to keep this "new"
\r
63 status after, for instance, an auto-tagging of new messages.
\r
65 However, as Austin mentioned and according to the maildir specification,
\r
66 messages living in "new/" are not allowed to have flags, even if mutt allows it
\r
67 to happen. For this reason, this patch prevents moving messages from "new/" to
\r
68 "cur/", only if no flags have to be changed. It's hopefully enough to satisfy
\r
69 mutt (and maybe other MUAs showing the "new" status) users checking the "new"
\r
73 * v2: Fix bool type as well as NULL returned despite having no errors (Austin
\r
76 Signed-off-by: Louis Rilling <l.rilling@av7.net>
\r
78 lib/message.cc | 12 +++++++++++-
\r
79 1 files changed, 11 insertions(+), 1 deletions(-)
\r
81 diff --git a/lib/message.cc b/lib/message.cc
\r
82 index 64b6cf8..3f8c4ba 100644
\r
83 --- a/lib/message.cc
\r
84 +++ b/lib/message.cc
\r
85 @@ -1139,7 +1139,7 @@ _get_maildir_flag_actions (notmuch_message_t *message,
\r
86 * compute the new maildir filename.
\r
88 * If the existing filename is in the directory "new", the new
\r
89 - * filename will be in the directory "cur".
\r
90 + * filename will be in the directory "cur", unless no flags are changed.
\r
92 * After a sequence of ":2," in the filename, any subsequent
\r
93 * single-character flags will be added or removed according to the
\r
94 @@ -1162,6 +1162,7 @@ _new_maildir_filename (void *ctx,
\r
95 char *filename_new, *dir;
\r
97 int flags_in_map = 0;
\r
98 + notmuch_bool_t flags_changed = FALSE;
\r
102 @@ -1202,6 +1203,7 @@ _new_maildir_filename (void *ctx,
\r
103 if (flag_map[flag] == 0) {
\r
104 flag_map[flag] = 1;
\r
106 + flags_changed = TRUE;
\r
110 @@ -1210,9 +1212,17 @@ _new_maildir_filename (void *ctx,
\r
111 if (flag_map[flag]) {
\r
112 flag_map[flag] = 0;
\r
114 + flags_changed = TRUE;
\r
118 + /* No need to rename. Messages in new/ can be kept in new/.
\r
119 + * Note: We don't even try to fix buggy messages having flags and living in
\r
120 + * new/. It's not our business.
\r
122 + if (!flags_changed)
\r
123 + return talloc_strdup (ctx, filename);
\r
125 filename_new = (char *) talloc_size (ctx,
\r
127 strlen (":2,") + flags_in_map + 1);
\r