Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id B7592404955 for ; Wed, 17 Mar 2010 20:06:02 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.251 X-Spam-Level: X-Spam-Status: No, score=-0.251 tagged_above=-999 required=5 tests=[AWL=-0.748, BAYES_50=0.001, NO_DNS_FOR_FROM=1.496, RCVD_IN_DNSWL_LOW=-1] autolearn=no Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d9tv7qda0c1b for ; Wed, 17 Mar 2010 20:06:02 -0700 (PDT) X-Greylist: delayed 414 seconds by postgrey-1.32 at olra; Wed, 17 Mar 2010 20:06:02 PDT Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com [66.111.4.27]) by olra.theworths.org (Postfix) with ESMTP id 15499404952 for ; Wed, 17 Mar 2010 20:06:02 -0700 (PDT) Received: from compute1.internal (compute1.internal [10.202.2.41]) by gateway1.messagingengine.com (Postfix) with ESMTP id E3DB1E65FF; Wed, 17 Mar 2010 22:59:07 -0400 (EDT) Received: from heartbeat2.messagingengine.com ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 17 Mar 2010 22:59:07 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=messagingengine.com; h=from:to:subject:date:message-id; s=smtpout; bh=2ZOysouhYydwa4Qi8MDzSosK/l0=; b=PjmKDFo735peRtjLPaTHCqy70uBxD0HIKZM2L1glZPbI0QpbvnMcGyp8OOcO5jRbIBcIQN8i0s9cC0WQgzl6CZDU/qb1XE0r4bloRFQP8UX9xalk1eMZopzGen9c6JGue+mnZG0WLrKPUBaLmGk0ItwgO6qP5UUS91exw0Iz26M= X-Sasl-enc: YxhkXx6fv9iX3bREd/PgmWH5EItJzkrEpfGm6Fm4/VHkHa/JkUSyFqc 1268881147 Received: from abydos.emilsit.net (c-76-24-28-147.hsd1.ma.comcast.net [76.24.28.147]) by mail.messagingengine.com (Postfix) with ESMTPSA id AD0968EB8 for ; Wed, 17 Mar 2010 22:59:07 -0400 (EDT) Received: by abydos.emilsit.net (Postfix, from userid 1000) id 336EF21E89; Wed, 17 Mar 2010 22:59:07 -0400 (EDT) From: Emil Sit To: notmuch@notmuchmail.org Date: Wed, 17 Mar 2010 22:59:07 -0400 Message-Id: <1268881147-32503-1-git-send-email-sit@emilsit.net> X-Mailer: git-send-email 1.6.3.3 X-Mailman-Approved-At: Mon, 22 Mar 2010 12:17:24 -0700 Subject: [notmuch] [PATCH] notmuch-new: Parse some maildir flags for labels X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Mar 2010 03:06:02 -0000 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 --- 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