From: Emil Sit <sit@emilsit.net>
To: notmuch@notmuchmail.org
Subject: [PATCH] notmuch-new: Parse some maildir flags for labels
Date: Wed, 17 Mar 2010 22:59:07 -0400 [thread overview]
Message-ID: <1268881147-32503-1-git-send-email-sit@emilsit.net> (raw)
Instead of blanket applying tag:inbox and tag:unread to
all messages, when parsing a Maildir file, attempt to
parse the flags encoded in the filename to determine whether
to mark something as unread (and inbox). Also, parse user
flagged messages and trash messages.
Signed-off-by: Emil Sit <sit@emilsit.net>
---
I confess that I'm not actively following the mailing list or actively using
notmuch to read mail (the vim client seems not to work well for me on Ubuntu
Hardy and not a huge emacs fan and don't have emacs23; still using mutt/mairix)
so I apologize if something like this has been discussed/rejected before. I've
been playing with this patch locally and it definitely helped with the initial
import. It's a nice complement to notmuchsync.
Hope someone finds it useful.
notmuch-new.c | 32 ++++++++++++++++++++++++++++----
1 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/notmuch-new.c b/notmuch-new.c
index 44b50aa..f937e85 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -94,10 +94,34 @@ _filename_list_add (_filename_list_t *list,
}
static void
-tag_inbox_and_unread (notmuch_message_t *message)
+tag_maildir_message (const char *filename, notmuch_message_t *message)
{
- notmuch_message_add_tag (message, "inbox");
- notmuch_message_add_tag (message, "unread");
+ notmuch_bool_t is_read = FALSE;
+
+ const char *p = strrchr (filename, ':');
+ if (p != NULL && strncmp(p + 1, "2,", 2) == 0) {
+ /* This appears to be a valid Maildir filename.
+ * Interpret some basic semantics */
+ while (*p) {
+ switch (*p) {
+ case 'S': /* seen */
+ is_read = TRUE;
+ break;
+ case 'T': /* trashed */
+ notmuch_message_add_tag (message, "trash");
+ break;
+ case 'F': /* flagged */
+ notmuch_message_add_tag (message, "flagged");
+ break;
+ }
+ p++;
+ }
+ }
+
+ if (!is_read) {
+ notmuch_message_add_tag (message, "inbox");
+ notmuch_message_add_tag (message, "unread");
+ }
}
static void
@@ -412,7 +436,7 @@ add_files_recursive (notmuch_database_t *notmuch,
/* success */
case NOTMUCH_STATUS_SUCCESS:
state->added_messages++;
- tag_inbox_and_unread (message);
+ tag_maildir_message (next, message);
break;
/* Non-fatal issues (go on to next file) */
case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
--
1.6.3.3
next reply other threads:[~2010-03-18 3:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-18 2:59 Emil Sit [this message]
2010-03-22 21:49 ` [PATCH] notmuch-new: Parse some maildir flags for labels Michal Sojka
2010-03-23 8:53 ` Sebastian Spaeth
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=1268881147-32503-1-git-send-email-sit@emilsit.net \
--to=sit@emilsit.net \
--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).