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 250794196F0 for ; Tue, 6 Apr 2010 22:15:17 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.599 X-Spam-Level: X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, UNPARSEABLE_RELAY=0.001] 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 yNmeNZ5ly+Ix for ; Tue, 6 Apr 2010 22:15:15 -0700 (PDT) Received: from mx1.riseup.net (mx1.riseup.net [204.13.164.18]) by olra.theworths.org (Postfix) with ESMTP id 8AA09431FC1 for ; Tue, 6 Apr 2010 22:15:15 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: micah@mx1.riseup.net) with ESMTPSA id 8036A25E4D2 Received: by algae (Postfix, from userid 1000) id A510A616F5; Wed, 7 Apr 2010 01:15:04 -0400 (EDT) From: micah anderson To: Sebastian Spaeth , Notmuch development list Subject: Re: [Sebastian Spaeth] Pull requests In-Reply-To: <87bpe9qr5f.fsf@SSpaeth.de> References: <87iq9gi0z8.fsf@SSpaeth.de> <87hbo3vlrn.fsf@algae.riseup.net> <87bpe9qr5f.fsf@SSpaeth.de> Date: Wed, 07 Apr 2010 01:15:02 -0400 Message-ID: <87d3yb6dyh.fsf@algae.riseup.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Virus-Scanned: clamav-milter 0.95.3 at mx1 X-Virus-Status: Clean 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: Wed, 07 Apr 2010 05:15:17 -0000 --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" --==-=-= Content-Transfer-Encoding: quoted-printable On 2010-03-27, micah anderson wrote: > On Thu, 25 Mar 2010 22:50:52 -0400, micah anderson wro= te: > > On Mon, 01 Mar 2010 15:57:00 +0100, "Sebastian Spaeth" wrote: > >=20 > > > From git repository git://github.com/spaetz/notmuch-all-feature.git I > > > would like to advocate the following branches for quick pulling. Each > > > contains 1 or 2 patches. They have all been based on todays > > > cworth/master, so it should be really painless. > >=20 > > Thanks for pulling these all together! All the ones that you propose I > > also use and would really like these to be merged as well. > >=20 > > The only other patch that I find absolutely crucial, that you do not > > include, is the 'Preserve folder information when indexing' patch which, > > although not perfect, does significantly change my life.=20 >=20 > Glad you find it useful. Yes, having the folder information would indeed > be nice. Is that patch working well for you? (Can you point me to the > mail ID of the patch you are using? There have been several versions > around). The patch works really well for me. I also had difficulty figuring out which was the latest. The thread is thread:4ca0710d708e648c214ba3a67469f5bd, and the Message-ID is: 1265122868-12133-1-git-send-email-sojkam1@fel.cvut.cz I had to rebase the patch to get it to apply with the other features that you have in your branch. I'm attaching that rebased patch to this message. --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBCgAGBQJLvBTXAAoJEIy/mjIoYaeQbScP/1J93bhk8J5IEDGue9h4bDiO /XC1Ot6gxha0m7MLTcXSURxsZ9WmgpkDA3WNCj00sJ7xe7FvJ1RAeT0D8HReIoOk vY8TM4Uba1s9Bp4MUBx+tn/R4uefodYfNjcabOui4EN9M3iBgo7ffO7KX7bvD7lg HqFIAbx0PuWZbkAcG/eSsttPhAD6HOiL2WFbKYT3SA07hSQcBvpuRyjf8JQBjlnH ShpstrgW3RweelVF0mZDKTacc+6GAes7ds48uqqNkIdURAxePAZS24d+fGsJnwQ4 GXULZdBNKG6K8YaXR7uBFn8fkk8D8W4U52JX8gIeI58O+53YZ9GlI//JijYPZwpW RKOvF5qFLfpELXrlAJlRJvfiHzGTDKdrg9fz37odOyV4JcG5BR38jLOME3J7ue8D kQdVj5Ps18GZNuIO30w1Z8K9wR4GTrGIp5MdCEC8aTUOuNcT5U+y8VRH1wh05Ds4 AXoinF7XsdzOUzWXZWPNUpUWd41PztK2FCshjvLlR9Tc5toq5FNtdAQa2VBEjKdJ wqefdU5JEsPn6v8lrxiu1fcjgw4PirPQNoCCGpScq0koCAgY2jFTZaZ+AJpzL3lG CUFvIXvSp4QhQMddkktus84PdgsVMGgrsVw3ZtVuDUGsnlK9htMldsNKiB+ya49z yEbnShhuPh0iMrW+YK0v =7WHz -----END PGP SIGNATURE----- --==-=-=-- --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=folder.diff commit 91e11a2a406683f1f80e19334da8124a25ec89fe Author: Micah Anderson Date: Thu Mar 25 23:07:10 2010 -0400 add folder patch, rebased diff --git a/lib/database.cc b/lib/database.cc index c91e97c..6364623 100644 --- a/lib/database.cc +++ b/lib/database.cc @@ -84,9 +84,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. + * "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. * * The data portion of a mail document is empty. * @@ -155,7 +155,8 @@ prefix_t PROBABILISTIC_PREFIX[]= { { "from", "XFROM" }, { "to", "XTO" }, { "attachment", "XATTACHMENT" }, - { "subject", "XSUBJECT"} + { "subject", "XSUBJECT"}, + { "folder", "XFOLDER"} }; int @@ -1362,6 +1363,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; @@ -1477,6 +1479,9 @@ notmuch_database_add_message (notmuch_database_t *notmuch, date = notmuch_message_file_get_header (message_file, "date"); _notmuch_message_set_date (message, date); + if (folder_name != NULL) + _notmuch_message_gen_terms (message, "folder", folder_name); + _notmuch_message_index_file (message, filename); } else { ret = NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID; diff --git a/lib/notmuch.h b/lib/notmuch.h index 0d9cb0f..e475072 100644 --- a/lib/notmuch.h +++ b/lib/notmuch.h @@ -263,6 +263,7 @@ notmuch_database_get_directory (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); /* Remove a message from the given notmuch database. diff --git a/notmuch-new.c b/notmuch-new.c index 93da1d7..394d76c 100644 --- a/notmuch-new.c +++ b/notmuch-new.c @@ -21,6 +21,7 @@ #include "notmuch-client.h" #include +#include typedef struct _filename_node { char *filename; @@ -224,6 +225,35 @@ derive_tags_from_maildir_flags (notmuch_message_t *message, } } +static char* +_get_folder_base_name(const char *path) +{ + 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; + } + return folder_base_name; +} + /* Examine 'path' recursively as follows: * * o Ask the filesystem for the mtime of 'path' (fs_mtime) @@ -277,6 +307,7 @@ add_files_recursive (notmuch_database_t *notmuch, notmuch_filenames_t *db_subdirs = NULL; struct stat st; notmuch_bool_t is_maildir, new_directory; + char *folder_base_name = NULL; if (stat (path, &st)) { fprintf (stderr, "Error reading directory %s: %s\n", @@ -464,7 +495,10 @@ add_files_recursive (notmuch_database_t *notmuch, fflush (stdout); } - status = notmuch_database_add_message (notmuch, next, &message); + folder_base_name = _get_folder_base_name(path); + status = notmuch_database_add_message (notmuch, next, + folder_base_name, + &message); switch (status) { /* success */ case NOTMUCH_STATUS_SUCCESS: @@ -561,6 +595,8 @@ add_files_recursive (notmuch_database_t *notmuch, notmuch_filenames_destroy (db_files); if (directory) notmuch_directory_destroy (directory); + if (folder_base_name) + g_free(folder_base_name); return ret; } --=-=-=--