[notmuch] [PATCH 4/4] Prompt for database location in notmuch setup

2010-02-23 Thread David Benjamin
Signed-off-by: David Benjamin 
---
 notmuch-setup.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/notmuch-setup.c b/notmuch-setup.c
index 622bbaa..e3c8465 100644
--- a/notmuch-setup.c
+++ b/notmuch-setup.c
@@ -159,6 +159,15 @@ notmuch_setup_command (unused (void *ctx),
notmuch_config_set_database_path (config, absolute_path);
 }

+prompt ("Location for notmuch database [%s]: ",
+   notmuch_config_get_database_notmuch_path (config));
+if (strlen (response)) {
+   const char *absolute_path;
+
+   absolute_path = make_path_absolute (ctx, response);
+   notmuch_config_set_database_notmuch_path (config, absolute_path);
+}
+
 if (! notmuch_config_save (config)) {
if (is_new)
  welcome_message_post_setup ();
-- 
1.7.0.18.g39b3



[notmuch] [PATCH 3/4] Configure the database separately from mail store

2010-02-23 Thread David Benjamin
Signed-off-by: David Benjamin 
---
 notmuch-client.h |7 ++
 notmuch-config.c |   62 --
 notmuch-new.c|   14 ---
 3 files changed, 58 insertions(+), 25 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 1a676d2..010fdc7 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -148,6 +148,13 @@ void
 notmuch_config_set_database_path (notmuch_config_t *config,
  const char *database_path);

+const char *
+notmuch_config_get_database_notmuch_path (notmuch_config_t *config);
+
+void
+notmuch_config_set_database_notmuch_path (notmuch_config_t *config,
+ const char *database_notmuch_path);
+
 notmuch_database_t *
 notmuch_config_open_database (notmuch_config_t *config,
  notmuch_database_mode_t mode);
diff --git a/notmuch-config.c b/notmuch-config.c
index 58a28b1..b20047c 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -58,6 +58,7 @@ struct _notmuch_config {
 GKeyFile *key_file;

 char *database_path;
+char *database_notmuch_path;
 char *user_name;
 char *user_primary_email;
 char **user_other_email;
@@ -151,6 +152,8 @@ get_username_from_passwd_file (void *ctx)
  *
  * database_path:  $HOME/mail
  *
+ * database_notmuch_path:  database_path/.notmuch
+ *
  * user_name:  From /etc/passwd
  *
  * user_primary_mail:  $EMAIL variable if set, otherwise
@@ -195,6 +198,7 @@ notmuch_config_open (void *ctx,
 config->key_file = g_key_file_new ();

 config->database_path = NULL;
+config->database_notmuch_path = NULL;
 config->user_name = NULL;
 config->user_primary_email = NULL;
 config->user_other_email = NULL;
@@ -351,6 +355,45 @@ notmuch_config_set_database_path (notmuch_config_t *config,

 talloc_free (config->database_path);
 config->database_path = NULL;
+/* In case this path is dynamically generated */
+talloc_free (config->database_notmuch_path);
+config->database_notmuch_path = NULL
+}
+
+const char *
+notmuch_config_get_database_notmuch_path (notmuch_config_t *config)
+{
+const char *path;
+char *notmuch_path;
+
+if (config->database_notmuch_path == NULL) {
+   notmuch_path = g_key_file_get_string (config->key_file,
+ "database", "notmuch_path", NULL);
+   if (notmuch_path) {
+   config->database_notmuch_path = talloc_strdup (config, 
notmuch_path);
+   free (notmuch_path);
+   } else {
+   path = notmuch_config_get_database_path (config);
+   if (path != NULL) {
+   notmuch_path = talloc_asprintf (config, "%s/%s",
+   path, ".notmuch");
+   config->database_notmuch_path = notmuch_path;
+   }
+   }
+}
+
+return config->database_notmuch_path;
+}
+
+void
+notmuch_config_set_database_notmuch_path (notmuch_config_t *config,
+ const char *database_notmuch_path)
+{
+g_key_file_set_string (config->key_file,
+  "database", "notmuch_path", database_notmuch_path);
+
+talloc_free (config->database_notmuch_path);
+config->database_notmuch_path = NULL;
 }

 notmuch_database_t *
@@ -358,26 +401,13 @@ notmuch_config_open_database (notmuch_config_t *config,
  notmuch_database_mode_t mode)
 {
 const char *path = NULL;
-char *db_path = NULL;
+const char *notmuch_path = NULL;
 notmuch_database_t *notmuch = NULL;

 path = notmuch_config_get_database_path (config);
-if (path == NULL) {
-   fprintf (stderr, "Error: Cannot create a database for a NULL path.\n");
-   goto DONE;
-}
-
-if (asprintf (_path, "%s/%s", path, ".notmuch") == -1) {
-   db_path = NULL;
-   fprintf (stderr, "Out of memory\n");
-   goto DONE;
-}
-
-notmuch = notmuch_database_open (path, db_path, mode);
+notmuch_path = notmuch_config_get_database_notmuch_path (config);

-DONE:
-if (db_path)
-   free(db_path);
+notmuch = notmuch_database_open (path, notmuch_path, mode);

 return notmuch;
 }
diff --git a/notmuch-new.c b/notmuch-new.c
index d24dab9..d36edd5 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -713,7 +713,7 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
 int ret = 0;
 struct stat st;
 const char *db_path;
-char *dot_notmuch_path;
+const char *notmuch_path;
 struct sigaction action;
 _filename_node_t *f;
 int renamed_files, removed_files;
@@ -737,10 +737,9 @@ notmuch_new_command (void *ctx, int argc, char *argv[])
return 1;

 db_path = notmuch_config_get_database_path (config);
+notmuch_path = notmuch_config_get_database_notmuch_path (config);

-dot_notmuch_path = talloc_asprintf (ctx, "%s/%s", db_path, ".notmuch");
-
-if (stat 

[notmuch] [PATCH 2/4] Pass separate notmuch_path when opening database

2010-02-23 Thread David Benjamin
Avoid hard-coding $MAILSTORE/.notmuch in the database layer.

Signed-off-by: David Benjamin 
---
 lib/database-private.h |1 +
 lib/database.cc|   28 ++--
 lib/notmuch.h  |   32 
 notmuch-client.h   |4 
 notmuch-config.c   |   29 +
 notmuch-count.c|4 ++--
 notmuch-dump.c |4 ++--
 notmuch-new.c  |3 ++-
 notmuch-reply.c|4 ++--
 notmuch-restore.c  |4 ++--
 notmuch-search-tags.c  |4 ++--
 notmuch-search.c   |4 ++--
 notmuch-show.c |4 ++--
 notmuch-tag.c  |4 ++--
 14 files changed, 86 insertions(+), 43 deletions(-)

diff --git a/lib/database-private.h b/lib/database-private.h
index 41918d7..59ed117 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -38,6 +38,7 @@ struct _notmuch_database {
 notmuch_bool_t exception_reported;

 char *path;
+char *notmuch_path;

 notmuch_bool_t needs_upgrade;
 notmuch_database_mode_t mode;
diff --git a/lib/database.cc b/lib/database.cc
index 1bb24ec..f54fbd1 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -437,14 +437,14 @@ parse_references (void *ctx,
 }

 notmuch_database_t *
-notmuch_database_create (const char *path)
+notmuch_database_create (const char *path,
+const char *notmuch_path)
 {
 notmuch_database_t *notmuch = NULL;
-char *notmuch_path = NULL;
 struct stat st;
 int err;

-if (path == NULL) {
+if (path == NULL || notmuch_path == NULL) {
fprintf (stderr, "Error: Cannot create a database for a NULL path.\n");
goto DONE;
 }
@@ -462,8 +462,6 @@ notmuch_database_create (const char *path)
goto DONE;
 }

-notmuch_path = talloc_asprintf (NULL, "%s/%s", path, ".notmuch");
-
 err = mkdir (notmuch_path, 0755);

 if (err) {
@@ -473,13 +471,11 @@ notmuch_database_create (const char *path)
 }

 notmuch = notmuch_database_open (path,
+notmuch_path,
 NOTMUCH_DATABASE_MODE_READ_WRITE);
 notmuch_database_upgrade (notmuch, NULL, NULL);

   DONE:
-if (notmuch_path)
-   talloc_free (notmuch_path);
-
 return notmuch;
 }

@@ -496,17 +492,17 @@ _notmuch_database_ensure_writable (notmuch_database_t 
*notmuch)

 notmuch_database_t *
 notmuch_database_open (const char *path,
+  const char *notmuch_path,
   notmuch_database_mode_t mode)
 {
 notmuch_database_t *notmuch = NULL;
-char *notmuch_path = NULL, *xapian_path = NULL;
+char *xapian_path = NULL;
 struct stat st;
 int err;
 unsigned int i, version;

-if (asprintf (_path, "%s/%s", path, ".notmuch") == -1) {
-   notmuch_path = NULL;
-   fprintf (stderr, "Out of memory\n");
+if (path == NULL || notmuch_path == NULL) {
+   fprintf (stderr, "Error: Cannot create a database for a NULL path.\n");
goto DONE;
 }

@@ -611,8 +607,6 @@ notmuch_database_open (const char *path,
 }

   DONE:
-if (notmuch_path)
-   free (notmuch_path);
 if (xapian_path)
free (xapian_path);

@@ -645,6 +639,12 @@ notmuch_database_get_path (notmuch_database_t *notmuch)
 return notmuch->path;
 }

+const char *
+notmuch_database_get_notmuch_path (notmuch_database_t *notmuch)
+{
+return notmuch->notmuch_path;
+}
+
 unsigned int
 notmuch_database_get_version (notmuch_database_t *notmuch)
 {
diff --git a/lib/notmuch.h b/lib/notmuch.h
index d3e50a7..943c297 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -120,12 +120,12 @@ typedef struct _notmuch_tags notmuch_tags_t;
 typedef struct _notmuch_directory notmuch_directory_t;
 typedef struct _notmuch_filenames notmuch_filenames_t;

-/* Create a new, empty notmuch database located at 'path'.
+/* Create a new, empty notmuch database located at 'notmuch_path',
+ * indexing mail store 'path'
  *
  * The path should be a top-level directory to a collection of
  * plain-text email messages (one message per file). This call will
- * create a new ".notmuch" directory within 'path' where notmuch will
- * store its data.
+ * create directory 'notmuch_path' where notmuch will store its data.
  *
  * After a successful call to notmuch_database_create, the returned
  * database will be open so the caller should call
@@ -140,7 +140,8 @@ typedef struct _notmuch_filenames notmuch_filenames_t;
  * an error message on stderr).
  */
 notmuch_database_t *
-notmuch_database_create (const char *path);
+notmuch_database_create (const char *path,
+const char *notmuch_path);

 typedef enum {
 NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
@@ -150,16 +151,15 @@ typedef enum {
 /* XXX: I think I'd like this to take an extra argument of
  * notmuch_status_t* for returning a status value on failure. */

-/* Open an existing notmuch database located at 'path'.
+/* Open an existing 

[notmuch] [PATCH 0/4] Allow separate database directory from mail store

2010-02-23 Thread David Benjamin
This patchset separates and makes configurable the database directory from the
mail store. In the code, I have elected to call the former the 'notmuch_path'
as, of the various of names in the source code ('path', 'db_path', etc.), that
was the only one that consistently refers to the .notmuch directory.

If notmuch_path is not configured, the usual location of $MAILSTORE/.notmuch is
used.

The first of the four is an irrelevant little documentation fix that I didn't
think was worth making a new thread for.

David Benjamin (4):
  lib/database.cc: Fix function name in comment
  Pass separate notmuch_path when opening database
  Configure the database separately from mail store
  Prompt for database location in notmuch setup

 lib/database-private.h |1 +
 lib/database.cc|   30 
 lib/notmuch.h  |   32 -
 notmuch-client.h   |   11 +
 notmuch-config.c   |   59 
 notmuch-count.c|4 +-
 notmuch-dump.c |4 +-
 notmuch-new.c  |   13 --
 notmuch-reply.c|4 +-
 notmuch-restore.c  |4 +-
 notmuch-search-tags.c  |4 +-
 notmuch-search.c   |4 +-
 notmuch-setup.c|9 +++
 notmuch-show.c |4 +-
 notmuch-tag.c  |4 +-
 15 files changed, 136 insertions(+), 51 deletions(-)



[notmuch] [PATCH] Added mail directory filename pattern support.

2010-02-23 Thread Stewart Smith
On Mon, Feb 22, 2010 at 12:07:31PM -0800, Bart Massey wrote:
> Typically, the filenames in a mail directory that actually
> contain mail obey some specific format.  For example, in my
> MH email directory, all mail filenames consist only of
> digits.
> 
> This patch adds support for a config file variable
> "filename_pattern" which maybe set to a regex used to filter
> only valid mail filenames when scanning.  Effective use of
> filename_pattern cuts down on the noise from notmuch, and
> may speed it up in some cases.

What about the other way around?

e.g. if anybody has ever pointed Evolution at a Maildir, you get a
bunch of Maildir-name.ev-summary and .ev-summary-meta and .ibex.index
and whatever.

A default list of ignored patterns would be pretty easy to come up with. 

-- 
Stewart Smith


[notmuch] JSON output as default [was: Re: [PATCH] Add an "--output=(json|text|)" command-line option...]

2010-02-23 Thread Jameson Rollins
Hey, Carl.  I mentioned this is an email a while back
(id:87eil4ygar.fsf at servo.finestructure.net), but I want to bring it up
again now that you're looking at the JSON output stuff.  I would like to
make the case for JSON being the one and only output format.  Here's the
arguments:

* JSON is a very well spec'd API
* JSON is a *very* well supported standard (it's basically well
  supported by every language)
* the JSONformat is perfectly suited for notmuch's output
* emacs has a json.el library, so it would not be hard at all to modify
  the notmuch.el to parse json output
* using only one output format would considerably reduce the code base
  in notmuch, keeping things simpler and easier to maintain

I think these are pretty good reason to just move to JSON as *the*
output format.

While I'm on this topic, let me rehash another point I made previously:
If we move to JSON output, it would be *so* sweet to provide means to
filter the output JSON fields.  The "--output" flag could be used to
pick the desired output fields.  For instance, the current "search"
output could be something like:

search --output=thread_id,date,number,author,subject,tags

while the current "show" output could be something like:

search --output=message_id,tags,path,header,body,attachments

This would all make things *much* easier for clients and wrappers.  For
instance, here are just a couple of things that would be made much
easier for wrapper scripts:

* Proper maildir sync ("search --output=message_id,tags,path" ...)

* Purging "delete" tagged messages ("search --output=path" tags:delete)

* Moving/archiving messages based on search results ("search --output=path" ...)

I would personally love to see this.  I think it would make notmuch
cleaner, simpler, and more powerful all at the same time.

Interested in hearing what other's thoughts on this idea are.

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/20100223/314f88dc/attachment.pgp>


[notmuch] JSON output as default [was: Re: [PATCH] Add an "--output=(json|text|)" command-line option...]

2010-02-23 Thread Carl Worth
On Tue, 23 Feb 2010 16:00:01 -0500, Jameson Rollins  wrote:
> Hey, Carl.  I mentioned this is an email a while back
> (id:87eil4ygar.fsf at servo.finestructure.net), but I want to bring it up
> again now that you're looking at the JSON output stuff.  I would like to
> make the case for JSON being the one and only output format.  Here's the
> arguments:

Oh, I'm definitely in favor of killing the %message{ format.

As soon as we get the emacs and vi frontends switched to the json
output, then that old thing can be eliminated.

> * using only one output format would considerably reduce the code base
>   in notmuch, keeping things simpler and easier to maintain

But I actually still want text-only output. It will be even less
"parseable" than the current output, (no delimiters at all), but also
have some niceties like thread indentation, etc.

The idea there is to support direct, human-readable output for quick
command-line use. (It also means that notmuch provides a much gentler
introduction to people just experimenting with it). And I'm willing to
keep the code base just a "little" bit complicated for that.

> If we move to JSON output, it would be *so* sweet to provide means to
> filter the output JSON fields.  The "--output" flag could be used to
> pick the desired output fields.  For instance, the current "search"
> output could be something like:

I definitely want to enable the user to select which fields are printed.

But I don't see how that depends on JSON output. In fact, for easy shell
scripts, etc. I want to be able to do search that give me filenames,
email addresses, etc. without any delimiters at all.

I definitely want to be able to pipe single-field lists coming from
notmuch to grep, xargs, shell for loops, etc. without having to decode
JSON.

So I'm still in favor of having a "plain text" output going forward,
(and by default).

-Carl
-- 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/20100223/d4b69631/attachment.pgp>


[notmuch] [PATCH] Added mail directory filename pattern support.

2010-02-23 Thread Bart Massey
In message <20100223061542.GR17878 at flamingspork.com> you wrote:
> On Mon, Feb 22, 2010 at 12:07:31PM -0800, Bart Massey wrote:
> > Typically, the filenames in a mail directory that actually
> > contain mail obey some specific format.  For example, in my
> > MH email directory, all mail filenames consist only of
> > digits.
> > 
> > This patch adds support for a config file variable
> > "filename_pattern" which maybe set to a regex used to filter
> > only valid mail filenames when scanning.  Effective use of
> > filename_pattern cuts down on the noise from notmuch, and
> > may speed it up in some cases.
> 
> What about the other way around?
> 
> e.g. if anybody has ever pointed Evolution at a Maildir, you get a
> bunch of Maildir-name.ev-summary and .ev-summary-meta and .ibex.index
> and whatever.
> 
> A default list of ignored patterns would be pretty easy to come up with. 

I'm not understanding your use case?  For the most common
cases, Maildir and MH, setting the appropriate
filename_pattern will ignore whatever garbage is lying
around the tree and just look at the mail messages.

Maybe my documentation is confusing?  By "filter only valid
mail filenames" I mean "accept only valid mail filenames", not
"filter out only valid mail filenames". :-)

Thanks much for any clarification you can provide.

Bart Massey
bart at cs.pdx.edu


[notmuch] [PATCH] Add an "--format=(json|text)" command-line option to both notmuch-search and notmuch-show.

2010-02-23 Thread Carl Worth
On Thu, 31 Dec 2009 11:17:40 -0400, david at tethera.net wrote:
> This is an updated version of Scott Robinson's patch of
> id:1261114167-sup-8228 at lisa. All of the hard work is Scott's. My
> changes to Scotts patch are 
>  - change option to --format from --output
>  - make a couple of calls to function points conditional on the 
>function pointers being non-null
>  - updated the built-in documentation and the man page
> 
> I also changed the copyright of json.c to Scott. Hope that's OK with
> Scott.

Well that's embarrassing. I just went through the effort of reviewing
the old patch and basically re-constructing that same list of tasks,
(only to find out that this updated patch was already sitting in my
queue, but later).

Anyway, very well done! I've applied this now with one change:

I'm now printing "thread" instead of "id" as the JSON name for the
field with the thread id in it.

I also added a mention to the TODO file that we should fix --format=json
to not imply --entire-thread.

Thanks again, David and Scott (and we hope that all the backpacking goes
well, Scott!).

-Carl
-- 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/20100223/0aa30c46/attachment.pgp>


[notmuch] [PATCH] Add an "--output=(json|text|)" command-line option to both notmuch-search and notmuch-show.

2010-02-23 Thread Carl Worth
On Fri, 18 Dec 2009 08:59:55 -0400, david at tethera.net wrote:
> From: Scott Robinson 

Hi Scott (and David),

I'm finally getting around to looking closely at the JSON patches
(hurrah!). Here are some comments:

> In the case of notmuch-show, "--output=json" also implies
> "--entire-thread" as the thread structure is implicit in the emitted
> document tree.

I think we've all agreed to use --output for selecting what to print and
to instead use --format for how to format it. I also think David's got a
patch to change that, but if we have to change the current patch anyway,
we might change that at the same time.

> --- /dev/null
> +++ b/json.c
> @@ -0,0 +1,73 @@
> +/* notmuch - Not much of an email program, (just index and search)
> + *
> + * Copyright ? 2009 Carl Worth
> + * Copyright ? 2009 Keith Packard

I know I didn't contribute any code to this file, so my name shouldn't
be here. Scott, I imagine you have made some non-trivial contributions
so your name (or suitable copyright-claiming entity) should be here.

> + * Authors: Carl Worth 
> + *   Keith Packard 

Same thing here.

> +/*
> + * json_quote_str derived from cJSON's print_string_ptr,
> + * Copyright (c) 2009 Dave Gamble
> + */

Thanks for attributing the source here, but let's please keep all the
copyright statements up at the top of the file.

It would still be reasonable to have a comment at this point that this
particular code came from Dave Gamble and cJSON. But it should also
mention the license under which the code is being integrated.

I suggest leaving the notmuch-standar GPLv3+ blurb at the top of the
file, but then quoting the license itself of the external code, (it's a
short MIT-style license, right?).

> +char *
> +json_quote_str(const void *ctx, const char *str)

It would be nice to have a little comment here describing what the
function does, (what characters get quoted and how, that the return
value is talloced with 'ctx' as a parent, and perhaps a pointer to the
appropriate JSON reference/specification).

But I definitely like this nice little function as opposed to some JSON
library. Thanks!


> +typedef struct search_format {
> +const char *results_start;
> +const char *thread_start;
> +void (*thread) (const void *ctx,
> + const char *id,
> + const time_t date,
> + const int matched,
> + const int total,
> + const char *authors,
> + const char *subject);
...

Definitely missing at least a quick comment for internal documentation
here as well. But I do like the way this works.

> --- a/notmuch.c
> +++ b/notmuch.c
> @@ -162,6 +162,11 @@ command_t commands[] = {
>"\n"
>"\t\tSupported options for search include:\n"
>"\n"
> +  "\t\t--output=(json|text)\n"
> +  "\n"
> +  "\t\t\tPresents the results in either JSON or plain-text\n"
> +  "\t\t\tformat, which is the default.\n"
> +  "\n"

Thanks for adding the documentation here. But please add to notmuch.1 as
well.

This all looks really great. And I can't wait to apply it and play with
it more.

-Carl
-- 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/20100223/c646b624/attachment-0001.pgp>


[notmuch] [PATCH] test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.

2010-02-23 Thread Tay Ray Chuan
Hi,

On Tue, Feb 23, 2010 at 11:42 AM, Junio C Hamano  wrote:
> FWIW, I only said "_at least_ you need consent from them", and it was not
> meant to be an exhaustive list. ?"blame -C -C -C" may tell you more.

Without substantial analysis, "blame" alone is not sufficient - it
does not show which work was original, or derivative.

-- 
Cheers,
Ray Chuan


[notmuch] [PATCH] Calls to notmuch get queued and executed asynchronously.

2010-02-23 Thread James Vasile
Added notmuch-enqueue-asynch to replace calls to
notmuch-call-notmuch-process.  Calls to notmuch are then queued and
executed asynchronously.  If the db is busy and we get an error saying
it was locked, keep trying until the db is no longer busy.  Errors go
in a buffer as per usual.

The only caveat here is that if the db is permanently locked (i.e. the
lock is broken), we just keep on trying forever.  Maybe there should
probably be a maximum number of tries or a timeout, but since 'notmuch
new' can take a long time, it's difficult to come up with a reasonable
limit.
---
 notmuch.el |   57 -
 1 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 6482170..7fc63e9 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -302,7 +302,7 @@ pseudoheader summary"
   "Add a tag to the current message."
   (interactive
(list (notmuch-select-tag-with-completion "Tag to add: ")))
-  (apply 'notmuch-call-notmuch-process
+  (apply 'notmuch-enqueue-asynch
 (append (cons "tag"
   (mapcar (lambda (s) (concat "+" s)) toadd))
 (cons (notmuch-show-get-message-id) nil)))
@@ -315,7 +315,7 @@ pseudoheader summary"
   (let ((tags (notmuch-show-get-tags)))
 (if (intersection tags toremove :test 'string=)
(progn
- (apply 'notmuch-call-notmuch-process
+ (apply 'notmuch-enqueue-asynch
 (append (cons "tag"
   (mapcar (lambda (s) (concat "-" s)) toremove))
 (cons (notmuch-show-get-message-id) nil)))
@@ -1374,6 +1374,53 @@ Complete list of currently available key bindings:
   (let ((message-id (notmuch-search-find-thread-id)))
 (notmuch-reply message-id)))

+(defun join-string-list (string-list)
+"Concatenates a list of strings and puts spaces between the
+elements."
+(mapconcat 'identity string-list " "))
+
+(defvar notmuch-asynch-queue nil)
+(defun notmuch-call-notmuch-process-asynch ( args)
+  "Asynchronously invoke \"notmuch\" with the given list of arguments.
+
+Error output from the process will be presented to the user as an
+error and will also appear in a buffer named \"*notmuch *\"."
+  (when args
+(let ((process-connection-type nil)
+ (buffer-name (format "*notmuch %s*" (join-string-list args
+  (when (get-buffer buffer-name)
+   (kill-buffer (get-buffer buffer-name)))
+  (let* ((process-buffer (get-buffer-create buffer-name))
+(process (apply 'start-process "notmuch-process" process-buffer
+notmuch-command args)))
+   (set-process-sentinel process 
'notmuch-call-notmuch-process-asynch-sentinel)
+(defun notmuch-enqueue-asynch ( args)
+  "Add a call to notmuch to the queue of notmuch calls.
+
+args is a list of arguments to notmuch.  ex: (\"tag\" \"+list\"
+\"to:mylist at example.com\")
+
+Calls to notmuch are queued and called asynchronously."
+  (setq notmuch-asynch-queue (append notmuch-asynch-queue (list args)))
+  (when (= (length notmuch-asynch-queue) 1)
+(apply 'notmuch-call-notmuch-process-asynch (pop notmuch-asynch-queue
+  
+(defun notmuch-call-notmuch-process-asynch-sentinel (process event)
+  "Handle the exit of a notmuch asynch process.
+
+When notmuch is done processing, display the error or kill the
+error buffer.  If the db was busy on the last attempt to execute
+command, try it again."
+  (with-current-buffer (process-buffer process)
+(goto-char (point-min))
+(if (= (process-exit-status process) 0)
+   (kill-buffer (buffer-name (process-buffer process)))
+   (if (search-forward "Unable to acquire database write lock" nil t)
+   (apply 'notmuch-call-notmuch-process-asynch (cdr (process-command 
process)))
+   (error (format "%s: %s" (join-string-list (process-command process))
+  (buffer-string))
+  (apply 'notmuch-call-notmuch-process-asynch (pop notmuch-asynch-queue)))
+
 (defun notmuch-call-notmuch-process ( args)
   "Synchronously invoke \"notmuch\" with the given list of arguments.

@@ -1420,7 +1467,7 @@ The tag is added to messages in the currently selected 
thread
 which match the current search terms."
   (interactive
(list (notmuch-select-tag-with-completion "Tag to add: ")))
-  (notmuch-call-notmuch-process "tag" (concat "+" tag) 
(notmuch-search-find-thread-id))
+  (notmuch-enqueue-asynch "tag" (concat "+" tag) 
(notmuch-search-find-thread-id))
   (notmuch-search-set-tags (delete-dups (sort (cons tag 
(notmuch-search-get-tags)) 'string<

 (defun notmuch-search-remove-tag (tag)
@@ -1430,7 +1477,7 @@ The tag is removed from messages in the currently 
selected thread
 which match the current search terms."
   (interactive
(list (notmuch-select-tag-with-completion "Tag to remove: " 
(notmuch-search-find-thread-id
-  (notmuch-call-notmuch-process "tag" (concat "-" tag) 
(notmuch-search-find-thread-id))
+  

[notmuch] [PATCH] Add ENVIRONMENT VARIABLES section to the man page

2010-02-23 Thread Carl Worth
On Sat, 19 Dec 2009 13:12:15 +, James Westby <jw+debian at jameswestby.net> 
wrote:
> Briefly describe the NOTMUCH_CONFIG variable there.

Thanks, James! I've pushed this out now.

>   I'm not sure how to phrase it to fit at the end of notmuch help,
>   suggestions welcome. For now I added a traditional ENVIRONMENT
>   VARIABLES section to the man page.

I had originally postponed your patch only because I wanted to try to
answer your question here about how to fit this at the end of notmuch
help as well. But it's not obvious to me that there's a good way to do
that.

-Carl
-- 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/20100223/3b58abb8/attachment.pgp>


[notmuch] [PATCH] Rework saving of attachments.

2010-02-23 Thread Carl Worth
On Mon, 14 Dec 2009 10:13:58 -0800, camalot at picnicpark.org wrote:
> From: Keith Amidon 

Hi Keith,

I apologize for the extraordinarly-late review, but here it is...

I tried this patch out, wanted to like it, and almost pushed it out, but
I decided against it in its current form. Here are some thoughts:

1. The commit message ("rework saving of attachments") is not
   adequate. It doesn't actually say what the commit does, (how can I
   test whether things have been reworked?). If the vagueness of the
   message is because the commit is changing several different aspects
   of behavior, then I would argue that the commit should be split up
   into separate pieces.

2. A binding to save a single attachment (with only a prefix argument to
   select which) just isn't usable. First, there's nothing in the UI to
   indicate the appropriate numbers to pass as the prefix argument,
   (other than manually counting the attachments). And second, the
   functionality is simply too hidden and non-obvious. This is most
   dangerous because in the common case of a single attachment, the 'w'
   binding will seem to be saving all attachments setting up confusion
   if the user tries to save multiple attachments with this same
   keybinding.

   Now, having a function to save a single attachment is just fine,
   (leaving someone else to hook up a binding to a particular button,
   say). So I'd accept a patch that added that, but didn't add a direct
   key-binding for it.

3. For saving multiple attachments, the feature I'd really like to see
   is the ability to specify a single directory and have all the
   attachments saved there.

Obviously, this third feature is just something different than what the
patch does, so not necessarily a reason to reject the patch. So what is
it that the patch actually does again?

I think the big advantage of the patch is getting rid of the initial
prompting "save this attachment (foo)?". It occurs to me that a simpler
way to get rid of that would be to simply not ask that question when the
user hits 'w' and there *is* only a single attachment. Then, with
multiple attachments, 'w' could prompt in turn as currently.

That would leave open the ability to use 'W' for a command to write all
attachments to a particular directory.

So that's one idea, at least. What do you think?

-Carl
-- 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/20100223/e96c3156/attachment.pgp>


[notmuch] [PATCH] test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.

2010-02-23 Thread Carl Worth
On Mon, 22 Feb 2010 19:42:30 -0800, Junio C Hamano  wrote:
> Please drop the above the next time.

Oops. Yes, I missed that.

> FWIW, I only said "_at least_ you need consent from them", and it was not
> meant to be an exhaustive list.  "blame -C -C -C" may tell you more.

Fair enough.

> You are the party that wants this relicensing, not me.  Please do not
> burden me with excessive legwork for you, but help me a bit more
> proactively to make this happen.

I hope you see I haven't asked you to do any additional legwork. A
suggestion was made to construct a patch, which I did. You always have
the option of accepting or rejecting the patch as you see fit.

> Oh, I never said "do not use message ID".  I said "message ID alone is not
> good enough for most people".  Users of gmane and notmuch who know the
> tool they use would benefit from having message ID, _too_, but even if you
> were a user of notmuch, unless you have subscribed to the list and have
> your own archive, you wouldn't be able to say "show id:frotz".

Certainly. My assumption was that in a commit message for git, readers
would naturally assume that a message ID with no additional
specification could be found in the archives of the standard git mailing
list, (which is the case here). Otherwise, I would have qualified the
message ID more specifically.

-Carl
-- 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/20100223/1a256ae2/attachment.pgp>


[notmuch] [PATCH V3] notmuch.el: Make notmuch-show buffer name first subject, instead of thread-id (supersedes V1 and V2)

2010-02-23 Thread Jesse Rosenthal
Change the buffer name to a uniquified subject of the thread (i.e. the
subject of the first message in the thread) instead of the thread-id. This
is more meaningful to the user, and will make it easier to scroll through
numerous open buffers.

Note that this patch adds an optional `buffer-name' argument to notmuch
show.

This version supersedes V1 and V2 of this patch. It is rebased on HEAD,
ensures that the buffer names are unique, and that the `notmuch-show'
command can still be used interactively (fixing a clumsy bug in V2 which
prevented that).

Signed-off-by: Jesse Rosenthal 
---
 notmuch.el |   21 +
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 6482170..685b2cd 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1162,7 +1162,7 @@ All currently available key bindings:
  (lambda()
(hl-line-mode 1) ))

-(defun notmuch-show (thread-id  parent-buffer query-context)
+(defun notmuch-show (thread-id  parent-buffer query-context 
buffer-name)
   "Run \"notmuch show\" with the given thread ID and display results.

 The optional PARENT-BUFFER is the notmuch-search buffer from
@@ -1172,7 +1172,10 @@ thread from that buffer can be show when done with this 
one).
 The optional QUERY-CONTEXT is a notmuch search term. Only messages from the 
thread
 matching this search term are shown if non-nil. "
   (interactive "sNotmuch show: ")
-  (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"
+  (when (null (buffer-name))
+(setq buffer-name (concat "*notmuch-" thread-id "*")))
+  (let* ((thread-buffer-name (generate-new-buffer-name buffer-name))
+(buffer (get-buffer-create thread-buffer-name)))
 (switch-to-buffer buffer)
 (notmuch-show-mode)
 (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)
@@ -1363,9 +1366,19 @@ Complete list of currently available key bindings:
 (defun notmuch-search-show-thread ()
   "Display the currently selected thread."
   (interactive)
-  (let ((thread-id (notmuch-search-find-thread-id)))
+  (let ((thread-id (notmuch-search-find-thread-id))
+   (subject (notmuch-search-find-subject))
+   buffer-name)
+(when (string-match "^[ \t]*$" subject)
+  (setq subject "[No Subject]"))
+(setq buffer-name (concat "*"
+ (truncate-string-to-width subject 32 nil nil t)
+ "*"))
 (if (> (length thread-id) 0)
-   (notmuch-show thread-id (current-buffer) notmuch-search-query-string)
+   (notmuch-show thread-id
+ (current-buffer)
+ notmuch-search-query-string
+ buffer-name)
   (error "End of search results"

 (defun notmuch-search-reply-to-thread ()
-- 
1.6.3.3



[notmuch] [PATCH] test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.

2010-02-23 Thread Johannes Schindelin
Hi,

On Tue, 23 Feb 2010, Tay Ray Chuan wrote:

> On Tue, Feb 23, 2010 at 11:42 AM, Junio C Hamano  
> wrote:
> > FWIW, I only said "_at least_ you need consent from them", and it was 
> > not meant to be an exhaustive list. ?"blame -C -C -C" may tell you 
> > more.
> 
> Without substantial analysis, "blame" alone is not sufficient - it does 
> not show which work was original, or derivative.

Well, I think that blame can get you very, very far. For example, you will 
see that Josh Triplett's only (surviving) contribution to test-lib.sh is a 
single line saying "unset MAIL", which is too trivial to be copyrightable 
(and if it was not trivial, it still would be the only way to accomplish 
what it does, so it is again not copyrightable).

Ciao,
Dscho


[notmuch] [PATCH] test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.

2010-02-23 Thread Matthieu Moy
Junio C Hamano  writes:

>> http://thread.gmane.org/gmane.mail.notmuch.general/1389/focus=140156
[...]
>> Meanwhile, a message ID lives forever and can be used in multiple
>> contexts.
>
> Oh, I never said "do not use message ID".  I said "message ID alone is not
> good enough for most people". 

FWIW, gmane allows links of the form

http://mid.gmane.org/7vaav8hpfo.fsf at alter.siamese.dyndns.org

which have the advantage of being simple to use, and still contain the
necessary information to get the message in case gmane dies.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/


[notmuch] [PATCH V3] notmuch.el: Make notmuch-show buffer name first subject, instead of thread-id (supersedes V1 and V2)

2010-02-23 Thread Jesse Rosenthal
Change the buffer name to a uniquified subject of the thread (i.e. the
subject of the first message in the thread) instead of the thread-id. This
is more meaningful to the user, and will make it easier to scroll through
numerous open buffers.

Note that this patch adds an optional `buffer-name' argument to notmuch
show.

This version supersedes V1 and V2 of this patch. It is rebased on HEAD,
ensures that the buffer names are unique, and that the `notmuch-show'
command can still be used interactively (fixing a clumsy bug in V2 which
prevented that).

Signed-off-by: Jesse Rosenthal jrosent...@jhu.edu
---
 notmuch.el |   21 +
 1 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 6482170..685b2cd 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1162,7 +1162,7 @@ All currently available key bindings:
  (lambda()
(hl-line-mode 1) ))
 
-(defun notmuch-show (thread-id optional parent-buffer query-context)
+(defun notmuch-show (thread-id optional parent-buffer query-context 
buffer-name)
   Run \notmuch show\ with the given thread ID and display results.
 
 The optional PARENT-BUFFER is the notmuch-search buffer from
@@ -1172,7 +1172,10 @@ thread from that buffer can be show when done with this 
one).
 The optional QUERY-CONTEXT is a notmuch search term. Only messages from the 
thread
 matching this search term are shown if non-nil. 
   (interactive sNotmuch show: )
-  (let ((buffer (get-buffer-create (concat *notmuch-show- thread-id *
+  (when (null (buffer-name))
+(setq buffer-name (concat *notmuch- thread-id *)))
+  (let* ((thread-buffer-name (generate-new-buffer-name buffer-name))
+(buffer (get-buffer-create thread-buffer-name)))
 (switch-to-buffer buffer)
 (notmuch-show-mode)
 (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)
@@ -1363,9 +1366,19 @@ Complete list of currently available key bindings:
 (defun notmuch-search-show-thread ()
   Display the currently selected thread.
   (interactive)
-  (let ((thread-id (notmuch-search-find-thread-id)))
+  (let ((thread-id (notmuch-search-find-thread-id))
+   (subject (notmuch-search-find-subject))
+   buffer-name)
+(when (string-match ^[ \t]*$ subject)
+  (setq subject [No Subject]))
+(setq buffer-name (concat *
+ (truncate-string-to-width subject 32 nil nil t)
+ *))
 (if ( (length thread-id) 0)
-   (notmuch-show thread-id (current-buffer) notmuch-search-query-string)
+   (notmuch-show thread-id
+ (current-buffer)
+ notmuch-search-query-string
+ buffer-name)
   (error End of search results
 
 (defun notmuch-search-reply-to-thread ()
-- 
1.6.3.3

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


[notmuch] [PATCH] Calls to notmuch get queued and executed asynchronously.

2010-02-23 Thread James Vasile
Added notmuch-enqueue-asynch to replace calls to
notmuch-call-notmuch-process.  Calls to notmuch are then queued and
executed asynchronously.  If the db is busy and we get an error saying
it was locked, keep trying until the db is no longer busy.  Errors go
in a buffer as per usual.

The only caveat here is that if the db is permanently locked (i.e. the
lock is broken), we just keep on trying forever.  Maybe there should
probably be a maximum number of tries or a timeout, but since 'notmuch
new' can take a long time, it's difficult to come up with a reasonable
limit.
---
 notmuch.el |   57 -
 1 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 6482170..7fc63e9 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -302,7 +302,7 @@ pseudoheader summary
   Add a tag to the current message.
   (interactive
(list (notmuch-select-tag-with-completion Tag to add: )))
-  (apply 'notmuch-call-notmuch-process
+  (apply 'notmuch-enqueue-asynch
 (append (cons tag
   (mapcar (lambda (s) (concat + s)) toadd))
 (cons (notmuch-show-get-message-id) nil)))
@@ -315,7 +315,7 @@ pseudoheader summary
   (let ((tags (notmuch-show-get-tags)))
 (if (intersection tags toremove :test 'string=)
(progn
- (apply 'notmuch-call-notmuch-process
+ (apply 'notmuch-enqueue-asynch
 (append (cons tag
   (mapcar (lambda (s) (concat - s)) toremove))
 (cons (notmuch-show-get-message-id) nil)))
@@ -1374,6 +1374,53 @@ Complete list of currently available key bindings:
   (let ((message-id (notmuch-search-find-thread-id)))
 (notmuch-reply message-id)))
 
+(defun join-string-list (string-list)
+Concatenates a list of strings and puts spaces between the
+elements.
+(mapconcat 'identity string-list  ))
+
+(defvar notmuch-asynch-queue nil)
+(defun notmuch-call-notmuch-process-asynch (rest args)
+  Asynchronously invoke \notmuch\ with the given list of arguments.
+
+Error output from the process will be presented to the user as an
+error and will also appear in a buffer named \*notmuch arguments*\.
+  (when args
+(let ((process-connection-type nil)
+ (buffer-name (format *notmuch %s* (join-string-list args
+  (when (get-buffer buffer-name)
+   (kill-buffer (get-buffer buffer-name)))
+  (let* ((process-buffer (get-buffer-create buffer-name))
+(process (apply 'start-process notmuch-process process-buffer
+notmuch-command args)))
+   (set-process-sentinel process 
'notmuch-call-notmuch-process-asynch-sentinel)
+(defun notmuch-enqueue-asynch (rest args)
+  Add a call to notmuch to the queue of notmuch calls.
+
+args is a list of arguments to notmuch.  ex: (\tag\ \+list\
+\to:myl...@example.com\)
+
+Calls to notmuch are queued and called asynchronously.
+  (setq notmuch-asynch-queue (append notmuch-asynch-queue (list args)))
+  (when (= (length notmuch-asynch-queue) 1)
+(apply 'notmuch-call-notmuch-process-asynch (pop notmuch-asynch-queue
+  
+(defun notmuch-call-notmuch-process-asynch-sentinel (process event)
+  Handle the exit of a notmuch asynch process.
+
+When notmuch is done processing, display the error or kill the
+error buffer.  If the db was busy on the last attempt to execute
+command, try it again.
+  (with-current-buffer (process-buffer process)
+(goto-char (point-min))
+(if (= (process-exit-status process) 0)
+   (kill-buffer (buffer-name (process-buffer process)))
+   (if (search-forward Unable to acquire database write lock nil t)
+   (apply 'notmuch-call-notmuch-process-asynch (cdr (process-command 
process)))
+   (error (format %s: %s (join-string-list (process-command process))
+  (buffer-string))
+  (apply 'notmuch-call-notmuch-process-asynch (pop notmuch-asynch-queue)))
+
 (defun notmuch-call-notmuch-process (rest args)
   Synchronously invoke \notmuch\ with the given list of arguments.
 
@@ -1420,7 +1467,7 @@ The tag is added to messages in the currently selected 
thread
 which match the current search terms.
   (interactive
(list (notmuch-select-tag-with-completion Tag to add: )))
-  (notmuch-call-notmuch-process tag (concat + tag) 
(notmuch-search-find-thread-id))
+  (notmuch-enqueue-asynch tag (concat + tag) 
(notmuch-search-find-thread-id))
   (notmuch-search-set-tags (delete-dups (sort (cons tag 
(notmuch-search-get-tags)) 'string
 
 (defun notmuch-search-remove-tag (tag)
@@ -1430,7 +1477,7 @@ The tag is removed from messages in the currently 
selected thread
 which match the current search terms.
   (interactive
(list (notmuch-select-tag-with-completion Tag to remove:  
(notmuch-search-find-thread-id
-  (notmuch-call-notmuch-process tag (concat - tag) 
(notmuch-search-find-thread-id))
+  (notmuch-enqueue-asynch tag (concat - tag) 

Re: [notmuch] [PATCH] test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.

2010-02-23 Thread Carl Worth
On Mon, 22 Feb 2010 19:42:30 -0800, Junio C Hamano gits...@pobox.com wrote:
 Please drop the above the next time.

Oops. Yes, I missed that.

 FWIW, I only said _at least_ you need consent from them, and it was not
 meant to be an exhaustive list.  blame -C -C -C may tell you more.

Fair enough.

 You are the party that wants this relicensing, not me.  Please do not
 burden me with excessive legwork for you, but help me a bit more
 proactively to make this happen.

I hope you see I haven't asked you to do any additional legwork. A
suggestion was made to construct a patch, which I did. You always have
the option of accepting or rejecting the patch as you see fit.

 Oh, I never said do not use message ID.  I said message ID alone is not
 good enough for most people.  Users of gmane and notmuch who know the
 tool they use would benefit from having message ID, _too_, but even if you
 were a user of notmuch, unless you have subscribed to the list and have
 your own archive, you wouldn't be able to say show id:frotz.

Certainly. My assumption was that in a commit message for git, readers
would naturally assume that a message ID with no additional
specification could be found in the archives of the standard git mailing
list, (which is the case here). Otherwise, I would have qualified the
message ID more specifically.

-Carl


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


Re: [notmuch] [PATCH] test-lib.sh: Add explicit license detail, with change from GPLv2 to GPLv2+.

2010-02-23 Thread Matthieu Moy
Junio C Hamano gits...@pobox.com writes:

 http://thread.gmane.org/gmane.mail.notmuch.general/1389/focus=140156
[...]
 Meanwhile, a message ID lives forever and can be used in multiple
 contexts.

 Oh, I never said do not use message ID.  I said message ID alone is not
 good enough for most people. 

FWIW, gmane allows links of the form

http://mid.gmane.org/7vaav8hpfo@alter.siamese.dyndns.org

which have the advantage of being simple to use, and still contain the
necessary information to get the message in case gmane dies.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] [PATCH] Rework saving of attachments.

2010-02-23 Thread Carl Worth
On Mon, 14 Dec 2009 10:13:58 -0800, cama...@picnicpark.org wrote:
 From: Keith Amidon ke...@nicira.com

Hi Keith,

I apologize for the extraordinarly-late review, but here it is...

I tried this patch out, wanted to like it, and almost pushed it out, but
I decided against it in its current form. Here are some thoughts:

1. The commit message (rework saving of attachments) is not
   adequate. It doesn't actually say what the commit does, (how can I
   test whether things have been reworked?). If the vagueness of the
   message is because the commit is changing several different aspects
   of behavior, then I would argue that the commit should be split up
   into separate pieces.

2. A binding to save a single attachment (with only a prefix argument to
   select which) just isn't usable. First, there's nothing in the UI to
   indicate the appropriate numbers to pass as the prefix argument,
   (other than manually counting the attachments). And second, the
   functionality is simply too hidden and non-obvious. This is most
   dangerous because in the common case of a single attachment, the 'w'
   binding will seem to be saving all attachments setting up confusion
   if the user tries to save multiple attachments with this same
   keybinding.

   Now, having a function to save a single attachment is just fine,
   (leaving someone else to hook up a binding to a particular button,
   say). So I'd accept a patch that added that, but didn't add a direct
   key-binding for it.

3. For saving multiple attachments, the feature I'd really like to see
   is the ability to specify a single directory and have all the
   attachments saved there.

Obviously, this third feature is just something different than what the
patch does, so not necessarily a reason to reject the patch. So what is
it that the patch actually does again?

I think the big advantage of the patch is getting rid of the initial
prompting save this attachment (foo)?. It occurs to me that a simpler
way to get rid of that would be to simply not ask that question when the
user hits 'w' and there *is* only a single attachment. Then, with
multiple attachments, 'w' could prompt in turn as currently.

That would leave open the ability to use 'W' for a command to write all
attachments to a particular directory.

So that's one idea, at least. What do you think?

-Carl


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


Re: [notmuch] [PATCH] Add ENVIRONMENT VARIABLES section to the man page

2010-02-23 Thread Carl Worth
On Sat, 19 Dec 2009 13:12:15 +, James Westby jw+deb...@jameswestby.net 
wrote:
 Briefly describe the NOTMUCH_CONFIG variable there.

Thanks, James! I've pushed this out now.

   I'm not sure how to phrase it to fit at the end of notmuch help,
   suggestions welcome. For now I added a traditional ENVIRONMENT
   VARIABLES section to the man page.

I had originally postponed your patch only because I wanted to try to
answer your question here about how to fit this at the end of notmuch
help as well. But it's not obvious to me that there's a good way to do
that.

-Carl


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


Re: [notmuch] [PATCH] Add an --format=(json|text) command-line option to both notmuch-search and notmuch-show.

2010-02-23 Thread Carl Worth
On Thu, 31 Dec 2009 11:17:40 -0400, da...@tethera.net wrote:
 This is an updated version of Scott Robinson's patch of
 id:1261114167-sup-8...@lisa. All of the hard work is Scott's. My
 changes to Scotts patch are 
  - change option to --format from --output
  - make a couple of calls to function points conditional on the 
function pointers being non-null
  - updated the built-in documentation and the man page
 
 I also changed the copyright of json.c to Scott. Hope that's OK with
 Scott.

Well that's embarrassing. I just went through the effort of reviewing
the old patch and basically re-constructing that same list of tasks,
(only to find out that this updated patch was already sitting in my
queue, but later).

Anyway, very well done! I've applied this now with one change:

I'm now printing thread instead of id as the JSON name for the
field with the thread id in it.

I also added a mention to the TODO file that we should fix --format=json
to not imply --entire-thread.

Thanks again, David and Scott (and we hope that all the backpacking goes
well, Scott!).

-Carl


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


[notmuch] JSON output as default [was: Re: [PATCH] Add an --output=(json|text|) command-line option...]

2010-02-23 Thread Jameson Rollins
Hey, Carl.  I mentioned this is an email a while back
(id:87eil4ygar@servo.finestructure.net), but I want to bring it up
again now that you're looking at the JSON output stuff.  I would like to
make the case for JSON being the one and only output format.  Here's the
arguments:

* JSON is a very well spec'd API
* JSON is a *very* well supported standard (it's basically well
  supported by every language)
* the JSONformat is perfectly suited for notmuch's output
* emacs has a json.el library, so it would not be hard at all to modify
  the notmuch.el to parse json output
* using only one output format would considerably reduce the code base
  in notmuch, keeping things simpler and easier to maintain

I think these are pretty good reason to just move to JSON as *the*
output format.

While I'm on this topic, let me rehash another point I made previously:
If we move to JSON output, it would be *so* sweet to provide means to
filter the output JSON fields.  The --output flag could be used to
pick the desired output fields.  For instance, the current search
output could be something like:

search --output=thread_id,date,number,author,subject,tags

while the current show output could be something like:

search --output=message_id,tags,path,header,body,attachments

This would all make things *much* easier for clients and wrappers.  For
instance, here are just a couple of things that would be made much
easier for wrapper scripts:

* Proper maildir sync (search --output=message_id,tags,path ...)

* Purging delete tagged messages (search --output=path tags:delete)

* Moving/archiving messages based on search results (search --output=path ...)

I would personally love to see this.  I think it would make notmuch
cleaner, simpler, and more powerful all at the same time.

Interested in hearing what other's thoughts on this idea are.

jamie.


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


Re: [notmuch] [PATCH] Added mail directory filename pattern support.

2010-02-23 Thread Bart Massey
In message 20100223061542.gr17...@flamingspork.com you wrote:
 On Mon, Feb 22, 2010 at 12:07:31PM -0800, Bart Massey wrote:
  Typically, the filenames in a mail directory that actually
  contain mail obey some specific format.  For example, in my
  MH email directory, all mail filenames consist only of
  digits.
  
  This patch adds support for a config file variable
  filename_pattern which maybe set to a regex used to filter
  only valid mail filenames when scanning.  Effective use of
  filename_pattern cuts down on the noise from notmuch, and
  may speed it up in some cases.
 
 What about the other way around?
 
 e.g. if anybody has ever pointed Evolution at a Maildir, you get a
 bunch of Maildir-name.ev-summary and .ev-summary-meta and .ibex.index
 and whatever.
 
 A default list of ignored patterns would be pretty easy to come up with. 

I'm not understanding your use case?  For the most common
cases, Maildir and MH, setting the appropriate
filename_pattern will ignore whatever garbage is lying
around the tree and just look at the mail messages.

Maybe my documentation is confusing?  By filter only valid
mail filenames I mean accept only valid mail filenames, not
filter out only valid mail filenames. :-)

Thanks much for any clarification you can provide.

Bart Massey
b...@cs.pdx.edu
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] JSON output as default [was: Re: [PATCH] Add an --output=(json|text|) command-line option...]

2010-02-23 Thread Carl Worth
On Tue, 23 Feb 2010 16:00:01 -0500, Jameson Rollins 
jroll...@finestructure.net wrote:
 Hey, Carl.  I mentioned this is an email a while back
 (id:87eil4ygar@servo.finestructure.net), but I want to bring it up
 again now that you're looking at the JSON output stuff.  I would like to
 make the case for JSON being the one and only output format.  Here's the
 arguments:

Oh, I'm definitely in favor of killing the %message{ format.

As soon as we get the emacs and vi frontends switched to the json
output, then that old thing can be eliminated.

 * using only one output format would considerably reduce the code base
   in notmuch, keeping things simpler and easier to maintain

But I actually still want text-only output. It will be even less
parseable than the current output, (no delimiters at all), but also
have some niceties like thread indentation, etc.

The idea there is to support direct, human-readable output for quick
command-line use. (It also means that notmuch provides a much gentler
introduction to people just experimenting with it). And I'm willing to
keep the code base just a little bit complicated for that.

 If we move to JSON output, it would be *so* sweet to provide means to
 filter the output JSON fields.  The --output flag could be used to
 pick the desired output fields.  For instance, the current search
 output could be something like:

I definitely want to enable the user to select which fields are printed.

But I don't see how that depends on JSON output. In fact, for easy shell
scripts, etc. I want to be able to do search that give me filenames,
email addresses, etc. without any delimiters at all.

I definitely want to be able to pipe single-field lists coming from
notmuch to grep, xargs, shell for loops, etc. without having to decode
JSON.

So I'm still in favor of having a plain text output going forward,
(and by default).

-Carl


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


[notmuch] [PATCH 0/4] Allow separate database directory from mail store

2010-02-23 Thread David Benjamin
This patchset separates and makes configurable the database directory from the
mail store. In the code, I have elected to call the former the 'notmuch_path'
as, of the various of names in the source code ('path', 'db_path', etc.), that
was the only one that consistently refers to the .notmuch directory.

If notmuch_path is not configured, the usual location of $MAILSTORE/.notmuch is
used.

The first of the four is an irrelevant little documentation fix that I didn't
think was worth making a new thread for.

David Benjamin (4):
  lib/database.cc: Fix function name in comment
  Pass separate notmuch_path when opening database
  Configure the database separately from mail store
  Prompt for database location in notmuch setup

 lib/database-private.h |1 +
 lib/database.cc|   30 
 lib/notmuch.h  |   32 -
 notmuch-client.h   |   11 +
 notmuch-config.c   |   59 
 notmuch-count.c|4 +-
 notmuch-dump.c |4 +-
 notmuch-new.c  |   13 --
 notmuch-reply.c|4 +-
 notmuch-restore.c  |4 +-
 notmuch-search-tags.c  |4 +-
 notmuch-search.c   |4 +-
 notmuch-setup.c|9 +++
 notmuch-show.c |4 +-
 notmuch-tag.c  |4 +-
 15 files changed, 136 insertions(+), 51 deletions(-)

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


[notmuch] [PATCH 1/4] lib/database.cc: Fix function name in comment

2010-02-23 Thread David Benjamin
notmuch_message_add_filename has a leading underscore in the name.

Signed-off-by: David Benjamin david...@mit.edu
---
 lib/database.cc |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index 2b5b64d..1bb24ec 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -739,7 +739,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
 
 /* Before version 1, each message document had its filename in the
  * data field. Copy that into the new format by calling
- * notmuch_message_add_filename.
+ * _notmuch_message_add_filename.
  */
 if (version  1) {
notmuch_query_t *query = notmuch_query_create (notmuch, );
-- 
1.7.0.18.g39b3

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


[notmuch] [PATCH 2/4] Pass separate notmuch_path when opening database

2010-02-23 Thread David Benjamin
Avoid hard-coding $MAILSTORE/.notmuch in the database layer.

Signed-off-by: David Benjamin david...@mit.edu
---
 lib/database-private.h |1 +
 lib/database.cc|   28 ++--
 lib/notmuch.h  |   32 
 notmuch-client.h   |4 
 notmuch-config.c   |   29 +
 notmuch-count.c|4 ++--
 notmuch-dump.c |4 ++--
 notmuch-new.c  |3 ++-
 notmuch-reply.c|4 ++--
 notmuch-restore.c  |4 ++--
 notmuch-search-tags.c  |4 ++--
 notmuch-search.c   |4 ++--
 notmuch-show.c |4 ++--
 notmuch-tag.c  |4 ++--
 14 files changed, 86 insertions(+), 43 deletions(-)

diff --git a/lib/database-private.h b/lib/database-private.h
index 41918d7..59ed117 100644
--- a/lib/database-private.h
+++ b/lib/database-private.h
@@ -38,6 +38,7 @@ struct _notmuch_database {
 notmuch_bool_t exception_reported;
 
 char *path;
+char *notmuch_path;
 
 notmuch_bool_t needs_upgrade;
 notmuch_database_mode_t mode;
diff --git a/lib/database.cc b/lib/database.cc
index 1bb24ec..f54fbd1 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -437,14 +437,14 @@ parse_references (void *ctx,
 }
 
 notmuch_database_t *
-notmuch_database_create (const char *path)
+notmuch_database_create (const char *path,
+const char *notmuch_path)
 {
 notmuch_database_t *notmuch = NULL;
-char *notmuch_path = NULL;
 struct stat st;
 int err;
 
-if (path == NULL) {
+if (path == NULL || notmuch_path == NULL) {
fprintf (stderr, Error: Cannot create a database for a NULL path.\n);
goto DONE;
 }
@@ -462,8 +462,6 @@ notmuch_database_create (const char *path)
goto DONE;
 }
 
-notmuch_path = talloc_asprintf (NULL, %s/%s, path, .notmuch);
-
 err = mkdir (notmuch_path, 0755);
 
 if (err) {
@@ -473,13 +471,11 @@ notmuch_database_create (const char *path)
 }
 
 notmuch = notmuch_database_open (path,
+notmuch_path,
 NOTMUCH_DATABASE_MODE_READ_WRITE);
 notmuch_database_upgrade (notmuch, NULL, NULL);
 
   DONE:
-if (notmuch_path)
-   talloc_free (notmuch_path);
-
 return notmuch;
 }
 
@@ -496,17 +492,17 @@ _notmuch_database_ensure_writable (notmuch_database_t 
*notmuch)
 
 notmuch_database_t *
 notmuch_database_open (const char *path,
+  const char *notmuch_path,
   notmuch_database_mode_t mode)
 {
 notmuch_database_t *notmuch = NULL;
-char *notmuch_path = NULL, *xapian_path = NULL;
+char *xapian_path = NULL;
 struct stat st;
 int err;
 unsigned int i, version;
 
-if (asprintf (notmuch_path, %s/%s, path, .notmuch) == -1) {
-   notmuch_path = NULL;
-   fprintf (stderr, Out of memory\n);
+if (path == NULL || notmuch_path == NULL) {
+   fprintf (stderr, Error: Cannot create a database for a NULL path.\n);
goto DONE;
 }
 
@@ -611,8 +607,6 @@ notmuch_database_open (const char *path,
 }
 
   DONE:
-if (notmuch_path)
-   free (notmuch_path);
 if (xapian_path)
free (xapian_path);
 
@@ -645,6 +639,12 @@ notmuch_database_get_path (notmuch_database_t *notmuch)
 return notmuch-path;
 }
 
+const char *
+notmuch_database_get_notmuch_path (notmuch_database_t *notmuch)
+{
+return notmuch-notmuch_path;
+}
+
 unsigned int
 notmuch_database_get_version (notmuch_database_t *notmuch)
 {
diff --git a/lib/notmuch.h b/lib/notmuch.h
index d3e50a7..943c297 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -120,12 +120,12 @@ typedef struct _notmuch_tags notmuch_tags_t;
 typedef struct _notmuch_directory notmuch_directory_t;
 typedef struct _notmuch_filenames notmuch_filenames_t;
 
-/* Create a new, empty notmuch database located at 'path'.
+/* Create a new, empty notmuch database located at 'notmuch_path',
+ * indexing mail store 'path'
  *
  * The path should be a top-level directory to a collection of
  * plain-text email messages (one message per file). This call will
- * create a new .notmuch directory within 'path' where notmuch will
- * store its data.
+ * create directory 'notmuch_path' where notmuch will store its data.
  *
  * After a successful call to notmuch_database_create, the returned
  * database will be open so the caller should call
@@ -140,7 +140,8 @@ typedef struct _notmuch_filenames notmuch_filenames_t;
  * an error message on stderr).
  */
 notmuch_database_t *
-notmuch_database_create (const char *path);
+notmuch_database_create (const char *path,
+const char *notmuch_path);
 
 typedef enum {
 NOTMUCH_DATABASE_MODE_READ_ONLY = 0,
@@ -150,16 +151,15 @@ typedef enum {
 /* XXX: I think I'd like this to take an extra argument of
  * notmuch_status_t* for returning a status value on failure. */
 
-/* Open an existing notmuch database located at 'path'.

[notmuch] [PATCH 4/4] Prompt for database location in notmuch setup

2010-02-23 Thread David Benjamin
Signed-off-by: David Benjamin david...@mit.edu
---
 notmuch-setup.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/notmuch-setup.c b/notmuch-setup.c
index 622bbaa..e3c8465 100644
--- a/notmuch-setup.c
+++ b/notmuch-setup.c
@@ -159,6 +159,15 @@ notmuch_setup_command (unused (void *ctx),
notmuch_config_set_database_path (config, absolute_path);
 }
 
+prompt (Location for notmuch database [%s]: ,
+   notmuch_config_get_database_notmuch_path (config));
+if (strlen (response)) {
+   const char *absolute_path;
+
+   absolute_path = make_path_absolute (ctx, response);
+   notmuch_config_set_database_notmuch_path (config, absolute_path);
+}
+
 if (! notmuch_config_save (config)) {
if (is_new)
  welcome_message_post_setup ();
-- 
1.7.0.18.g39b3

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