* [PATCH 1/2] Initial support for maildir flags.
2010-02-26 19:49 [PATCH] A simple approach to maildir flags Mike Kelly
@ 2010-02-26 19:49 ` Mike Kelly
2010-02-26 19:49 ` [PATCH 2/2] document new `notmuch new` behavior Mike Kelly
2010-03-01 0:09 ` [PATCH] A simple approach to maildir flags Stewart Smith
2 siblings, 0 replies; 4+ messages in thread
From: Mike Kelly @ 2010-02-26 19:49 UTC (permalink / raw)
To: notmuch
When adding new messages, if they have the 'S' (seen) flag, do not add
them to the 'unread' tag.
---
lib/message.cc | 25 +++++++++++++++++++++++++
lib/notmuch.h | 5 +++++
notmuch-new.c | 3 ++-
3 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/lib/message.cc b/lib/message.cc
index f0e905b..61c9cc3 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -516,6 +516,31 @@ notmuch_message_set_flag (notmuch_message_t *message,
message->flags &= ~(1 << flag);
}
+notmuch_bool_t
+notmuch_message_md_flag (notmuch_message_t *message,
+ const char flag)
+{
+ const char *filename;
+ const char *p;
+
+ filename = notmuch_message_get_filename (message);
+
+ p = strstr (filename, ":2,");
+ if (p == NULL) {
+ /* Not a valid maildir filename */
+ return FALSE;
+ }
+
+ for (p += 3; *p != '\0'; p++) {
+ if (*p == flag) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
time_t
notmuch_message_get_date (notmuch_message_t *message)
{
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 15c9db4..db9e917 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -753,6 +753,11 @@ void
notmuch_message_set_flag (notmuch_message_t *message,
notmuch_message_flag_t flag, notmuch_bool_t value);
+/* See if a given maildir flag is set, based on the message's filename. */
+notmuch_bool_t
+notmuch_message_md_flag (notmuch_message_t *message,
+ const char flag);
+
/* Get the date of 'message' as a time_t value.
*
* For the original textual representation of the Date header from the
diff --git a/notmuch-new.c b/notmuch-new.c
index b740ee2..6d62f3f 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -97,7 +97,8 @@ static void
tag_inbox_and_unread (notmuch_message_t *message)
{
notmuch_message_add_tag (message, "inbox");
- notmuch_message_add_tag (message, "unread");
+ if (! notmuch_message_md_flag(message, 'S'))
+ notmuch_message_add_tag (message, "unread");
}
static void
--
1.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] document new `notmuch new` behavior
2010-02-26 19:49 [PATCH] A simple approach to maildir flags Mike Kelly
2010-02-26 19:49 ` [PATCH 1/2] Initial support for " Mike Kelly
@ 2010-02-26 19:49 ` Mike Kelly
2010-03-01 0:09 ` [PATCH] A simple approach to maildir flags Stewart Smith
2 siblings, 0 replies; 4+ messages in thread
From: Mike Kelly @ 2010-02-26 19:49 UTC (permalink / raw)
To: notmuch
---
notmuch.1 | 8 +++++---
notmuch.c | 3 ++-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/notmuch.1 b/notmuch.1
index 282ad98..f03529e 100644
--- a/notmuch.1
+++ b/notmuch.1
@@ -93,9 +93,11 @@ The
.B new
command scans all sub-directories of the database, performing
full-text indexing on new messages that are found. Each new message
-will automatically be tagged with both the
-.BR inbox " and " unread
-tags.
+will automatically be tagged with the
+.BR inbox
+tag, and, unless it was already "seen" by another client, the
+.BR unread
+tag.
You should run
.B "notmuch new"
diff --git a/notmuch.c b/notmuch.c
index 87479f8..fc6bb7f 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -127,7 +127,8 @@ command_t commands[] = {
"\t\tFind and import new messages to the notmuch database.",
"\t\tScans all sub-directories of the mail directory, performing\n"
"\t\tfull-text indexing on new messages that are found. Each new\n"
- "\t\tmessage will be tagged as both \"inbox\" and \"unread\".\n"
+ "\t\tmessage will be tagged as \"inbox\" and, unless it is\n"
+ "\t\tmarked as \"seen\", \"unread\".\n"
"\n"
"\t\tYou should run \"notmuch new\" once after first running\n"
"\t\t\"notmuch setup\" to create the initial database. The first\n"
--
1.7.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] A simple approach to maildir flags
2010-02-26 19:49 [PATCH] A simple approach to maildir flags Mike Kelly
2010-02-26 19:49 ` [PATCH 1/2] Initial support for " Mike Kelly
2010-02-26 19:49 ` [PATCH 2/2] document new `notmuch new` behavior Mike Kelly
@ 2010-03-01 0:09 ` Stewart Smith
2 siblings, 0 replies; 4+ messages in thread
From: Stewart Smith @ 2010-03-01 0:09 UTC (permalink / raw)
To: Mike Kelly, notmuch
On Fri, 26 Feb 2010 14:49:25 -0500, Mike Kelly <pioto@pioto.org> wrote:
> The following patches attempt to provide a simple, extendable approach
> to handling the 'Seen' maildir flag. To appease (hopefully) everyone, it
> will only do this for new messages. This means that people coming from
> another MUA won't be stuck with 30,000 unread messages, for example.
>
> It should be simple to extend this to other maildir flags, too, if
> people want them and can decide on what tags they should correspond to.
Personally, I like the seen messages not to be in inbox (by default) as
either:
1) I'm importing an old Maildir, in which case if it's read it's
probably been dealt with
2) i've used another mail client, same as above.
--
Stewart Smith
^ permalink raw reply [flat|nested] 4+ messages in thread