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 625D0431FBD for ; Mon, 14 Dec 2009 11:28:07 -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 oOr2qMlFOKTu for ; Mon, 14 Dec 2009 11:28:06 -0800 (PST) X-Greylist: delayed 399 seconds by postgrey-1.32 at olra; Mon, 14 Dec 2009 11:28:06 PST Received: from outbound-mail-13.bluehost.com (outbound-mail-13.bluehost.com [69.89.18.113]) by olra.theworths.org (Postfix) with SMTP id 4318A431FAE for ; Mon, 14 Dec 2009 11:28:06 -0800 (PST) Received: (qmail 5184 invoked by uid 0); 14 Dec 2009 19:21:26 -0000 Received: from unknown (HELO host304.hostmonster.com) (74.220.215.104) by outboundproxy1.bluehost.com with SMTP; 14 Dec 2009 19:21:26 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=informa.tiker.net; h=Received:From:To:Subject:Date:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:X-Identified-User; b=Vz72pF1VkS4iE6Y8Wik61cuUXzFLq6VGDO+N8oSn6WplA9tsgh7bDpky0HpbSfU/stLbcqwAMy3SA3eyF0J9vFy7djl8lJqW4lOWxAVgUqAAn8AoQWeA7dAANFMmNRcG; Received: from ip72-221-120-106.ri.ri.cox.net ([72.221.120.106] helo=grizzly.localnet) by host304.hostmonster.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1NKGU2-00079r-E0 for notmuch@notmuchmail.org; Mon, 14 Dec 2009 12:21:26 -0700 From: Andreas =?iso-8859-1?q?Kl=F6ckner?= To: notmuch@notmuchmail.org Date: Mon, 14 Dec 2009 14:21:50 -0500 User-Agent: KMail/1.12.2 (Linux/2.6.31-trunk-686; KDE/4.3.2; i686; ; ) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1983344.e7oaIR2PZV"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200912141421.52561.lists@informa.tiker.net> X-Identified-User: {11749:host304.hostmonster.com:tikernet:tiker.net} {sentby:smtp auth 72.221.120.106 authed with andreas-store+tiker.net} X-Mailman-Approved-At: Mon, 14 Dec 2009 14:44:28 -0800 Subject: [patch] store folder information 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: Mon, 14 Dec 2009 19:28:07 -0000 --nextPart1983344.e7oaIR2PZV Content-Type: multipart/mixed; boundary="Boundary-01=_OBpJLuJNt54jnVC" Content-Transfer-Encoding: 7bit --Boundary-01=_OBpJLuJNt54jnVC Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Hi there, I've patched notmuch to retain information on which folder emails are store= d=20 in. This makes the transition from a folders-and-procmail model somewhat=20 easier. The resulting changes are attached. Andreas --Boundary-01=_OBpJLuJNt54jnVC Content-Type: text/x-patch; charset="UTF-8"; name="0001-Preseve-folder-information-when-indexing.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Preseve-folder-information-when-indexing.patch" =46rom 179af7f436d8c21bad90e7eb88fc17c56f83c26c Mon Sep 17 00:00:00 2001 =46rom: Andreas Kloeckner Date: Mon, 14 Dec 2009 14:16:20 -0500 Subject: [PATCH] Preseve folder information when indexing. =2D-- 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 =2D-- 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) * =2D * In addition, terms from the content of the message are added with =2D * "from", "to", "attachment", and "subject" prefixes for use by the =2D * user in searching. But the database doesn't really care itself =2D * 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 use= r in + * searching. But the database doesn't really care itself about any of the= se. * * Timestamp document * ------------------ @@ -124,7 +123,8 @@ prefix_t PROBABILISTIC_PREFIX[]=3D { { "from", "XFROM" }, { "to", "XTO" }, { "attachment", "XATTACHMENT" }, =2D { "subject", "XSUBJECT"} + { "subject", "XSUBJECT"}, + { "folder", "XFOLDER"} }; =20 int @@ -889,6 +889,7 @@ _notmuch_database_link_message (notmuch_database_t *not= much, 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 *not= much, =20 _notmuch_message_index_file (message, filename); =20 + if (folder_name !=3D 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 =2D-- 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) =3D=3D 0) s +=3D 3; + else if (strncasecmp (s, "aw:", 3) =3D=3D 0) + s +=3D 3; else break; } diff --git a/lib/notmuch.h b/lib/notmuch.h index 60834fb..5d3b3c6 100644 =2D-- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -265,6 +265,7 @@ notmuch_database_get_timestamp (notmuch_database_t *dat= abase, notmuch_status_t notmuch_database_add_message (notmuch_database_t *database, const char *filename, + const char *folder_name, notmuch_message_t **message); =20 /* Find a message with the given message_id. diff --git a/notmuch-new.c b/notmuch-new.c index 9d20616..bc8adc8 100644 =2D-- a/notmuch-new.c +++ b/notmuch-new.c @@ -21,6 +21,7 @@ #include "notmuch-client.h" =20 #include +#include =20 static volatile sig_atomic_t do_add_files_print_progress =3D 0; =20 @@ -144,6 +145,34 @@ add_files_recursive (notmuch_database_t *notmuch, struct dirent **namelist =3D NULL; int num_entries; =20 + gchar *full_folder_name =3D NULL; + gchar *folder_base_name =3D NULL; + + /* Find name of "folder" containing the email. */ + full_folder_name =3D g_strdup(path); + while (1) + { + folder_base_name =3D g_path_get_basename(full_folder_name); + + if (strcmp(folder_base_name, "cur") =3D=3D 0 + || strcmp(folder_base_name, "new") =3D=3D 0) + { + gchar *parent_name =3D g_path_get_dirname(full_folder_name); + g_free(full_folder_name); + full_folder_name =3D parent_name; + } + else + break; + } + + g_free(full_folder_name); + + if (strcmp(folder_base_name, ".") =3D=3D 0) + { + g_free(folder_base_name); + folder_base_name =3D 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); } =20 =2D status =3D notmuch_database_add_message (notmuch, next, &message); + status =3D notmuch_database_add_message (notmuch, next,=20 + folder_base_name,=20 + &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) + g_free(folder_base_name); =20 return ret; } =2D-=20 1.6.5 --Boundary-01=_OBpJLuJNt54jnVC-- --nextPart1983344.e7oaIR2PZV Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iD8DBQBLJpBOJZ7T4Hn4+FIRAv5IAJ9Yd+fs8bxZiQ05CTfh8ZEQYo2yLQCgg+pP sPs3672uLyTZNkcIZlj0zR8= =vdx5 -----END PGP SIGNATURE----- --nextPart1983344.e7oaIR2PZV--