[alot] announcing v0.3.3

2012-09-12 Thread Joseph Tannhuber
Dear Patrick

> You can, but its not so comfortable at the moment: just use
> `set From OtherAccount Realname `
Ok, let's try it right now. I think it would be the best to determine the sender
account from the header of the answered mail. But I have no idea if it is
possible. 

Thank you
Joseph


[alot] announcing v0.3.3

2012-09-12 Thread Sepp Tannhuber
Hi Patrick, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
my abook is working now. I don't know why it did not yesterday. Probably it was 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
not a bug but rather something stupid with my config. ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
> Could you open up a feature request issue on github for this? ? ? ? ? ? ? ? ? 
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
Yes. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
> This feature would not be hard to implement, but so far I did not bother ? ? 
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
> to do so as I considered mail-fetching not part of alots responsibility. ? ? 
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
I would like to have a shortcut to jump quickly to a window that has the 
urgency ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
flag set. This is why I asked for that feature. But I agree with you. A simple 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
script can do it as well. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
However I'd like to raise another question. I have configured two mail 
accounts. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
It seems that I cannot choose between them when I reply to a message. Can I? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Hopefully this was my last question. ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
Thanks alot ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
Joseph ? ? ??


[PATCH v3 9/9] NEWS: date range search support

2012-09-12 Thread Jani Nikula
---
 NEWS |   14 ++
 1 file changed, 14 insertions(+)

diff --git a/NEWS b/NEWS
index 2b50ba3..5f5b726 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,17 @@
+Notmuch 0.15 (-MM-DD)
+=
+
+Library changes
+---
+
+Date range search support
+
+  The `date:` prefix can now be used in queries to restrict the results to only
+  messages within a particular time range (based on the Date: header) with a
+  range syntax of `date:..`. Notmuch supports a wide variety of
+  expressions in `` and ``. Please refer to the
+  `notmuch-search-terms(7)` manual page for details.
+
 Notmuch 0.14 (2012-08-20)
 =
 
-- 
1.7.9.5

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


[PATCH v3 8/9] man: document the date:since..until range queries

2012-09-12 Thread Jani Nikula
---
 man/man7/notmuch-search-terms.7 |  147 +++
 1 file changed, 135 insertions(+), 12 deletions(-)

diff --git a/man/man7/notmuch-search-terms.7 b/man/man7/notmuch-search-terms.7
index 17a109e..fbd3ee7 100644
--- a/man/man7/notmuch-search-terms.7
+++ b/man/man7/notmuch-search-terms.7
@@ -54,6 +54,8 @@ terms to match against specific portions of an email, (where
 
folder:
 
+   date:..
+
 The
 .B from:
 prefix is used to match the name or address of the sender of an email
@@ -104,6 +106,26 @@ contained within particular directories within the mail 
store. Only
 the directory components below the top-level mail database path are
 available to be searched.
 
+The
+.B date:
+prefix can be used to restrict the results to only messages within a
+particular time range (based on the Date: header) with a range syntax
+of:
+
+   date:..
+
+See \fBDATE AND TIME SEARCH\fR below for details on the range
+expression, and supported syntax for  and  date and time
+expressions.
+
+The time range can also be specified using timestamps with a syntax
+of:
+
+   ..
+
+Each timestamp is a number representing the number of seconds since
+1970\-01\-01 00:00:00 UTC.
+
 In addition to individual terms, multiple terms can be
 combined with Boolean operators (
 .BR and ", " or ", " not
@@ -117,20 +139,121 @@ operators, but will have to be protected from 
interpretation by the
 shell, (such as by putting quotation marks around any parenthesized
 expression).
 
-Finally, results can be restricted to only messages within a
-particular time range, (based on the Date: header) with a syntax of:
+.SH DATE AND TIME SEARCH
 
-   ..
+This is a non-exhaustive description of the date and time search with
+some pseudo notation. Most of the constructs can be mixed freely, and
+in any order, but the same absolute date or time can't be expressed
+twice.
 
-Each timestamp is a number representing the number of seconds since
-1970\-01\-01 00:00:00 UTC. This is not the most convenient means of
-expressing date ranges, but until notmuch is fixed to accept a more
-convenient form, one can use the date program to construct
-timestamps. For example, with the bash shell the following syntax would
-specify a date range to return messages from 2009\-10\-01 until the
-current time:
-
-   $(date +%s \-d 2009\-10\-01)..$(date +%s)
+.RS 4
+.TP 4
+.B The range expression
+
+date:..
+
+The above expression restricts the results to only messages from
+ to , based on the Date: header.
+
+If  or  describes time at an accuracy of days or less,
+the date/time is rounded, towards past for  and towards future
+for , to be inclusive. For example, date:january..february
+matches from the beginning of January until the end of
+February. Similarly, date:yesterday..yesterday matches from the
+beginning of yesterday until the end of yesterday.
+
+Open-ended ranges are supported (since Xapian 1.2.1), i.e. it's
+possible to specify date:.. or date:.. to not limit the
+start or end time, respectively. Unfortunately, pre-1.2.1 Xapian does
+not report an error on open ended ranges, but it does not work as
+expected either.
+
+Xapian does not support spaces in range expressions. You can replace
+the spaces with '_', or (in most cases) '-', or (in some cases) leave
+the spaces out altogether.
+
+Entering date:expr without ".." (for example date:yesterday) won't
+work, as it's not interpreted as a range expression at all. You can
+achieve the expected result by duplicating the expr both sides of ".."
+(for example date:yesterday..yesterday).
+.RE
+
+.RS 4
+.TP 4
+.B Relative date and time
+[N|number] (years|months|weeks|days|hours|hrs|minutes|mins|seconds|secs) [...]
+
+All refer to past, can be repeated and will be accumulated.
+
+Units can be abbreviated to any length, with the otherwise ambiguous
+single m being m for minutes and M for months.
+
+Number multiplier can also be written out one, two, ..., ten, dozen,
+hundred. As special cases last means one ("last week") and this means
+zero ("this month").
+
+When combined with absolute date and time, the relative date and time
+specification will be relative from the specified absolute date and
+time.
+
+Examples: 5M2d, two weeks
+.RE
+
+.RS 4
+.TP 4
+.B Supported time formats
+H[H]:MM[:SS] [(am|a.m.|pm|p.m.)]
+
+H[H] (am|a.m.|pm|p.m.)
+
+HHMMSS
+
+now
+
+noon
+
+midnight
+
+Examples: 17:05, 5pm
+.RE
+
+.RS 4
+.TP 4
+.B Supported date formats
+-MM[-DD]
+
+DD-MM[-[YY]YY]
+
+MM-
+
+M[M]/D[D][/[YY]YY]
+
+M[M]/
+
+D[D].M[M][.[YY]YY]
+
+D[D][(st|nd|rd|th)] Mon[thname] []
+
+Mon[thname] D[D][(st|nd|rd|th)] []
+
+Wee[kday]
+
+Month names can be abbreviated at three or more characters.
+
+Weekday names can be abbreviated at three or more characters.
+
+Examples: 2012-07-31, 31-07-2012, 7/31/2012, August 3
+.RE
+
+.RS 4
+.TP 4
+.B Time zones
+(+|-)HH:MM
+
+(+|-)HH[MM]
+
+Some time zone codes, e.g. UTC, EET.
+.RE
 
 .SH SEE ALSO
 
-- 
1.7.9.5

___

[PATCH v3 7/9] test: add tests for date:since..until range queries

2012-09-12 Thread Jani Nikula
A brief initial test set.
---
 test/notmuch-test |1 +
 test/search-date  |   21 +
 2 files changed, 22 insertions(+)
 create mode 100755 test/search-date

diff --git a/test/notmuch-test b/test/notmuch-test
index 7eadfdf..9a1b375 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -61,6 +61,7 @@ TESTS="
   emacs-show
   missing-headers
   parse-time-string
+  search-date
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/search-date b/test/search-date
new file mode 100755
index 000..70bcf34
--- /dev/null
+++ b/test/search-date
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+test_description="date:since..until queries"
+. ./test-lib.sh
+
+add_email_corpus
+
+test_begin_subtest "Absolute date range"
+output=$(notmuch search date:2010-12-16..12/16/2010 | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2010-12-16 [1/1] Olivier Berger; 
Essai accentué (inbox unread)"
+
+test_begin_subtest "Absolute time range with TZ"
+notmuch search date:18-Nov-2009_02:19:26-0800..2009-11-18_04:49:52-06:00 | 
notmuch_search_sanitize > OUTPUT
+cat 

[PATCH v3 6/9] lib: add date range query support

2012-09-12 Thread Jani Nikula
Add a custom value range processor to enable date and time searches of
the form date:since..until, where "since" and "until" are expressions
understood by the previously added date/time parser, to restrict the
results to messages within a particular time range (based on the Date:
header).

If "since" or "until" describes date/time at an accuracy of days or
less, the values are rounded according to the accuracy, towards past
for "since" and towards future for "until". For example,
date:november..yesterday would match from the beginning of November
until the end of yesterday. Expressions such as date:today..today
means since the beginning of today until the end of today.

Open-ended ranges are supported (since Xapian 1.2.1), i.e. you can
specify date:..until or date:since.. to not limit the start or end
date, respectively.

CAVEATS:

Xapian does not support spaces in range expressions. You can replace
the spaces with '_', or (in most cases) '-', or (in some cases) leave
the spaces out altogether.

Entering date:expr without ".." (for example date:yesterday) will not
work as you might expect. You can achieve the expected result by
duplicating the expr both sides of ".." (for example
date:yesterday..yesterday).

Open-ended ranges won't work with pre-1.2.1 Xapian, but they don't
produce an error either.

Signed-off-by: Jani Nikula 
---
 lib/Makefile.local |1 +
 lib/database-private.h |1 +
 lib/database.cc|5 +
 lib/parse-time-vrp.cc  |   40 
 lib/parse-time-vrp.h   |   19 +++
 5 files changed, 66 insertions(+)
 create mode 100644 lib/parse-time-vrp.cc
 create mode 100644 lib/parse-time-vrp.h

diff --git a/lib/Makefile.local b/lib/Makefile.local
index d1635cf..6c0f42f 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -58,6 +58,7 @@ libnotmuch_c_srcs =   \
 
 libnotmuch_cxx_srcs =  \
$(dir)/database.cc  \
+   $(dir)/parse-time-vrp.cc\
$(dir)/directory.cc \
$(dir)/index.cc \
$(dir)/message.cc   \
diff --git a/lib/database-private.h b/lib/database-private.h
index 88532d5..d3e65fd 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -52,6 +52,7 @@ struct _notmuch_database {
 Xapian::QueryParser *query_parser;
 Xapian::TermGenerator *term_gen;
 Xapian::ValueRangeProcessor *value_range_processor;
+Xapian::ValueRangeProcessor *date_range_processor;
 };
 
 /* Return the list of terms from the given iterator matching a prefix.
diff --git a/lib/database.cc b/lib/database.cc
index 761dc1a..4df3217 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -19,6 +19,7 @@
  */
 
 #include "database-private.h"
+#include "parse-time-vrp.h"
 
 #include 
 
@@ -710,12 +711,14 @@ notmuch_database_open (const char *path,
notmuch->term_gen = new Xapian::TermGenerator;
notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));
notmuch->value_range_processor = new Xapian::NumberValueRangeProcessor 
(NOTMUCH_VALUE_TIMESTAMP);
+   notmuch->date_range_processor = new ParseTimeValueRangeProcessor 
(NOTMUCH_VALUE_TIMESTAMP);
 
notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
notmuch->query_parser->set_database (*notmuch->xapian_db);
notmuch->query_parser->set_stemmer (Xapian::Stem ("english"));
notmuch->query_parser->set_stemming_strategy 
(Xapian::QueryParser::STEM_SOME);
notmuch->query_parser->add_valuerangeprocessor 
(notmuch->value_range_processor);
+   notmuch->query_parser->add_valuerangeprocessor 
(notmuch->date_range_processor);
 
for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX_EXTERNAL); i++) {
prefix_t *prefix = &BOOLEAN_PREFIX_EXTERNAL[i];
@@ -778,6 +781,8 @@ notmuch_database_close (notmuch_database_t *notmuch)
 notmuch->xapian_db = NULL;
 delete notmuch->value_range_processor;
 notmuch->value_range_processor = NULL;
+delete notmuch->date_range_processor;
+notmuch->date_range_processor = NULL;
 }
 
 void
diff --git a/lib/parse-time-vrp.cc b/lib/parse-time-vrp.cc
new file mode 100644
index 000..148c117
--- /dev/null
+++ b/lib/parse-time-vrp.cc
@@ -0,0 +1,40 @@
+
+#include "database-private.h"
+#include "parse-time-vrp.h"
+#include "parse-time-string.h"
+
+#define PREFIX "date:"
+
+/* See *ValueRangeProcessor in xapian-core/api/valuerangeproc.cc */
+Xapian::valueno
+ParseTimeValueRangeProcessor::operator() (std::string &begin, std::string &end)
+{
+time_t t, now;
+
+/* Require date: prefix in start of the range... */
+if (STRNCMP_LITERAL (begin.c_str (), PREFIX))
+   return Xapian::BAD_VALUENO;
+
+/* ...and remove it. */
+begin.erase (0, sizeof (PREFIX) - 1);
+
+/* Use the same 'now' for begin and end. */
+if (time (&now) == (time_t) -1)
+   return Xapian::BAD_VALUENO;
+
+if (!begin.empty ()) {
+   if (parse_time_string (begin.c_str (), &t, &now, PARSE_TIME_ROUND_DOWN))

[PATCH v3 5/9] build: build parse-time-string as part of the notmuch lib and static cli

2012-09-12 Thread Jani Nikula
---
 Makefile.local |2 +-
 lib/Makefile.local |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile.local b/Makefile.local
index 7f2d4f1..2b91946 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -277,7 +277,7 @@ notmuch_client_srcs =   \
 
 notmuch_client_modules = $(notmuch_client_srcs:.c=.o)
 
-notmuch: $(notmuch_client_modules) lib/libnotmuch.a util/libutil.a
+notmuch: $(notmuch_client_modules) lib/libnotmuch.a util/libutil.a 
parse-time-string/libparse-time-string.a
$(call quiet,CXX $(CFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) -o $@
 
 notmuch-shared: $(notmuch_client_modules) lib/$(LINKER_NAME)
diff --git a/lib/Makefile.local b/lib/Makefile.local
index 8a9aa28..d1635cf 100644
--- a/lib/Makefile.local
+++ b/lib/Makefile.local
@@ -70,7 +70,7 @@ $(dir)/libnotmuch.a: $(libnotmuch_modules)
$(call quiet,AR) rcs $@ $^
 
 $(dir)/$(LIBNAME): $(libnotmuch_modules) notmuch.sym
-   $(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) 
$(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@ util/libutil.a
+   $(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) 
$(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@ util/libutil.a 
parse-time-string/libparse-time-string.a
 
 notmuch.sym: $(srcdir)/$(dir)/notmuch.h $(libnotmuch_modules)
sh $(srcdir)/$(lib)/gen-version-script.sh $< $(libnotmuch_modules) > $@
-- 
1.7.9.5

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


[PATCH v3 4/9] test: add smoke tests for the date/time parser module

2012-09-12 Thread Jani Nikula
Test the date/time parser module directly. Just a small sanity test
initially.
---
 test/notmuch-test  |1 +
 test/parse-time-string |   26 ++
 2 files changed, 27 insertions(+)
 create mode 100755 test/parse-time-string

diff --git a/test/notmuch-test b/test/notmuch-test
index cc732c3..7eadfdf 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -60,6 +60,7 @@ TESTS="
   emacs-hello
   emacs-show
   missing-headers
+  parse-time-string
 "
 TESTS=${NOTMUCH_TESTS:=$TESTS}
 
diff --git a/test/parse-time-string b/test/parse-time-string
new file mode 100755
index 000..34b80d7
--- /dev/null
+++ b/test/parse-time-string
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+test_description="date/time parser module"
+. ./test-lib.sh
+
+# This is currently just a quick sanity/smoke test.
+
+_date ()
+{
+date -d "$*" +%s
+}
+
+_parse_time ()
+{
+${TEST_DIRECTORY}/parse-time --format=%s "$*"
+}
+
+test_begin_subtest "date(1) default format without TZ code"
+test_expect_equal "$(_parse_time Fri Aug 3 23:06:06 2012)" "$(_date Fri Aug 3 
23:06:06 2012)"
+
+test_begin_subtest "date(1) --rfc-2822 format"
+test_expect_equal "$(_parse_time Fri, 03 Aug 2012 23:07:46 +0100)" "$(_date 
Fri, 03 Aug 2012 23:07:46 +0100)"
+
+test_begin_subtest "date(1) --rfc=3339=seconds format"
+test_expect_equal "$(_parse_time 2012-08-03 23:09:37+03:00)" "$(_date 
2012-08-03 23:09:37+03:00)"
+
+test_done
-- 
1.7.9.5

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


[PATCH v3 3/9] test: add new test tool parse-time for date/time parser

2012-09-12 Thread Jani Nikula
Add a smoke testing tool to support testing the date/time parser
module directly and independent of the rest of notmuch.
---
 test/Makefile.local |7 ++-
 test/basic  |2 +-
 test/parse-time.c   |  145 +++
 3 files changed, 152 insertions(+), 2 deletions(-)
 create mode 100644 test/parse-time.c

diff --git a/test/Makefile.local b/test/Makefile.local
index 45df4c7..9ae130a 100644
--- a/test/Makefile.local
+++ b/test/Makefile.local
@@ -19,9 +19,13 @@ $(dir)/smtp-dummy: $(smtp_dummy_modules)
 $(dir)/symbol-test: $(dir)/symbol-test.o
$(call quiet,CXX) $^ -o $@ -Llib -lnotmuch $(XAPIAN_LDFLAGS)
 
+$(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o
+   $(call quiet,CC) $^ -o $@
+
 .PHONY: test check
 
-test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test
+test-binaries: $(dir)/arg-test $(dir)/smtp-dummy $(dir)/symbol-test \
+   $(dir)/parse-time
 
 test:  all test-binaries
@${dir}/notmuch-test $(OPTIONS)
@@ -32,4 +36,5 @@ SRCS := $(SRCS) $(smtp_dummy_srcs)
 CLEAN := $(CLEAN) $(dir)/smtp-dummy $(dir)/smtp-dummy.o \
 $(dir)/symbol-test $(dir)/symbol-test.o \
 $(dir)/arg-test $(dir)/arg-test.o \
+$(dir)/parse-time $(dir)/parse-time.o \
 $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.*
diff --git a/test/basic b/test/basic
index 3b635c8..c47197c 100755
--- a/test/basic
+++ b/test/basic
@@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be 
run by notmuch-test'
 eval $(sed -n -e '/^TESTS="$/,/^"$/p' $TEST_DIRECTORY/notmuch-test)
 tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
 available=$(find "$TEST_DIRECTORY" -maxdepth 1 -type f -perm +111 | \
-sed -r -e "s,.*/,," -e 
"/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test)$/d"
 | \
+sed -r -e "s,.*/,," -e 
"/^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|parse-time)$/d"
 | \
 sort)
 test_expect_equal "$tests_in_suite" "$available"
 
diff --git a/test/parse-time.c b/test/parse-time.c
new file mode 100644
index 000..b4de76b
--- /dev/null
+++ b/test/parse-time.c
@@ -0,0 +1,145 @@
+/*
+ * parse time string - user friendly date and time parser
+ * Copyright © 2012 Jani Nikula
+ *
+ * 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 2 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, see .
+ *
+ * Author: Jani Nikula 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "parse-time-string.h"
+
+/*
+ * concat argv[start]...argv[end - 1], separating them by a single
+ * space, to a malloced string
+ */
+static char *
+concat_args (int start, int end, char *argv[])
+{
+int i;
+size_t len = 1;
+char *p;
+
+for (i = start; i < end; i++)
+   len += strlen (argv[i]) + 1;
+
+p = malloc (len);
+if (!p)
+   return NULL;
+
+*p = 0;
+
+for (i = start; i < end; i++) {
+   if (i != start)
+   strcat (p, " ");
+   strcat (p, argv[i]);
+}
+
+return p;
+}
+
+#define DEFAULT_FORMAT "%a %b %d %T %z %Y"
+
+static void
+usage (const char *name)
+{
+printf ("Usage: %s [options ...] \n\n", name);
+printf (
+   "Parse  and display it in given format.\n\n"
+   "  -f, --format=FMT output format, FMT according to strftime(3)\n"
+   "   (default: \"%s\")\n"
+   "  -n, --now=N  use N seconds since epoch as now (default: now)\n"
+   "  -u, --up round result up (default: no rounding)\n"
+   "  -d, --down   round result down (default: no rounding)\n"
+   "  -h, --help   print this help\n",
+   DEFAULT_FORMAT);
+}
+
+int
+main (int argc, char *argv[])
+{
+int r;
+struct tm tm;
+time_t result;
+time_t now;
+time_t *nowp = NULL;
+char *argstr;
+int round = PARSE_TIME_NO_ROUND;
+char buf[1024];
+const char *format = DEFAULT_FORMAT;
+struct option options[] = {
+   { "help",   no_argument,NULL,   'h' },
+   { "up", no_argument,NULL,   'u' },
+   { "down",   no_argument,NULL,   'd' },
+   { "format", required_argument,  NULL,   'f' },
+   { "now",required_argument,  NULL,   'n' },
+   { NULL, 0, NULL, 0 },
+};
+
+for (;;) {
+   int c;
+
+   c = getopt_long (argc, argv, "hudf:n:", options, NULL);
+   if

[PATCH v3 1/9] build: drop the -Wswitch-enum warning

2012-09-12 Thread Jani Nikula
-Wswitch-enum is a bit awkward if a switch statement is intended to
handle just some of the named codes of an enumeration especially, and
leave the rest to the default label.

We already have -Wall, which enables -Wswitch by default, and per GCC
documentation, "The only difference between -Wswitch and this option
[-Wswitch-enum] is that this option gives a warning about an omitted
enumeration code even if there is a default label."

Drop -Wswitch-enum to not force listing all named codes of
enumerations in switch statements that have a default label.

---

This will be useful in the next patch.
---
 configure |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index acb90a8..afa5c16 100755
--- a/configure
+++ b/configure
@@ -532,7 +532,7 @@ fi
 
 WARN_CXXFLAGS=""
 printf "Checking for available C++ compiler warning flags... "
-for flag in -Wall -Wextra -Wwrite-strings -Wswitch-enum; do
+for flag in -Wall -Wextra -Wwrite-strings; do
 if ${CC} $flag -o minimal minimal.c > /dev/null 2>&1
 then
WARN_CXXFLAGS="${WARN_CXXFLAGS}${WARN_CXXFLAGS:+ }${flag}"
-- 
1.7.9.5

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


[PATCH v3 0/9] notmuch search date:since..until query support

2012-09-12 Thread Jani Nikula
Hi all, v3 of id:"cover.1344065790.git.j...@nikula.org".

Notable changes since v2:

* Address most of David's comments in id:"877gtdmqol.fsf@zancas.localnet".
  Delegating the list of time zones to the system is not without
  problems, so not done. Also create_output() is not split further.

* Move the parser to a subdirectory of its own to be independent of the
  rest of the notmuch code base, and build it as a static library. This
  should be useful if the parser is ever packaged as a library of its
  own.

* Add a high level documentation comment, and improve comments all
  around.

* Add NEWS with hopes that this would make 0.15. :)


BR,
Jani.

Jani Nikula (9):
  build: drop the -Wswitch-enum warning
  parse-time-string: add a date/time parser to notmuch
  test: add new test tool parse-time for date/time parser
  test: add smoke tests for the date/time parser module
  build: build parse-time-string as part of the notmuch lib and static
cli
  lib: add date range query support
  test: add tests for date:since..until range queries
  man: document the date:since..until range queries
  NEWS: date range search support

 Makefile  |2 +-
 Makefile.local|2 +-
 NEWS  |   14 +
 configure |2 +-
 lib/Makefile.local|3 +-
 lib/database-private.h|1 +
 lib/database.cc   |5 +
 lib/parse-time-vrp.cc |   40 +
 lib/parse-time-vrp.h  |   19 +
 man/man7/notmuch-search-terms.7   |  147 +++-
 parse-time-string/Makefile|5 +
 parse-time-string/Makefile.local  |   12 +
 parse-time-string/README  |9 +
 parse-time-string/parse-time-string.c | 1484 +
 parse-time-string/parse-time-string.h |   95 +++
 test/Makefile.local   |7 +-
 test/basic|2 +-
 test/notmuch-test |2 +
 test/parse-time-string|   26 +
 test/parse-time.c |  145 
 test/search-date  |   21 +
 21 files changed, 2025 insertions(+), 18 deletions(-)
 create mode 100644 lib/parse-time-vrp.cc
 create mode 100644 lib/parse-time-vrp.h
 create mode 100644 parse-time-string/Makefile
 create mode 100644 parse-time-string/Makefile.local
 create mode 100644 parse-time-string/README
 create mode 100644 parse-time-string/parse-time-string.c
 create mode 100644 parse-time-string/parse-time-string.h
 create mode 100755 test/parse-time-string
 create mode 100644 test/parse-time.c
 create mode 100755 test/search-date

-- 
1.7.9.5

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


Re: [alot] announcing v0.3.3

2012-09-12 Thread Joseph Tannhuber
Dear Patrick

> You can, but its not so comfortable at the moment: just use
> `set From OtherAccount Realname `
Ok, let's try it right now. I think it would be the best to determine the sender
account from the header of the answered mail. But I have no idea if it is
possible. 

Thank you
Joseph
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[alot] announcing v0.3.3

2012-09-12 Thread Christophe-Marie Duquesne
On Sun, Sep 9, 2012 at 5:34 PM, Patrick Totzke  
wrote:
> Good news everyone!

I could not help but read the rest of your announcement in the voice
of professor Farnsworth.


[alot] announcing v0.3.3

2012-09-12 Thread Patrick Totzke
Quoting Sepp Tannhuber (2012-09-11 17:59:12)
> Hi Patrick,
> 
> thank you for answering and for this really good mail client!
pleasure :)

> > One reason I have not bothered to implement this so far is that in the long 
> > run,
> > I want to have urwid Tree widgets as top level widgets in thread buffers.
> > This would also allow "move to next sibling/parent" and so on.
> I did not know that it would be so complicated. But nice to hear that 
> development
> is going on.
Yea, trees in urwid are a bit messed up atm. alot's thread buffer uses its own
archaic widget layout, which is eventually to be replaced.

> > So you can of course use this method to set an "Attach" header, but as of 
> > now
> > alot will not interpret and remove this when reading the edited text.
> Exactly!

I think this will not so hard to do. Could you open up a feature request issue
on github for this?

> > When you see the "to>" prompt, type in some prefix of a (realname part of a)
> > contact from abook and hit .
> This was my assumption. But it is not working here. Obviously I make a 
> mistake. Here is my
> config:
> -- BEGIN ~/.config/alot/config --
> theme = solarized_dark
> editor_cmd = 'vim +/^$ "+normal j" "+:set textwidth=80" "+:set ft=mail"'
> 
> [accounts]
> 
> ? ? [[work]]
> ? ? ? ? realname = Joseph Tannhuber
> ? ? ? ? address = jtannhuber at work.de
> ? ? ? ? signature = ~/.signature
> ? ? ? ? sendmail_command = msmtp --account=work -t
> ? ? ? ? sent_box = maildir:///home/sepp/Maildir/Sent
> ? ? ? ? draft_box = maildir:///home/sepp/Maildir/Drafts
> ? ? ? ? [[[abook]]]
> ? ? ? ? ? ? type = abook
> -- END --
> Is there anything missing?

No, that's what I use as well.
Note that this variant assumes your contact file is ~/.abook/addressbook. I'm 
not aware of format
issues for different abook versions so far. Also note that this will complete 
case-sensitive
strings of the format "Firstname Lastname ".

To debug this you can replay this introspect session and see how far you get.
Start alots python shell (pyshell command), then:

>>> from alot.settings import settings
>>> settings.get_addressbooks()
[, 
]
>>> settings.get_addressbooks()[0]

>>> A=settings.get_addressbooks()[0]
>>> A.get_contacts()
[... CONTACT TUPLES HERE...]

Hope this helps. Otherwise don't hesitate to open a bug report on github.

> By the way: Is it possible to set the X11 urgency hint flag when new mail 
> arrives? In principle
> one can use the visual bell in the terminal. Then alot must only invoke a 
> shell command:
> ? echo -e "\b"

Well, alot does not pull your mails itself, so has no means of knowing when new 
mail arrives.
I personally use a mail indicator widget I wrote for my window manager that 
periodically
checks the notmuch index for new mail: 
http://awesome.naquadah.org/wiki/Notmuch_mail_integration

Alot can of course fire shell commands. What it is lacking at the moment is the 
ability to periodically
fire custom (alot-)commands. This feature would not be hard to implement, but 
so far I did not bother
to do so as I considered mail-fetching not part of alots responsibility.
But you're not the first one to want this, so I guess it'd be worth it.

Cheers,
/p
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120912/374fac13/attachment.pgp>


Re: [alot] announcing v0.3.3

2012-09-12 Thread Sepp Tannhuber
Hi Patrick,                                                                     
                                              
                                                                                
                                              
my abook is working now. I don't know why it did not yesterday. Probably it was 
                                              
not a bug but rather something stupid with my config.                           
                                              
                                                                                
                                              
> Could you open up a feature request issue on github for this?                 
>                                               
Yes.                                                                            
                                              
                                                                                
                                              
> This feature would not be hard to implement, but so far I did not bother      
>                                               
> to do so as I considered mail-fetching not part of alots responsibility.      
>                                               
I would like to have a shortcut to jump quickly to a window that has the 
urgency                                              
flag set. This is why I asked for that feature. But I agree with you. A simple  
                                              
script can do it as well.                                                       
                                              
                                                                                
                                              
However I'd like to raise another question. I have configured two mail 
accounts.                                              
It seems that I cannot choose between them when I reply to a message. Can I?    
                                              
Hopefully this was my last question.                                            
                                              
                                                                                
                                              
Thanks alot                                                                     
                                              
Joseph       
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [alot] announcing v0.3.3

2012-09-12 Thread Christophe-Marie Duquesne
On Sun, Sep 9, 2012 at 5:34 PM, Patrick Totzke  wrote:
> Good news everyone!

I could not help but read the rest of your announcement in the voice
of professor Farnsworth.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch