[notmuch] Fwd: Re: [patch] store folder information

2010-01-27 Thread Andreas Klöckner
As instructed by Micah below, I'm hereby letting the list know I'm no
longer interesting in shepherding that patch.

Best,
Andreas
--  Forwarded Message  --

Betreff: Re: [notmuch] [patch] store folder information
Datum: Mittwoch 27 Januar 2010
Von: micah anderson mi...@riseup.net
An: Andreas Klöckner li...@informa.tiker.net

On Wed, 27 Jan 2010 14:42:39 -0500, Andreas Klöckner li...@informa.tiker.net 
wrote:
 Hi Micah,
 
 On Mittwoch 27 Januar 2010, you wrote:
  I'm wondering what your plans are for addressing these issues? I've come
  to depend on this functionality, and would love to see it incorporated
  upstream! 
 
 That's easy to answer: I don't use notmuch any more, I've caved and gone
 back to KMail.

Ah! That is too bad :(

Would you mind sending the same to the notmuch list in reply to the
thread? I spoke with Carl at the recent LCA and he said he was waiting
for a response from you on that patch before doing anything with it. If
he knows that you are no longer interested in it, then he may take care
of it himself.

micah

---


signature.asc
Description: This is a digitally signed message part.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [patch] store folder information

2009-12-14 Thread Andreas Klöckner
Hi there,

I've patched notmuch to retain information on which folder emails are stored 
in. This makes the transition from a folders-and-procmail model somewhat 
easier. The resulting changes are attached.

Andreas
-- next part --
A non-text attachment was scrubbed...
Name: 0001-Preseve-folder-information-when-indexing.patch
Type: text/x-patch
Size: 4899 bytes
Desc: not available
URL: 

-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: 



[notmuch] [patch] store folder information

2009-12-14 Thread Andreas Klöckner
Hi there,

I've patched notmuch to retain information on which folder emails are stored 
in. This makes the transition from a folders-and-procmail model somewhat 
easier. The resulting changes are attached.

Andreas
From 179af7f436d8c21bad90e7eb88fc17c56f83c26c Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner inf...@tiker.net
Date: Mon, 14 Dec 2009 14:16:20 -0500
Subject: [PATCH] Preseve folder information when indexing.

---
 lib/database.cc |   14 +-
 lib/index.cc|2 ++
 lib/notmuch.h   |1 +
 notmuch-new.c   |   35 ++-
 4 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index b6c4d07..e6b4272 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -70,10 +70,9 @@ typedef struct {
  *
  *	MESSAGE_ID:	The unique ID of the mail mess (see id above)
  *
- * In addition, terms from the content of the message are added with
- * from, to, attachment, and subject prefixes for use by the
- * user in searching. But the database doesn't really care itself
- * about any of these.
+ * In addition, terms from the content of the message are added with from,
+ * to, attachment, subject, and folder prefixes for use by the user in
+ * searching. But the database doesn't really care itself about any of these.
  *
  * Timestamp document
  * --
@@ -124,7 +123,8 @@ prefix_t PROBABILISTIC_PREFIX[]= {
 { from, XFROM },
 { to, XTO },
 { attachment, XATTACHMENT },
-{ subject, XSUBJECT}
+{ subject, XSUBJECT},
+{ folder, XFOLDER}
 };
 
 int
@@ -889,6 +889,7 @@ _notmuch_database_link_message (notmuch_database_t *notmuch,
 notmuch_status_t
 notmuch_database_add_message (notmuch_database_t *notmuch,
 			  const char *filename,
+			  const char *folder_name,
 			  notmuch_message_t **message_ret)
 {
 notmuch_message_file_t *message_file;
@@ -1006,6 +1007,9 @@ notmuch_database_add_message (notmuch_database_t *notmuch,
 
 	_notmuch_message_index_file (message, filename);
 
+if (folder_name != NULL)
+_notmuch_message_gen_terms (message, folder, folder_name);
+
 	_notmuch_message_sync (message);
 } catch (const Xapian::Error error) {
 	fprintf (stderr, A Xapian exception occurred adding message: %s.\n,
diff --git a/lib/index.cc b/lib/index.cc
index 125fa6c..55f3fbc 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -116,6 +116,8 @@ skip_re_in_subject (const char *subject)
 	s++;
 	if (strncasecmp (s, re:, 3) == 0)
 	s += 3;
+else if (strncasecmp (s, aw:, 3) == 0)
+	s += 3;
 	else
 	break;
 }
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 60834fb..5d3b3c6 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -265,6 +265,7 @@ notmuch_database_get_timestamp (notmuch_database_t *database,
 notmuch_status_t
 notmuch_database_add_message (notmuch_database_t *database,
 			  const char *filename,
+			  const char *folder_name,
 			  notmuch_message_t **message);
 
 /* Find a message with the given message_id.
diff --git a/notmuch-new.c b/notmuch-new.c
index 9d20616..bc8adc8 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -21,6 +21,7 @@
 #include notmuch-client.h
 
 #include unistd.h
+#include glib.h
 
 static volatile sig_atomic_t do_add_files_print_progress = 0;
 
@@ -144,6 +145,34 @@ add_files_recursive (notmuch_database_t *notmuch,
 struct dirent **namelist = NULL;
 int num_entries;
 
+gchar *full_folder_name = NULL;
+gchar *folder_base_name = NULL;
+
+/* Find name of folder containing the email. */
+full_folder_name = g_strdup(path);
+while (1)
+{
+folder_base_name = g_path_get_basename(full_folder_name);
+
+if (strcmp(folder_base_name, cur) == 0
+|| strcmp(folder_base_name, new) == 0)
+{
+gchar *parent_name = g_path_get_dirname(full_folder_name);
+g_free(full_folder_name);
+full_folder_name = parent_name;
+}
+else
+break;
+}
+
+g_free(full_folder_name);
+
+if (strcmp(folder_base_name, .) == 0)
+{
+g_free(folder_base_name);
+folder_base_name = NULL;
+}
+
 /* If we're told to, we bail out on encountering a read-only
  * directory, (with this being a clear clue from the user to
  * Notmuch that new mail won't be arriving there and we need not
@@ -235,7 +264,9 @@ add_files_recursive (notmuch_database_t *notmuch,
 		fflush (stdout);
 		}
 
-		status = notmuch_database_add_message (notmuch, next, message);
+		status = notmuch_database_add_message (notmuch, next, 
+   folder_base_name, 
+   message);
 		switch (status) {
 		/* success */
 		case NOTMUCH_STATUS_SUCCESS:
@@ -301,6 +332,8 @@ add_files_recursive (notmuch_database_t *notmuch,
 	closedir (dir);
 if (namelist)
 	free (namelist);
+if (folder_base_name)
+