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 7005F4196F0 for ; Thu, 8 Apr 2010 12:44:44 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham 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 eA-OOBdtaIO4 for ; Thu, 8 Apr 2010 12:44:43 -0700 (PDT) Received: from everglades.pioto.org (everglades.pioto.org [207.192.69.249]) by olra.theworths.org (Postfix) with ESMTP id A0B61431FC1 for ; Thu, 8 Apr 2010 12:44:43 -0700 (PDT) Received: from aether.pioto.org (pool-96-236-149-110.pitbpa.fios.verizon.net [96.236.149.110]) (Authenticated sender: pioto) by everglades.pioto.org (Postfix) with ESMTPA id 26E4F160E00; Thu, 8 Apr 2010 15:44:43 -0400 (EDT) Received: by aether.pioto.org (Postfix, from userid 1000) id 5B5176B08C; Thu, 8 Apr 2010 15:45:47 -0400 (EDT) From: Mike Kelly To: notmuch@notmuchmail.org Subject: [PATCH 1/3] Initial support for maildir flags. Date: Thu, 8 Apr 2010 15:45:29 -0400 Message-Id: <1270755931-24290-1-git-send-email-pioto@pioto.org> X-Mailer: git-send-email 1.7.0.4 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, 08 Apr 2010 19:44:44 -0000 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