From: Louis Rilling <l.rilling@av7.net>
To: Austin Clements <amdragon@MIT.EDU>
Cc: notmuch@notmuchmail.org
Subject: [PATCH v2] tags_to_maildir_flags: Don't rename if no flags change
Date: Tue, 12 Jul 2011 00:41:55 +0200 [thread overview]
Message-ID: <1310424115-18850-1-git-send-email-l.rilling@av7.net> (raw)
In-Reply-To: <20110711223805.GC3583@localdomain>
notmuch_message_tags_to_maildir_flags() unconditionally moves messages from
maildir directory "new/" to maildir directory "cur/", which makes messages lose
their "new" status in the MUA. However some users want to keep this "new"
status after, for instance, an auto-tagging of new messages.
However, as Austin mentioned and according to the maildir specification,
messages living in "new/" are not allowed to have flags, even if mutt allows it
to happen. For this reason, this patch prevents moving messages from "new/" to
"cur/", only if no flags have to be changed. It's hopefully enough to satisfy
mutt (and maybe other MUAs showing the "new" status) users checking the "new"
status.
Changelog:
* v2: Fix bool type as well as NULL returned despite having no errors (Austin
Clements)
Signed-off-by: Louis Rilling <l.rilling@av7.net>
---
lib/message.cc | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/lib/message.cc b/lib/message.cc
index 64b6cf8..3f8c4ba 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -1139,7 +1139,7 @@ _get_maildir_flag_actions (notmuch_message_t *message,
* compute the new maildir filename.
*
* If the existing filename is in the directory "new", the new
- * filename will be in the directory "cur".
+ * filename will be in the directory "cur", unless no flags are changed.
*
* After a sequence of ":2," in the filename, any subsequent
* single-character flags will be added or removed according to the
@@ -1162,6 +1162,7 @@ _new_maildir_filename (void *ctx,
char *filename_new, *dir;
char flag_map[128];
int flags_in_map = 0;
+ notmuch_bool_t flags_changed = FALSE;
unsigned int i;
char *s;
@@ -1202,6 +1203,7 @@ _new_maildir_filename (void *ctx,
if (flag_map[flag] == 0) {
flag_map[flag] = 1;
flags_in_map++;
+ flags_changed = TRUE;
}
}
@@ -1210,9 +1212,17 @@ _new_maildir_filename (void *ctx,
if (flag_map[flag]) {
flag_map[flag] = 0;
flags_in_map--;
+ flags_changed = TRUE;
}
}
+ /* No need to rename. Messages in new/ can be kept in new/.
+ * Note: We don't even try to fix buggy messages having flags and living in
+ * new/. It's not our business.
+ */
+ if (!flags_changed)
+ return talloc_strdup (ctx, filename);
+
filename_new = (char *) talloc_size (ctx,
info - filename +
strlen (":2,") + flags_in_map + 1);
--
1.7.2.5
next prev parent reply other threads:[~2011-07-11 22:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-23 15:36 [RFC][PATCH] tags_to_maildir_flags: Add option to not move messages from "new/" to "cur/" Louis Rilling
2011-06-24 15:19 ` Austin Clements
2011-06-24 20:34 ` Louis Rilling
2011-06-27 21:15 ` Carl Worth
2011-07-11 14:36 ` [PATCH 0/2] lib: Don't always move from maildir new/ to maildir cur/ Louis Rilling
2011-07-11 14:36 ` [PATCH 1/2] tags_to_maildir_flags: Cleanup double assignement Louis Rilling
2011-07-11 14:36 ` [PATCH 2/2] tags_to_maildir_flags: Don't rename if no flags change Louis Rilling
2011-07-11 20:07 ` Austin Clements
2011-07-11 22:38 ` Louis Rilling
2011-07-11 22:41 ` Louis Rilling [this message]
2011-07-12 0:04 ` [PATCH v2] " Austin Clements
2011-07-12 0:03 ` [PATCH 2/2] " Austin Clements
2011-07-12 13:47 ` Louis Rilling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1310424115-18850-1-git-send-email-l.rilling@av7.net \
--to=l.rilling@av7.net \
--cc=amdragon@MIT.EDU \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).