From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4F8FF431FBC for ; Wed, 18 Nov 2009 07:55:35 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org 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 N50h8iyRuDGV for ; Wed, 18 Nov 2009 07:55:34 -0800 (PST) Received: from e23smtp04.au.ibm.com (e23smtp04.au.ibm.com [202.81.31.146]) by olra.theworths.org (Postfix) with ESMTP id EEE52431FAE for ; Wed, 18 Nov 2009 07:55:33 -0800 (PST) Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp04.au.ibm.com (8.14.3/8.13.1) with ESMTP id nAIFqMx7015553 for ; Thu, 19 Nov 2009 02:52:22 +1100 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id nAIFqDHn1667326 for ; Thu, 19 Nov 2009 02:52:13 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id nAIFtVNl024406 for ; Thu, 19 Nov 2009 02:55:31 +1100 Received: from skywalker.linux.vnet.ibm.com ([9.77.125.7]) by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id nAIFtT4s024387 for ; Thu, 19 Nov 2009 02:55:30 +1100 From: aneesh.kumar@linux.vnet.ibm.com (Aneesh Kumar K.V) To: notmuch Date: Wed, 18 Nov 2009 21:25:28 +0530 Message-ID: <87fx8bygi7.fsf@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [PATCH] notmuch: Add Maildir directory name as tag name for messages X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 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: Wed, 18 Nov 2009 15:55:35 -0000 >From 24711481dfe770417aa0a13308a9bb842dfb03f4 Mon Sep 17 00:00:00 2001 From: Aneesh Kumar K.V Date: Wed, 18 Nov 2009 21:20:12 +0530 Subject: [PATCH] notmuch: Add Maildir directory name as tag name for messages This patch adds maildir directory name as the tag name for messages. This helps in adding tags using filtering already provided by procmail. Signed-off-by: Aneesh Kumar K.V --- notmuch-new.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/notmuch-new.c b/notmuch-new.c index 5405a9f..50d0a5a 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -96,6 +96,7 @@ add_files_print_progress (add_files_state_t *state) static notmuch_status_t add_files_recursive (notmuch_database_t *notmuch, const char *path, + const char *tag, struct stat *st, add_files_state_t *state) { @@ -186,6 +187,7 @@ add_files_recursive (notmuch_database_t *notmuch, case NOTMUCH_STATUS_SUCCESS: state->added_messages++; tag_inbox_and_unread (message); + notmuch_message_add_tag (message, tag); break; /* Non-fatal issues (go on to next file) */ case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID: @@ -223,7 +225,13 @@ add_files_recursive (notmuch_database_t *notmuch, } } } else if (S_ISDIR (st->st_mode)) { - status = add_files_recursive (notmuch, next, st, state); + if ((strcmp (entry->d_name, "cur") == 0) || + (strcmp (entry->d_name, "new") == 0) || + (strcmp (entry->d_name, "tmp") == 0)) { + status = add_files_recursive (notmuch, next, tag, st, state); + } else { + status = add_files_recursive (notmuch, next, entry->d_name, st, state); + } if (status && ret == NOTMUCH_STATUS_SUCCESS) ret = status; } @@ -285,7 +293,7 @@ add_files (notmuch_database_t *notmuch, timerval.it_value.tv_usec = 0; setitimer (ITIMER_REAL, &timerval, NULL); - status = add_files_recursive (notmuch, path, &st, state); + status = add_files_recursive (notmuch, path, basename(path), &st, state); /* Now stop the timer. */ timerval.it_interval.tv_sec = 0; -- 1.6.5.2.74.g610f9