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 51789431FBF for ; Fri, 26 Feb 2010 11:49:09 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.76 X-Spam-Level: X-Spam-Status: No, score=-0.76 tagged_above=-999 required=5 tests=[AWL=-0.575, BAYES_40=-0.185] 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 yyXrB9B6EJYY for ; Fri, 26 Feb 2010 11:49:08 -0800 (PST) Received: from everglades.pioto.org (everglades.pioto.org [207.192.69.249]) by olra.theworths.org (Postfix) with ESMTP id B250F431FAE for ; Fri, 26 Feb 2010 11:49:08 -0800 (PST) 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 DA64B1603FC; Fri, 26 Feb 2010 14:49:03 -0500 (EST) Received: by aether.pioto.org (Postfix, from userid 1000) id 6E84B60344; Fri, 26 Feb 2010 14:49:56 -0500 (EST) From: Mike Kelly To: notmuch@notmuchmail.org Date: Fri, 26 Feb 2010 14:49:26 -0500 Message-Id: <1267213767-31255-2-git-send-email-pioto@pioto.org> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1267213767-31255-1-git-send-email-pioto@pioto.org> References: <1267213767-31255-1-git-send-email-pioto@pioto.org> Subject: [notmuch] [PATCH 1/2] Initial support for maildir flags. 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: Fri, 26 Feb 2010 19:49:09 -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 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