[notmuch] [PATCH v3] notmuch-query.el: new file to support access to the notmuch database.

2010-04-05 Thread David Edmondson
On Mon,  5 Apr 2010 13:46:16 -0300, david at tethera.net wrote:
> diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
> new file mode 100644
> index 000..3f1a7b3
> --- /dev/null
> +++ b/emacs/notmuch-query.el
> @@ -0,0 +1,90 @@
> +; notmuch-query.el --- provide an emacs api to query notmuch

Should this comment prefix be ';;'? A single ';' is indented way over to
the right by default.

> +(defun notmuch-query-map-aux  (mapper function seq)
> +  "private function to do the actual mapping and flattening"
> +
> +  (apply 'append
> +  (mapcar
> +(lambda (tree)
> +  (funcall mapper fn tree))
> +seq)))
> +
> +

There are a bunch of spurious blank lines in various places.

dme.
-- 
David Edmondson, http://dme.org


Notmuch release 0.1 now available

2010-04-05 Thread Carl Worth
In trying to get notmuch to grow up a little bit, I've just added a
version number (0.1 initially) and have started doing releases. My idea
for now is to have 2-part versions for releases, and 3-part versions to
indicate intermediate states within git.

For example, I just released notmuch 0.1, current git clone will
create notmuch 0.1.1, and the next anticipated release will be 0.2.

The first release announcement is below, with very thin release notes. I
hope to have better release announcements in the future. For this, I'll
need the help of all contributors. Here's my request:

When you submit a patch adding a new feature to notmuch, please
include with it an edit to the NEWS file adding a sentence or
paragraph to the top of that file.

Thanks, and have fun out there.

-Carl

Where to obtain notmuch 0.1
===
  http://notmuchmail.org/releases/notmuch-0.1.tar.gz

Which can be verified with:

  http://notmuchmail.org/releases/notmuch-0.1.tar.gz.sha1
  fa390b7e652bebbdd5c178a60d8056e662df03ba  notmuch-0.1.tar.gz

  http://notmuchmail.org/releases/notmuch-0.1.tar.gz.sha1.asc
  (signed by Carl Worth)

What's new in notmuch 0.1
=
This is the first release of the notmuch mail system.

It includes the libnotmuch library, the notmuch command-line
interface, and an emacs-based interface to notmuch.

Note: Notmuch will work best with Xapian 1.0.18 (or later) or Xapian
1.1.4 (or later). Previous versions of Xapian (whether 1.0 or 1.1) had
a performance bug that made notmuch very slow when modifying
tags. This would cause distracting pauses when reading mail while
notmuch would wait for Xapian when removing the "inbox" and "unread"
tags from messages in a thread.

What is notmuch
===
Notmuch is a system for indexing, searching, reading, and tagging
large collections of email messages in maildir or mh format. It uses
the Xapian library to provide fast, full-text search with a convenient
search syntax.

For more about notmuch, see http://notmuchmail.org
-- 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/20100405/df78d232/attachment.pgp>


[notmuch] Bulk message tagging

2010-04-05 Thread Jason White
Xavier Maillard  wrote:

> Sadly, git is not really something I know wll enough to play with
> all this stuff :(

http://progit.org/book/



[notmuch] vala, this is notmuch. notmuch, this is vala

2010-04-05 Thread Adrien Bustany
On Mon, 5 Apr 2010 14:50:04 +0100, Enrico Zini 
wrote:
> On Mon, Apr 05, 2010 at 02:49:23PM +0200, Sebastian Spaeth wrote:
> 
>> So I bound notmuch.so to vala (at least what I needed) and played with
>> the code a bit. The resulting 100 lines of vala code are here:
> 
> Ooh, a .vapi for notmuch, that is something that makes me happy. It
> could be shipped with notmuch proper, even if it's rough now, and then
> improved as people use it.
We actually realized with spaetz that we duplicated work on this one... I
also have a vapi file, which is working pretty well so far (I've used
almost all the functions in it). I guess we should merge them, and include
the result in notmuch's tree.

See
http://git.mymadcat.com/index.php/p/abitmore/source/tree/master/src/notmuch.vapi
> 
> 
>> Usage: "./vnotmuch Seb" will output all 'to:' addresses according to
>> frequency for all messages where to, cc, or bcc matches "Seb*". It also
>> filters with AND "from:yourprimarymailaddress". Just
>> "./vnotmuch" outputs all addresses that you ever sent mails to. It
never
>> writes/modifies your db.
> 
> Now I use "lbdb", which gets very slow as time goes. You idea creates a
> most definitely superior system.
> 
> 
>> Just a teaser to make you interested in vala :).
> 
> As it happens, some of us already are interested.
> 
> As soon as automatic gobject introspection based language bindings
> become workable for at least python and perl, my plan is to rewrite
> buffy[1] in Vala.
> 
> A second plan would be to have buffy show stats for saved notmuch
> queries as well as (or instead of) mail folders.
> 
> It's very nice to know I wouldn't be the only person playing with Vala
> around here.
Make them two ;)

Cheers

Adrien

> 
> 
> Ciao,
> 
> Enrico
> 
> [1] http://packages.debian.org/sid/buffy


[notmuch] vala, this is notmuch. notmuch, this is vala

2010-04-05 Thread Enrico Zini
On Mon, Apr 05, 2010 at 02:49:23PM +0200, Sebastian Spaeth wrote:

> So I bound notmuch.so to vala (at least what I needed) and played with
> the code a bit. The resulting 100 lines of vala code are here:

Ooh, a .vapi for notmuch, that is something that makes me happy. It
could be shipped with notmuch proper, even if it's rough now, and then
improved as people use it.


> Usage: "./vnotmuch Seb" will output all 'to:' addresses according to
> frequency for all messages where to, cc, or bcc matches "Seb*". It also
> filters with AND "from:yourprimarymailaddress". Just
> "./vnotmuch" outputs all addresses that you ever sent mails to. It never
> writes/modifies your db.

Now I use "lbdb", which gets very slow as time goes. You idea creates a
most definitely superior system.


> Just a teaser to make you interested in vala :).

As it happens, some of us already are interested.

As soon as automatic gobject introspection based language bindings
become workable for at least python and perl, my plan is to rewrite
buffy[1] in Vala.

A second plan would be to have buffy show stats for saved notmuch
queries as well as (or instead of) mail folders.

It's very nice to know I wouldn't be the only person playing with Vala
around here.


Ciao,

Enrico

[1] http://packages.debian.org/sid/buffy
-- 
GPG key: 4096R/E7AD5568 2009-05-08 Enrico Zini 
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20100405/d04bdd78/attachment.pgp>


[notmuch] vala, this is notmuch. notmuch, this is vala

2010-04-05 Thread Sebastian Spaeth
I really want to replace my address book with dynamic notmuch searches
and while python gives me those in 0.3 seconds or so, I wanted better.

So I bound notmuch.so to vala (at least what I needed) and played with
the code a bit. The resulting 100 lines of vala code are here:

http://github.com/spaetz/vala-notmuch/tree/master/src

For those without vala, this is the generated C file which can be
compiled with './make' in the same directory:

http://github.com/spaetz/vala-notmuch/blob/static-sources/src/notmuch.c

Usage: "./vnotmuch Seb" will output all 'to:' addresses according to
frequency for all messages where to, cc, or bcc matches "Seb*". It also
filters with AND "from:yourprimarymailaddress". Just
"./vnotmuch" outputs all addresses that you ever sent mails to. It never
writes/modifies your db.

The only output you get are the lowercased email addresses and the
frequency, no names are preserved/output.

It is fast. This is my "./vnotmuch Seb" search over 14.5k mails with
857 mails from my primary account:
real0m0.026s
user0m0.000s
sys 0m0.020s

Just a teaser to make you interested in vala :).

Sebastian


[notmuch] [PATCH v3] notmuch-query.el: new file to support access to the notmuch database.

2010-04-05 Thread da...@tethera.net
From: David Bremner 

Initially this file provides one main function
notmuch-query-get-threads, which takes a set of search terms, and
returns a parsed set of matching threads as a lisp data structure.

A set of notmuch-query-map-* functions are provided to help map
functions over the data structure.

The function notmuch-query-get-message-ids uses this machinery to get
the set of message-ids matching a query.
---

Commentary on this revision of the patch.
- Rebased to current master.
- Last time I checked, used by dme's json rewrite of the emacs ui
- Warnings eliminated by including the new notmuch-lib.el

 emacs/Makefile.local   |1 +
 emacs/notmuch-query.el |   90 
 2 files changed, 91 insertions(+), 0 deletions(-)
 create mode 100644 emacs/notmuch-query.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 95b6fa4..626a4e5 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -4,6 +4,7 @@ dir := emacs
 emacs_sources := \
$(dir)/notmuch-lib.el \
$(dir)/notmuch.el \
+   $(dir)/notmuch-query.el \
$(dir)/notmuch-show.el

 emacs_bytecode := $(subst .el,.elc,$(emacs_sources))
diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
new file mode 100644
index 000..3f1a7b3
--- /dev/null
+++ b/emacs/notmuch-query.el
@@ -0,0 +1,90 @@
+; notmuch-query.el --- provide an emacs api to query notmuch
+;
+; Copyright ?? David Bremner
+;
+; This file is part of Notmuch.
+;
+; Notmuch is free software: you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by
+; the Free Software Foundation, either version 3 of the License, or
+; (at your option) any later version.
+;
+; Notmuch is distributed in the hope that it will be useful, but
+; WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+; General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with Notmuch.  If not, see .
+;
+; Authors: David Bremner 
+
+(require 'notmuch-lib)
+(require 'json)
+
+(defun notmuch-query-get-threads (search-terms  options)
+  "Return a list of threads of messages matching SEARCH-TERMS.
+
+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.
+"
+  (let  ((args (append '("show" "--format=json") search-terms))
+(json-object-type 'plist)
+(json-array-type 'list)
+(json-false 'nil))
+(with-temp-buffer
+  (progn
+   (apply 'call-process (append (list notmuch-command nil t nil) args))
+   (goto-char (point-min))
+   (json-read)
+
+;;
+;; Mapping functions across collections of messages.
+
+(defun notmuch-query-map-aux  (mapper function seq)
+  "private function to do the actual mapping and flattening"
+
+  (apply 'append
+(mapcar
+  (lambda (tree)
+(funcall mapper fn tree))
+  seq)))
+
+
+(defun notmuch-query-map-threads (fn threads)
+  "apply FN to every thread in  THREADS. Flatten results to a list.
+
+See the function notmuch-query-get-threads for more information."
+
+  (notmuch-query-map-aux 'notmuch-query-map-forest fn threads))
+
+
+(defun notmuch-query-map-forest (fn forest)
+  "apply function to every message in a forest. Flatten results to a list.
+
+See the function notmuch-query-get-threads for more information.
+"
+
+  (notmuch-query-map-aux 'notmuch-query-map-tree fn forest))
+
+
+(defun notmuch-query-map-tree (fn tree)
+  "Apply function FN to every message in TREE. Flatten results to a list
+
+See the function notmuch-query-get-threads for more information."
+
+  (cons (funcall fn (car tree)) (notmuch-query-map-forest fn (cadr tree
+
+
+;;
+;; Predefined queries
+
+(defun notmuch-query-get-message-ids ( search-terms)
+  "Return a list of message-ids of messages that match SEARCH-TERMS"
+
+  (notmuch-query-map-threads
+   (lambda (msg) (plist-get msg :id))
+   (notmuch-query-get-threads search-terms)))
+
+(provide 'notmuch-query)
-- 
1.7.0



[notmuch] vala, this is notmuch. notmuch, this is vala

2010-04-05 Thread Carl Worth
On Mon, 05 Apr 2010 16:12:02 +0200, Adrien Bustany  
wrote:
> We actually realized with spaetz that we duplicated work on this one... I
> also have a vapi file, which is working pretty well so far (I've used
> almost all the functions in it). I guess we should merge them, and include
> the result in notmuch's tree.

Very interesting stuff. Yes, please let me know when things are merged
and I'll be glad to carry this in the notmuch repository.

-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/20100405/09fbe2dd/attachment.pgp>


[notmuch] [PATCH v3] notmuch-query.el: new file to support access to the notmuch database.

2010-04-05 Thread Carl Worth
On Mon,  5 Apr 2010 13:46:16 -0300, david at tethera.net wrote:
> Commentary on this revision of the patch.
>   - Rebased to current master.
>   - Last time I checked, used by dme's json rewrite of the emacs ui
> - Warnings eliminated by including the new notmuch-lib.el

Very nice stuff indeed. I incorporated the two minor style issues that
David E. mentioned in his reply. I do think that
"notmuch-query-get-threads" would be better named something much closer
to "notmuch-search". But we can wait to clear up the naming until we get
everything switched to this and the old calls to "notmuch search"
removed.

-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/20100405/7dc9eae2/attachment.pgp>


[notmuch] [PATCH] format_part_json: part_content->data is not null terminated

2010-04-05 Thread Carl Worth
On Mon, 05 Apr 2010 10:36:38 +0100, David Edmondson  wrote:
> Agreed. How about this patch:
>   
> http://github.com/dme/notmuch/commit/5f23ae341788d28e455e53488d184d8caaa618c5
> ?

Thanks, David.

(And thanks also, to David Bremner for providing a version with
cleaned-up whitespace issues.)

This is pushed now.

-Carl

PS. David, (Edmonson), putting the actual patch into the email message
is preferred. That lets me reply for any review necessary, and also
apply the patch when reading email when not online.
-- 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/20100405/f6848b65/attachment.pgp>


[notmuch] [PATCH] format_part_json: part_content->data is not null terminated

2010-04-05 Thread David Edmondson
On Thu, 01 Apr 2010 14:05:06 +0200, Michal Sojka  wrote:
> On Thu, 04 Mar 2010, Gregor Hoffleit wrote:
> > -   printf (", \"content\": %s", json_quote_str (ctx, (char *) 
> > part_content->data));
> > +   content_data = talloc_size (ctx, part_content->len+1);
> > +   memcpy (content_data, (char *)part_content->data, part_content->len+1);
> > +   content_data[part_content->len] = 0;
> > +   printf (", \"content\": %s", json_quote_str (ctx, content_data));
> 
> What about modifying json_quote_str() to accept additional parameter
> len? If I have 10MB attachment to the email, this unnecessary copy is
> quite expensive, isn't it?

Agreed. How about this patch:
  http://github.com/dme/notmuch/commit/5f23ae341788d28e455e53488d184d8caaa618c5
?

dme.
-- 
David Edmondson, http://dme.org


[notmuch] pull request [was Re: pull request]

2010-04-05 Thread Carl Worth
On Sun, 04 Apr 2010 09:08:34 +0100, David Edmondson  wrote:
> It's the 'for-cworth' branch of git://github.com/dme/notmuch.git.
> 
> There's also a simple update to tell git to ignore notmuch-shared.

Thanks. This is pushed.

-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/20100405/5ba0842b/attachment.pgp>


[notmuch] Bulk message tagging

2010-04-05 Thread Xavier Maillard
On Sun, 4 Apr 2010 15:46:40 +1000, Jason White  wrote:
> Xavier Maillard  wrote:
>  
> > You are right I forgot to mention I am using the GNU Emacs
> > interface exclusively.
> 
> Then it's the * command from the buffer with the mail threads dislayed.
> See also the ?h command for further help.

Thank you. It worked perfectly though it is not mentionned that
you have to do the search *first* and press the '*' then after. I
would have thought to do a "all-in-one-operation" -i.e press the
* key, enter a search criteria and enter a list of tags -.

Regards,

Xavier


[notmuch] Bulk message tagging

2010-04-05 Thread Xavier Maillard
On Sun, 04 Apr 2010 07:38:03 -0400, Jesse Rosenthal  
wrote:
> On Sun, 04 Apr 2010 06:37:53 +0200, Xavier Maillard  wrote:
> > Is there an easy way to mark a whole bunch of message (restricted
> > in a region, result of a search, ...) ?
> 
> In addition to the "*" command that was mentioned, there is a patch I
> wrote to tag messages in search view by region in emacs. You can find it

Sounds interesting. * is good when your search criteria is
perfect but you proposed patch is a good companion for all the
rest.

Sadly, git is not really something I know wll enough to play with
all this stuff :(

Xavier


[notmuch] Debian package update ?

2010-04-05 Thread Xavier Maillard
Hi,

I feel like being far behind master with my current (official)
Debian package. Is there any chance to get a more recent one soon
?

I know I was given instructions to build my own from the Git
repository but I am still stuck and I did not get any success in
doing so :/

Regards,

Xavier


[notmuch] cnotmuch 0.1.1 release

2010-04-05 Thread Sebastian Spaeth
On 2010-04-03, C?dric Cabessa wrote:
> libnotmuch.so is in my personal folder, I'd like to use LD_LIBRARY_PATH for
> that.
> The problem is that find_library does not read this variable, but hopefully
> CDLL does.
> 
> I suggest to not use find_library. If the library do not exist, we just have
> to catch the exception.
> The other advantage is that CDLL allow us to choose a library version
> (find_library will always take the latest).

Sounds reasonable enough. When I coded this, there was no official
library version yet, so searching for the latest sounded useful
enough. Now that we have an official shared lib, I'm just going to apply
your patch.

Thanks, hope it is useful
Sebastian


[notmuch] Debian package update ?

2010-04-05 Thread Xavier Maillard
Hi,

I feel like being far behind master with my current (official)
Debian package. Is there any chance to get a more recent one soon
?

I know I was given instructions to build my own from the Git
repository but I am still stuck and I did not get any success in
doing so :/

Regards,

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


Re: [notmuch] Bulk message tagging

2010-04-05 Thread Xavier Maillard
On Sun, 04 Apr 2010 07:38:03 -0400, Jesse Rosenthal jrosent...@jhu.edu wrote:
 On Sun, 04 Apr 2010 06:37:53 +0200, Xavier Maillard x...@gnu.org wrote:
  Is there an easy way to mark a whole bunch of message (restricted
  in a region, result of a search, ...) ?
 
 In addition to the * command that was mentioned, there is a patch I
 wrote to tag messages in search view by region in emacs. You can find it

Sounds interesting. * is good when your search criteria is
perfect but you proposed patch is a good companion for all the
rest.

Sadly, git is not really something I know wll enough to play with
all this stuff :(

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


Re: [notmuch] Bulk message tagging

2010-04-05 Thread Jason White
Xavier Maillard x...@gnu.org wrote:
 
 Sadly, git is not really something I know wll enough to play with
 all this stuff :(

http://progit.org/book/

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


Re: [notmuch] [PATCH] format_part_json: part_content-data is not null terminated

2010-04-05 Thread David Edmondson
On Thu, 01 Apr 2010 14:05:06 +0200, Michal Sojka sojk...@fel.cvut.cz wrote:
 On Thu, 04 Mar 2010, Gregor Hoffleit wrote:
  -   printf (, \content\: %s, json_quote_str (ctx, (char *) 
  part_content-data));
  +   content_data = talloc_size (ctx, part_content-len+1);
  +   memcpy (content_data, (char *)part_content-data, part_content-len+1);
  +   content_data[part_content-len] = 0;
  +   printf (, \content\: %s, json_quote_str (ctx, content_data));
 
 What about modifying json_quote_str() to accept additional parameter
 len? If I have 10MB attachment to the email, this unnecessary copy is
 quite expensive, isn't it?

Agreed. How about this patch:
  http://github.com/dme/notmuch/commit/5f23ae341788d28e455e53488d184d8caaa618c5
?

dme.
-- 
David Edmondson, http://dme.org
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] vala, this is notmuch. notmuch, this is vala

2010-04-05 Thread Sebastian Spaeth
I really want to replace my address book with dynamic notmuch searches
and while python gives me those in 0.3 seconds or so, I wanted better.

So I bound notmuch.so to vala (at least what I needed) and played with
the code a bit. The resulting 100 lines of vala code are here:

http://github.com/spaetz/vala-notmuch/tree/master/src

For those without vala, this is the generated C file which can be
compiled with './make' in the same directory:

http://github.com/spaetz/vala-notmuch/blob/static-sources/src/notmuch.c

Usage: ./vnotmuch Seb will output all 'to:' addresses according to
frequency for all messages where to, cc, or bcc matches Seb*. It also
filters with AND from:yourprimarymailaddress. Just
./vnotmuch outputs all addresses that you ever sent mails to. It never
writes/modifies your db.

The only output you get are the lowercased email addresses and the
frequency, no names are preserved/output.

It is fast. This is my ./vnotmuch Seb search over 14.5k mails with
857 mails from my primary account:
real0m0.026s
user0m0.000s
sys 0m0.020s

Just a teaser to make you interested in vala :).

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


Re: [notmuch] vala, this is notmuch. notmuch, this is vala

2010-04-05 Thread Enrico Zini
On Mon, Apr 05, 2010 at 02:49:23PM +0200, Sebastian Spaeth wrote:

 So I bound notmuch.so to vala (at least what I needed) and played with
 the code a bit. The resulting 100 lines of vala code are here:

Ooh, a .vapi for notmuch, that is something that makes me happy. It
could be shipped with notmuch proper, even if it's rough now, and then
improved as people use it.


 Usage: ./vnotmuch Seb will output all 'to:' addresses according to
 frequency for all messages where to, cc, or bcc matches Seb*. It also
 filters with AND from:yourprimarymailaddress. Just
 ./vnotmuch outputs all addresses that you ever sent mails to. It never
 writes/modifies your db.

Now I use lbdb, which gets very slow as time goes. You idea creates a
most definitely superior system.


 Just a teaser to make you interested in vala :).

As it happens, some of us already are interested.

As soon as automatic gobject introspection based language bindings
become workable for at least python and perl, my plan is to rewrite
buffy[1] in Vala.

A second plan would be to have buffy show stats for saved notmuch
queries as well as (or instead of) mail folders.

It's very nice to know I wouldn't be the only person playing with Vala
around here.


Ciao,

Enrico

[1] http://packages.debian.org/sid/buffy
-- 
GPG key: 4096R/E7AD5568 2009-05-08 Enrico Zini enr...@enricozini.org


signature.asc
Description: Digital signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [notmuch] pull request [was Re: pull request]

2010-04-05 Thread Carl Worth
On Sun, 04 Apr 2010 09:08:34 +0100, David Edmondson d...@dme.org wrote:
 It's the 'for-cworth' branch of git://github.com/dme/notmuch.git.
 
 There's also a simple update to tell git to ignore notmuch-shared.

Thanks. This is pushed.

-Carl


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


[notmuch] [PATCH v3] notmuch-query.el: new file to support access to the notmuch database.

2010-04-05 Thread david
From: David Bremner brem...@unb.ca

Initially this file provides one main function
notmuch-query-get-threads, which takes a set of search terms, and
returns a parsed set of matching threads as a lisp data structure.

A set of notmuch-query-map-* functions are provided to help map
functions over the data structure.

The function notmuch-query-get-message-ids uses this machinery to get
the set of message-ids matching a query.
---

Commentary on this revision of the patch.
- Rebased to current master.
- Last time I checked, used by dme's json rewrite of the emacs ui
- Warnings eliminated by including the new notmuch-lib.el

 emacs/Makefile.local   |1 +
 emacs/notmuch-query.el |   90 
 2 files changed, 91 insertions(+), 0 deletions(-)
 create mode 100644 emacs/notmuch-query.el

diff --git a/emacs/Makefile.local b/emacs/Makefile.local
index 95b6fa4..626a4e5 100644
--- a/emacs/Makefile.local
+++ b/emacs/Makefile.local
@@ -4,6 +4,7 @@ dir := emacs
 emacs_sources := \
$(dir)/notmuch-lib.el \
$(dir)/notmuch.el \
+   $(dir)/notmuch-query.el \
$(dir)/notmuch-show.el
 
 emacs_bytecode := $(subst .el,.elc,$(emacs_sources))
diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
new file mode 100644
index 000..3f1a7b3
--- /dev/null
+++ b/emacs/notmuch-query.el
@@ -0,0 +1,90 @@
+; notmuch-query.el --- provide an emacs api to query notmuch
+;
+; Copyright © David Bremner
+;
+; This file is part of Notmuch.
+;
+; Notmuch is free software: you can redistribute it and/or modify it
+; under the terms of the GNU General Public License as published by
+; the Free Software Foundation, either version 3 of the License, or
+; (at your option) any later version.
+;
+; Notmuch is distributed in the hope that it will be useful, but
+; WITHOUT ANY WARRANTY; without even the implied warranty of
+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+; General Public License for more details.
+;
+; You should have received a copy of the GNU General Public License
+; along with Notmuch.  If not, see http://www.gnu.org/licenses/.
+;
+; Authors: David Bremner da...@tethera.net
+
+(require 'notmuch-lib)
+(require 'json)
+
+(defun notmuch-query-get-threads (search-terms rest options)
+  Return a list of threads of messages matching SEARCH-TERMS.
+
+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.
+
+  (let  ((args (append '(show --format=json) search-terms))
+(json-object-type 'plist)
+(json-array-type 'list)
+(json-false 'nil))
+(with-temp-buffer
+  (progn
+   (apply 'call-process (append (list notmuch-command nil t nil) args))
+   (goto-char (point-min))
+   (json-read)
+
+;;
+;; Mapping functions across collections of messages.
+
+(defun notmuch-query-map-aux  (mapper function seq)
+  private function to do the actual mapping and flattening
+
+  (apply 'append
+(mapcar
+  (lambda (tree)
+(funcall mapper fn tree))
+  seq)))
+
+
+(defun notmuch-query-map-threads (fn threads)
+  apply FN to every thread in  THREADS. Flatten results to a list.
+
+See the function notmuch-query-get-threads for more information.
+
+  (notmuch-query-map-aux 'notmuch-query-map-forest fn threads))
+
+
+(defun notmuch-query-map-forest (fn forest)
+  apply function to every message in a forest. Flatten results to a list.
+
+See the function notmuch-query-get-threads for more information.
+
+
+  (notmuch-query-map-aux 'notmuch-query-map-tree fn forest))
+
+
+(defun notmuch-query-map-tree (fn tree)
+  Apply function FN to every message in TREE. Flatten results to a list
+
+See the function notmuch-query-get-threads for more information.
+
+  (cons (funcall fn (car tree)) (notmuch-query-map-forest fn (cadr tree
+
+
+;;
+;; Predefined queries
+
+(defun notmuch-query-get-message-ids (rest search-terms)
+  Return a list of message-ids of messages that match SEARCH-TERMS
+
+  (notmuch-query-map-threads
+   (lambda (msg) (plist-get msg :id))
+   (notmuch-query-get-threads search-terms)))
+
+(provide 'notmuch-query)
-- 
1.7.0

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


Re: [notmuch] [PATCH] format_part_json: part_content-data is not null terminated

2010-04-05 Thread Carl Worth
On Mon, 05 Apr 2010 10:36:38 +0100, David Edmondson d...@dme.org wrote:
 Agreed. How about this patch:
   
 http://github.com/dme/notmuch/commit/5f23ae341788d28e455e53488d184d8caaa618c5
 ?

Thanks, David.

(And thanks also, to David Bremner for providing a version with
cleaned-up whitespace issues.)

This is pushed now.

-Carl

PS. David, (Edmonson), putting the actual patch into the email message
is preferred. That lets me reply for any review necessary, and also
apply the patch when reading email when not online.


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


Re: [notmuch] [PATCH v3] notmuch-query.el: new file to support access to the notmuch database.

2010-04-05 Thread Carl Worth
On Mon,  5 Apr 2010 13:46:16 -0300, da...@tethera.net wrote:
 Commentary on this revision of the patch.
   - Rebased to current master.
   - Last time I checked, used by dme's json rewrite of the emacs ui
 - Warnings eliminated by including the new notmuch-lib.el

Very nice stuff indeed. I incorporated the two minor style issues that
David E. mentioned in his reply. I do think that
notmuch-query-get-threads would be better named something much closer
to notmuch-search. But we can wait to clear up the naming until we get
everything switched to this and the old calls to notmuch search
removed.

-Carl


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