unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] Initial support for maildir flags.
@ 2010-04-08 19:45 Mike Kelly
  2010-04-08 19:45 ` [PATCH 2/3] apply all the other maildir flag->tag conversions Mike Kelly
  2010-04-08 19:45 ` [PATCH 3/3] document new `notmuch new` behavior Mike Kelly
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Kelly @ 2010-04-08 19:45 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 721c9a6..2ca1562 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -509,6 +509,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 88da078..018c002 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -763,6 +763,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 44b50aa..511347d 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.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] apply all the other maildir flag->tag conversions
  2010-04-08 19:45 [PATCH 1/3] Initial support for maildir flags Mike Kelly
@ 2010-04-08 19:45 ` Mike Kelly
  2010-04-08 19:45 ` [PATCH 3/3] document new `notmuch new` behavior Mike Kelly
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Kelly @ 2010-04-08 19:45 UTC (permalink / raw)
  To: notmuch

---
 notmuch-new.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index 511347d..dc33d69 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -99,6 +99,16 @@ tag_inbox_and_unread (notmuch_message_t *message)
     notmuch_message_add_tag (message, "inbox");
     if (! notmuch_message_md_flag(message, 'S'))
         notmuch_message_add_tag (message, "unread");
+    if (notmuch_message_md_flag(message, 'T'))
+        notmuch_message_add_tag (message, "deleted");
+    if (notmuch_message_md_flag(message, 'D'))
+        notmuch_message_add_tag (message, "draft");
+    if (notmuch_message_md_flag(message, 'F'))
+        notmuch_message_add_tag (message, "flagged");
+    if (notmuch_message_md_flag(message, 'P'))
+        notmuch_message_add_tag (message, "passed");
+    if (notmuch_message_md_flag(message, 'R'))
+        notmuch_message_add_tag (message, "replied");
 }
 
 static void
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] document new `notmuch new` behavior
  2010-04-08 19:45 [PATCH 1/3] Initial support for maildir flags Mike Kelly
  2010-04-08 19:45 ` [PATCH 2/3] apply all the other maildir flag->tag conversions Mike Kelly
@ 2010-04-08 19:45 ` Mike Kelly
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Kelly @ 2010-04-08 19:45 UTC (permalink / raw)
  To: notmuch

---
 notmuch.1 |    8 +++++---
 notmuch.c |    7 ++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/notmuch.1 b/notmuch.1
index 0e6a2ed..8b4021e 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 f5669fc..9002e7d 100644
--- a/notmuch.c
+++ b/notmuch.c
@@ -125,9 +125,10 @@ command_t commands[] = {
     { "new", notmuch_new_command,
       "[--verbose]",
       "Find and import new messages to the notmuch database.",
-      "\tScans all sub-directories of the mail directory, performing\n"
-      "\tfull-text indexing on new messages that are found. Each new\n"
-      "\tmessage will be tagged as both \"inbox\" and \"unread\".\n"
+      "\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 \"inbox\" and, unless it is\n"
+      "\t\tmarked as \"seen\", \"unread\".\n"
       "\n"
       "\tYou should run \"notmuch new\" once after first running\n"
       "\t\"notmuch setup\" to create the initial database. The first\n"
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-04-08 19:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-08 19:45 [PATCH 1/3] Initial support for maildir flags Mike Kelly
2010-04-08 19:45 ` [PATCH 2/3] apply all the other maildir flag->tag conversions Mike Kelly
2010-04-08 19:45 ` [PATCH 3/3] document new `notmuch new` behavior Mike Kelly

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).