output file argument to notmuch dump.

2011-10-10 Thread David Bremner
On Mon, 10 Oct 2011 09:41:47 -0700, Jameson Graef Rollins  wrote:

> >notmuch --stdout=foo.txt dump
> > 
> > could be dealt with later.
> 
> I realize the later probably requires more work, since we would have to
> replace all print calls with a new function, but I think it's the
> cleaner and more elegant solution.  There's no reason to have an output
> redirection option for "dump"s and not for any of the other commands.

As far as I know, freopen(3) makes this a one-liner. I think the hardest
part of this would be figuring out the name of the option ;)

d





emacs email appears empty

2011-10-10 Thread David Bremner
On Tue, 11 Oct 2011 10:02:48 +1100, Brian May  wrote:
> I also have attached an email with nothing but the signature. This
> email comes out completely blank without any option to see the
> signature. Not sure if this is expected or not.
> 

I can confirm the latter is a bug in 0.9~rc2

David


Re: output file argument to notmuch dump.

2011-10-10 Thread David Bremner
On Mon, 10 Oct 2011 09:41:47 -0700, Jameson Graef Rollins 
 wrote:

> >notmuch --stdout=foo.txt dump
> > 
> > could be dealt with later.
> 
> I realize the later probably requires more work, since we would have to
> replace all print calls with a new function, but I think it's the
> cleaner and more elegant solution.  There's no reason to have an output
> redirection option for "dump"s and not for any of the other commands.

As far as I know, freopen(3) makes this a one-liner. I think the hardest
part of this would be figuring out the name of the option ;)

d



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


Re: [PATCH 2/4] emacs: Support a message-mode switch function in notmuch-mua

2011-10-10 Thread Jameson Graef Rollins
Another question about this feature: how do you make the window (frame)
go away after the email is sent?

jamie.


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


Re: output file argument to notmuch dump.

2011-10-10 Thread Jameson Graef Rollins
On Sun, 09 Oct 2011 13:01:53 -0300, David Bremner  wrote:
> Another option occured to me that is consistent at least with notmuch
> tag and notmuch show would be to support the following transitional
> syntaxes
> 
> notmuch dump file
> notmuch dump file [--] search terms
> notmuch dump -- search terms
> 
> the first two could then be deprecated, and eventually the syntax
> 
> notmuch dump search terms 
> 
> could be enabled.

Hey, David.  I think this is a fine approach, Go with the transitional
"--" separator for one release or so, with a deprecation warning, and
then move to the standard form in the release after that.

> the question of whether to support 
> 
> notmuch dump --file foo.txt
> 
> or something like 
> 
>notmuch --stdout=foo.txt dump
> 
> could be dealt with later.

I realize the later probably requires more work, since we would have to
replace all print calls with a new function, but I think it's the
cleaner and more elegant solution.  There's no reason to have an output
redirection option for "dump"s and not for any of the other commands.

jamie.




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


Re: [PATCH 2/4] emacs: Support a message-mode switch function in notmuch-mua

2011-10-10 Thread Jameson Graef Rollins
Hey, Thomas.  I think these are all totally reasonable emacs
improvements, and I think we should merge them all.

I particularly like this feature to launch compose buffers in new
frames.  Thanks so much for figuring it out.  I had hacked up something
for myself but your solution is *much* more elegant and Just Works.
Thanks!

However, I find the customization variable a bit clunky.  Since I wasn't
presented with any options in the customization, I didn't know what to
put in.  I copy and pasted "switch-to-buffer-other-frame" into the
customization field but that didn't work since I didn't protect the
function name.  Finally I got it to work by putting in
"'switch-to-buffer-other-frame" (with the initial "'").

So I definitely love this feature, but can we make the customization
work better so that it's easier for the user to figure out how to set
it?

jamie.


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


output file argument to notmuch dump.

2011-10-10 Thread Tomi Ollila
On Sun 09 Oct 2011 19:01, David Bremner  writes:

> On Thu, 06 Oct 2011 21:20:40 -0300, David Bremner  wrote:
>> 
>> I'd like to add a search term argument to notmuch dump (see
>> id:"87wrcijn1w.fsf at zancas.localnet" and followup for context). The
>> "notmuch" way would be to have
>> 
>> notmuch dump 
>> 
>> do the right thing
>
> Another option occured to me that is consistent at least with notmuch
> tag and notmuch show would be to support the following transitional
> syntaxes
>
> notmuch dump file
> notmuch dump file [--] search terms
> notmuch dump -- search terms
>
> the first two could then be deprecated, and eventually the syntax
>
> notmuch dump search terms 
>
> could be enabled.

In this case there would be 2 transitional syntaxes. IMHO 

'notmuch dump ' causes least transitional pain.

> the question of whether to support 
>
> notmuch dump --file foo.txt
>
> or something like 
>
>notmuch --stdout=foo.txt dump

who about 

notmuch [--output-file=]  ...

> could be dealt with later.
>
> David

Tomi


Re: [PATCH] emacs: Modify notmuch-show-get-message-id to return message-id unprefixed with "id:".

2011-10-10 Thread Thomas Schwinge
Hi!

On Sun,  9 Oct 2011 15:35:48 -0700, Jameson Graef Rollins 
 wrote:
>  (defun notmuch-show-get-message-id ()
>"Return the message id of the current message."
> -  (concat "id:\"" (notmuch-show-get-prop :id) "\""))
> +  (concat "\"" (notmuch-show-get-prop :id) "\""))

Shouldn't the double quotes be removed here, too?  (And be re-added in
the other places where id: is added.)


Grüße,
 Thomas


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


Re: emacs email appears empty

2011-10-10 Thread David Bremner
On Tue, 11 Oct 2011 10:02:48 +1100, Brian May  
wrote:
> I also have attached an email with nothing but the signature. This
> email comes out completely blank without any option to see the
> signature. Not sure if this is expected or not.
> 

I can confirm the latter is a bug in 0.9~rc2

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


Re: emacs email appears empty

2011-10-10 Thread Brian May
On 29 September 2011 21:05, David Bremner  wrote:
> Any chance you could share such a message with us?

Unfortunately the emails with this problem are private, I probably
shouldn't repost without getting permission first from the sender.

I think it might be emails sent with Zimbra web interface. Maybe the
"- Original Message -" text? At least this is what the emails
have in common. Unfortunately, my test messages all work fine. There
is a copy below anyway.

I also have attached an email with nothing but the signature. This
email comes out completely blank without any option to see the
signature. Not sure if this is expected or not.

Fingers crossed gmail isn't going to mess with the line formatting...

=== cut ===
Return-Path: br...@vpac.org
Received: from mail.vpac.org [2001:388:60ac::4]
by aquitard with IMAP (fetchmail-6.3.18)
for  (single-drop); Tue, 11 Oct 2011 09:44:51 +1100 
(EST)
Received: from mail.vpac.org (LHLO mail.vpac.org) (202.158.218.6) by
 mail.vpac.org with LMTP; Tue, 11 Oct 2011 09:44:29 +1100 (EST)
Received: from localhost (localhost.localdomain [127.0.0.1])
by mail.vpac.org (Postfix) with ESMTP id E23F2C0197372
for ; Tue, 11 Oct 2011 09:44:29 +1100 (EST)
X-Virus-Scanned: amavisd-new at mail.vpac.org
X-Spam-Flag: NO
X-Spam-Score: -1.106
X-Spam-Level:
X-Spam-Status: No, score=-1.106 tagged_above=-10 required=5
tests=[BAYES_00=-1.9, HELO_NO_DOMAIN=0.001, RDNS_NONE=0.793]
autolearn=no
Received: from mail.vpac.org ([127.0.0.1])
by localhost (mail.vpac.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id KeztsuHiXzIh; Tue, 11 Oct 2011 09:44:29 +1100 (EST)
Received: from mail.vpac.org (mail.vpac.org [202.158.218.6])
by mail.vpac.org (Postfix) with ESMTP id 3A2D6C0197369;
Tue, 11 Oct 2011 09:44:29 +1100 (EST)
Date: Tue, 11 Oct 2011 09:44:29 +1100 (EST)
From: Brian May 
To: Brian May 
Cc: Brian May 
Message-ID: <1567978915.114359.1318286669223.javamail.r...@mail.vpac.org>
In-Reply-To: 

Subject: Re: test 2
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
X-Originating-IP: [128.250.103.200]
X-Mailer: Zimbra 6.0.13_GA_2918 (ZimbraWebClient - SAF3 (Linux)/6.0.13_GA_2918)



- Original Message -
> This is a test. Proof is not attached.
> --
> Brian May 

You don't have any proof do you?
-- 
Brian May
=== cut ===

=== cut ===
Return-Path: br...@microcomaustralia.com.au
Received: from mail.vpac.org [2001:388:60ac::4]
by aquitard with IMAP (fetchmail-6.3.18)
for  (single-drop); Tue, 11 Oct 2011 09:40:48 +1100 
(EST)
Received: from mail.vpac.org (LHLO mail.vpac.org) (202.158.218.6) by
 mail.vpac.org with LMTP; Tue, 11 Oct 2011 09:40:33 +1100 (EST)
Received: from localhost (localhost.localdomain [127.0.0.1])
by mail.vpac.org (Postfix) with ESMTP id C218CC0197370
for ; Tue, 11 Oct 2011 09:40:33 +1100 (EST)
X-Virus-Scanned: amavisd-new at mail.vpac.org
X-Spam-Flag: NO
X-Spam-Score: -2.464
X-Spam-Level:
X-Spam-Status: No, score=-2.464 tagged_above=-10 required=5 tests=[AWL=0.236,
BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
Authentication-Results: mail.vpac.org (amavisd-new); dkim=pass
header.i=@microcomaustralia.com.au
Received: from mail.vpac.org ([127.0.0.1])
by localhost (mail.vpac.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id nF6unVC7D49c for ;
Tue, 11 Oct 2011 09:40:32 +1100 (EST)
Received: from mail-ww0-f48.google.com (mail-ww0-f48.google.com [74.125.82.48])
by mail.vpac.org (Postfix) with ESMTPS id AB51AC0197369
for ; Tue, 11 Oct 2011 09:40:31 +1100 (EST)
Received: by wwe32 with SMTP id 32so9383984wwe.29
for ; Mon, 10 Oct 2011 15:40:27 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=microcomaustralia.com.au; s=google;
h=mime-version:x-originating-ip:date:message-id:subject:from:to
 :content-type;
bh=x9j2t6NjG/AVcHxbwM/oIFlLTOFwF3y1ZW22PVeCbT0=;
b=HSCTN2sYz7ixqfK08MeDu/0owkvqzMCzyyGEYuIq4htrxTM5Vlkd/MTkN79okgDWBx
 RpVG7GmIU4jf/xUVut4n002e6nTVRBUcM6VWMhaIZMPrmtHN/N2NobMDIQh2pqYKiO/1
 T5pcHKqFp9TQNumFn/4FH0AGZfxbYLQvD+n58=
MIME-Version: 1.0
Received: by 10.216.131.193 with SMTP id m43mr5932606wei.114.1318286427492;
 Mon, 10 Oct 2011 15:40:27 -0700 (PDT)
Received: by 10.216.179.134 with HTTP; Mon, 10 Oct 2011 15:40:27 -0700 (PDT)
X-Originating-IP: [128.250.103.200]
Date: Tue, 11 Oct 2011 09:40:27 +1100
Message-ID: 
Subject: test only
From: Brian May 
To: Brian May 
Content-Type: text/plain; charset=ISO-8859-1

-- 
Brian May 
=== cut ===

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


[PATCH] emacs: logically group def{custom,face}s

2011-10-10 Thread Daniel Schoepe
On Tue,  5 Jul 2011 20:33:00 +0200, Pieter Praet  wrote:
> To allow for expansion whilst keeping everything tidy and organized,
> move all defcustom/defface variables to the following subgroups,
> defined in notmuch-lib.el:

Since the customize page for notmuch is getting pretty crowded, I think
this patch is a good idea and should be applied.

Cheers,
Daniel
-- 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/20111010/f9766d4c/attachment.pgp>


[PATCH v6 2/2] emacs: Tests for user-defined sections

2011-10-10 Thread Daniel Schoepe
From: Daniel Schoepe 

---
 test/emacs |   37 
 test/emacs.expected-output/notmuch-hello   |4 ++-
 .../notmuch-hello-new-section  |4 ++
 .../notmuch-hello-no-saved-searches|4 ++-
 .../notmuch-hello-section-counts   |5 +++
 .../notmuch-hello-section-hidden-tag   |4 ++
 .../notmuch-hello-section-with-empty   |4 ++
 .../emacs.expected-output/notmuch-hello-with-empty |4 ++-
 8 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 test/emacs.expected-output/notmuch-hello-new-section
 create mode 100644 test/emacs.expected-output/notmuch-hello-section-counts
 create mode 100644 test/emacs.expected-output/notmuch-hello-section-hidden-tag
 create mode 100644 test/emacs.expected-output/notmuch-hello-section-with-empty

diff --git a/test/emacs b/test/emacs
index 0303d7d..15854ae 100755
--- a/test/emacs
+++ b/test/emacs
@@ -29,6 +29,43 @@ test_emacs '(let ((notmuch-saved-searches
  (test-output))'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches

+test_begin_subtest "User defined section with inbox tag"
+test_emacs "(let ((notmuch-hello-sections 
+   (list (lambda () (notmuch-hello-insert-searches
+ \"Test\" '((\"inbox\" . 
\"tag:inbox\")))
+   (notmuch-hello)
+   (test-output))"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-new-section
+
+test_begin_subtest "User defined section with empty, hidden entry"
+test_emacs "(let ((notmuch-hello-sections 
+   (list (lambda () (notmuch-hello-insert-searches
+ \"Test-with-empty\" 
+ '((\"inbox\" . \"tag:inbox\")
+   (\"doesnotexist\" . 
\"tag:doesnotexist\"))
+ :hide-empty-searches t)
+ (notmuch-hello)
+ (test-output))"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-with-empty
+
+test_begin_subtest "User defined section, unread tag filtered out"
+test_emacs "(let ((notmuch-hello-sections 
+   (list (lambda () (notmuch-hello-insert-tags-section
+ \"Test-with-filtered\"
+ :hide-tags '(\"unread\"))
+ (notmuch-hello)
+ (test-output))"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-hidden-tag
+
+test_begin_subtest "User defined section, different query for counts"
+test_emacs "(let ((notmuch-hello-sections
+   (list (lambda () (notmuch-hello-insert-tags-section
+ \"Test-with-counts\"
+ :filter-count \"tag:signed\")
+ (notmuch-hello)
+ (test-output))"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-counts
+
 test_begin_subtest "Basic notmuch-search view in emacs"
 test_emacs '(notmuch-search "tag:inbox")
(notmuch-test-wait)
diff --git a/test/emacs.expected-output/notmuch-hello 
b/test/emacs.expected-output/notmuch-hello
index 64b7e42..fd512d3 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -6,9 +6,11 @@ Saved searches: [edit]

 Search: 

-[Show all tags]
+All tags: [show]

 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
 `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+   Customize this page.
+
diff --git a/test/emacs.expected-output/notmuch-hello-new-section 
b/test/emacs.expected-output/notmuch-hello-new-section
new file mode 100644
index 000..be7b26a
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-hello-new-section
@@ -0,0 +1,4 @@
+Test: [hide]
+
+ 50 inbox  
+
diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches 
b/test/emacs.expected-output/notmuch-hello-no-saved-searches
index 7f8206a..37b2303 100644
--- a/test/emacs.expected-output/notmuch-hello-no-saved-searches
+++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches
@@ -2,9 +2,11 @@

 Search: 

-[Show all tags]
+All tags: [show]

 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
 `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+   Customize this page.
+
diff --git a/test/emacs.expected-output/notmuch-hello-section-counts 
b

[PATCH v6 1/2] emacs: User-defined sections in notmuch-hello

2011-10-10 Thread Daniel Schoepe
From: Daniel Schoepe 

This patch makes the notmuch-hello screen fully customizable
by allowing the user to add and remove arbitrary sections. It
also provides some convenience functions for constructing sections,
e.g. showing the unread message count for each tag.

This is done by specifying a list of functions that will be run
when notmuch-hello is invoked.
---
 emacs/notmuch-hello.el |  624 
 1 files changed, 423 insertions(+), 201 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 65fde75..f7ec4dd 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -70,11 +70,6 @@ should return a filter for that tag, or nil to hide the tag."
 (const :tag "Custom filter function" function))
   :group 'notmuch)

-(defcustom notmuch-hello-hide-tags nil
-  "List of tags to be hidden in the \"all tags\"-section."
-  :type '(repeat string)
-  :group 'notmuch)
-
 (defface notmuch-hello-logo-background
   'class color)
   (background dark))
@@ -123,6 +118,94 @@ Typically \",\" in the US and UK and \".\" in Europe."

 (defvar notmuch-hello-recent-searches nil)

+(defvar notmuch-custom-section-options
+  '((:filter (string :tag "Filter for each tag"))
+(:filter-count (string :tag "Different filter message counts"))
+(:initially-hidden (const :tag "Hide this on startup?" t))
+(:show-empty-searches (const :tag "Show queries with no matching messages" 
t))
+(:hide-if-empty (const :tag "Hide if empty" t)))
+  "Various customization-options for notmuch-hello-tags/query-section.")
+
+(define-widget 'notmuch-hello-tags-section 'lazy
+  "Customize-type for notmuch-hello tag-list sections."
+  :tag "Customized tag-list (see docstring for details)"
+  :type
+  `(list :tag ""
+(const :tag "" notmuch-hello-insert-tags-section)
+(string :tag "Title for this section")
+(plist
+ :inline t
+ :options
+ ,(append notmuch-custom-section-options
+  '((:hide-tags (repeat :tag "Tags that will be hidden"
+string)))
+
+(define-widget 'notmuch-hello-query-section 'lazy
+  "Customize-type for custom saved-search-like sections"
+  :tag "Customized queries section (see docstring for details)"
+  :type
+  `(list :tag ""
+(const :tag "" notmuch-hello-insert-query-list)
+(string :tag "Title for this section")
+(repeat :tag "Queries"
+(cons (string :tag "Name") (string :tag "Query")))
+(plist :inline t :options ,notmuch-custom-section-options)))
+
+(defcustom notmuch-hello-sections
+  (list #'notmuch-hello-insert-header
+   #'notmuch-hello-insert-saved-searches
+   #'notmuch-hello-insert-search
+   #'notmuch-hello-insert-recent-searches
+   #'notmuch-hello-insert-alltags
+   #'notmuch-hello-insert-footer)
+  "Sections for notmuch-hello.
+
+Each entry of this list should be a function of no arguments that
+should return if `notmuch-hello-target' is produced as part of its
+output and nil otherwise. For convenience an element can also be
+a list of the form (FUNC ARG1 ARG2 .. ARGN) in which case FUNC
+will be applied to the rest of the list.
+
+The functions will be run to construct the content of the
+notmuch-hello buffer in the order they appear in this list. A
+section should not end with an empty line, because a newline will
+be inserted after each section by `notmuch-hello'.
+
+A \"Customized tag-list\" item in the customize-interface
+displays a list of all tags, optionally hiding some of them. It
+is also possible to filter the list of messages matching each tag
+by an additional filter query. Similarly, the count of messages
+displayed next to the buttons can be generated by applying a
+different filter to the tag query. These filters are also
+supported for \"Customized queries section\" items."
+  :group 'notmuch
+  :type 
+  '(repeat
+(choice (function-item notmuch-hello-insert-header)
+   (function-item notmuch-hello-insert-saved-searches)
+   (function-item notmuch-hello-insert-search)
+   (function-item notmuch-hello-insert-recent-searches)
+   (function-item notmuch-hello-insert-alltags)
+   (function-item notmuch-hello-insert-footer)
+   (function-item notmuch-hello-insert-inbox)
+   notmuch-hello-tags-section
+   notmuch-hello-query-section
+   (function :tag "Custom function"
+
+(defvar notmuch-hello-target nil
+  "Button at position of point before rebuilding the notmuch-buffer
+
+This variable contains the string of the button, if any, the
+point was positioned at before the notmuch-hello buffer was
+rebuilt. This is never actually set globally and defined as a
+defvar only for documentation purposes and to avoid a compiler
+warning about it occurring as a free variable.")
+
+(defvar notmuch-hello-hidden-sections nil
+  "List of query section titles whose cont

[PATCH v6 0/2] emacs: User-defined sections in notmuch-hello

2011-10-10 Thread Daniel Schoepe
Fixed that and rebased against master.



[PATCH 2/4] emacs: Support a message-mode switch function in notmuch-mua

2011-10-10 Thread Jameson Graef Rollins
Another question about this feature: how do you make the window (frame)
go away after the email is sent?

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/20111010/184b49a7/attachment.pgp>


output file argument to notmuch dump.

2011-10-10 Thread David Bremner
On Mon, 10 Oct 2011 16:59:06 +0300, Tomi Ollila  wrote:
> 
> In this case there would be 2 transitional syntaxes. IMHO 
> 
> 'notmuch dump ' causes least transitional pain.
> 

I don't understand what you mean here. Can you elaborate?

  notmuch dump  

is not a transitional syntax, but rather a new syntax that breaks
existing scripts. 

The advantage of using -- here is that it allows things like

notmuch dump --format=something-better -- --output

to search for --output (of course the query is then parsed a bit
surprisingly, but this is a different issue.)

d
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 315 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20111010/2ddc6b15/attachment.pgp>


[PATCH 6/6] notmuch-dump: deprecate use of output file argument.

2011-10-10 Thread da...@tethera.net
From: David Bremner 

We print an intentionally non-specific message on stderr, since it
isn't clear if there will be some global output file argument to
replace.

We update the test suite atomically, since it relies on having the
same text in two files.
---
 notmuch-dump.c|1 +
 test/dump-restore |4 
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index ac5d074..409c86a 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -42,6 +42,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
return 1;

 if (argc && strcmp (argv[0], "--") != 0) {
+   fprintf (stderr, "Warning: the output file argument of dump is 
deprecated.\n");
output = fopen (argv[0], "w");
if (output == NULL) {
fprintf (stderr, "Error opening %s for writing: %s\n",
diff --git a/test/dump-restore b/test/dump-restore
index d8db259..5f3f0db 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -12,6 +12,10 @@ test_begin_subtest "dump outfile"
 notmuch dump dump-outfile.actual
 test_expect_equal_file dump.expected dump-outfile.actual

+test_begin_subtest "dump outfile # deprecated"
+test_expect_equal "Warning: the output file argument of dump is deprecated."\
+  "$(notmuch dump /dev/null 2>&1)"
+
 test_begin_subtest "dump outfile --"
 notmuch dump dump-1-arg-dash.actual
 test_expect_equal_file dump.expected dump-1-arg-dash.actual
-- 
1.7.6.3



[PATCH 5/6] test: all dump-restore tests should be working now

2011-10-10 Thread da...@tethera.net
From: David Bremner 

3 x test_subtest_known_broken removed to tidy up the output.
---
 test/dump-restore |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/test/dump-restore b/test/dump-restore
index 699337c..d8db259 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -22,17 +22,14 @@ test_expect_equal_file dump.expected dump-1-arg-dash.actual
 grep cworth\.org dump.expected > dump-cworth.expected

 test_begin_subtest "dump -- from:cworth"
-test_subtest_known_broken
 notmuch dump -- from:cworth > dump-dash-cworth.actual
 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual

 test_begin_subtest "dump outfile from:cworth"
-test_subtest_known_broken
 notmuch dump dump-outfile-cworth.actual from:cworth
 test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual

 test_begin_subtest "dump outfile -- from:cworth"
-test_subtest_known_broken
 notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual

-- 
1.7.6.3



[PATCH 4/6] notmuch-dump: treat any remaining arguments after the filename as search terms

2011-10-10 Thread da...@tethera.net
From: David Bremner 

The main motivation here is allow the fast dumping of tag data for
messages having certain tags.  In practice it seems too slow to pipe
dump to grep.
---
 notmuch-dump.c |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index 610144e..ac5d074 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -30,6 +30,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
 notmuch_messages_t *messages;
 notmuch_message_t *message;
 notmuch_tags_t *tags;
+const char* query_str = "";

 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
@@ -56,7 +57,15 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
argv++;
 }

-query = notmuch_query_create (notmuch, "");
+if (argc) {
+   query_str = query_string_from_args (notmuch, argc, argv);
+   if (query_str == NULL) {
+   fprintf (stderr, "Out of memory.\n");
+   return 1;
+   }
+}
+ 
+query = notmuch_query_create (notmuch, query_str);
 if (query == NULL) {
fprintf (stderr, "Out of memory\n");
return 1;
-- 
1.7.6.3



[PATCH 3/6] notmuch-dump: update handling of file name argument

2011-10-10 Thread da...@tethera.net
From: David Bremner 

We permit -- as an "option processing terminator".

Currently this does not do anything useful, but we plan to add
search terms after the --.
---
 notmuch-dump.c |   27 ---
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index 7e7bc17..610144e 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -26,7 +26,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
 notmuch_config_t *config;
 notmuch_database_t *notmuch;
 notmuch_query_t *query;
-FILE *output;
+FILE *output = stdout;
 notmuch_messages_t *messages;
 notmuch_message_t *message;
 notmuch_tags_t *tags;
@@ -40,23 +40,28 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
 if (notmuch == NULL)
return 1;

-query = notmuch_query_create (notmuch, "");
-if (query == NULL) {
-   fprintf (stderr, "Out of memory\n");
-   return 1;
-}
-notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID);
-
-if (argc) {
+if (argc && strcmp (argv[0], "--") != 0) {
output = fopen (argv[0], "w");
if (output == NULL) {
fprintf (stderr, "Error opening %s for writing: %s\n",
 argv[0], strerror (errno));
return 1;
}
-} else {
-   output = stdout;
+   argc--;
+   argv++;
+}
+
+if (argc && strcmp (argv[0], "--") == 0){
+   argc--;
+   argv++;
+}
+
+query = notmuch_query_create (notmuch, "");
+if (query == NULL) {
+   fprintf (stderr, "Out of memory\n");
+   return 1;
 }
+notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID);

 for (messages = notmuch_query_search_messages (query);
 notmuch_messages_valid (messages);
-- 
1.7.6.3



[PATCH 2/6] test: add tests for command line arguments to notmuch-dump

2011-10-10 Thread da...@tethera.net
From: David Bremner 

The plan is to add the possibility of search terms after the file name,
and the use of -- to stop looking for an output file name.
---
 test/dump-restore |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/test/dump-restore b/test/dump-restore
index 96c4f19..699337c 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -8,6 +8,34 @@ test_expect_success "Dumping all tags" "generate_message &&
 notmuch new &&
 notmuch dump > dump.expected"

+test_begin_subtest "dump outfile"
+notmuch dump dump-outfile.actual
+test_expect_equal_file dump.expected dump-outfile.actual
+
+test_begin_subtest "dump outfile --"
+notmuch dump dump-1-arg-dash.actual
+test_expect_equal_file dump.expected dump-1-arg-dash.actual
+
+# Note, we assume all messages from cworth have a message-id
+# containing cworth.org
+
+grep cworth\.org dump.expected > dump-cworth.expected
+
+test_begin_subtest "dump -- from:cworth"
+test_subtest_known_broken
+notmuch dump -- from:cworth > dump-dash-cworth.actual
+test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
+
+test_begin_subtest "dump outfile from:cworth"
+test_subtest_known_broken
+notmuch dump dump-outfile-cworth.actual from:cworth
+test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
+
+test_begin_subtest "dump outfile -- from:cworth"
+test_subtest_known_broken
+notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
+test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
+
 test_begin_subtest "Clearing all tags"
 sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected
 notmuch restore < clear.expected
-- 
1.7.6.3



[PATCH 1/6] test: update dump-restore to use redirection instead of filename args

2011-10-10 Thread da...@tethera.net
From: David Bremner 

The idea here is that we want to deprecate the use of arguments to
dump and restore to specify paths, since in particular we want to use
the non-option arguments to dump to form a query.
---
 test/dump-restore |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/dump-restore b/test/dump-restore
index a4de370..96c4f19 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -6,17 +6,17 @@ add_email_corpus

 test_expect_success "Dumping all tags" "generate_message &&
 notmuch new &&
-notmuch dump dump.expected"
+notmuch dump > dump.expected"

 test_begin_subtest "Clearing all tags"
 sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected
-notmuch restore clear.expected
-notmuch dump clear.actual
+notmuch restore < clear.expected
+notmuch dump > clear.actual
 test_expect_equal "$(< clear.actual)" "$(< clear.expected)"

 test_begin_subtest "Restoring original tags"
-notmuch restore dump.expected
-notmuch dump dump.actual
+notmuch restore < dump.expected
+notmuch dump > dump.actual
 test_expect_equal "$(< dump.actual)" "$(< dump.expected)"

 test_expect_success "Restore with nothing to do" "notmuch restore 
dump.expected"
-- 
1.7.6.3



No subject

2011-10-10 Thread da...@tethera.net
OK, here is my proposal to add search terms to notmuch dump.

Most of the work is in argument processing. It would be nice if we
could factor some of that out.

02be821 notmuch-dump: deprecate use of output file argument.  
2b7781d test: all dump-restore tests should be working now
7a203d6 notmuch-dump: treat any remaining arguments after the filename as 
search t
be762d9 notmuch-dump: update handling of file name argument
d6715d7 test: add tests for command line arguments to notmuch-dump
08e76cc test: update dump-restore to use redirection instead of filename args

 notmuch-dump.c|   37 ++---
 test/dump-restore |   39 ++-
 2 files changed, 60 insertions(+), 16 deletions(-)


output file argument to notmuch dump.

2011-10-10 Thread Tomi Ollila
On Fri 07 Oct 2011 20:22, Jameson Graef Rollins  
writes:

> On Fri, 07 Oct 2011 14:15:39 +0300, Tomi Ollila  wrote:
>> The option 2, i.e. optional --write (or -o|--output) should be available;
>> someone may run notmuch without using environment that provides
>> redirections (or it is just plain simpler to give the command line option
>> instead of doing redirections).
>
> If that were the case then none of the other notmuch commands would work
> in the environment either.  If that's a concern, then notmuch should
> have a generic --redirect option that works for all commands, as Tom
> suggested out earlier.

Good point. I Agree. So, no spesific --write|-o|--output for dump is my
current vote.

>
> jamie.

Tomi


output file argument to notmuch dump.

2011-10-10 Thread Jameson Graef Rollins
On Sun, 09 Oct 2011 13:01:53 -0300, David Bremner  wrote:
> Another option occured to me that is consistent at least with notmuch
> tag and notmuch show would be to support the following transitional
> syntaxes
> 
> notmuch dump file
> notmuch dump file [--] search terms
> notmuch dump -- search terms
> 
> the first two could then be deprecated, and eventually the syntax
> 
> notmuch dump search terms 
> 
> could be enabled.

Hey, David.  I think this is a fine approach, Go with the transitional
"--" separator for one release or so, with a deprecation warning, and
then move to the standard form in the release after that.

> the question of whether to support 
> 
> notmuch dump --file foo.txt
> 
> or something like 
> 
>notmuch --stdout=foo.txt dump
> 
> could be dealt with later.

I realize the later probably requires more work, since we would have to
replace all print calls with a new function, but I think it's the
cleaner and more elegant solution.  There's no reason to have an output
redirection option for "dump"s and not for any of the other commands.

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/20111010/103e3647/attachment.pgp>


[PATCH 2/4] emacs: Support a message-mode switch function in notmuch-mua

2011-10-10 Thread Jameson Graef Rollins
Hey, Thomas.  I think these are all totally reasonable emacs
improvements, and I think we should merge them all.

I particularly like this feature to launch compose buffers in new
frames.  Thanks so much for figuring it out.  I had hacked up something
for myself but your solution is *much* more elegant and Just Works.
Thanks!

However, I find the customization variable a bit clunky.  Since I wasn't
presented with any options in the customization, I didn't know what to
put in.  I copy and pasted "switch-to-buffer-other-frame" into the
customization field but that didn't work since I didn't protect the
function name.  Finally I got it to work by putting in
"'switch-to-buffer-other-frame" (with the initial "'").

So I definitely love this feature, but can we make the customization
work better so that it's easier for the user to figure out how to set
it?

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/20111010/f59eba06/attachment.pgp>


Re: output file argument to notmuch dump.

2011-10-10 Thread David Bremner
On Mon, 10 Oct 2011 16:59:06 +0300, Tomi Ollila  wrote:
> 
> In this case there would be 2 transitional syntaxes. IMHO 
> 
> 'notmuch dump ' causes least transitional pain.
> 

I don't understand what you mean here. Can you elaborate?

  notmuch dump  

is not a transitional syntax, but rather a new syntax that breaks
existing scripts. 

The advantage of using -- here is that it allows things like

notmuch dump --format=something-better -- --output

to search for --output (of course the query is then parsed a bit
surprisingly, but this is a different issue.)

d


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


Re: output file argument to notmuch dump.

2011-10-10 Thread Tomi Ollila
On Sun 09 Oct 2011 19:01, David Bremner  writes:

> On Thu, 06 Oct 2011 21:20:40 -0300, David Bremner  wrote:
>> 
>> I'd like to add a search term argument to notmuch dump (see
>> id:"87wrcijn1w.fsf@zancas.localnet" and followup for context). The
>> "notmuch" way would be to have
>> 
>> notmuch dump 
>> 
>> do the right thing
>
> Another option occured to me that is consistent at least with notmuch
> tag and notmuch show would be to support the following transitional
> syntaxes
>
> notmuch dump file
> notmuch dump file [--] search terms
> notmuch dump -- search terms
>
> the first two could then be deprecated, and eventually the syntax
>
> notmuch dump search terms 
>
> could be enabled.

In this case there would be 2 transitional syntaxes. IMHO 

'notmuch dump ' causes least transitional pain.

> the question of whether to support 
>
> notmuch dump --file foo.txt
>
> or something like 
>
>notmuch --stdout=foo.txt dump

who about 

notmuch [--output-file=]  ...

> could be dealt with later.
>
> David

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


[PATCH 3/6] notmuch-dump: update handling of file name argument

2011-10-10 Thread david
From: David Bremner 

We permit -- as an "option processing terminator".

Currently this does not do anything useful, but we plan to add
search terms after the --.
---
 notmuch-dump.c |   27 ---
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index 7e7bc17..610144e 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -26,7 +26,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
 notmuch_config_t *config;
 notmuch_database_t *notmuch;
 notmuch_query_t *query;
-FILE *output;
+FILE *output = stdout;
 notmuch_messages_t *messages;
 notmuch_message_t *message;
 notmuch_tags_t *tags;
@@ -40,23 +40,28 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
 if (notmuch == NULL)
return 1;
 
-query = notmuch_query_create (notmuch, "");
-if (query == NULL) {
-   fprintf (stderr, "Out of memory\n");
-   return 1;
-}
-notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID);
-
-if (argc) {
+if (argc && strcmp (argv[0], "--") != 0) {
output = fopen (argv[0], "w");
if (output == NULL) {
fprintf (stderr, "Error opening %s for writing: %s\n",
 argv[0], strerror (errno));
return 1;
}
-} else {
-   output = stdout;
+   argc--;
+   argv++;
+}
+
+if (argc && strcmp (argv[0], "--") == 0){
+   argc--;
+   argv++;
+}
+
+query = notmuch_query_create (notmuch, "");
+if (query == NULL) {
+   fprintf (stderr, "Out of memory\n");
+   return 1;
 }
+notmuch_query_set_sort (query, NOTMUCH_SORT_MESSAGE_ID);
 
 for (messages = notmuch_query_search_messages (query);
 notmuch_messages_valid (messages);
-- 
1.7.6.3

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


[PATCH 4/6] notmuch-dump: treat any remaining arguments after the filename as search terms

2011-10-10 Thread david
From: David Bremner 

The main motivation here is allow the fast dumping of tag data for
messages having certain tags.  In practice it seems too slow to pipe
dump to grep.
---
 notmuch-dump.c |   11 ++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index 610144e..ac5d074 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -30,6 +30,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
 notmuch_messages_t *messages;
 notmuch_message_t *message;
 notmuch_tags_t *tags;
+const char* query_str = "";
 
 config = notmuch_config_open (ctx, NULL, NULL);
 if (config == NULL)
@@ -56,7 +57,15 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
argv++;
 }
 
-query = notmuch_query_create (notmuch, "");
+if (argc) {
+   query_str = query_string_from_args (notmuch, argc, argv);
+   if (query_str == NULL) {
+   fprintf (stderr, "Out of memory.\n");
+   return 1;
+   }
+}
+ 
+query = notmuch_query_create (notmuch, query_str);
 if (query == NULL) {
fprintf (stderr, "Out of memory\n");
return 1;
-- 
1.7.6.3

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


[PATCH 6/6] notmuch-dump: deprecate use of output file argument.

2011-10-10 Thread david
From: David Bremner 

We print an intentionally non-specific message on stderr, since it
isn't clear if there will be some global output file argument to
replace.

We update the test suite atomically, since it relies on having the
same text in two files.
---
 notmuch-dump.c|1 +
 test/dump-restore |4 
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/notmuch-dump.c b/notmuch-dump.c
index ac5d074..409c86a 100644
--- a/notmuch-dump.c
+++ b/notmuch-dump.c
@@ -42,6 +42,7 @@ notmuch_dump_command (unused (void *ctx), int argc, char 
*argv[])
return 1;
 
 if (argc && strcmp (argv[0], "--") != 0) {
+   fprintf (stderr, "Warning: the output file argument of dump is 
deprecated.\n");
output = fopen (argv[0], "w");
if (output == NULL) {
fprintf (stderr, "Error opening %s for writing: %s\n",
diff --git a/test/dump-restore b/test/dump-restore
index d8db259..5f3f0db 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -12,6 +12,10 @@ test_begin_subtest "dump outfile"
 notmuch dump dump-outfile.actual
 test_expect_equal_file dump.expected dump-outfile.actual
 
+test_begin_subtest "dump outfile # deprecated"
+test_expect_equal "Warning: the output file argument of dump is deprecated."\
+  "$(notmuch dump /dev/null 2>&1)"
+
 test_begin_subtest "dump outfile --"
 notmuch dump dump-1-arg-dash.actual
 test_expect_equal_file dump.expected dump-1-arg-dash.actual
-- 
1.7.6.3

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


[PATCH 5/6] test: all dump-restore tests should be working now

2011-10-10 Thread david
From: David Bremner 

3 x test_subtest_known_broken removed to tidy up the output.
---
 test/dump-restore |3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/test/dump-restore b/test/dump-restore
index 699337c..d8db259 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -22,17 +22,14 @@ test_expect_equal_file dump.expected dump-1-arg-dash.actual
 grep cworth\.org dump.expected > dump-cworth.expected
 
 test_begin_subtest "dump -- from:cworth"
-test_subtest_known_broken
 notmuch dump -- from:cworth > dump-dash-cworth.actual
 test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
 
 test_begin_subtest "dump outfile from:cworth"
-test_subtest_known_broken
 notmuch dump dump-outfile-cworth.actual from:cworth
 test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
 
 test_begin_subtest "dump outfile -- from:cworth"
-test_subtest_known_broken
 notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
 test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
 
-- 
1.7.6.3

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


[PATCH 2/6] test: add tests for command line arguments to notmuch-dump

2011-10-10 Thread david
From: David Bremner 

The plan is to add the possibility of search terms after the file name,
and the use of -- to stop looking for an output file name.
---
 test/dump-restore |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/test/dump-restore b/test/dump-restore
index 96c4f19..699337c 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -8,6 +8,34 @@ test_expect_success "Dumping all tags" "generate_message &&
 notmuch new &&
 notmuch dump > dump.expected"
 
+test_begin_subtest "dump outfile"
+notmuch dump dump-outfile.actual
+test_expect_equal_file dump.expected dump-outfile.actual
+
+test_begin_subtest "dump outfile --"
+notmuch dump dump-1-arg-dash.actual
+test_expect_equal_file dump.expected dump-1-arg-dash.actual
+
+# Note, we assume all messages from cworth have a message-id
+# containing cworth.org
+
+grep cworth\.org dump.expected > dump-cworth.expected
+
+test_begin_subtest "dump -- from:cworth"
+test_subtest_known_broken
+notmuch dump -- from:cworth > dump-dash-cworth.actual
+test_expect_equal_file dump-cworth.expected dump-dash-cworth.actual
+
+test_begin_subtest "dump outfile from:cworth"
+test_subtest_known_broken
+notmuch dump dump-outfile-cworth.actual from:cworth
+test_expect_equal_file dump-cworth.expected dump-outfile-cworth.actual
+
+test_begin_subtest "dump outfile -- from:cworth"
+test_subtest_known_broken
+notmuch dump dump-outfile-dash-inbox.actual -- from:cworth
+test_expect_equal_file dump-cworth.expected dump-outfile-dash-inbox.actual
+
 test_begin_subtest "Clearing all tags"
 sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected
 notmuch restore < clear.expected
-- 
1.7.6.3

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


[PATCH 1/6] test: update dump-restore to use redirection instead of filename args

2011-10-10 Thread david
From: David Bremner 

The idea here is that we want to deprecate the use of arguments to
dump and restore to specify paths, since in particular we want to use
the non-option arguments to dump to form a query.
---
 test/dump-restore |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/test/dump-restore b/test/dump-restore
index a4de370..96c4f19 100755
--- a/test/dump-restore
+++ b/test/dump-restore
@@ -6,17 +6,17 @@ add_email_corpus
 
 test_expect_success "Dumping all tags" "generate_message &&
 notmuch new &&
-notmuch dump dump.expected"
+notmuch dump > dump.expected"
 
 test_begin_subtest "Clearing all tags"
 sed -e "s/(\([^(]*\))$/()/" < dump.expected > clear.expected
-notmuch restore clear.expected
-notmuch dump clear.actual
+notmuch restore < clear.expected
+notmuch dump > clear.actual
 test_expect_equal "$(< clear.actual)" "$(< clear.expected)"
 
 test_begin_subtest "Restoring original tags"
-notmuch restore dump.expected
-notmuch dump dump.actual
+notmuch restore < dump.expected
+notmuch dump > dump.actual
 test_expect_equal "$(< dump.actual)" "$(< dump.expected)"
 
 test_expect_success "Restore with nothing to do" "notmuch restore 
dump.expected"
-- 
1.7.6.3

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


[no subject]

2011-10-10 Thread david
OK, here is my proposal to add search terms to notmuch dump.

Most of the work is in argument processing. It would be nice if we
could factor some of that out.

02be821 notmuch-dump: deprecate use of output file argument.  
2b7781d test: all dump-restore tests should be working now
7a203d6 notmuch-dump: treat any remaining arguments after the filename as 
search t
be762d9 notmuch-dump: update handling of file name argument
d6715d7 test: add tests for command line arguments to notmuch-dump
08e76cc test: update dump-restore to use redirection instead of filename args

 notmuch-dump.c|   37 ++---
 test/dump-restore |   39 ++-
 2 files changed, 60 insertions(+), 16 deletions(-)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: logically group def{custom,face}s

2011-10-10 Thread Daniel Schoepe
On Tue,  5 Jul 2011 20:33:00 +0200, Pieter Praet  wrote:
> To allow for expansion whilst keeping everything tidy and organized,
> move all defcustom/defface variables to the following subgroups,
> defined in notmuch-lib.el:

Since the customize page for notmuch is getting pretty crowded, I think
this patch is a good idea and should be applied.

Cheers,
Daniel


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


[PATCH v6 1/2] emacs: User-defined sections in notmuch-hello

2011-10-10 Thread Daniel Schoepe
From: Daniel Schoepe 

This patch makes the notmuch-hello screen fully customizable
by allowing the user to add and remove arbitrary sections. It
also provides some convenience functions for constructing sections,
e.g. showing the unread message count for each tag.

This is done by specifying a list of functions that will be run
when notmuch-hello is invoked.
---
 emacs/notmuch-hello.el |  624 
 1 files changed, 423 insertions(+), 201 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 65fde75..f7ec4dd 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -70,11 +70,6 @@ should return a filter for that tag, or nil to hide the tag."
 (const :tag "Custom filter function" function))
   :group 'notmuch)
 
-(defcustom notmuch-hello-hide-tags nil
-  "List of tags to be hidden in the \"all tags\"-section."
-  :type '(repeat string)
-  :group 'notmuch)
-
 (defface notmuch-hello-logo-background
   'class color)
   (background dark))
@@ -123,6 +118,94 @@ Typically \",\" in the US and UK and \".\" in Europe."
 
 (defvar notmuch-hello-recent-searches nil)
 
+(defvar notmuch-custom-section-options
+  '((:filter (string :tag "Filter for each tag"))
+(:filter-count (string :tag "Different filter message counts"))
+(:initially-hidden (const :tag "Hide this on startup?" t))
+(:show-empty-searches (const :tag "Show queries with no matching messages" 
t))
+(:hide-if-empty (const :tag "Hide if empty" t)))
+  "Various customization-options for notmuch-hello-tags/query-section.")
+
+(define-widget 'notmuch-hello-tags-section 'lazy
+  "Customize-type for notmuch-hello tag-list sections."
+  :tag "Customized tag-list (see docstring for details)"
+  :type
+  `(list :tag ""
+(const :tag "" notmuch-hello-insert-tags-section)
+(string :tag "Title for this section")
+(plist
+ :inline t
+ :options
+ ,(append notmuch-custom-section-options
+  '((:hide-tags (repeat :tag "Tags that will be hidden"
+string)))
+
+(define-widget 'notmuch-hello-query-section 'lazy
+  "Customize-type for custom saved-search-like sections"
+  :tag "Customized queries section (see docstring for details)"
+  :type
+  `(list :tag ""
+(const :tag "" notmuch-hello-insert-query-list)
+(string :tag "Title for this section")
+(repeat :tag "Queries"
+(cons (string :tag "Name") (string :tag "Query")))
+(plist :inline t :options ,notmuch-custom-section-options)))
+
+(defcustom notmuch-hello-sections
+  (list #'notmuch-hello-insert-header
+   #'notmuch-hello-insert-saved-searches
+   #'notmuch-hello-insert-search
+   #'notmuch-hello-insert-recent-searches
+   #'notmuch-hello-insert-alltags
+   #'notmuch-hello-insert-footer)
+  "Sections for notmuch-hello.
+
+Each entry of this list should be a function of no arguments that
+should return if `notmuch-hello-target' is produced as part of its
+output and nil otherwise. For convenience an element can also be
+a list of the form (FUNC ARG1 ARG2 .. ARGN) in which case FUNC
+will be applied to the rest of the list.
+
+The functions will be run to construct the content of the
+notmuch-hello buffer in the order they appear in this list. A
+section should not end with an empty line, because a newline will
+be inserted after each section by `notmuch-hello'.
+
+A \"Customized tag-list\" item in the customize-interface
+displays a list of all tags, optionally hiding some of them. It
+is also possible to filter the list of messages matching each tag
+by an additional filter query. Similarly, the count of messages
+displayed next to the buttons can be generated by applying a
+different filter to the tag query. These filters are also
+supported for \"Customized queries section\" items."
+  :group 'notmuch
+  :type 
+  '(repeat
+(choice (function-item notmuch-hello-insert-header)
+   (function-item notmuch-hello-insert-saved-searches)
+   (function-item notmuch-hello-insert-search)
+   (function-item notmuch-hello-insert-recent-searches)
+   (function-item notmuch-hello-insert-alltags)
+   (function-item notmuch-hello-insert-footer)
+   (function-item notmuch-hello-insert-inbox)
+   notmuch-hello-tags-section
+   notmuch-hello-query-section
+   (function :tag "Custom function"
+
+(defvar notmuch-hello-target nil
+  "Button at position of point before rebuilding the notmuch-buffer
+
+This variable contains the string of the button, if any, the
+point was positioned at before the notmuch-hello buffer was
+rebuilt. This is never actually set globally and defined as a
+defvar only for documentation purposes and to avoid a compiler
+warning about it occurring as a free variable.")
+
+(defvar notmuch-hello-hidden-sections nil
+  "List of query section titles whose c

[PATCH v6 2/2] emacs: Tests for user-defined sections

2011-10-10 Thread Daniel Schoepe
From: Daniel Schoepe 

---
 test/emacs |   37 
 test/emacs.expected-output/notmuch-hello   |4 ++-
 .../notmuch-hello-new-section  |4 ++
 .../notmuch-hello-no-saved-searches|4 ++-
 .../notmuch-hello-section-counts   |5 +++
 .../notmuch-hello-section-hidden-tag   |4 ++
 .../notmuch-hello-section-with-empty   |4 ++
 .../emacs.expected-output/notmuch-hello-with-empty |4 ++-
 8 files changed, 63 insertions(+), 3 deletions(-)
 create mode 100644 test/emacs.expected-output/notmuch-hello-new-section
 create mode 100644 test/emacs.expected-output/notmuch-hello-section-counts
 create mode 100644 test/emacs.expected-output/notmuch-hello-section-hidden-tag
 create mode 100644 test/emacs.expected-output/notmuch-hello-section-with-empty

diff --git a/test/emacs b/test/emacs
index 0303d7d..15854ae 100755
--- a/test/emacs
+++ b/test/emacs
@@ -29,6 +29,43 @@ test_emacs '(let ((notmuch-saved-searches
  (test-output))'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
 
+test_begin_subtest "User defined section with inbox tag"
+test_emacs "(let ((notmuch-hello-sections 
+   (list (lambda () (notmuch-hello-insert-searches
+ \"Test\" '((\"inbox\" . 
\"tag:inbox\")))
+   (notmuch-hello)
+   (test-output))"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-new-section
+
+test_begin_subtest "User defined section with empty, hidden entry"
+test_emacs "(let ((notmuch-hello-sections 
+   (list (lambda () (notmuch-hello-insert-searches
+ \"Test-with-empty\" 
+ '((\"inbox\" . \"tag:inbox\")
+   (\"doesnotexist\" . 
\"tag:doesnotexist\"))
+ :hide-empty-searches t)
+ (notmuch-hello)
+ (test-output))"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-with-empty
+
+test_begin_subtest "User defined section, unread tag filtered out"
+test_emacs "(let ((notmuch-hello-sections 
+   (list (lambda () (notmuch-hello-insert-tags-section
+ \"Test-with-filtered\"
+ :hide-tags '(\"unread\"))
+ (notmuch-hello)
+ (test-output))"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-hidden-tag
+
+test_begin_subtest "User defined section, different query for counts"
+test_emacs "(let ((notmuch-hello-sections
+   (list (lambda () (notmuch-hello-insert-tags-section
+ \"Test-with-counts\"
+ :filter-count \"tag:signed\")
+ (notmuch-hello)
+ (test-output))"
+test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-section-counts
+
 test_begin_subtest "Basic notmuch-search view in emacs"
 test_emacs '(notmuch-search "tag:inbox")
(notmuch-test-wait)
diff --git a/test/emacs.expected-output/notmuch-hello 
b/test/emacs.expected-output/notmuch-hello
index 64b7e42..fd512d3 100644
--- a/test/emacs.expected-output/notmuch-hello
+++ b/test/emacs.expected-output/notmuch-hello
@@ -6,9 +6,11 @@ Saved searches: [edit]
 
 Search: 
 
-[Show all tags]
+All tags: [show]
 
 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
 `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+   Customize this page.
+
diff --git a/test/emacs.expected-output/notmuch-hello-new-section 
b/test/emacs.expected-output/notmuch-hello-new-section
new file mode 100644
index 000..be7b26a
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-hello-new-section
@@ -0,0 +1,4 @@
+Test: [hide]
+
+ 50 inbox  
+
diff --git a/test/emacs.expected-output/notmuch-hello-no-saved-searches 
b/test/emacs.expected-output/notmuch-hello-no-saved-searches
index 7f8206a..37b2303 100644
--- a/test/emacs.expected-output/notmuch-hello-no-saved-searches
+++ b/test/emacs.expected-output/notmuch-hello-no-saved-searches
@@ -2,9 +2,11 @@
 
 Search: 
 
-[Show all tags]
+All tags: [show]
 
 Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button.
   Hit RET or click on a saved search or tag name to view matching threads.
 `=' refreshes this screen. `s' jumps to the search box. `q' to quit.
+   Customize this page.
+
diff --git a/test/emacs.expected-output/notmuch-hello-section-co

[PATCH v6 0/2] emacs: User-defined sections in notmuch-hello

2011-10-10 Thread Daniel Schoepe
Fixed that and rebased against master.

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


[PATCH 2/2] python: annotate all calls into libnotmuch with types

2011-10-10 Thread Justus Winter
Add type information to the ctypes._FuncPtr wrappers and
use the wrapper classes instead of c_void_p for pointers
to notmuch_*_t.

This enables the ctypes library to type check parameters
being handed to functions from the notmuch library.

Signed-off-by: Justus Winter <4win...@informatik.uni-hamburg.de>
---
 bindings/python/notmuch/database.py |  127 ++
 bindings/python/notmuch/filename.py |   22 +-
 bindings/python/notmuch/message.py  |   91 -
 bindings/python/notmuch/tag.py  |   23 +--
 bindings/python/notmuch/thread.py   |   63 +
 5 files changed, 255 insertions(+), 71 deletions(-)

diff --git a/bindings/python/notmuch/database.py 
b/bindings/python/notmuch/database.py
index f4bc53e..25b4b1b 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -18,9 +18,11 @@ Copyright 2010 Sebastian Spaeth '
 """
 
 import os
-from ctypes import c_int, c_char_p, c_void_p, c_uint, c_long, byref
+from ctypes import c_int, c_char_p, c_void_p, c_uint, c_long, byref, POINTER
 from notmuch.globals import (nmlib, STATUS, NotmuchError, NotInitializedError,
- NullPointerError, OutOfMemoryError, XapianError, Enum, _str)
+ NullPointerError, OutOfMemoryError, XapianError, Enum, _str,
+ NotmuchDatabaseP, NotmuchDirectoryP, NotmuchMessageP, NotmuchTagsP,
+ NotmuchQueryP, NotmuchMessagesP, NotmuchThreadsP, NotmuchFilenamesP)
 from notmuch.thread import Threads
 from notmuch.message import Messages, Message
 from notmuch.tag import Tags
@@ -56,37 +58,48 @@ class Database(object):
 
 """notmuch_database_get_directory"""
 _get_directory = nmlib.notmuch_database_get_directory
-_get_directory.restype = c_void_p
+_get_directory.argtypes = [NotmuchDatabaseP, c_char_p]
+_get_directory.restype = NotmuchDirectoryP
 
 """notmuch_database_get_path"""
 _get_path = nmlib.notmuch_database_get_path
+_get_path.argtypes = [NotmuchDatabaseP]
 _get_path.restype = c_char_p
 
 """notmuch_database_get_version"""
 _get_version = nmlib.notmuch_database_get_version
+_get_version.argtypes = [NotmuchDatabaseP]
 _get_version.restype = c_uint
 
 """notmuch_database_open"""
 _open = nmlib.notmuch_database_open
-_open.restype = c_void_p
+_open.argtypes = [c_char_p, c_uint]
+_open.restype = NotmuchDatabaseP
 
 """notmuch_database_upgrade"""
 _upgrade = nmlib.notmuch_database_upgrade
-_upgrade.argtypes = [c_void_p, c_void_p, c_void_p]
+_upgrade.argtypes = [NotmuchDatabaseP, c_void_p, c_void_p]
+_upgrade.restype = c_uint
 
 """ notmuch_database_find_message"""
 _find_message = nmlib.notmuch_database_find_message
+_find_message.argtypes = [NotmuchDatabaseP, c_char_p, 
POINTER(NotmuchMessageP)]
+_find_message.restype = c_uint
 
 """notmuch_database_find_message_by_filename"""
 _find_message_by_filename = nmlib.notmuch_database_find_message_by_filename
+_find_message_by_filename.argtypes = [NotmuchDatabaseP, c_char_p, 
POINTER(NotmuchMessageP)]
+_find_message_by_filename.restype = c_uint
 
 """notmuch_database_get_all_tags"""
 _get_all_tags = nmlib.notmuch_database_get_all_tags
-_get_all_tags.restype = c_void_p
+_get_all_tags.argtypes = [NotmuchDatabaseP]
+_get_all_tags.restype = NotmuchTagsP
 
 """notmuch_database_create"""
 _create = nmlib.notmuch_database_create
-_create.restype = c_void_p
+_create.argtypes = [c_char_p]
+_create.restype = NotmuchDatabaseP
 
 def __init__(self, path=None, create=False, mode=0):
 """If *path* is `None`, we will try to read a users notmuch
@@ -186,6 +199,10 @@ class Database(object):
 self._assert_db_is_initialized()
 return Database._get_version(self._db)
 
+_needs_upgrade = nmlib.notmuch_database_needs_upgrade
+_needs_upgrade.argtypes = [NotmuchDatabaseP]
+_needs_upgrade.restype = bool
+
 def needs_upgrade(self):
 """Does this database need to be upgraded before writing to it?
 
@@ -197,7 +214,7 @@ class Database(object):
 :returns: `True` or `False`
 """
 self._assert_db_is_initialized()
-return nmlib.notmuch_database_needs_upgrade(self._db)
+return self._needs_upgrade(self._db)
 
 def upgrade(self):
 """Upgrades the current database
@@ -219,6 +236,10 @@ class Database(object):
 #TODO: catch exceptions, document return values and etc
 return status
 
+_begin_atomic = nmlib.notmuch_database_begin_atomic
+_begin_atomic.argtypes = [NotmuchDatabaseP]
+_begin_atomic.restype = c_uint
+
 def begin_atomic(self):
 """Begin an atomic database operation
 
@@ -236,11 +257,15 @@ class Database(object):
 
 *Added in notmuch 0.9*"""
 self._assert_db_is_initialized()
-status = nmlib.notmuch_database_begin_atomic(self._db)
+status = self._begin_atomic(self._db)
 if statu

[PATCH 1/2] python: add classes to wrap all notmuch_*_t types

2011-10-10 Thread Justus Winter
Signed-off-by: Justus Winter <4win...@informatik.uni-hamburg.de>
---
 bindings/python/notmuch/globals.py |   38 +++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/bindings/python/notmuch/globals.py 
b/bindings/python/notmuch/globals.py
index de1db16..36354fc 100644
--- a/bindings/python/notmuch/globals.py
+++ b/bindings/python/notmuch/globals.py
@@ -17,7 +17,7 @@ along with notmuch.  If not, see 
.
 Copyright 2010 Sebastian Spaeth '
 """
 
-from ctypes import CDLL, c_char_p, c_int
+from ctypes import CDLL, c_char_p, c_int, Structure, POINTER
 from ctypes.util import find_library
 
 #-
@@ -182,3 +182,39 @@ def _str(value):
 return value.encode('UTF-8')
 return value
 
+
+class NotmuchDatabaseS(Structure):
+pass
+NotmuchDatabaseP = POINTER(NotmuchDatabaseS)
+
+class NotmuchQueryS(Structure):
+pass
+NotmuchQueryP = POINTER(NotmuchQueryS)
+
+class NotmuchThreadsS(Structure):
+pass
+NotmuchThreadsP = POINTER(NotmuchThreadsS)
+
+class NotmuchThreadS(Structure):
+pass
+NotmuchThreadP = POINTER(NotmuchThreadS)
+
+class NotmuchMessagesS(Structure):
+pass
+NotmuchMessagesP = POINTER(NotmuchMessagesS)
+
+class NotmuchMessageS(Structure):
+pass
+NotmuchMessageP = POINTER(NotmuchMessageS)
+
+class NotmuchTagsS(Structure):
+pass
+NotmuchTagsP = POINTER(NotmuchTagsS)
+
+class NotmuchDirectoryS(Structure):
+pass
+NotmuchDirectoryP = POINTER(NotmuchDirectoryS)
+
+class NotmuchFilenamesS(Structure):
+pass
+NotmuchFilenamesP = POINTER(NotmuchFilenamesS)
-- 
1.7.6.3

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


Re: output file argument to notmuch dump.

2011-10-10 Thread Tomi Ollila
On Fri 07 Oct 2011 20:22, Jameson Graef Rollins  
writes:

> On Fri, 07 Oct 2011 14:15:39 +0300, Tomi Ollila  wrote:
>> The option 2, i.e. optional --write (or -o|--output) should be available;
>> someone may run notmuch without using environment that provides
>> redirections (or it is just plain simpler to give the command line option
>> instead of doing redirections).
>
> If that were the case then none of the other notmuch commands would work
> in the environment either.  If that's a concern, then notmuch should
> have a generic --redirect option that works for all commands, as Tom
> suggested out earlier.

Good point. I Agree. So, no spesific --write|-o|--output for dump is my
current vote.

>
> jamie.

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


Re: [PATCH] NEWS: add notes about emacs improvements and reply formating cleanup

2011-10-10 Thread Jameson Graef Rollins
On Sun, 09 Oct 2011 19:54:17 +0200, Thomas Schwinge  
wrote:
> Hmm, don't know.  Of course, c f also doesn't stash From:"Some One
> ", but just Some One .  On the
> other hand, the id:"[Message ID]" format has the advantage that it's
> directly usable as a notmuch search term.  I'm ambivalent.

I agree that it's sort of nice to be able to paste the result directly
on the command line, but I think it's really not that big of a deal to
just type "id:" before pasting on the command line.  I think that the
argument of consistency and the confusion it causes in non-notmuch
contexts makes it a stronger argument to remove the search term prefix.

My patch follows.  If anyone has any really vehement objection please
raise them, but ultimately I think this makes things cleaner and less
likely to cause problems in the long run.

jamie.


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


[PATCH] emacs: Modify notmuch-show-get-message-id to return message-id unprefixed with "id:".

2011-10-10 Thread Jameson Graef Rollins
This modifies the notmuch-show "c i" binding to yank just the
message-id to the kill-ring, without the "id:" prefix.  This makes
this yank binding consistent with the rest of the yank bindings in
that they don't include any search term prefixes.  This is a more
natural interface and will cause less confusion when pasting into
non-notmuch contexts.

Internal functions are modified to prepend the "id:" prefix as needed,
including the notmuch-show-get-bodypart-internal and
notmuch-show-save-part internal functions which are modified to accept
just the bare message-id as the primary argument.
---
 emacs/notmuch-show.el |   27 ++-
 test/emacs|2 +-
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8db5435..be85b12 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -99,7 +99,7 @@ any given message."
 (defmacro with-current-notmuch-show-message (&rest body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
- (let ((id (notmuch-show-get-message-id)))
+ (let ((id (concat "id:" (notmuch-show-get-message-id
(let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*"
  (with-current-buffer buf
(call-process notmuch-command nil t nil "show" "--format=raw" id)
@@ -412,7 +412,7 @@ current buffer, if possible."
  ;; times (hundreds!), which results in many calls to
  ;; `notmuch part'.
  (unless content
-   (setq content (notmuch-show-get-bodypart-internal (concat "id:" 
message-id)
+   (setq content (notmuch-show-get-bodypart-internal message-id
  part-number))
(with-current-buffer w3m-current-buffer
  (notmuch-show-w3m-cid-store-internal url
@@ -615,12 +615,13 @@ current buffer, if possible."
 ;; Uses the buffer-local variable notmuch-show-process-crypto to
 ;; determine if parts should be decrypted first.
 (defun notmuch-show-get-bodypart-internal (message-id part-number)
-  (let ((args '("show" "--format=raw"))
+  (let ((id (concat "id:" message-id))
+   (args '("show" "--format=raw"))
(part-arg (format "--part=%s" part-number)))
 (setq args (append args (list part-arg)))
 (if notmuch-show-process-crypto
(setq args (append args '("--decrypt"
-(setq args (append args (list message-id)))
+(setq args (append args (list id)))
 (with-temp-buffer
   (let ((coding-system-for-read 'no-conversion))
(progn
@@ -629,7 +630,7 @@ current buffer, if possible."
 
 (defun notmuch-show-get-bodypart-content (msg part nth)
   (or (plist-get part :content)
-  (notmuch-show-get-bodypart-internal (concat "id:" (plist-get msg :id)) 
nth)))
+  (notmuch-show-get-bodypart-internal (plist-get msg :id) nth)))
 
 ;; 
 
@@ -1050,7 +1051,7 @@ All currently available key bindings:
 
 (defun notmuch-show-get-message-id ()
   "Return the message id of the current message."
-  (concat "id:\"" (notmuch-show-get-prop :id) "\""))
+  (concat "\"" (notmuch-show-get-prop :id) "\""))
 
 ;; dme: Would it make sense to use a macro for many of these?
 
@@ -1195,7 +1196,7 @@ any effects from previous calls to
 (defun notmuch-show-reply (&optional prompt-for-sender)
   "Reply to the current message."
   (interactive "P")
-  (notmuch-mua-new-reply (notmuch-show-get-message-id) prompt-for-sender))
+  (notmuch-mua-new-reply (concat "id:" (notmuch-show-get-message-id)) 
prompt-for-sender))
 
 (defun notmuch-show-forward-message (&optional prompt-for-sender)
   "Forward the current message."
@@ -1242,7 +1243,7 @@ any effects from previous calls to
 (defun notmuch-show-view-raw-message ()
   "View the file holding the current message."
   (interactive)
-  (let* ((id (notmuch-show-get-message-id))
+  (let* ((id (concat "id:" (notmuch-show-get-message-id)))
 (buf (get-buffer-create (concat "*notmuch-raw-" id "*"
 (call-process notmuch-command nil buf nil "show" "--format=raw" id)
 (switch-to-buffer buf)
@@ -1266,11 +1267,11 @@ than only the current message."
(setq shell-command 
  (concat notmuch-command " show --format=mbox "
  (shell-quote-argument
-  (mapconcat 'identity 
(notmuch-show-get-message-ids-for-open-messages) " OR "))
+  (mapconcat 'identity "id:" 
(notmuch-show-get-message-ids-for-open-messages) " OR "))
  " | " command))
   (setq shell-command
(concat notmuch-command " show --format=raw "
-   (shell-quote-argument (notmuch-show-get-message-id)) " | " 
command)))
+   (shell-quote-argument (concat "id:" 
(notmuch-show-get-message-id))) " | " command)))
 (let ((buf (get-buffer-create (concat "*notmuch-pipe*"
   (with-current-buffer buf
(setq buffer-read-only nil)
@@ -1312,7 +1313,7

Re: [PATCH] NEWS: add notes about emacs improvements and reply formating cleanup

2011-10-10 Thread Thomas Schwinge
Hi!

On Sat, 08 Oct 2011 20:55:59 -0700, Jameson Graef Rollins 
 wrote:
> Ok, I just realized why these messages aren't showing up in reply to the
> messages I intend: it's the "id:" prefix that's there when I use "c i"
> to copy the message ID to the kill-ring!  I'm then in-reply-to'ing
> 
> id:87ipnzd4ds.fsf@zancas.localnet
> 
> instead of just
> 
> 87ipnzd4ds.fsf@zancas.localnet

Well, yes.  :-)

> Patch to fix that to follow!

Hmm, don't know.  Of course, c f also doesn't stash From:"Some One
", but just Some One .  On the
other hand, the id:"[Message ID]" format has the advantage that it's
directly usable as a notmuch search term.  I'm ambivalent.


Grüße,
 Thomas


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


Re: output file argument to notmuch dump.

2011-10-10 Thread David Bremner
On Thu, 06 Oct 2011 21:20:40 -0300, David Bremner  wrote:
> 
> I'd like to add a search term argument to notmuch dump (see
> id:"87wrcijn1w.fsf@zancas.localnet" and followup for context). The
> "notmuch" way would be to have
> 
> notmuch dump 
> 
> do the right thing

Another option occured to me that is consistent at least with notmuch
tag and notmuch show would be to support the following transitional
syntaxes

notmuch dump file
notmuch dump file [--] search terms
notmuch dump -- search terms

the first two could then be deprecated, and eventually the syntax

notmuch dump search terms 

could be enabled.

the question of whether to support 

notmuch dump --file foo.txt

or something like 

   notmuch --stdout=foo.txt dump

could be dealt with later.

David


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


[PATCH 2/2] python: annotate all calls into libnotmuch with types

2011-10-10 Thread Justus Winter
Add type information to the ctypes._FuncPtr wrappers and
use the wrapper classes instead of c_void_p for pointers
to notmuch_*_t.

This enables the ctypes library to type check parameters
being handed to functions from the notmuch library.

Signed-off-by: Justus Winter <4winter at informatik.uni-hamburg.de>
---
 bindings/python/notmuch/database.py |  127 ++
 bindings/python/notmuch/filename.py |   22 +-
 bindings/python/notmuch/message.py  |   91 -
 bindings/python/notmuch/tag.py  |   23 +--
 bindings/python/notmuch/thread.py   |   63 +
 5 files changed, 255 insertions(+), 71 deletions(-)

diff --git a/bindings/python/notmuch/database.py 
b/bindings/python/notmuch/database.py
index f4bc53e..25b4b1b 100644
--- a/bindings/python/notmuch/database.py
+++ b/bindings/python/notmuch/database.py
@@ -18,9 +18,11 @@ Copyright 2010 Sebastian Spaeth '
 """

 import os
-from ctypes import c_int, c_char_p, c_void_p, c_uint, c_long, byref
+from ctypes import c_int, c_char_p, c_void_p, c_uint, c_long, byref, POINTER
 from notmuch.globals import (nmlib, STATUS, NotmuchError, NotInitializedError,
- NullPointerError, OutOfMemoryError, XapianError, Enum, _str)
+ NullPointerError, OutOfMemoryError, XapianError, Enum, _str,
+ NotmuchDatabaseP, NotmuchDirectoryP, NotmuchMessageP, NotmuchTagsP,
+ NotmuchQueryP, NotmuchMessagesP, NotmuchThreadsP, NotmuchFilenamesP)
 from notmuch.thread import Threads
 from notmuch.message import Messages, Message
 from notmuch.tag import Tags
@@ -56,37 +58,48 @@ class Database(object):

 """notmuch_database_get_directory"""
 _get_directory = nmlib.notmuch_database_get_directory
-_get_directory.restype = c_void_p
+_get_directory.argtypes = [NotmuchDatabaseP, c_char_p]
+_get_directory.restype = NotmuchDirectoryP

 """notmuch_database_get_path"""
 _get_path = nmlib.notmuch_database_get_path
+_get_path.argtypes = [NotmuchDatabaseP]
 _get_path.restype = c_char_p

 """notmuch_database_get_version"""
 _get_version = nmlib.notmuch_database_get_version
+_get_version.argtypes = [NotmuchDatabaseP]
 _get_version.restype = c_uint

 """notmuch_database_open"""
 _open = nmlib.notmuch_database_open
-_open.restype = c_void_p
+_open.argtypes = [c_char_p, c_uint]
+_open.restype = NotmuchDatabaseP

 """notmuch_database_upgrade"""
 _upgrade = nmlib.notmuch_database_upgrade
-_upgrade.argtypes = [c_void_p, c_void_p, c_void_p]
+_upgrade.argtypes = [NotmuchDatabaseP, c_void_p, c_void_p]
+_upgrade.restype = c_uint

 """ notmuch_database_find_message"""
 _find_message = nmlib.notmuch_database_find_message
+_find_message.argtypes = [NotmuchDatabaseP, c_char_p, 
POINTER(NotmuchMessageP)]
+_find_message.restype = c_uint

 """notmuch_database_find_message_by_filename"""
 _find_message_by_filename = nmlib.notmuch_database_find_message_by_filename
+_find_message_by_filename.argtypes = [NotmuchDatabaseP, c_char_p, 
POINTER(NotmuchMessageP)]
+_find_message_by_filename.restype = c_uint

 """notmuch_database_get_all_tags"""
 _get_all_tags = nmlib.notmuch_database_get_all_tags
-_get_all_tags.restype = c_void_p
+_get_all_tags.argtypes = [NotmuchDatabaseP]
+_get_all_tags.restype = NotmuchTagsP

 """notmuch_database_create"""
 _create = nmlib.notmuch_database_create
-_create.restype = c_void_p
+_create.argtypes = [c_char_p]
+_create.restype = NotmuchDatabaseP

 def __init__(self, path=None, create=False, mode=0):
 """If *path* is `None`, we will try to read a users notmuch
@@ -186,6 +199,10 @@ class Database(object):
 self._assert_db_is_initialized()
 return Database._get_version(self._db)

+_needs_upgrade = nmlib.notmuch_database_needs_upgrade
+_needs_upgrade.argtypes = [NotmuchDatabaseP]
+_needs_upgrade.restype = bool
+
 def needs_upgrade(self):
 """Does this database need to be upgraded before writing to it?

@@ -197,7 +214,7 @@ class Database(object):
 :returns: `True` or `False`
 """
 self._assert_db_is_initialized()
-return nmlib.notmuch_database_needs_upgrade(self._db)
+return self._needs_upgrade(self._db)

 def upgrade(self):
 """Upgrades the current database
@@ -219,6 +236,10 @@ class Database(object):
 #TODO: catch exceptions, document return values and etc
 return status

+_begin_atomic = nmlib.notmuch_database_begin_atomic
+_begin_atomic.argtypes = [NotmuchDatabaseP]
+_begin_atomic.restype = c_uint
+
 def begin_atomic(self):
 """Begin an atomic database operation

@@ -236,11 +257,15 @@ class Database(object):

 *Added in notmuch 0.9*"""
 self._assert_db_is_initialized()
-status = nmlib.notmuch_database_begin_atomic(self._db)
+status = self._begin_atomic(self._db)
 if status != STATUS.SU

[PATCH 1/2] python: add classes to wrap all notmuch_*_t types

2011-10-10 Thread Justus Winter
Signed-off-by: Justus Winter <4winter at informatik.uni-hamburg.de>
---
 bindings/python/notmuch/globals.py |   38 +++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/bindings/python/notmuch/globals.py 
b/bindings/python/notmuch/globals.py
index de1db16..36354fc 100644
--- a/bindings/python/notmuch/globals.py
+++ b/bindings/python/notmuch/globals.py
@@ -17,7 +17,7 @@ along with notmuch.  If not, see 
.
 Copyright 2010 Sebastian Spaeth '
 """

-from ctypes import CDLL, c_char_p, c_int
+from ctypes import CDLL, c_char_p, c_int, Structure, POINTER
 from ctypes.util import find_library

 #-
@@ -182,3 +182,39 @@ def _str(value):
 return value.encode('UTF-8')
 return value

+
+class NotmuchDatabaseS(Structure):
+pass
+NotmuchDatabaseP = POINTER(NotmuchDatabaseS)
+
+class NotmuchQueryS(Structure):
+pass
+NotmuchQueryP = POINTER(NotmuchQueryS)
+
+class NotmuchThreadsS(Structure):
+pass
+NotmuchThreadsP = POINTER(NotmuchThreadsS)
+
+class NotmuchThreadS(Structure):
+pass
+NotmuchThreadP = POINTER(NotmuchThreadS)
+
+class NotmuchMessagesS(Structure):
+pass
+NotmuchMessagesP = POINTER(NotmuchMessagesS)
+
+class NotmuchMessageS(Structure):
+pass
+NotmuchMessageP = POINTER(NotmuchMessageS)
+
+class NotmuchTagsS(Structure):
+pass
+NotmuchTagsP = POINTER(NotmuchTagsS)
+
+class NotmuchDirectoryS(Structure):
+pass
+NotmuchDirectoryP = POINTER(NotmuchDirectoryS)
+
+class NotmuchFilenamesS(Structure):
+pass
+NotmuchFilenamesP = POINTER(NotmuchFilenamesS)
-- 
1.7.6.3