unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch: Add Maildir directory name as tag name for messages
@ 2009-11-18 15:55 Aneesh Kumar K.V
  2009-11-21 18:39 ` Carl Worth
  0 siblings, 1 reply; 28+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-18 15:55 UTC (permalink / raw)
  To: notmuch


From 24711481dfe770417aa0a13308a9bb842dfb03f4 Mon Sep 17 00:00:00 2001
From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
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 <aneesh.kumar@linux.vnet.ibm.com>
---
 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

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2010-04-08 12:57 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-18 15:55 [PATCH] notmuch: Add Maildir directory name as tag name for messages Aneesh Kumar K.V
2009-11-21 18:39 ` Carl Worth
2009-11-21 20:28   ` Carl Worth
2009-11-21 22:12     ` Bart Trojanowski
     [not found]       ` <9cce5525b093b87fe74d427954ffad89@localhost>
2009-11-22  4:04         ` Carl Worth
2009-11-22  9:33           ` Michiel Buddingh'
2009-11-22 10:57             ` Dirk-Jan C. Binnema
2009-11-22 16:00               ` Michiel Buddingh'
2009-11-22 21:44                 ` Dirk-Jan C. Binnema
2009-11-22 12:19             ` Carl Worth
2009-11-22 15:57               ` Michiel Buddingh'
2009-11-25 17:52             ` Carl Worth
2009-11-26 21:12               ` Michiel Buddingh'
2009-11-26 21:53                 ` Ingmar Vanhassel
2009-11-27 12:01                   ` Jan Janak
2009-11-28  3:26                 ` Carl Worth
2009-12-06 19:55                   ` Michiel Buddingh'
2010-02-10  3:13                     ` [PATCH] notmuch: Respect maildir message flags Tim Stoakes
2010-02-15  8:13                       ` Stewart Smith
2010-02-16  1:58                         ` Stewart Smith
2010-02-16  2:12                           ` martin f krafft
2010-02-16  2:21                             ` Stewart Smith
2010-02-16  4:21                               ` martin f krafft
2010-02-16  9:35                               ` Michal Sojka
2010-03-01 13:28                               ` [PATCH] notmuch-new: Respect maildir flags when importing a new message Sebastian Spaeth
2010-04-07 21:16                                 ` Carl Worth
2010-04-08 12:57                                   ` Michal Sojka
2009-11-22 10:37           ` [PATCH] notmuch: Add Maildir directory name as tag name for messages Dirk-Jan C. Binnema

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).