Re: [notmuch] [Sebastian Spaeth] Pull requests
authormicah anderson <micah@riseup.net>
Wed, 7 Apr 2010 05:15:02 +0000 (01:15 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:30 +0000 (09:36 -0800)
0d/fd8e659912f710aa960b789a1aefe9a03de3b7 [new file with mode: 0644]

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