[PATCH] Add --include-duplicates option to a couple of commands.

2011-01-24 Thread Carl Worth
This adds new functionality under the names of:

notmuch search --output=files --include-duplicates
notmuch show --include-duplicates
notmuch show --format=json --include-duplicates

These new commands behave similarly to the existing commands without
the --include-duplicates agument. The difference is that with the new
argument any duplicate mail files will be included in the
output. Here, files are considered duplicates if they contain
identical contents for the Message-Id header, (regardless of any other
differences in the content of the file). Without the
--include-duplicates argument, these commands would emit a single,
arbitrary file in the face of duplicates.

WARNING: This commit is not yet ready to be pushed to the notmuch
repository. There are at least two problems with the commit so far:

1. Nothing has been documented yet.

   Fixing this shouldn't be too hard. It's mostly just taking
   the text from above and shoving it into the
   documentation. I can do this easily enough myself.

2. show --format=json --include-duplicates doesn't work yet

   This is a more serious problem. I believe the JSON output
   with this patch is not correct and will likely break a
   client trying to consume it. It inserts the duplicate
   message into an array next to the existing message. Our
   current JSON schema isn't documented formally that I could
   find, except for a comment in the emacs code that consumes
   it:

A thread is a forest or list of trees. A tree is a two
element list where the first element is a message, and
the second element is a possibly empty forest of
replies.

   I believe this commit breaks the "two-element list"
   expectation. What we would want instead is the duplicate
   message to appear as a peer next to the original message,
   (and then perhaps have replies appear only to one of the
   messages).

My current need for --include-duplicates was recently satisfied, so I
won't likely pursue this further for now. But I wanted to put this
code out rather than losing it.

If someone wants to fix the patch to do the "right thing" with the
JSON output, then that would be great.

ALSO NOTE: I left the
json.expected-output/notmuch-show-thread-format-json-maildir-storage
out of this commit. It has lines in it that are too long to be sent
via git-send-email.
---
 notmuch-search.c   |   30 +-
 notmuch-show.c |   61 +--
 test/basic |2 +-
 test/json  |   33 ++-
 ...-show-thread-include-duplicates-maildir-storage |   94 
 .../notmuch-show-thread-maildir-storage|   47 
 test/search-output |  113 
 7 files changed, 361 insertions(+), 19 deletions(-)
 create mode 100644 
test/json.expected-output/notmuch-show-thread-include-duplicates-maildir-storage
 create mode 100644 
test/json.expected-output/notmuch-show-thread-maildir-storage

diff --git a/notmuch-search.c b/notmuch-search.c
index c628b36..6d032c2 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -247,7 +247,8 @@ static int
 do_search_messages (const void *ctx,
const search_format_t *format,
notmuch_query_t *query,
-   output_t output)
+   output_t output,
+   notmuch_bool_t include_duplicates)
 {
 notmuch_message_t *message;
 notmuch_messages_t *messages;
@@ -269,8 +270,25 @@ do_search_messages (const void *ctx,
fputs (format->item_sep, stdout);
 
if (output == OUTPUT_FILES) {
-   format->item_id (ctx, "",
-notmuch_message_get_filename (message));
+   if (include_duplicates) {
+   notmuch_filenames_t *filenames;
+   int first_filename = 1;
+
+   for (filenames = notmuch_message_get_filenames (message);
+notmuch_filenames_valid (filenames);
+notmuch_filenames_move_to_next (filenames))
+   {
+   if (! first_filename)
+   fputs (format->item_sep, stdout);
+   first_filename = 0;
+
+   format->item_id (ctx, "",
+notmuch_filenames_get (filenames));
+   }
+   } else {
+   format->item_id (ctx, "",
+notmuch_message_get_filename (message));
+   }
} else { /* output == OUTPUT_MESSAGES */
format->item_id (ctx, "id:",
 notmuch_message_get_message_id (message));
@@ -352,6 +370,7 @@ notmuch_search_command (void *

[PATCH] configure: add options to disable emacs/zsh/bash and choose install dir.

2011-01-24 Thread Cédric Cabessa
On Monday 24 January 2011 08:10:20 Xavier Maillard wrote:
> 
> Why not just try to detect whether bash/zsh or even emacs is available
> on the system and install the dependent files when it is the case ?

Hi Xavier,

I think it is better to let user explicitly choose what he want to install
or not. 
For the story, I am a gentoo user, in gentoo you can choose what
you want to install from a package with the USE flag mechanism.
(for example a ncurse client will depend of notmuch but without emacs support, 
another user will install the same notmuch package but with emacs support).

So the with/without options make the packaging very easy.

I think we can do autodetection if needed, but the user should be able to 
override the automatic behavior.


-- 
C?dric



Re: Tag timestamps and synchronization

2011-01-24 Thread dm-list-email-notmuch
At Tue, 25 Jan 2011 10:08:12 +1030,
Tim Stoakes wrote:
> 
> I do something like this by using some shell scripts with formail, to
> 'store' notmuch tags into the X-Label headers of the individual mails.
> Offlineimap then syncs these headers. If I need the tags to become
> notmuch-ified on the target, I just scan all the mail's X-Label headers.

How well does offlineimap work when you modify the contents of
messages?  This doesn't change the message UIDs, does it?  Are you
syncing between two imapd instances, or one imapd and a maildir?  (I
currently run a local imap server as well, because it seems to be a
lot faster.)

How does the imap server even detect that the message contents has
been modified?  Does it have to stat 300,000 files every time you
check your email?

In my setup, I regularly check email from three or four different
machines, so the syncing is not just for backup purposes.  When I
switch between computers all my label changes need to be visible.

> I'm happy to share this hack glue if it would help.

Yes, I'd be glad to take a look at your scripts.

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


Tag timestamps and synchronization

2011-01-24 Thread dm-list-email-notm...@scs.stanford.edu
At Tue, 25 Jan 2011 10:08:12 +1030,
Tim Stoakes wrote:
> 
> I do something like this by using some shell scripts with formail, to
> 'store' notmuch tags into the X-Label headers of the individual mails.
> Offlineimap then syncs these headers. If I need the tags to become
> notmuch-ified on the target, I just scan all the mail's X-Label headers.

How well does offlineimap work when you modify the contents of
messages?  This doesn't change the message UIDs, does it?  Are you
syncing between two imapd instances, or one imapd and a maildir?  (I
currently run a local imap server as well, because it seems to be a
lot faster.)

How does the imap server even detect that the message contents has
been modified?  Does it have to stat 300,000 files every time you
check your email?

In my setup, I regularly check email from three or four different
machines, so the syncing is not just for backup purposes.  When I
switch between computers all my label changes need to be visible.

> I'm happy to share this hack glue if it would help.

Yes, I'd be glad to take a look at your scripts.

Thanks,
David


Re: Tag timestamps and synchronization

2011-01-24 Thread Tim Stoakes
dm-list-email-notm...@scs.stanford.edu(dm-list-email-notm...@scs.stanford.edu)@240111-11:10:
> One of the features I would like to see from notmuch is an easier
> ability to synchronize tags across machines.  At the very least, I
> would need either incremental dump and restore, or some way to
> communicate arbitrary tags to a local imap server that shares
> notmuch's maildir (much as notmuch currently syncs the standard tags),
> so that I synchronize two maildirs with a tool like offlineimap.

David,

I do something like this by using some shell scripts with formail, to
'store' notmuch tags into the X-Label headers of the individual mails.
Offlineimap then syncs these headers. If I need the tags to become
notmuch-ified on the target, I just scan all the mail's X-Label headers.

(Actually it's better than this, since I use maildrop to set notmuch
tags with notmuch-deliver, *and* set X-Label headers to the same thing,
at mail delivery time. Then I use keybindings and shell scripts in mutt
such that whenever I retag a message, it is pushed to both notmuch and
X-Label.)

I'm happy to share this hack glue if it would help.

This is not great for a few reasons - there are a ton of moving parts,
and some double-work. If notmuch could index X-Label headers (a coming
feature I hear) then this would be much cleaner.

This is just one way of doing it, that works for me...

Tim

> As Carl pointed out to me in private email, there has been some
> previous discussion in the following thread:
> 
>   notmuch show id:87hbfnmiux@yoom.home.cworth.org
> 
> Based on that thread, there seems to be some desire for notmuch to
> keep track of a per-message timestamp when the flags were last
> updated.  This would allow much easier expiration for people who want
> the deleted tag.  It would also allow incremental dump and restore of
> tags, which is exactly what I need to sync tags across servers with
> reasonable amounts of bandwidth.
> 
> Metadata timestamps are one of those things that probably have a lot
> of different applications, so since Carl is considering a new database
> format for the next release anyway, perhaps it also makes sense to add
> a metadata change time for each messages.
> 
> The timestamp would be included in "dump" output, and you could
> request a dump of changes since a particular time.  On restore, you
> might have several options:
> 
>   - overwrite: always set the new tags and timestamp in the database
> to the value in the restore data.
> 
>   - update: always set the tags, but update the to the current time.
> 
>   - conditional T: update only if the message metadata has not been
> updated since time T.
> 
> To sync flags, then you just need to keep track of the last time you
> synced with a particular server--call this time T.  Do a dump since
> time T, upload to server, do a conditional restore for time T on
> server.  Finally do a partial dump from time T on the server and an
> overwrite import on the client.  (This policy makes changes on the
> server always override conflicting ones on the client--perhaps people
> want other policies, like union of the tags, etc.)
> 
> 
> Second, there seems to be some desire in that thread to sync with IMAP
> flags.  This would be particularly great, but the easies way to do it
> is probably *not* to try to implement IMAP, but rather to use an
> existing IMAP server and just modify the maildir so that the IMAP
> server will pick up the flags.
> 
> In the case of dovecot, the arbitrary tag format is very simple.  Each
> maildir has a file called dovecot-keywords mapping numbers 0, 1,
> ... to keywords.  Then mail file names contain lower-case letters for
> the flags they are marked with--0 => a, 1 => b, etc.--allowing up to
> 26 arbitrary tags for each maildir.  One could probably sync to
> dovecot's maildir format relatively easily in a script given
> incremental dump and restore of tags.  Or possibly notmuch could
> natively support dovecot as one of multiple back-end tag storage
> schemes.
> 
> Having a static tag mapping in the .notmuch-config file would be much
> better than hard-coding flag2tag.  However, I'm not sure it's
> sufficient.  The reason is that if you ever completely delete a tag
> (e.g., you have "todo", and "meeting" tags and periodically have no
> messages in either categories in a given mail folder), then an IMAP
> server like dovecot might end up re-allocating the letters
> corresponding to those tags in a different order.  Also, at least for
> dovecot, the flag mappings are per-folder, which you kind of want
> since you are limited to 26 non-standard tags, so global values might
> not work.
> 
> I'm curious to hear people's thoughts/reactions?
> 
> David

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


Re: [PATCH 1/4] Import date/time parser from GNU coreutils

2011-01-24 Thread Jameson Rollins
On Sun, 23 Jan 2011 12:47:24 +0100, Michal Sojka  wrote:
> This function have quite a lot dependencies. We may reduce them later it
> it is a problem.
> ---
>  lib/c-ctype.c  |  398 +++
>  lib/c-ctype.h  |  297 +
>  lib/getdate.c  | 3497 
> 
>  lib/getdate.h  |   22 +
>  lib/getdate.y  | 1572 +
>  lib/gettime.c  |   48 +
>  lib/intprops.h |   83 ++
>  lib/timespec.h |   39 +
>  lib/verify.h   |  140 +++
>  9 files changed, 6096 insertions(+), 0 deletions(-)
>  create mode 100644 lib/c-ctype.c
>  create mode 100644 lib/c-ctype.h
>  create mode 100644 lib/getdate.c
>  create mode 100644 lib/getdate.h
>  create mode 100644 lib/getdate.y
>  create mode 100644 lib/gettime.c
>  create mode 100644 lib/gettime.h
>  create mode 100644 lib/intprops.h
>  create mode 100644 lib/timespec.h
>  create mode 100644 lib/verify.h

Hi, Michal.  I don't fully understand what's going on here, but it seems
like you're embedding code copies from somewhere else.  If that's the
case, is there a reason that we would need to do that, rather than just
linking against an external library?

jamie.


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


[PATCH 1/4] Import date/time parser from GNU coreutils

2011-01-24 Thread Jameson Rollins
On Sun, 23 Jan 2011 12:47:24 +0100, Michal Sojka  wrote:
> This function have quite a lot dependencies. We may reduce them later it
> it is a problem.
> ---
>  lib/c-ctype.c  |  398 +++
>  lib/c-ctype.h  |  297 +
>  lib/getdate.c  | 3497 
> 
>  lib/getdate.h  |   22 +
>  lib/getdate.y  | 1572 +
>  lib/gettime.c  |   48 +
>  lib/intprops.h |   83 ++
>  lib/timespec.h |   39 +
>  lib/verify.h   |  140 +++
>  9 files changed, 6096 insertions(+), 0 deletions(-)
>  create mode 100644 lib/c-ctype.c
>  create mode 100644 lib/c-ctype.h
>  create mode 100644 lib/getdate.c
>  create mode 100644 lib/getdate.h
>  create mode 100644 lib/getdate.y
>  create mode 100644 lib/gettime.c
>  create mode 100644 lib/gettime.h
>  create mode 100644 lib/intprops.h
>  create mode 100644 lib/timespec.h
>  create mode 100644 lib/verify.h

Hi, Michal.  I don't fully understand what's going on here, but it seems
like you're embedding code copies from somewhere else.  If that's the
case, is there a reason that we would need to do that, rather than just
linking against an external library?

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/20110124/47f5bb49/attachment.pgp>


[PATCH 3.5/8] Query parser tests for wildcard queries.

2011-01-24 Thread Michal Sojka
On Sun, 23 Jan 2011, Austin Clements wrote:
> Oops, yes.  I'm not sure why you had to initialize qparser_desc (are you
> sure it doesn't compile if you omit that?), 

This was another problem - I got a warning that this variable might be
uninitialized.

-Michal


[PATCH 8.5/8] test: Add tests for search by date.

2011-01-24 Thread Austin Clements
---
 test/search |   67 +++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/test/search b/test/search
index 7d1dedb..6425359 100755
--- a/test/search
+++ b/test/search
@@ -73,6 +73,73 @@ add_message '[subject]="this phrase should not match the 
subject search test"' '
 output=$(notmuch search 'subject:"subject search test (phrase)"' | 
notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; 
subject search test (phrase) (inbox unread)"

+test_begin_subtest "Search by after:"
+output=$(notmuch search 'after:2009/11/18' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [1/1] Chris Wilson; 
[notmuch] [PATCH 1/2] Makefile: evaluate pkg-config once (inbox unread)
+thread:XXX   2009-11-18 [2/2] Alex Botero-Lowry, Carl Worth; [notmuch] [PATCH] 
Error out if no query is supplied to search instead of going into an infinite 
loop (attachment inbox unread)
+thread:XXX   2009-11-18 [1/2] Carl Worth| Ingmar Vanhassel; [notmuch] [PATCH] 
Typsos (inbox unread)
+thread:XXX   2009-11-18 [2/3] Keith Packard, Carl Worth| Adrian Perez de 
Castro; [notmuch] Introducing myself (inbox unread)
+thread:XXX   2009-11-18 [2/3] Keith Packard, Carl Worth| Israel Herraiz; 
[notmuch] New to the list (inbox unread)
+thread:XXX   2009-11-18 [1/3] Carl Worth| Jan Janak; [notmuch] What a great 
idea! (inbox unread)
+thread:XXX   2009-11-18 [1/2] Carl Worth| Jan Janak; [notmuch] [PATCH] Older 
versions of install do not support -C. (inbox unread)
+thread:XXX   2009-11-18 [2/3] Keith Packard, Carl Worth| Aron Griffis; 
[notmuch] archive (inbox unread)
+thread:XXX   2009-11-18 [1/2] Carl Worth| Keith Packard; [notmuch] [PATCH] 
Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox 
unread)
+thread:XXX   2009-11-18 [2/7] Lars Kellogg-Stedman, Carl Worth| Mikhail 
Gusarov, Keith Packard; [notmuch] Working with Maildir storage? (inbox unread)
+thread:XXX   2009-11-18 [1/5] Carl Worth| Mikhail Gusarov, Keith Packard; 
[notmuch] [PATCH 1/2] Close message file after parsing message headers (inbox 
unread)
+thread:XXX   2009-11-18 [2/2] Keith Packard, Alexander Botero-Lowry; [notmuch] 
[PATCH] Create a default notmuch-show-hook that highlights URLs and uses 
word-wrap (inbox unread)
+thread:XXX   2009-11-18 [1/1] Alexander Botero-Lowry; [notmuch] request for 
pull (inbox unread)
+thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] 
Mac OS X/Darwin compatibility issues (inbox unread)
+thread:XXX   2009-11-18 [1/1] Rolland Santimano; [notmuch] Link to mailing 
list archives ? (inbox unread)
+thread:XXX   2009-11-18 [1/1] Jan Janak; [notmuch] [PATCH] notmuch new: 
Support for conversion of spool subdirectories into tags (inbox unread)
+thread:XXX   2009-11-18 [1/1] Stewart Smith; [notmuch] [PATCH] count_files: 
sort directory in inode order before statting (inbox unread)
+thread:XXX   2009-11-18 [1/1] Stewart Smith; [notmuch] [PATCH 2/2] Read mail 
directory in inode number order (inbox unread)
+thread:XXX   2009-11-18 [1/1] Stewart Smith; [notmuch] [PATCH] Fix linking 
with gcc to use g++ to link in C++ libs. (inbox unread)
+thread:XXX   2009-11-18 [2/2] Lars Kellogg-Stedman; [notmuch] \"notmuch help\" 
outputs to stderr? (attachment inbox unread)"
+
+test_begin_subtest "Search by after: (no results)"
+output=$(notmuch search 'after:2009/11/19' | notmuch_search_sanitize)
+test_expect_equal "$output" ""
+
+test_begin_subtest "Search by before:"
+output=$(notmuch search 'before:2000/01/02' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; 
body search (inbox unread)
+thread:XXX   2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox 
searchbytag unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; negative result (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] searchbyfrom at example.com; search by from 
(address) (inbox unread)
+thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) 
(inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (address) 
(inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) 
(inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match 
the subject search test (inbox unread)"
+
+tes

[PATCH 6.5/8] test: Add tests for custom query parser-based folder searches.

2011-01-24 Thread Austin Clements
---
 test/notmuch-test |2 +-
 test/search-by-folder |   52 +
 2 files changed, 53 insertions(+), 1 deletions(-)
 create mode 100755 test/search-by-folder

diff --git a/test/notmuch-test b/test/notmuch-test
index 1e331b3..2aa3489 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -16,7 +16,7 @@ fi

 cd $(dirname "$0")

-TESTS="basic new qparser search search-output json thread-naming raw reply 
dump-restore uuencode thread-order author-order from-guessing long-id encoding 
emacs maildir-sync"
+TESTS="basic new qparser search search-output search-by-folder json 
thread-naming raw reply dump-restore uuencode thread-order author-order 
from-guessing long-id encoding emacs maildir-sync"

 # Clean up any results from a previous run
 rm -r test-results >/dev/null 2>/dev/null
diff --git a/test/search-by-folder b/test/search-by-folder
new file mode 100755
index 000..ebf724f
--- /dev/null
+++ b/test/search-by-folder
@@ -0,0 +1,52 @@
+#!/bin/bash
+test_description='"notmuch search" by folder: (with variations)'
+. ./test-lib.sh
+
+add_message '[dir]=bad' '[subject]="To the bone"'
+add_message '[dir]=bad/news' '[subject]="Bears"'
+mkdir -p "${MAIL_DIR}/duplicate/bad/news"
+cp "$gen_msg_filename" "${MAIL_DIR}/duplicate/bad/news"
+
+add_message '[dir]=things' '[subject]="These are a few"'
+add_message '[dir]=things/favorite' '[subject]="Raindrops, whiskers, kettles"'
+add_message '[dir]=things/bad' '[subject]="Bites, stings, sad feelings"'
+
+test_begin_subtest "Top-level folder"
+output=$(notmuch search folder:bad | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
To the bone (inbox unread)"
+
+test_begin_subtest "Nested folder"
+output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Bears (inbox unread)"
+
+test_begin_subtest "Search is rooted"
+output=$(notmuch search folder:news | notmuch_search_sanitize)
+test_expect_equal "$output" ""
+
+test_begin_subtest "Absolute path"
+output=$(notmuch search folder:$MAIL_DIR/bad | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
To the bone (inbox unread)"
+
+test_begin_subtest "Duplicate path"
+output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Bears (inbox unread)"
+
+test_begin_subtest "After removing duplicate instance of matching path"
+rm -r "${MAIL_DIR}/bad/news"
+increment_mtime "${MAIL_DIR}/bad"
+notmuch new
+output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Bears (inbox unread)"
+
+test_begin_subtest "After rename, old path returns nothing"
+mv "${MAIL_DIR}/duplicate/bad/news" "${MAIL_DIR}/duplicate/bad/olds"
+increment_mtime "${MAIL_DIR}/duplicate/bad"
+notmuch new
+output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" ""
+
+test_begin_subtest "After rename, new path returns result"
+output=$(notmuch search folder:duplicate/bad/olds | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Bears (inbox unread)"
+
+test_done
-- 
1.7.2.3


[PATCH 5.5/8] test: Wildcard tag search and untagged search.

2011-01-24 Thread Austin Clements
---
 test/qparser-test.cc   |6 +++---
 test/qparser.expected-output/wildcards |   13 +
 test/search|   12 
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/test/qparser-test.cc b/test/qparser-test.cc
index ae6c8b9..7b145cc 100644
--- a/test/qparser-test.cc
+++ b/test/qparser-test.cc
@@ -100,9 +100,9 @@ static _notmuch_qparser_t *
 create_qparser (void *ctx)
 {
 _notmuch_qparser_t *qparser = _notmuch_qparser_create (ctx, notmuch);
-_notmuch_qparser_add_db_prefix (qparser, "prob", "P", FALSE);
-_notmuch_qparser_add_db_prefix (qparser, "lit", "L", TRUE);
-_notmuch_qparser_add_db_prefix (qparser, "tag", "K", TRUE);
+_notmuch_qparser_add_db_prefix (qparser, "prob", "P", FALSE, FALSE);
+_notmuch_qparser_add_db_prefix (qparser, "lit", "L", TRUE, FALSE);
+_notmuch_qparser_add_db_prefix (qparser, "tag", "K", TRUE, TRUE);
 return qparser;
 }

diff --git a/test/qparser.expected-output/wildcards 
b/test/qparser.expected-output/wildcards
index 6f62829..0558732 100644
--- a/test/qparser.expected-output/wildcards
+++ b/test/qparser.expected-output/wildcards
@@ -18,3 +18,16 @@ nosuchterm* AND x
 [parse]  (AND "nosuchterm"* "x")
 [gen](nosuchterm AND x:(pos=1))
 [xapian] 
+
+# Incompatible; Xapian doesn't accept wildcards in boolean prefixes
+tag:*
+[lex]PREFIX/tag "*"
+[parse]  (FILTER (PREFIX/tag '*'))
+[gen]0 * (Kinbox:(pos=1) SYNONYM Kunread:(pos=1))
+[xapian] 0 * K*
+
+tag:i*
+[lex]PREFIX/tag "i*"
+[parse]  (FILTER (PREFIX/tag 'i*'))
+[gen]0 * Kinbox:(pos=1)
+[xapian] 0 * Ki*
diff --git a/test/search b/test/search
index b180c7f..7d1dedb 100755
--- a/test/search
+++ b/test/search
@@ -113,6 +113,18 @@ thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search 
by to (name) (inbox unr
 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) 
(inbox unread)
 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match 
the subject search test (inbox unread)"

+test_begin_subtest 'Search by wildcard tag ("at*")'
+output=$(notmuch search 'tag:at*' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [2/2] Lars 
Kellogg-Stedman; [notmuch] \"notmuch help\" outputs to stderr? (attachment 
inbox unread)
+thread:XXX   2009-11-18 [1/2] Alex Botero-Lowry| Carl Worth; [notmuch] [PATCH] 
Error out if no query is supplied to search instead of going into an infinite 
loop (attachment inbox unread)
+thread:XXX   2009-11-17 [1/2] Alex Botero-Lowry| Carl Worth; [notmuch] 
preliminary FreeBSD support (attachment inbox unread)"
+
+test_begin_subtest 'Search for untagged messages'
+add_message '[subject]="untagged message"'
+notmuch tag -inbox -unread id:$gen_msg_id
+output=$(notmuch search 'NOT tag:*' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
untagged message ()"
+
 test_begin_subtest "Search body (utf-8):"
 add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 
12:00:00 -"' '[body]="message body utf8: b?d?"'
 output=$(notmuch search "b?d?" | notmuch_search_sanitize)
-- 
1.7.2.3


[PATCH 6/8 v2] Support maildir folder search.

2011-01-24 Thread Austin Clements
This implements a folder: query prefix by constructing a wildcard
query that matches all files within the specified folder, folder/new,
or folder/cur.  This works with hierarchical folder names, and accepts
both absolute and relative paths.
---

Well, that's embarrassing.  I somehow lost the critical "tok->wildcard
= TRUE;" line below somewhere between testing and posting this patch.
This is identical to version 1 of patch 6/8 except this one addition.

 lib/database.cc |   57 +++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 3af82b0..d42039c 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -582,6 +582,58 @@ transform_type_mail (_notmuch_token_t *root, unused (void 
*opaque))
 return _notmuch_token_create_op (root, TOK_AND, mail_ast, root);
 }

+static _notmuch_token_t *
+transform_folder_one (const void *ctx, notmuch_database_t *notmuch,
+ const char *relpath, const char *rest)
+{
+const char *db_path;
+notmuch_private_status_t status;
+unsigned int doc_id;
+_notmuch_token_t *tok;
+
+/* Get the docid for (relpath + rest). */
+if (*rest)
+   relpath = talloc_asprintf (ctx, "%s%s", relpath, rest);
+db_path = _notmuch_database_get_directory_db_path (relpath);
+status = _notmuch_database_find_unique_doc_id (notmuch, "directory",
+  db_path, &doc_id);
+if (db_path != relpath)
+   free ((char*) db_path);
+
+/* Construct a wildcard query that matches files in this directory. */
+if (status)
+   /* Directory doesn't exist.  Perhaps this should be an error? */
+   doc_id = 0;
+tok = _notmuch_token_create_term (ctx, TOK_LIT,
+ talloc_asprintf (ctx, "%u:", doc_id));
+tok->prefix = _find_prefix ("file-direntry");
+tok->wildcard = TRUE;
+return tok;
+}
+
+static _notmuch_token_t *
+transform_folder (_notmuch_token_t *root, void *opaque)
+{
+if (!root)
+   return NULL;
+if (root->type == TOK_PREFIX && strcmp (root->text, "folder") == 0) {
+   notmuch_database_t *notmuch = (notmuch_database_t *)opaque;
+   _notmuch_token_t *lit = root->left, *subs[3], *tok;
+   const char *relpath;
+   assert (lit && lit->type == TOK_LIT);
+   relpath = _notmuch_database_relative_path (notmuch, lit->text);
+   subs[0] = transform_folder_one (root, notmuch, relpath, "");
+   subs[1] = transform_folder_one (root, notmuch, relpath, "/new");
+   subs[2] = transform_folder_one (root, notmuch, relpath, "/cur");
+   tok = _notmuch_token_create_op (root, TOK_OR, subs[1], subs[2]);
+   return _notmuch_token_create_op (root, TOK_OR, subs[0], tok);
+}
+
+root->left = transform_folder (root->left, opaque);
+root->right = transform_folder (root->right, opaque);
+return root;
+}
+
 notmuch_database_t *
 notmuch_database_open (const char *path,
   notmuch_database_mode_t mode)
@@ -690,6 +742,11 @@ notmuch_database_open (const char *path,

_notmuch_qparser_add_transform (notmuch->query_parser,
transform_type_mail, NULL);
+
+   _notmuch_qparser_add_prefix (notmuch->query_parser, "folder",
+TRUE, TRUE);
+   _notmuch_qparser_add_transform (notmuch->query_parser,
+   transform_folder, notmuch);
 } catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred opening database: %s\n",
 error.get_msg().c_str());
-- 
1.7.2.3



Re: [PATCH] configure: add options to disable emacs/zsh/bash and choose install dir.

2011-01-24 Thread Cédric Cabessa
On Monday 24 January 2011 08:10:20 Xavier Maillard wrote:
> 
> Why not just try to detect whether bash/zsh or even emacs is available
> on the system and install the dependent files when it is the case ?

Hi Xavier,

I think it is better to let user explicitly choose what he want to install
or not. 
For the story, I am a gentoo user, in gentoo you can choose what
you want to install from a package with the USE flag mechanism.
(for example a ncurse client will depend of notmuch but without emacs support, 
another user will install the same notmuch package but with emacs support).
 
So the with/without options make the packaging very easy.

I think we can do autodetection if needed, but the user should be able to 
override the automatic behavior.


-- 
Cédric

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


Tag timestamps and synchronization

2011-01-24 Thread dm-list-email-notmuch
One of the features I would like to see from notmuch is an easier
ability to synchronize tags across machines.  At the very least, I
would need either incremental dump and restore, or some way to
communicate arbitrary tags to a local imap server that shares
notmuch's maildir (much as notmuch currently syncs the standard tags),
so that I synchronize two maildirs with a tool like offlineimap.

As Carl pointed out to me in private email, there has been some
previous discussion in the following thread:

notmuch show id:87hbfnmiux@yoom.home.cworth.org

Based on that thread, there seems to be some desire for notmuch to
keep track of a per-message timestamp when the flags were last
updated.  This would allow much easier expiration for people who want
the deleted tag.  It would also allow incremental dump and restore of
tags, which is exactly what I need to sync tags across servers with
reasonable amounts of bandwidth.

Metadata timestamps are one of those things that probably have a lot
of different applications, so since Carl is considering a new database
format for the next release anyway, perhaps it also makes sense to add
a metadata change time for each messages.

The timestamp would be included in "dump" output, and you could
request a dump of changes since a particular time.  On restore, you
might have several options:

  - overwrite: always set the new tags and timestamp in the database
to the value in the restore data.

  - update: always set the tags, but update the to the current time.

  - conditional T: update only if the message metadata has not been
updated since time T.

To sync flags, then you just need to keep track of the last time you
synced with a particular server--call this time T.  Do a dump since
time T, upload to server, do a conditional restore for time T on
server.  Finally do a partial dump from time T on the server and an
overwrite import on the client.  (This policy makes changes on the
server always override conflicting ones on the client--perhaps people
want other policies, like union of the tags, etc.)


Second, there seems to be some desire in that thread to sync with IMAP
flags.  This would be particularly great, but the easies way to do it
is probably *not* to try to implement IMAP, but rather to use an
existing IMAP server and just modify the maildir so that the IMAP
server will pick up the flags.

In the case of dovecot, the arbitrary tag format is very simple.  Each
maildir has a file called dovecot-keywords mapping numbers 0, 1,
... to keywords.  Then mail file names contain lower-case letters for
the flags they are marked with--0 => a, 1 => b, etc.--allowing up to
26 arbitrary tags for each maildir.  One could probably sync to
dovecot's maildir format relatively easily in a script given
incremental dump and restore of tags.  Or possibly notmuch could
natively support dovecot as one of multiple back-end tag storage
schemes.

Having a static tag mapping in the .notmuch-config file would be much
better than hard-coding flag2tag.  However, I'm not sure it's
sufficient.  The reason is that if you ever completely delete a tag
(e.g., you have "todo", and "meeting" tags and periodically have no
messages in either categories in a given mail folder), then an IMAP
server like dovecot might end up re-allocating the letters
corresponding to those tags in a different order.  Also, at least for
dovecot, the flag mappings are per-folder, which you kind of want
since you are limited to 26 non-standard tags, so global values might
not work.

I'm curious to hear people's thoughts/reactions?

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


Tag timestamps and synchronization

2011-01-24 Thread dm-list-email-notm...@scs.stanford.edu
One of the features I would like to see from notmuch is an easier
ability to synchronize tags across machines.  At the very least, I
would need either incremental dump and restore, or some way to
communicate arbitrary tags to a local imap server that shares
notmuch's maildir (much as notmuch currently syncs the standard tags),
so that I synchronize two maildirs with a tool like offlineimap.

As Carl pointed out to me in private email, there has been some
previous discussion in the following thread:

notmuch show id:87hbfnmiux.fsf at yoom.home.cworth.org

Based on that thread, there seems to be some desire for notmuch to
keep track of a per-message timestamp when the flags were last
updated.  This would allow much easier expiration for people who want
the deleted tag.  It would also allow incremental dump and restore of
tags, which is exactly what I need to sync tags across servers with
reasonable amounts of bandwidth.

Metadata timestamps are one of those things that probably have a lot
of different applications, so since Carl is considering a new database
format for the next release anyway, perhaps it also makes sense to add
a metadata change time for each messages.

The timestamp would be included in "dump" output, and you could
request a dump of changes since a particular time.  On restore, you
might have several options:

  - overwrite: always set the new tags and timestamp in the database
to the value in the restore data.

  - update: always set the tags, but update the to the current time.

  - conditional T: update only if the message metadata has not been
updated since time T.

To sync flags, then you just need to keep track of the last time you
synced with a particular server--call this time T.  Do a dump since
time T, upload to server, do a conditional restore for time T on
server.  Finally do a partial dump from time T on the server and an
overwrite import on the client.  (This policy makes changes on the
server always override conflicting ones on the client--perhaps people
want other policies, like union of the tags, etc.)


Second, there seems to be some desire in that thread to sync with IMAP
flags.  This would be particularly great, but the easies way to do it
is probably *not* to try to implement IMAP, but rather to use an
existing IMAP server and just modify the maildir so that the IMAP
server will pick up the flags.

In the case of dovecot, the arbitrary tag format is very simple.  Each
maildir has a file called dovecot-keywords mapping numbers 0, 1,
... to keywords.  Then mail file names contain lower-case letters for
the flags they are marked with--0 => a, 1 => b, etc.--allowing up to
26 arbitrary tags for each maildir.  One could probably sync to
dovecot's maildir format relatively easily in a script given
incremental dump and restore of tags.  Or possibly notmuch could
natively support dovecot as one of multiple back-end tag storage
schemes.

Having a static tag mapping in the .notmuch-config file would be much
better than hard-coding flag2tag.  However, I'm not sure it's
sufficient.  The reason is that if you ever completely delete a tag
(e.g., you have "todo", and "meeting" tags and periodically have no
messages in either categories in a given mail folder), then an IMAP
server like dovecot might end up re-allocating the letters
corresponding to those tags in a different order.  Also, at least for
dovecot, the flag mappings are per-folder, which you kind of want
since you are limited to 26 non-standard tags, so global values might
not work.

I'm curious to hear people's thoughts/reactions?

David


[PATCH 8.5/8] test: Add tests for search by date.

2011-01-24 Thread Austin Clements
---
 test/search |   67 +++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/test/search b/test/search
index 7d1dedb..6425359 100755
--- a/test/search
+++ b/test/search
@@ -73,6 +73,73 @@ add_message '[subject]="this phrase should not match the 
subject search test"' '
 output=$(notmuch search 'subject:"subject search test (phrase)"' | 
notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; 
subject search test (phrase) (inbox unread)"
 
+test_begin_subtest "Search by after:"
+output=$(notmuch search 'after:2009/11/18' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [1/1] Chris Wilson; 
[notmuch] [PATCH 1/2] Makefile: evaluate pkg-config once (inbox unread)
+thread:XXX   2009-11-18 [2/2] Alex Botero-Lowry, Carl Worth; [notmuch] [PATCH] 
Error out if no query is supplied to search instead of going into an infinite 
loop (attachment inbox unread)
+thread:XXX   2009-11-18 [1/2] Carl Worth| Ingmar Vanhassel; [notmuch] [PATCH] 
Typsos (inbox unread)
+thread:XXX   2009-11-18 [2/3] Keith Packard, Carl Worth| Adrian Perez de 
Castro; [notmuch] Introducing myself (inbox unread)
+thread:XXX   2009-11-18 [2/3] Keith Packard, Carl Worth| Israel Herraiz; 
[notmuch] New to the list (inbox unread)
+thread:XXX   2009-11-18 [1/3] Carl Worth| Jan Janak; [notmuch] What a great 
idea! (inbox unread)
+thread:XXX   2009-11-18 [1/2] Carl Worth| Jan Janak; [notmuch] [PATCH] Older 
versions of install do not support -C. (inbox unread)
+thread:XXX   2009-11-18 [2/3] Keith Packard, Carl Worth| Aron Griffis; 
[notmuch] archive (inbox unread)
+thread:XXX   2009-11-18 [1/2] Carl Worth| Keith Packard; [notmuch] [PATCH] 
Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox 
unread)
+thread:XXX   2009-11-18 [2/7] Lars Kellogg-Stedman, Carl Worth| Mikhail 
Gusarov, Keith Packard; [notmuch] Working with Maildir storage? (inbox unread)
+thread:XXX   2009-11-18 [1/5] Carl Worth| Mikhail Gusarov, Keith Packard; 
[notmuch] [PATCH 1/2] Close message file after parsing message headers (inbox 
unread)
+thread:XXX   2009-11-18 [2/2] Keith Packard, Alexander Botero-Lowry; [notmuch] 
[PATCH] Create a default notmuch-show-hook that highlights URLs and uses 
word-wrap (inbox unread)
+thread:XXX   2009-11-18 [1/1] Alexander Botero-Lowry; [notmuch] request for 
pull (inbox unread)
+thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] 
Mac OS X/Darwin compatibility issues (inbox unread)
+thread:XXX   2009-11-18 [1/1] Rolland Santimano; [notmuch] Link to mailing 
list archives ? (inbox unread)
+thread:XXX   2009-11-18 [1/1] Jan Janak; [notmuch] [PATCH] notmuch new: 
Support for conversion of spool subdirectories into tags (inbox unread)
+thread:XXX   2009-11-18 [1/1] Stewart Smith; [notmuch] [PATCH] count_files: 
sort directory in inode order before statting (inbox unread)
+thread:XXX   2009-11-18 [1/1] Stewart Smith; [notmuch] [PATCH 2/2] Read mail 
directory in inode number order (inbox unread)
+thread:XXX   2009-11-18 [1/1] Stewart Smith; [notmuch] [PATCH] Fix linking 
with gcc to use g++ to link in C++ libs. (inbox unread)
+thread:XXX   2009-11-18 [2/2] Lars Kellogg-Stedman; [notmuch] \"notmuch help\" 
outputs to stderr? (attachment inbox unread)"
+
+test_begin_subtest "Search by after: (no results)"
+output=$(notmuch search 'after:2009/11/19' | notmuch_search_sanitize)
+test_expect_equal "$output" ""
+
+test_begin_subtest "Search by before:"
+output=$(notmuch search 'before:2000/01/02' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; 
body search (inbox unread)
+thread:XXX   2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox 
searchbytag unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; negative result (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] searchbyf...@example.com; search by from 
(address) (inbox unread)
+thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) 
(inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (address) 
(inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox 
unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) 
(inbox unread)
+thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match 
the subject search test (inbox unread)"
+
+test_

[PATCH 6.5/8] test: Add tests for custom query parser-based folder searches.

2011-01-24 Thread Austin Clements
---
 test/notmuch-test |2 +-
 test/search-by-folder |   52 +
 2 files changed, 53 insertions(+), 1 deletions(-)
 create mode 100755 test/search-by-folder

diff --git a/test/notmuch-test b/test/notmuch-test
index 1e331b3..2aa3489 100755
--- a/test/notmuch-test
+++ b/test/notmuch-test
@@ -16,7 +16,7 @@ fi
 
 cd $(dirname "$0")
 
-TESTS="basic new qparser search search-output json thread-naming raw reply 
dump-restore uuencode thread-order author-order from-guessing long-id encoding 
emacs maildir-sync"
+TESTS="basic new qparser search search-output search-by-folder json 
thread-naming raw reply dump-restore uuencode thread-order author-order 
from-guessing long-id encoding emacs maildir-sync"
 
 # Clean up any results from a previous run
 rm -r test-results >/dev/null 2>/dev/null
diff --git a/test/search-by-folder b/test/search-by-folder
new file mode 100755
index 000..ebf724f
--- /dev/null
+++ b/test/search-by-folder
@@ -0,0 +1,52 @@
+#!/bin/bash
+test_description='"notmuch search" by folder: (with variations)'
+. ./test-lib.sh
+
+add_message '[dir]=bad' '[subject]="To the bone"'
+add_message '[dir]=bad/news' '[subject]="Bears"'
+mkdir -p "${MAIL_DIR}/duplicate/bad/news"
+cp "$gen_msg_filename" "${MAIL_DIR}/duplicate/bad/news"
+
+add_message '[dir]=things' '[subject]="These are a few"'
+add_message '[dir]=things/favorite' '[subject]="Raindrops, whiskers, kettles"'
+add_message '[dir]=things/bad' '[subject]="Bites, stings, sad feelings"'
+
+test_begin_subtest "Top-level folder"
+output=$(notmuch search folder:bad | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
To the bone (inbox unread)"
+
+test_begin_subtest "Nested folder"
+output=$(notmuch search folder:bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Bears (inbox unread)"
+
+test_begin_subtest "Search is rooted"
+output=$(notmuch search folder:news | notmuch_search_sanitize)
+test_expect_equal "$output" ""
+
+test_begin_subtest "Absolute path"
+output=$(notmuch search folder:$MAIL_DIR/bad | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
To the bone (inbox unread)"
+
+test_begin_subtest "Duplicate path"
+output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Bears (inbox unread)"
+
+test_begin_subtest "After removing duplicate instance of matching path"
+rm -r "${MAIL_DIR}/bad/news"
+increment_mtime "${MAIL_DIR}/bad"
+notmuch new
+output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Bears (inbox unread)"
+
+test_begin_subtest "After rename, old path returns nothing"
+mv "${MAIL_DIR}/duplicate/bad/news" "${MAIL_DIR}/duplicate/bad/olds"
+increment_mtime "${MAIL_DIR}/duplicate/bad"
+notmuch new
+output=$(notmuch search folder:duplicate/bad/news | notmuch_search_sanitize)
+test_expect_equal "$output" ""
+
+test_begin_subtest "After rename, new path returns result"
+output=$(notmuch search folder:duplicate/bad/olds | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Bears (inbox unread)"
+
+test_done
-- 
1.7.2.3
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 5.5/8] test: Wildcard tag search and untagged search.

2011-01-24 Thread Austin Clements
---
 test/qparser-test.cc   |6 +++---
 test/qparser.expected-output/wildcards |   13 +
 test/search|   12 
 3 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/test/qparser-test.cc b/test/qparser-test.cc
index ae6c8b9..7b145cc 100644
--- a/test/qparser-test.cc
+++ b/test/qparser-test.cc
@@ -100,9 +100,9 @@ static _notmuch_qparser_t *
 create_qparser (void *ctx)
 {
 _notmuch_qparser_t *qparser = _notmuch_qparser_create (ctx, notmuch);
-_notmuch_qparser_add_db_prefix (qparser, "prob", "P", FALSE);
-_notmuch_qparser_add_db_prefix (qparser, "lit", "L", TRUE);
-_notmuch_qparser_add_db_prefix (qparser, "tag", "K", TRUE);
+_notmuch_qparser_add_db_prefix (qparser, "prob", "P", FALSE, FALSE);
+_notmuch_qparser_add_db_prefix (qparser, "lit", "L", TRUE, FALSE);
+_notmuch_qparser_add_db_prefix (qparser, "tag", "K", TRUE, TRUE);
 return qparser;
 }
 
diff --git a/test/qparser.expected-output/wildcards 
b/test/qparser.expected-output/wildcards
index 6f62829..0558732 100644
--- a/test/qparser.expected-output/wildcards
+++ b/test/qparser.expected-output/wildcards
@@ -18,3 +18,16 @@ nosuchterm* AND x
 [parse]  (AND "nosuchterm"* "x")
 [gen](nosuchterm AND x:(pos=1))
 [xapian] 
+
+# Incompatible; Xapian doesn't accept wildcards in boolean prefixes
+tag:*
+[lex]PREFIX/tag "*"
+[parse]  (FILTER (PREFIX/tag '*'))
+[gen]0 * (Kinbox:(pos=1) SYNONYM Kunread:(pos=1))
+[xapian] 0 * K*
+
+tag:i*
+[lex]PREFIX/tag "i*"
+[parse]  (FILTER (PREFIX/tag 'i*'))
+[gen]0 * Kinbox:(pos=1)
+[xapian] 0 * Ki*
diff --git a/test/search b/test/search
index b180c7f..7d1dedb 100755
--- a/test/search
+++ b/test/search
@@ -113,6 +113,18 @@ thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search 
by to (name) (inbox unr
 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) 
(inbox unread)
 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match 
the subject search test (inbox unread)"
 
+test_begin_subtest 'Search by wildcard tag ("at*")'
+output=$(notmuch search 'tag:at*' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [2/2] Lars 
Kellogg-Stedman; [notmuch] \"notmuch help\" outputs to stderr? (attachment 
inbox unread)
+thread:XXX   2009-11-18 [1/2] Alex Botero-Lowry| Carl Worth; [notmuch] [PATCH] 
Error out if no query is supplied to search instead of going into an infinite 
loop (attachment inbox unread)
+thread:XXX   2009-11-17 [1/2] Alex Botero-Lowry| Carl Worth; [notmuch] 
preliminary FreeBSD support (attachment inbox unread)"
+
+test_begin_subtest 'Search for untagged messages'
+add_message '[subject]="untagged message"'
+notmuch tag -inbox -unread id:$gen_msg_id
+output=$(notmuch search 'NOT tag:*' | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
untagged message ()"
+
 test_begin_subtest "Search body (utf-8):"
 add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 
12:00:00 -"' '[body]="message body utf8: bödý"'
 output=$(notmuch search "bödý" | notmuch_search_sanitize)
-- 
1.7.2.3
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 6/8 v2] Support maildir folder search.

2011-01-24 Thread Austin Clements
This implements a folder: query prefix by constructing a wildcard
query that matches all files within the specified folder, folder/new,
or folder/cur.  This works with hierarchical folder names, and accepts
both absolute and relative paths.
---

Well, that's embarrassing.  I somehow lost the critical "tok->wildcard
= TRUE;" line below somewhere between testing and posting this patch.
This is identical to version 1 of patch 6/8 except this one addition.

 lib/database.cc |   57 +++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 3af82b0..d42039c 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -582,6 +582,58 @@ transform_type_mail (_notmuch_token_t *root, unused (void 
*opaque))
 return _notmuch_token_create_op (root, TOK_AND, mail_ast, root);
 }
 
+static _notmuch_token_t *
+transform_folder_one (const void *ctx, notmuch_database_t *notmuch,
+ const char *relpath, const char *rest)
+{
+const char *db_path;
+notmuch_private_status_t status;
+unsigned int doc_id;
+_notmuch_token_t *tok;
+
+/* Get the docid for (relpath + rest). */
+if (*rest)
+   relpath = talloc_asprintf (ctx, "%s%s", relpath, rest);
+db_path = _notmuch_database_get_directory_db_path (relpath);
+status = _notmuch_database_find_unique_doc_id (notmuch, "directory",
+  db_path, &doc_id);
+if (db_path != relpath)
+   free ((char*) db_path);
+
+/* Construct a wildcard query that matches files in this directory. */
+if (status)
+   /* Directory doesn't exist.  Perhaps this should be an error? */
+   doc_id = 0;
+tok = _notmuch_token_create_term (ctx, TOK_LIT,
+ talloc_asprintf (ctx, "%u:", doc_id));
+tok->prefix = _find_prefix ("file-direntry");
+tok->wildcard = TRUE;
+return tok;
+}
+
+static _notmuch_token_t *
+transform_folder (_notmuch_token_t *root, void *opaque)
+{
+if (!root)
+   return NULL;
+if (root->type == TOK_PREFIX && strcmp (root->text, "folder") == 0) {
+   notmuch_database_t *notmuch = (notmuch_database_t *)opaque;
+   _notmuch_token_t *lit = root->left, *subs[3], *tok;
+   const char *relpath;
+   assert (lit && lit->type == TOK_LIT);
+   relpath = _notmuch_database_relative_path (notmuch, lit->text);
+   subs[0] = transform_folder_one (root, notmuch, relpath, "");
+   subs[1] = transform_folder_one (root, notmuch, relpath, "/new");
+   subs[2] = transform_folder_one (root, notmuch, relpath, "/cur");
+   tok = _notmuch_token_create_op (root, TOK_OR, subs[1], subs[2]);
+   return _notmuch_token_create_op (root, TOK_OR, subs[0], tok);
+}
+
+root->left = transform_folder (root->left, opaque);
+root->right = transform_folder (root->right, opaque);
+return root;
+}
+
 notmuch_database_t *
 notmuch_database_open (const char *path,
   notmuch_database_mode_t mode)
@@ -690,6 +742,11 @@ notmuch_database_open (const char *path,
 
_notmuch_qparser_add_transform (notmuch->query_parser,
transform_type_mail, NULL);
+
+   _notmuch_qparser_add_prefix (notmuch->query_parser, "folder",
+TRUE, TRUE);
+   _notmuch_qparser_add_transform (notmuch->query_parser,
+   transform_folder, notmuch);
 } catch (const Xapian::Error &error) {
fprintf (stderr, "A Xapian exception occurred opening database: %s\n",
 error.get_msg().c_str());
-- 
1.7.2.3

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


[PATCH] configure: add options to disable emacs/zsh/bash and choose install dir.

2011-01-24 Thread Xavier Maillard
Hi Cedric,

On Sun, 23 Jan 2011 14:33:43 +0100, C?dric Cabessa  wrote:
> add --bashcompletiondir and --zshcompletiondir (like --emacslispdir) to choose
> installation dir for bash/zsh completion files
> 
> Make some features optional:
>   --without-emacs / --with-emacs=no do not install lisp file
>   --without-bash-completion / --with-bash-completion=no  do not install bash
> files
>   --without-zsh-completion / --with-zsh-completion=no do not install zsh files
> By default, everything is enabled. You can reenable something with
>   --with-feature=yes

Why not just try to detect whether bash/zsh or even emacs is available
on the system and install the dependent files when it is the case ?

/Xavier


Re: [PATCH] configure: add options to disable emacs/zsh/bash and choose install dir.

2011-01-24 Thread Michal Sojka
Hi Cédric,

thanks for the patch. I checked it and it didn't break anything for me.
But it made me thinking why zsh completion does not work for a long
time. Carl, please apply the patch below.

-Michal

From 72f6488b39aec318264caf26d2b163f73d3cf694 Mon Sep 17 00:00:00 2001
From: Michal Sojka 
Date: Sun, 23 Jan 2011 21:57:07 +0100
Subject: [PATCH] Fix installation of zsh completion

---
 completion/Makefile.local |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/completion/Makefile.local b/completion/Makefile.local
index 6a6012d..1624bd7 100644
--- a/completion/Makefile.local
+++ b/completion/Makefile.local
@@ -15,4 +15,4 @@ install-$(dir):
mkdir -p $(DESTDIR)$(bash_completion_dir)
install -m0644 $(bash_script) $(DESTDIR)$(bash_completion_dir)/notmuch
mkdir -p $(DESTDIR)$(zsh_completion_dir)
-   install -m0644 $(zsh_script) $(DESTDIR)$(zsh_completion_dir)/notmuch
+   install -m0644 $(zsh_script) $(DESTDIR)$(zsh_completion_dir)/_notmuch
-- 
1.7.2.3

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


Re: [PATCH 3.5/8] Query parser tests for wildcard queries.

2011-01-24 Thread Michal Sojka
On Sun, 23 Jan 2011, Austin Clements wrote:
> Oops, yes.  I'm not sure why you had to initialize qparser_desc (are you
> sure it doesn't compile if you omit that?), 

This was another problem - I got a warning that this variable might be
uninitialized.

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