[notmuch] [PATCH] Remove bcc header from notmuch reply.

2010-01-26 Thread Jameson Rollins
Notmuch reply should not be Bcc'ing the sender by default.  This is
not the appropriate way to save copies of sent mail (which should
probably be handled by an Fcc header) and it doesn't give the user the
option to not be bcc'd.  This is really something that should be
handled by the reader UI.  For instance, emacs message-mode can easily
be configured to add Bcc's if the user wishes.
---
 notmuch-reply.c |9 +
 1 files changed, 1 insertions(+), 8 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 0cda72d..de05aaf 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -30,8 +30,7 @@ static const struct {
 } reply_to_map[] = {
 { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO  },
 { "to", NULL, GMIME_RECIPIENT_TYPE_TO  },
-{ "cc", NULL, GMIME_RECIPIENT_TYPE_CC  },
-{ "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC }
+{ "cc", NULL, GMIME_RECIPIENT_TYPE_CC  }
 };

 static void
@@ -254,9 +253,6 @@ notmuch_reply_format_default(void *ctx, notmuch_config_t 
*config, notmuch_query_
g_mime_object_set_header (GMIME_OBJECT (reply),
  "From", from_addr);

-   g_mime_object_set_header (GMIME_OBJECT (reply), "Bcc",
-  notmuch_config_get_user_primary_email (config));
-
in_reply_to = talloc_asprintf (ctx, "<%s>",
 notmuch_message_get_message_id (message));

@@ -346,9 +342,6 @@ notmuch_reply_format_headers_only(void *ctx, 
notmuch_config_t *config, notmuch_q
  recipients);
}

-   g_mime_object_set_header (GMIME_OBJECT (reply), "Bcc",
-  notmuch_config_get_user_primary_email (config));
-
reply_headers = g_mime_object_to_string (GMIME_OBJECT (reply));
printf ("%s", reply_headers);
free (reply_headers);
-- 
1.6.5

-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100126/97606bab/attachment.pgp>


[notmuch] [PATCH] simplify notmuch new output

2010-01-26 Thread Jameson Rollins
This patch just simplifies the notmuch new output to make it easier to
read, as well as more easily machine parsable.
---
 notmuch-new.c |   31 ---
 1 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index f25c71f..e07107e 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -816,41 +816,34 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
tv_now);

 if (add_files_state.processed_files) {
-   printf ("Processed %d %s in ", add_files_state.processed_files,
-   add_files_state.processed_files == 1 ?
-   "file" : "total files");
+   printf ("processed: %d %s (",
+   add_files_state.processed_files,
+   add_files_state.processed_files == 1 ? "file" : "files");
notmuch_time_print_formatted_seconds (elapsed);
+   printf (")");
if (elapsed > 1) {
-   printf (" (%d files/sec.). \n",
+   printf (" (%d files/sec.)\n",
(int) (add_files_state.processed_files / elapsed));
} else {
-   printf (".\n");
+   printf ("\n");
}
 }

 if (add_files_state.added_messages) {
-   printf ("Added %d new %s to the database.",
-   add_files_state.added_messages,
-   add_files_state.added_messages == 1 ?
-   "message" : "messages");
-} else {
-   printf ("No new mail.");
+   printf (" new: %d\n",
+   add_files_state.added_messages);
 }

 if (removed_files) {
-   printf (" Removed %d %s.",
-   removed_files,
-   removed_files == 1 ? "message" : "messages");
+   printf (" deletes: %d\n",
+   removed_files);
 }

 if (renamed_files) {
-   printf (" Detected %d file %s.",
-   renamed_files,
-   renamed_files == 1 ? "rename" : "renames");
+   printf (" renames: %d\n",
+   renamed_files);
 }

-printf ("\n");
-
 if (ret) {
printf ("\nNote: At least one error was encountered: %s\n",
notmuch_status_to_string (ret));
-- 
1.6.5
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100126/e6ce1c2e/attachment.pgp>


[notmuch] [PATCH] Make the date parser nicer

2010-01-26 Thread Sebastian Spaeth
On Mon, 25 Jan 2010 22:36:35 -0800, Keith Packard  wrote:
> Here's some code which further improves date parsing by allowing lots of
> date formats, including things like "today", "thisweek", ISO and US date
> formats and month names. You can separate two dates with .. to make a
> range, or you can just use the default range ("lastmonth" is everything
> From the 1st of the previous month to the 1st of the current month).
> 
> I think this fits nicely with your code.

It fit nicely indeed. I have just integrated your date parser into my
code and sent it as a series of 4 patches based on current cworth
master. (commits 2565fc6 and 96e11c3 will not compile on their own)

ec3c79a integrate keithp's date.c into the notmuch date parser and delete my 
previous own 
2565fc6 compile date.c as well
96e11c3 add date parser file from Keith
6ed2569 Make the date parser nicer.

The topic branch is here for those who don't want to apply mail patches:
http://github.com/spaetz/notmuch-all-feature/commits/dateparser3

Documentation of the new notmuch_parse_date function:
/* Parse a string into the first and last possible timestamps.
 * It parses the possible formats and stops if one pattern matches.
 * Keywords: 'today','yesterday','thisweek','lastweek','thismonth',
 *   'lastmonth'
 * Month-day : month[-day]] (month: January, Jan, or 1)\n"
 * ISO format: year[-month[-day]]
 * US format : month[/day[/year]]
 *
 * 'after' is used to fill in bits from context if left out, e.g. a
 * 'date:2004..01' will find from 2004-01-01 through 2004-01-31
 *
 * Return values:
 * NOTMUCH_STATUS_SUCCESS
 * NOTMUCH_STATUS_INVALID_DATE: Error parsing the date string

Please pull :-).

Sebastian


[notmuch] [PATCH 4/4] integrate keithp's date.c into the notmuch date parser and delete my previous own attempt

2010-01-26 Thread Sebastian Spaeth
Signed-off-by: Sebastian Spaeth 
---
 lib/database.cc |   84 ++
 lib/date.c  |   59 ++
 lib/notmuch.h   |   20 +
 notmuch-new.c   |1 +
 notmuch.1   |   33 +++--
 notmuch.c   |   20 +++--
 6 files changed, 74 insertions(+), 143 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index b386e1a..78cd898 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -219,6 +219,8 @@ notmuch_status_to_string (notmuch_status_t status)
return "Erroneous NULL pointer";
 case NOTMUCH_STATUS_TAG_TOO_LONG:
return "Tag value is too long (exceeds NOTMUCH_TAG_MAX)";
+case NOTMUCH_STATUS_INVALID_DATE:
+   return "Date value did not parse to a valid date";
 case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:
return "Unbalanced number of calls to notmuch_message_freeze/thaw";
 default:
@@ -497,83 +499,29 @@ _notmuch_database_ensure_writable (notmuch_database_t 
*notmuch)
 struct MaildateValueRangeProcessor : public Xapian::ValueRangeProcessor {
 MaildateValueRangeProcessor() {}

-  time_t
-  parsedate(std::string , bool early) {
-/* Parse the date to a 'time_t', return NULL on error*/
-/* possible time formats: -MM-DD, -MM, , */
-/* MM-DD (current month), DD (day in current month). */
-/* Uses start of time unit when 'early', end otherwise, e.g. */
-/* 2001:=2001-01-01:00:00:00 when 'early' or 2001-12-31:23:59:59 */
-bool now = false;
-struct tm *timeinfo;
-time_t timet;
-int year = 0, month = 0, day = 0;
-
-now = (str == "now");
-
-if (str.size() == 2) {
-  /* We got just current day in month, parse & remove it */
-  day = atoi(str.c_str());
-  str.erase(0,2);
-}
-
-if (str.size() == 4 or str.size() > 5) {
-  /* expect a year, parse & remove it */
-  year = atoi(str.c_str());
-  str.erase(0,5);
-}
-
-/* parse & remove month if there is sth left in the string */
-month = atoi(str.c_str());
-str.erase(0,3);
-
-/* Parse day if we have one left */
-if (str.size())
-  day = atoi(str.c_str()); 
-
-if (!now && year == 0 && month == 0 && day == 0)
-  // no expected time format
-  return -1 ;
-
-timet = time(NULL);/* init timeinfo with current time */
-timeinfo = gmtime();
-
-if (!now) {
-  /* add timeunit if !early (1 second too much, which we deduct later   */
-  if (!early) {
-   if (year && !month)++year;  /* only year given  */
-   if (year && month && !day) ++month; /* year & month given   */
-  }
-  if (year)  timeinfo -> tm_year = year - 1900;
-  if (month) timeinfo -> tm_mon = month - 1;
-  if (day)   timeinfo -> tm_mday = (early ? day : ++day);
-  else   timeinfo -> tm_mday = 1;
-
-  timeinfo -> tm_hour = 0;
-  timeinfo -> tm_min  = 0;
-  timeinfo -> tm_sec  = (early ? 0 : -1); /* -1 sec if !early */
-}
-timet = mktime(timeinfo);
-
-return timet;
-  }
-
 Xapian::valueno operator()(std::string , std::string ) {
-  time_t begintime, endtime;
+  time_t begin_first,begin_last, end_first, end_last;
+  int retval;

   if (begin.substr(0, 5) != "date:")
 return Xapian::BAD_VALUENO;
   begin.erase(0, 5);

-  begintime = parsedate(begin, true);
-  endtime   = parsedate(end, false);
+  retval = notmuch_parse_date(begin.c_str(), _first, _last, 0);

-  if ((begintime == -1) || (endtime == -1))
-   // parsedate failed, no valid time format
+  if (retval == NOTMUCH_STATUS_INVALID_DATE) {
+   fprintf(stderr,"Begin date failed to parse: %s",begin.c_str());
return Xapian::BAD_VALUENO;
+  }
+
+  retval = 
notmuch_parse_date(end.c_str(),_first,_last,begin_first);
+  if (retval == NOTMUCH_STATUS_INVALID_DATE) {
+   fprintf(stderr,"End date failed to parse: %s",end.c_str());
+   return Xapian::BAD_VALUENO;
+  }

-  begin.assign(Xapian::sortable_serialise(begintime));
-  end.assign(Xapian::sortable_serialise(endtime));
+  begin.assign(Xapian::sortable_serialise(begin_first));
+  end.assign(Xapian::sortable_serialise(end_last));

   return NOTMUCH_VALUE_TIMESTAMP;
 }
diff --git a/lib/date.c b/lib/date.c
index 09c5ef9..805a1d9 100644
--- a/lib/date.c
+++ b/lib/date.c
@@ -37,6 +37,7 @@ today(struct tm *result, time_t after) {
 }

 static int parse_today(const char *text, time_t *first, time_t *last, time_t 
after) {
+(void)after; /*disable unused paramter warning*/
 if (strcasecmp(text, "today") == 0) {
struct tm n;
today(, 0);
@@ -56,6 +57,7 @@ static int parse_yesterday(const char *text, time_t *first, 
time_t *last, time_t
return 0;
 }
 return 1;
+(void)after; /*disable unused paramter warning*/
 }

 static int 

[notmuch] [PATCH 3/4] compile date.c as well

2010-01-26 Thread Sebastian Spaeth
Signed-off-by: Sebastian Spaeth 
---
 lib/Makefile.local |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/Makefile.local b/lib/Makefile.local
index 70489e1..44deaf8 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -3,6 +3,7 @@ extra_cflags += -I$(dir)

 libnotmuch_c_srcs =\
$(dir)/libsha1.c\
+   $(dir)/date.c   \
$(dir)/message-file.c   \
$(dir)/messages.c   \
$(dir)/sha1.c   \
-- 
1.6.3.3



[notmuch] [PATCH 2/4] add date parser file from Keith

2010-01-26 Thread Sebastian Spaeth
From: Keith Packard 

Here's some code which further improves date parsing by allowing lots of
date formats, including things like "today", "thisweek", ISO and US date
formats and month names. You can separate two dates with .. to make a
range, or you can just use the default range ("lastmonth" is everything
>From the 1st of the previous month to the 1st of the current month).
---
 lib/date.c |  455 
 1 files changed, 455 insertions(+), 0 deletions(-)
 create mode 100644 lib/date.c

diff --git a/lib/date.c b/lib/date.c
new file mode 100644
index 000..09c5ef9
--- /dev/null
+++ b/lib/date.c
@@ -0,0 +1,455 @@
+/*
+ * Copyright ?? 2009 Keith Packard 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "notmuch.h"
+#include 
+#include 
+#include 
+#include 
+
+#define DAY(24 * 60 * 60)
+
+static void
+today(struct tm *result, time_t after) {
+time_t t;
+
+if (after)
+   t = after;
+else
+   time();
+localtime_r(, result);
+result->tm_sec = result->tm_min = result->tm_hour = 0;
+}
+
+static int parse_today(const char *text, time_t *first, time_t *last, time_t 
after) {
+if (strcasecmp(text, "today") == 0) {
+   struct tm n;
+   today(, 0);
+   *first = mktime();
+   *last = *first + DAY;
+   return 0;
+}
+return 1;
+}
+
+static int parse_yesterday(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, "yesterday") == 0) {
+   struct tm n;
+   today(, 0);
+   *last = mktime();
+   *first = *last - DAY;
+   return 0;
+}
+return 1;
+}
+
+static int parse_thisweek(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, "thisweek") == 0) {
+   struct tm n;
+   today(, 0);
+   *first = mktime() - (n.tm_wday * DAY);
+   *last = *first + DAY * 7;
+   return 0;
+}
+return 1;
+}
+
+static int parse_lastweek(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, "lastweek") == 0) {
+   struct tm n;
+   today(, 0);
+   *last = mktime() - (n.tm_wday * DAY);
+   *first = *last - DAY * 7;
+   return 0;
+}
+return 1;
+}
+
+static int parse_thismonth(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, "thismonth") == 0) {
+   struct tm n;
+   today(, 0);
+   n.tm_mday = 1;
+   *first = mktime();
+   if (n.tm_mon++ == 12) {
+   n.tm_mon = 0;
+   n.tm_year++;
+   }
+   *last = mktime();
+   return 0;
+}
+return 1;
+}
+
+static int parse_lastmonth(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, "lastmonth") == 0) {
+   struct tm n;
+   today(, 0);
+   n.tm_mday = 1;
+   if (n.tm_mon == 0) {
+   n.tm_year--;
+   n.tm_mon = 11;
+   } else
+   n.tm_mon--;
+   *first = mktime();
+   if (n.tm_mon++ == 12) {
+   n.tm_mon = 0;
+   n.tm_year++;
+   }
+   *last = mktime();
+   return 0;
+}
+return 1;
+}
+
+static const char *months[12][2] = {
+{ "January", "Jan" },
+{ "February", "Feb" },
+{ "March", "Mar" },
+{ "April", "Apr" },
+{ "May", "May" },
+{ "June", "Jun" },
+{ "July", "Jul" },
+{ "August", "Aug" },
+{ "September", "Sep" },
+{ "October", "Oct" },
+{ "November", "Nov" },
+{ "December", "Dec" },
+};
+
+static int year(const char *text, int *y) {
+char *end;
+*y = strtol(text, , 10);
+if (end == text)
+   return 1;
+if (*end != '\0')
+   return 1;
+if (*y < 1970 || *y > 2038)
+   return 1;
+*y -= 1900;
+return 0;
+}
+
+static int month(const char *text, int *m) {
+char *end;
+int i;
+for (i = 0; i < 12; i++) {
+   if (strcasecmp(text, months[i][0]) == 0 ||
+   strcasecmp(text, months[i][1]) == 0)
+   {
+   *m = i;
+   return 0;
+   }
+}
+*m = strtol(text, , 10);
+if (end == text)
+   return 1;
+if (*end != '\0')
+   return 1;
+if (*m < 1 || *m > 12)
+   return 1;
+*m -= 1;
+return 0;
+}
+
+static int day(const char *text, int 

[notmuch] [PATCH 1/4] Make the date parser nicer.

2010-01-26 Thread Sebastian Spaeth
Currently we have to enter mail dates as timestamps. This approach does 2 
things:
1) it requires the prefix 'date:'
2) it allows dates to be specified in a flexible way. So a notmuch show 
date:2005..2006-05-12 will find all mails from 2005-01-01 until 2006-05-12.
3) allow 'now' as keyword for NOW. This let's us search for messages 2001..now 
(note that this won't find timestamps in the future). Also adapt the 
documentation to state the new date search syntax.

Possible time formats: -MM-DD, -MM (from/through that month) ,  
(from/through that year), MM-DD (month-day in current year), DD (day in current 
month).

Signed-off-by: Sebastian Spaeth 
---
 TODO|9 --
 lib/database.cc |   87 ++-
 notmuch.1   |   30 --
 notmuch.c   |   24 +++---
 4 files changed, 118 insertions(+), 32 deletions(-)

diff --git a/TODO b/TODO
index bdfe64c..86cbf74 100644
--- a/TODO
+++ b/TODO
@@ -114,15 +114,6 @@ notmuch library
 ---
 Index content from citations, please.

-Provide a sane syntax for date ranges. First, we don't want to require
-both endpoints to be specified. For example it would be nice to be
-able to say things like "since:2009-01-1" or "until:2009-01-1" and
-have the other endpoint be implicit. Second we'd like to support
-relative specifications of time such as "since:'2 months ago'". To do
-any of this we're probably going to need to break down an write our
-own parser for the query string rather than using Xapian's QueryParser
-class.
-
 Make failure to read a file (such as a permissions problem) a warning
 rather than an error (should be similar to the existing warning for a
 non-mail file).
diff --git a/lib/database.cc b/lib/database.cc
index cce7847..b386e1a 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -494,6 +494,91 @@ _notmuch_database_ensure_writable (notmuch_database_t 
*notmuch)
 return NOTMUCH_STATUS_SUCCESS;
 }

+struct MaildateValueRangeProcessor : public Xapian::ValueRangeProcessor {
+MaildateValueRangeProcessor() {}
+
+  time_t
+  parsedate(std::string , bool early) {
+/* Parse the date to a 'time_t', return NULL on error*/
+/* possible time formats: -MM-DD, -MM, , */
+/* MM-DD (current month), DD (day in current month). */
+/* Uses start of time unit when 'early', end otherwise, e.g. */
+/* 2001:=2001-01-01:00:00:00 when 'early' or 2001-12-31:23:59:59 */
+bool now = false;
+struct tm *timeinfo;
+time_t timet;
+int year = 0, month = 0, day = 0;
+
+now = (str == "now");
+
+if (str.size() == 2) {
+  /* We got just current day in month, parse & remove it */
+  day = atoi(str.c_str());
+  str.erase(0,2);
+}
+
+if (str.size() == 4 or str.size() > 5) {
+  /* expect a year, parse & remove it */
+  year = atoi(str.c_str());
+  str.erase(0,5);
+}
+
+/* parse & remove month if there is sth left in the string */
+month = atoi(str.c_str());
+str.erase(0,3);
+
+/* Parse day if we have one left */
+if (str.size())
+  day = atoi(str.c_str()); 
+
+if (!now && year == 0 && month == 0 && day == 0)
+  // no expected time format
+  return -1 ;
+
+timet = time(NULL);/* init timeinfo with current time */
+timeinfo = gmtime();
+
+if (!now) {
+  /* add timeunit if !early (1 second too much, which we deduct later   */
+  if (!early) {
+   if (year && !month)++year;  /* only year given  */
+   if (year && month && !day) ++month; /* year & month given   */
+  }
+  if (year)  timeinfo -> tm_year = year - 1900;
+  if (month) timeinfo -> tm_mon = month - 1;
+  if (day)   timeinfo -> tm_mday = (early ? day : ++day);
+  else   timeinfo -> tm_mday = 1;
+
+  timeinfo -> tm_hour = 0;
+  timeinfo -> tm_min  = 0;
+  timeinfo -> tm_sec  = (early ? 0 : -1); /* -1 sec if !early */
+}
+timet = mktime(timeinfo);
+
+return timet;
+  }
+
+Xapian::valueno operator()(std::string , std::string ) {
+  time_t begintime, endtime;
+
+  if (begin.substr(0, 5) != "date:")
+return Xapian::BAD_VALUENO;
+  begin.erase(0, 5);
+
+  begintime = parsedate(begin, true);
+  endtime   = parsedate(end, false);
+
+  if ((begintime == -1) || (endtime == -1))
+   // parsedate failed, no valid time format
+   return Xapian::BAD_VALUENO;
+
+  begin.assign(Xapian::sortable_serialise(begintime));
+  end.assign(Xapian::sortable_serialise(endtime));
+
+  return NOTMUCH_VALUE_TIMESTAMP;
+}
+};
+
 notmuch_database_t *
 notmuch_database_open (const char *path,
   notmuch_database_mode_t mode)
@@ -570,7 +655,7 @@ notmuch_database_open (const char *path,
notmuch->query_parser = new Xapian::QueryParser;
notmuch->term_gen = new Xapian::TermGenerator;
 

[notmuch] tag dir proposal [was: Re: Git as notmuch object store]

2010-01-26 Thread Jameson Rollins
On Tue, 26 Jan 2010 10:32:02 -0600, Scott Robinson  
wrote:
> Excerpts from Jameson Rollins's message of Mon Jan 25 15:46:55 -0600 2010:
> > I think this idea is a really good one and I would like to pursue it as
> > a tangent thread here.  I was going to propose something very similar to
> > this.  I think it's a very flexible idea that would help in a lot of
> > ways.
> > 
> > [...]
> 
> This is getting involved. 
> 
> Maybe I'm missing something in this thread; but, why couldn't these complex 
> and
> context-sensitive decisions be delegated to sub-processes? ala git hooks?

I think this idea is completely independent of anything having to do
with using git as a mail store.  That's why I was trying to separate it
into a separate thread.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100126/b4d85a50/attachment-0001.pgp>


[notmuch] [PATCH] Mail::Notmuch Perl wrapper

2010-01-26 Thread Ben Gamari
Excerpts from Simon Cozens's message of Tue Jan 26 03:34:57 -0500 2010:
> 
> Yes, this is why I chose not to use SWIG: if I'm going to automatically
> get code that doesn't do what I want and then have to manually write
> code that does, why not just manually write code that does? (well,
> semi-manually: xsubpp extracted all the function signatures for me.)
> 
You bring up a very good point here. It seems like Perl is nice in that
it has tools that allow you to easily bring up a set of bindings.
Unfortunately, it seems that many other languages (Python included)
aren't as well endowed.

> I guess the advantage of SWIG is that it gets you code that you don't
> want in many different languages.
> 
This is actually precisely my logic. It saves you the work of having to
do the grunt work of writing the glue for each of the signatures.
However, it seems that in some languages this isn't nearly as difficult.

> Anyway, whichever way you do it, you'll still need the class
> documentation and the tests - feel free to take them from my patch if
> you end up going the SWIG route for Perl.
> 
You might have the right approach in not choosing a cookie-cutter
solution for binding generation. There certainly are tools[1][2][3] for
Python that make the job a great deal easier. Maybe these would be a
better choice. Ultimately, we'd probably end up with more code to
maintain, however the end result would likely be cleaner than the
current stacked bindings approach. What do people think?

- Ben

[1] http://www.cython.org/
[2] http://freshmeat.net/projects/python-sip/
[3] http://code.google.com/p/pybindgen/


[notmuch] Git feature branch

2010-01-26 Thread martin f krafft
also sprach Carl Worth  [2010.01.23.1010 +1300]:
> Anyway, I'll be on vacation for the next few days, so will likely
> not have much, (likely have not much?), time for patch merging.
> 
> But I *am* anxious to get back to the backlog. And in the
> meantime, I really appreciate others merging and sharing patches.

I discussed this with Carl at LCA a bit and ideally we should come
up with a way to relieve Carl of the bottleneck burden (obviously
without stealing away his dictator hat ;)

I think it would make sense to move the mainline to git.debian.org
for now, or another place where everyone can easily get an account.
As alternatives I propose repo.or.cz. I'd prefer to stay away from
commercial services like Github.

Once we're there, how about copying the branch structure from
Git development[0]:

  maint/? the stable release
  master/   ? the stablising head
  next/ ? testing branch
  pu/   ? patch integration branch (proposed updates)

Each of the four branches is usually a direct descendant of the one
above it. Conceptually, the feature enters at an unstable branch
(usually 'next' or 'pu'), and "graduates" to 'master' for the next
release once it is considered stable enough.

0. http://repo.or.cz/w/git.git/blob/HEAD:/Documentation/gitworkflows.txt

Sebastian, would it make sense to migrate your work into a 'pu'
branch?

What patch tracking workflow should we adopt? Keep sending patches
to the mailing list and have a few people who integrate them into
master or pu (or even maint/next), as appropriate? Use the Debian
bug tracker? Use Sebastian's Roundup instance? Set up a patch queue
manager on notmuchmail.org? Use patchwork [1]?

Cheers,

-- 
martin | http://madduck.net/ | http://two.sentenc.es/

"in all unimportant matters, style, not sincerity, is the essential.
 in all important matters, style, not sincerity, is the essential."
-- oscar wilde

spamtraps: madduck.bogus at madduck.net
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100126/e5371d3b/attachment.pgp>


[notmuch] tag dir proposal [was: Re: Git as notmuch object store]

2010-01-26 Thread Scott Robinson
Excerpts from Jameson Rollins's message of Mon Jan 25 15:46:55 -0600 2010:
> I think this idea is a really good one and I would like to pursue it as
> a tangent thread here.  I was going to propose something very similar to
> this.  I think it's a very flexible idea that would help in a lot of
> ways.
> 
> [...]

This is getting involved. 

Maybe I'm missing something in this thread; but, why couldn't these complex and
context-sensitive decisions be delegated to sub-processes? ala git hooks?


[notmuch] [PATCH] Make the date parser nicer

2010-01-26 Thread Sebastian Spaeth
On Mon, 25 Jan 2010 22:36:35 -0800, Keith Packard  wrote:
> Here's some code which further improves date parsing by allowing lots of
> date formats, including things like "today", "thisweek", ISO and US date
> formats and month names. You can separate two dates with .. to make a
> range, or you can just use the default range ("lastmonth" is everything
> From the 1st of the previous month to the 1st of the current month).
> 
> I think this fits nicely with your code.

Hey, cool. I tried to keep my patch as small as possible, thanks for a
full-fledged date string parser :). I'll see how I can integrate that
into my dateparser branch.

Thanks
Sebastian


[notmuch] proposal for more streamlined mail flow in notmuch

2010-01-26 Thread martin f krafft
also sprach Jameson Rollins  [2010.01.17.0949 
+1300]:
> I would like to put forth here a proposal for a couple of changes
> to notmuch that I believe will considerably streamline message
> handling and new message flow through notmuch.  Notmuch is still
> new and I believe it hasn't quite figured out the best way to
> handle message flow in the new mail handling paradigm that it is
> working.  This is a proposal to fix that.
>
> I believe that most people are syncing their mail from remote IMAP or
> POP servers to local maildirs (via offlineimap for instance), and that
> most people's IMAP servers have limited storage capacity.  This
> practically means that people can not keep all of their mail in a
> single directory.  However, notmuch currently basically assumes that
> this is what is happening.  In order to keep synced maildirs from
> growing out of hand, messages need to be either deleted or moved out
> of the "inbox" where they initially show up.

We should keep this in mind when designing an object store, whether
or not that's based on Git. If we use Git, then a local branch is
all we really need to support this. \o/

-- 
martin | http://madduck.net/ | http://two.sentenc.es/

above all, we should not wish to divest
our existence of its rich ambiguity.
 --friedrich nietzsche

spamtraps: madduck.bogus at madduck.net
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100126/95e4c7f6/attachment.pgp>


[notmuch] [PATCH] Make the date parser nicer

2010-01-26 Thread Keith Packard
On Tue, 26 Jan 2010 12:50:41 +0100, "Sebastian Spaeth"  wrote:
> On Mon, 25 Jan 2010 22:36:35 -0800, Keith Packard  
> wrote:
> > Here's some code which further improves date parsing by allowing lots of
> > date formats, including things like "today", "thisweek", ISO and US date
> > formats and month names. You can separate two dates with .. to make a
> > range, or you can just use the default range ("lastmonth" is everything
> > From the 1st of the previous month to the 1st of the current month).
> > 
> > I think this fits nicely with your code.
> 
> It fit nicely indeed. I have just integrated your date parser into my
> code and sent it as a series of 4 patches based on current cworth
> master. (commits 2565fc6 and 96e11c3 will not compile on their own)

Very cool. Oh, if you've got commits that don't compile on their own,
you should squash them together (or fix it in some other way). Makes
bisecting easier in the future.

Also, cworth is on vacation this week, so we won't be seeing any
merging to master...

-- 
keith.packard at intel.com
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100126/228d26b3/attachment.pgp>


[notmuch] Git as notmuch object store (was: Potential problem using Git for mail)

2010-01-26 Thread martin f krafft
also sprach Sebastian Spaeth  [2010.01.26.0249 +1300]:
> While notmuchsync fullfils my needs, it is a kludge. It needs to
> call "notmuch" for each mail where a MailDir flag has changed
> (which can be quite often on an initial run, where most mails are
> likely to be read), this can take a long, long time. It would
> makes sense IMHO to at least pick pioto's "don't set unread if 'S'
> flag is set" on notmuch new[1].

I am sure this could be implemented with libnotmuch if it proves to
be useful.

-- 
martin | http://madduck.net/ | http://two.sentenc.es/

"it isn't pollution that's harming the environment.
 it's the impurities in our air and water that are doing it."
  - dan quayle

spamtraps: madduck.bogus at madduck.net
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/)
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100126/9ecde01e/attachment.pgp>


[notmuch] [PATCH] Mail::Notmuch Perl wrapper

2010-01-26 Thread Simon Cozens
On 26/01/2010 03:30, Ben Gamari wrote:
> I know practically nothing about writing Perl bindings,

I recommend http://www.manning.com/jenness/ ;)

> but it seems
> like this might be work better left to a bindings generator. I currently
> have a patch which enables binding generation through SWIG. It works
> well, although SWIG unfortunately doesn't have very good support for
> exposing object-oriented C interfaces like notmuchs' through the target
> language's type system.

Yes, this is why I chose not to use SWIG: if I'm going to automatically
get code that doesn't do what I want and then have to manually write
code that does, why not just manually write code that does? (well,
semi-manually: xsubpp extracted all the function signatures for me.)

I guess the advantage of SWIG is that it gets you code that you don't
want in many different languages.

Anyway, whichever way you do it, you'll still need the class
documentation and the tests - feel free to take them from my patch if
you end up going the SWIG route for Perl.

Simon


[notmuch] [PATCH] Build and link against notmuch shared library

2010-01-26 Thread Ben Gamari
Inger in #notmuch brought to light some build issues that will occur when the
notmuch binary is being built before libnotmuch is installed. Here is an
updated patch that resolves these issues.

---
 .gitignore |1 +
 Makefile   |1 +
 Makefile.local |6 --
 lib/Makefile.local |9 +
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index efa98fb..daf8094 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@ tags
 .deps
 notmuch
 notmuch.1.gz
+libnotmuch.so*
 *.[ao]
 *~
 .*.swp
diff --git a/Makefile b/Makefile
index 64b9d4a..6f296bb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,4 @@
+SONAME = libnotmuch.so.1
 WARN_CXXFLAGS=-Wall -Wextra -Wwrite-strings -Wswitch-enum
 WARN_CFLAGS=$(WARN_CXXFLAGS) -Wmissing-declarations

diff --git a/Makefile.local b/Makefile.local
index 04bac83..5b6af0a 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -21,8 +21,8 @@ notmuch_client_srcs = \
show-message.c

 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
-notmuch: $(notmuch_client_modules) lib/notmuch.a
-   $(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -o $@
+notmuch: $(notmuch_client_modules) lib/libnotmuch.so
+   $(call quiet,CC,$(LDFLAGS)) -Llib -lnotmuch $(filter-out 
lib/libnotmuch.so,$^) $(FINAL_LDFLAGS) -o $@

 notmuch.1.gz: notmuch.1
$(call quiet,gzip) --stdout $^ > $@
@@ -33,6 +33,8 @@ install: all notmuch.1.gz
install -d $$d ; \
done ;
install notmuch $(DESTDIR)$(prefix)/bin/
+   install lib/$(SONAME) $(DESTDIR)$(prefix)/lib/
+   ln -sf $(DESTDIR)$(prefix)/lib/$(SONAME) 
$(DESTDIR)$(prefix)/lib/libnotmuch.so
install -m0644 notmuch.1.gz $(DESTDIR)$(prefix)/share/man/man1/

 install-emacs: install emacs
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 70489e1..a6462ae 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -1,5 +1,5 @@
 dir=lib
-extra_cflags += -I$(dir)
+extra_cflags += -I$(dir) -fPIC

 libnotmuch_c_srcs =\
$(dir)/libsha1.c\
@@ -18,8 +18,9 @@ libnotmuch_cxx_srcs = \
$(dir)/thread.cc

 libnotmuch_modules = $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
-$(dir)/notmuch.a: $(libnotmuch_modules)
-   $(call quiet,AR) rcs $@ $^
+$(dir)/libnotmuch.so : $(libnotmuch_modules)
+   $(call quiet,CXX,$(LDFLAGS)) $^ $(FINAL_LDFLAGS) -shared 
-Wl,-soname=$(SONAME) -o $@
+   ln -sf $(SONAME) $@

 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
-CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/notmuch.a
+CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/libnotmuch.so *.so
-- 
1.6.3.3



[notmuch] [PATCH] Add SWIG interface file

2010-01-26 Thread Ben Gamari

For the record, both the swig branch and the shared-library branch are
available from,
  anonymous: git://goldnerlab.physics.umass.edu/notmuch
  gitweb: http://goldnerlab.physics.umass.edu/git?p=notmuch.git;a=summary

Hope this helps,

- Ben


Re: [notmuch] [PATCH] Make the date parser nicer

2010-01-26 Thread Sebastian Spaeth
On Mon, 25 Jan 2010 22:36:35 -0800, Keith Packard kei...@keithp.com wrote:
 Here's some code which further improves date parsing by allowing lots of
 date formats, including things like today, thisweek, ISO and US date
 formats and month names. You can separate two dates with .. to make a
 range, or you can just use the default range (lastmonth is everything
 From the 1st of the previous month to the 1st of the current month).
 
 I think this fits nicely with your code.

Hey, cool. I tried to keep my patch as small as possible, thanks for a
full-fledged date string parser :). I'll see how I can integrate that
into my dateparser branch.

Thanks
Sebastian
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Mail::Notmuch Perl wrapper

2010-01-26 Thread Simon Cozens
On 26/01/2010 03:30, Ben Gamari wrote:
 I know practically nothing about writing Perl bindings,

I recommend http://www.manning.com/jenness/ ;)

 but it seems
 like this might be work better left to a bindings generator. I currently
 have a patch which enables binding generation through SWIG. It works
 well, although SWIG unfortunately doesn't have very good support for
 exposing object-oriented C interfaces like notmuchs' through the target
 language's type system.

Yes, this is why I chose not to use SWIG: if I'm going to automatically
get code that doesn't do what I want and then have to manually write
code that does, why not just manually write code that does? (well,
semi-manually: xsubpp extracted all the function signatures for me.)

I guess the advantage of SWIG is that it gets you code that you don't
want in many different languages.

Anyway, whichever way you do it, you'll still need the class
documentation and the tests - feel free to take them from my patch if
you end up going the SWIG route for Perl.

Simon
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH 2/4] add date parser file from Keith

2010-01-26 Thread Sebastian Spaeth
From: Keith Packard kei...@keithp.com

Here's some code which further improves date parsing by allowing lots of
date formats, including things like today, thisweek, ISO and US date
formats and month names. You can separate two dates with .. to make a
range, or you can just use the default range (lastmonth is everything
From the 1st of the previous month to the 1st of the current month).
---
 lib/date.c |  455 
 1 files changed, 455 insertions(+), 0 deletions(-)
 create mode 100644 lib/date.c

diff --git a/lib/date.c b/lib/date.c
new file mode 100644
index 000..09c5ef9
--- /dev/null
+++ b/lib/date.c
@@ -0,0 +1,455 @@
+/*
+ * Copyright © 2009 Keith Packard kei...@keithp.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include notmuch.h
+#include time.h
+#include stdio.h
+#include string.h
+#include stdlib.h
+
+#define DAY(24 * 60 * 60)
+
+static void
+today(struct tm *result, time_t after) {
+time_t t;
+
+if (after)
+   t = after;
+else
+   time(t);
+localtime_r(t, result);
+result-tm_sec = result-tm_min = result-tm_hour = 0;
+}
+
+static int parse_today(const char *text, time_t *first, time_t *last, time_t 
after) {
+if (strcasecmp(text, today) == 0) {
+   struct tm n;
+   today(n, 0);
+   *first = mktime(n);
+   *last = *first + DAY;
+   return 0;
+}
+return 1;
+}
+
+static int parse_yesterday(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, yesterday) == 0) {
+   struct tm n;
+   today(n, 0);
+   *last = mktime(n);
+   *first = *last - DAY;
+   return 0;
+}
+return 1;
+}
+
+static int parse_thisweek(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, thisweek) == 0) {
+   struct tm n;
+   today(n, 0);
+   *first = mktime(n) - (n.tm_wday * DAY);
+   *last = *first + DAY * 7;
+   return 0;
+}
+return 1;
+}
+
+static int parse_lastweek(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, lastweek) == 0) {
+   struct tm n;
+   today(n, 0);
+   *last = mktime(n) - (n.tm_wday * DAY);
+   *first = *last - DAY * 7;
+   return 0;
+}
+return 1;
+}
+
+static int parse_thismonth(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, thismonth) == 0) {
+   struct tm n;
+   today(n, 0);
+   n.tm_mday = 1;
+   *first = mktime(n);
+   if (n.tm_mon++ == 12) {
+   n.tm_mon = 0;
+   n.tm_year++;
+   }
+   *last = mktime(n);
+   return 0;
+}
+return 1;
+}
+
+static int parse_lastmonth(const char *text, time_t *first, time_t *last, 
time_t after) {
+if (strcasecmp(text, lastmonth) == 0) {
+   struct tm n;
+   today(n, 0);
+   n.tm_mday = 1;
+   if (n.tm_mon == 0) {
+   n.tm_year--;
+   n.tm_mon = 11;
+   } else
+   n.tm_mon--;
+   *first = mktime(n);
+   if (n.tm_mon++ == 12) {
+   n.tm_mon = 0;
+   n.tm_year++;
+   }
+   *last = mktime(n);
+   return 0;
+}
+return 1;
+}
+
+static const char *months[12][2] = {
+{ January, Jan },
+{ February, Feb },
+{ March, Mar },
+{ April, Apr },
+{ May, May },
+{ June, Jun },
+{ July, Jul },
+{ August, Aug },
+{ September, Sep },
+{ October, Oct },
+{ November, Nov },
+{ December, Dec },
+};
+
+static int year(const char *text, int *y) {
+char *end;
+*y = strtol(text, end, 10);
+if (end == text)
+   return 1;
+if (*end != '\0')
+   return 1;
+if (*y  1970 || *y  2038)
+   return 1;
+*y -= 1900;
+return 0;
+}
+
+static int month(const char *text, int *m) {
+char *end;
+int i;
+for (i = 0; i  12; i++) {
+   if (strcasecmp(text, months[i][0]) == 0 ||
+   strcasecmp(text, months[i][1]) == 0)
+   {
+   *m = i;
+   return 0;
+   }
+}
+*m = strtol(text, end, 10);
+if (end == text)
+   return 1;
+if (*end != '\0')
+   return 1;
+if (*m  1 || *m  12)
+   return 1;
+*m -= 1;
+return 0;
+}
+
+static int day(const char *text, int *d) {
+

[notmuch] [PATCH 4/4] integrate keithp's date.c into the notmuch date parser and delete my previous own attempt

2010-01-26 Thread Sebastian Spaeth
Signed-off-by: Sebastian Spaeth sebast...@sspaeth.de
---
 lib/database.cc |   84 ++
 lib/date.c  |   59 ++
 lib/notmuch.h   |   20 +
 notmuch-new.c   |1 +
 notmuch.1   |   33 +++--
 notmuch.c   |   20 +++--
 6 files changed, 74 insertions(+), 143 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index b386e1a..78cd898 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -219,6 +219,8 @@ notmuch_status_to_string (notmuch_status_t status)
return Erroneous NULL pointer;
 case NOTMUCH_STATUS_TAG_TOO_LONG:
return Tag value is too long (exceeds NOTMUCH_TAG_MAX);
+case NOTMUCH_STATUS_INVALID_DATE:
+   return Date value did not parse to a valid date;
 case NOTMUCH_STATUS_UNBALANCED_FREEZE_THAW:
return Unbalanced number of calls to notmuch_message_freeze/thaw;
 default:
@@ -497,83 +499,29 @@ _notmuch_database_ensure_writable (notmuch_database_t 
*notmuch)
 struct MaildateValueRangeProcessor : public Xapian::ValueRangeProcessor {
 MaildateValueRangeProcessor() {}
 
-  time_t
-  parsedate(std::string str, bool early) {
-/* Parse the date to a 'time_t', return NULL on error*/
-/* possible time formats: -MM-DD, -MM, , */
-/* MM-DD (current month), DD (day in current month). */
-/* Uses start of time unit when 'early', end otherwise, e.g. */
-/* 2001:=2001-01-01:00:00:00 when 'early' or 2001-12-31:23:59:59 */
-bool now = false;
-struct tm *timeinfo;
-time_t timet;
-int year = 0, month = 0, day = 0;
-
-now = (str == now);
-
-if (str.size() == 2) {
-  /* We got just current day in month, parse  remove it */
-  day = atoi(str.c_str());
-  str.erase(0,2);
-}
-
-if (str.size() == 4 or str.size()  5) {
-  /* expect a year, parse  remove it */
-  year = atoi(str.c_str());
-  str.erase(0,5);
-}
-
-/* parse  remove month if there is sth left in the string */
-month = atoi(str.c_str());
-str.erase(0,3);
-
-/* Parse day if we have one left */
-if (str.size())
-  day = atoi(str.c_str()); 
-
-if (!now  year == 0  month == 0  day == 0)
-  // no expected time format
-  return -1 ;
-
-timet = time(NULL);/* init timeinfo with current time */
-timeinfo = gmtime(timet);
-
-if (!now) {
-  /* add timeunit if !early (1 second too much, which we deduct later   */
-  if (!early) {
-   if (year  !month)++year;  /* only year given  */
-   if (year  month  !day) ++month; /* year  month given   */
-  }
-  if (year)  timeinfo - tm_year = year - 1900;
-  if (month) timeinfo - tm_mon = month - 1;
-  if (day)   timeinfo - tm_mday = (early ? day : ++day);
-  else   timeinfo - tm_mday = 1;
-
-  timeinfo - tm_hour = 0;
-  timeinfo - tm_min  = 0;
-  timeinfo - tm_sec  = (early ? 0 : -1); /* -1 sec if !early */
-}
-timet = mktime(timeinfo);
-
-return timet;
-  }
-
 Xapian::valueno operator()(std::string begin, std::string end) {
-  time_t begintime, endtime;
+  time_t begin_first,begin_last, end_first, end_last;
+  int retval;
 
   if (begin.substr(0, 5) != date:)
 return Xapian::BAD_VALUENO;
   begin.erase(0, 5);
 
-  begintime = parsedate(begin, true);
-  endtime   = parsedate(end, false);
+  retval = notmuch_parse_date(begin.c_str(), begin_first, begin_last, 0);
 
-  if ((begintime == -1) || (endtime == -1))
-   // parsedate failed, no valid time format
+  if (retval == NOTMUCH_STATUS_INVALID_DATE) {
+   fprintf(stderr,Begin date failed to parse: %s,begin.c_str());
return Xapian::BAD_VALUENO;
+  }
+
+  retval = 
notmuch_parse_date(end.c_str(),end_first,end_last,begin_first);
+  if (retval == NOTMUCH_STATUS_INVALID_DATE) {
+   fprintf(stderr,End date failed to parse: %s,end.c_str());
+   return Xapian::BAD_VALUENO;
+  }
 
-  begin.assign(Xapian::sortable_serialise(begintime));
-  end.assign(Xapian::sortable_serialise(endtime));
+  begin.assign(Xapian::sortable_serialise(begin_first));
+  end.assign(Xapian::sortable_serialise(end_last));
 
   return NOTMUCH_VALUE_TIMESTAMP;
 }
diff --git a/lib/date.c b/lib/date.c
index 09c5ef9..805a1d9 100644
--- a/lib/date.c
+++ b/lib/date.c
@@ -37,6 +37,7 @@ today(struct tm *result, time_t after) {
 }
 
 static int parse_today(const char *text, time_t *first, time_t *last, time_t 
after) {
+(void)after; /*disable unused paramter warning*/
 if (strcasecmp(text, today) == 0) {
struct tm n;
today(n, 0);
@@ -56,6 +57,7 @@ static int parse_yesterday(const char *text, time_t *first, 
time_t *last, time_t
return 0;
 }
 return 1;
+(void)after; /*disable unused paramter warning*/
 }
 
 

Re: [notmuch] [PATCH] Make the date parser nicer

2010-01-26 Thread Sebastian Spaeth
On Mon, 25 Jan 2010 22:36:35 -0800, Keith Packard kei...@keithp.com wrote:
 Here's some code which further improves date parsing by allowing lots of
 date formats, including things like today, thisweek, ISO and US date
 formats and month names. You can separate two dates with .. to make a
 range, or you can just use the default range (lastmonth is everything
 From the 1st of the previous month to the 1st of the current month).
 
 I think this fits nicely with your code.

It fit nicely indeed. I have just integrated your date parser into my
code and sent it as a series of 4 patches based on current cworth
master. (commits 2565fc6 and 96e11c3 will not compile on their own)

ec3c79a integrate keithp's date.c into the notmuch date parser and delete my 
previous own 
2565fc6 compile date.c as well
96e11c3 add date parser file from Keith
6ed2569 Make the date parser nicer.

The topic branch is here for those who don't want to apply mail patches:
http://github.com/spaetz/notmuch-all-feature/commits/dateparser3

Documentation of the new notmuch_parse_date function:
/* Parse a string into the first and last possible timestamps.
 * It parses the possible formats and stops if one pattern matches.
 * Keywords: 'today','yesterday','thisweek','lastweek','thismonth',
 *   'lastmonth'
 * Month-day : month[-day]] (month: January, Jan, or 1)\n
 * ISO format: year[-month[-day]]
 * US format : month[/day[/year]]
 *
 * 'after' is used to fill in bits from context if left out, e.g. a
 * 'date:2004..01' will find from 2004-01-01 through 2004-01-31
 *
 * Return values:
 * NOTMUCH_STATUS_SUCCESS
 * NOTMUCH_STATUS_INVALID_DATE: Error parsing the date string

Please pull :-).

Sebastian
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Mail::Notmuch Perl wrapper

2010-01-26 Thread Ben Gamari
Excerpts from Simon Cozens's message of Tue Jan 26 03:34:57 -0500 2010:
 
 Yes, this is why I chose not to use SWIG: if I'm going to automatically
 get code that doesn't do what I want and then have to manually write
 code that does, why not just manually write code that does? (well,
 semi-manually: xsubpp extracted all the function signatures for me.)
 
You bring up a very good point here. It seems like Perl is nice in that
it has tools that allow you to easily bring up a set of bindings.
Unfortunately, it seems that many other languages (Python included)
aren't as well endowed.

 I guess the advantage of SWIG is that it gets you code that you don't
 want in many different languages.
 
This is actually precisely my logic. It saves you the work of having to
do the grunt work of writing the glue for each of the signatures.
However, it seems that in some languages this isn't nearly as difficult.

 Anyway, whichever way you do it, you'll still need the class
 documentation and the tests - feel free to take them from my patch if
 you end up going the SWIG route for Perl.
 
You might have the right approach in not choosing a cookie-cutter
solution for binding generation. There certainly are tools[1][2][3] for
Python that make the job a great deal easier. Maybe these would be a
better choice. Ultimately, we'd probably end up with more code to
maintain, however the end result would likely be cleaner than the
current stacked bindings approach. What do people think?

- Ben

[1] http://www.cython.org/
[2] http://freshmeat.net/projects/python-sip/
[3] http://code.google.com/p/pybindgen/
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] tag dir proposal [was: Re: Git as notmuch object store]

2010-01-26 Thread Scott Robinson
Excerpts from Jameson Rollins's message of Mon Jan 25 15:46:55 -0600 2010:
 I think this idea is a really good one and I would like to pursue it as
 a tangent thread here.  I was going to propose something very similar to
 this.  I think it's a very flexible idea that would help in a lot of
 ways.
 
 [...]

This is getting involved. 

Maybe I'm missing something in this thread; but, why couldn't these complex and
context-sensitive decisions be delegated to sub-processes? ala git hooks?
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Make the date parser nicer

2010-01-26 Thread Keith Packard
On Tue, 26 Jan 2010 12:50:41 +0100, Sebastian Spaeth sebast...@sspaeth.de 
wrote:
 On Mon, 25 Jan 2010 22:36:35 -0800, Keith Packard kei...@keithp.com wrote:
  Here's some code which further improves date parsing by allowing lots of
  date formats, including things like today, thisweek, ISO and US date
  formats and month names. You can separate two dates with .. to make a
  range, or you can just use the default range (lastmonth is everything
  From the 1st of the previous month to the 1st of the current month).
  
  I think this fits nicely with your code.
 
 It fit nicely indeed. I have just integrated your date parser into my
 code and sent it as a series of 4 patches based on current cworth
 master. (commits 2565fc6 and 96e11c3 will not compile on their own)

Very cool. Oh, if you've got commits that don't compile on their own,
you should squash them together (or fix it in some other way). Makes
bisecting easier in the future.

Also, cworth is on vacation this week, so we won't be seeing any
merging to master...

-- 
keith.pack...@intel.com


pgpXXzLGP8ACa.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCH] simplify notmuch new output

2010-01-26 Thread Jameson Rollins
This patch just simplifies the notmuch new output to make it easier to
read, as well as more easily machine parsable.
---
 notmuch-new.c |   31 ---
 1 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/notmuch-new.c b/notmuch-new.c
index f25c71f..e07107e 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -816,41 +816,34 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
tv_now);
 
 if (add_files_state.processed_files) {
-   printf (Processed %d %s in , add_files_state.processed_files,
-   add_files_state.processed_files == 1 ?
-   file : total files);
+   printf (processed: %d %s (,
+   add_files_state.processed_files,
+   add_files_state.processed_files == 1 ? file : files);
notmuch_time_print_formatted_seconds (elapsed);
+   printf ());
if (elapsed  1) {
-   printf ( (%d files/sec.). \n,
+   printf ( (%d files/sec.)\n,
(int) (add_files_state.processed_files / elapsed));
} else {
-   printf (.\n);
+   printf (\n);
}
 }
 
 if (add_files_state.added_messages) {
-   printf (Added %d new %s to the database.,
-   add_files_state.added_messages,
-   add_files_state.added_messages == 1 ?
-   message : messages);
-} else {
-   printf (No new mail.);
+   printf ( new: %d\n,
+   add_files_state.added_messages);
 }
 
 if (removed_files) {
-   printf ( Removed %d %s.,
-   removed_files,
-   removed_files == 1 ? message : messages);
+   printf ( deletes: %d\n,
+   removed_files);
 }
 
 if (renamed_files) {
-   printf ( Detected %d file %s.,
-   renamed_files,
-   renamed_files == 1 ? rename : renames);
+   printf ( renames: %d\n,
+   renamed_files);
 }
 
-printf (\n);
-
 if (ret) {
printf (\nNote: At least one error was encountered: %s\n,
notmuch_status_to_string (ret));
-- 
1.6.5


pgpTmEdxyTmdd.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch