[RFC PATCH 3/9] lib: fix messages.c build warn

2012-01-07 Thread Austin Clements
I don't have much opinion on the other patches in this series (the C99
variadic macro stuff is unfortunate), but this one should go in.

Quoth Jani Nikula on Jan 08 at  1:26 am:
> lib/messages.c: In function ?notmuch_messages_move_to_next?:
> lib/messages.c:131:2: warning: ISO C forbids ?return? with expression, in 
> function returning void [-pedantic]
> 
> Signed-off-by: Jani Nikula 
> ---
>  lib/messages.c |6 --
>  1 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/messages.c b/lib/messages.c
> index 7bcd1ab..1121864 100644
> --- a/lib/messages.c
> +++ b/lib/messages.c
> @@ -127,8 +127,10 @@ notmuch_messages_get (notmuch_messages_t *messages)
>  void
>  notmuch_messages_move_to_next (notmuch_messages_t *messages)
>  {
> -if (! messages->is_of_list_type)
> - return _notmuch_mset_messages_move_to_next (messages);
> +if (! messages->is_of_list_type) {
> + _notmuch_mset_messages_move_to_next (messages);
> + return;
> +}
>  
>  if (messages->iterator == NULL)
>   return;


[PATCH 4/4] emacs: use pop-at-end functionality in archive/delete-message functions

2012-01-07 Thread Jameson Graef Rollins
This provides a smoother message processing flow by reducing the
number of key presses needed for these common operations.
---
 emacs/notmuch-show.el |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 4c2b507..7103c23 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1454,7 +1454,7 @@ thread.
 "
 (interactive)
 (notmuch-show-remove-tag "inbox")
-(notmuch-show-next-open-message)))
+(notmuch-show-next-open-message t)))

 (defun notmuch-show-archive-thread ()
   "Archive each message in thread, then show next thread from search.
@@ -1485,7 +1485,7 @@ thread.
 "
 (interactive)
 (notmuch-show-add-tag "deleted")
-(notmuch-show-next-open-message)))
+(notmuch-show-next-open-message t)))

 (defun notmuch-show-delete-thread ()
   "Delete each message in thread, then show next thread from search.
-- 
1.7.7.3



[PATCH 3/4] emacs: modify the default show-mode key bindings for archiving/deleting

2012-01-07 Thread Jameson Graef Rollins
This changes the default key bindings for the 'a' and 'd' keys in
notmuch-show mode.  Instead of archiving/deleting the entire thread,
they now just archive/delete the current message, and then advance to
the next open message.

'A' and 'D' are rebound to the previous archive/delete-thread
functions.
---
 emacs/notmuch-show.el |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e7bb958..4c2b507 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -943,8 +943,10 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
(define-key map "-" 'notmuch-show-remove-tag)
(define-key map "+" 'notmuch-show-add-tag)
(define-key map "x" 'notmuch-show-archive-thread-then-exit)
-   (define-key map "a" 'notmuch-show-archive-thread)
-   (define-key map "d" 'notmuch-show-delete-thread)
+   (define-key map "a" 'notmuch-show-archive-message)
+   (define-key map "A" 'notmuch-show-archive-thread)
+   (define-key map "d" 'notmuch-show-delete-message)
+   (define-key map "D" 'notmuch-show-delete-thread)
(define-key map "N" 'notmuch-show-next-message)
(define-key map "P" 'notmuch-show-previous-message)
(define-key map "n" 'notmuch-show-next-open-message)
-- 
1.7.7.3



[PATCH 2/4] emacs: add option to notmuch-show-next-open-message to pop out to parent buffer if at end

2012-01-07 Thread Jameson Graef Rollins
This will allow for keybindings that achieve a smoother message
processing flow by reducing the number of key presses needed for most
common operations.
---
 emacs/notmuch-show.el |   12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8bb052e..e7bb958 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1264,17 +1264,23 @@ any effects from previous calls to
   (notmuch-show-mark-read)
   (notmuch-show-message-adjust))

-(defun notmuch-show-next-open-message ()
+(defun notmuch-show-next-open-message ( pop-at-end)
   "Show the next message."
   (interactive)
-  (let (r)
+  (let ((r)
+   (parent-buffer notmuch-show-parent-buffer))
 (while (and (setq r (notmuch-show-goto-message-next))
(not (notmuch-show-message-visible-p
 (if r
(progn
  (notmuch-show-mark-read)
  (notmuch-show-message-adjust))
-  (goto-char (point-max)
+  (if (and parent-buffer pop-at-end)
+ (progn
+   (kill-this-buffer)
+   (switch-to-buffer parent-buffer)
+   (forward-line 1))
+   (goto-char (point-max))

 (defun notmuch-show-previous-open-message ()
   "Show the previous message."
-- 
1.7.7.3



[PATCH 1/4] emacs: add show-mode functions to archive/delete only current message

2012-01-07 Thread Jameson Graef Rollins
This adds two new function, notmuch-show-{archive,delete}-message,
that archive/delete the current message, and then move to the next
open one.
---
 emacs/notmuch-show.el |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e1d15f4..8bb052e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1436,6 +1436,18 @@ argument, hide all of the messages."
(if show-next
(notmuch-search-show-thread)))

+(defun notmuch-show-archive-message ()
+  "Archive the current message and advance.
+
+After the last message is reached, either the buffer will be
+closed and the cursor will move to the search result if
+available, or the cursor will move to the end of the current
+thread.
+"
+(interactive)
+(notmuch-show-remove-tag "inbox")
+(notmuch-show-next-open-message)))
+
 (defun notmuch-show-archive-thread ()
   "Archive each message in thread, then show next thread from search.

@@ -1455,6 +1467,18 @@ buffer."
   (interactive)
   (notmuch-show-tag-thread-internal "-" "inbox" nil))

+(defun notmuch-show-delete-message ()
+  "Delete the current message and advance.
+
+After the last message is reached, either the buffer will be
+closed and the cursor will move to the search result if
+available, or the cursor will move to the end of the current
+thread.
+"
+(interactive)
+(notmuch-show-add-tag "deleted")
+(notmuch-show-next-open-message)))
+
 (defun notmuch-show-delete-thread ()
   "Delete each message in thread, then show next thread from search.

-- 
1.7.7.3



change to default archive/delete key bindings

2012-01-07 Thread Jameson Graef Rollins
While working on the delete message handling patches, I was reminded
how much I really dislike the default show-mode key bindings.  Why
can't I just archive/delete the current message, without archiving the
entire thread?  It doesn't make any sense.

Here we add two new functions to archive and delete just the single
message, and then move to the next open message.  We also add an
option to the -next-open-message function so that it will pop back out
to the parent search buffer when reaching the end of the thread.  This
should make message processing flow much smoother.

Patches 1,2 and 4 can be applied even if the consensus is to not
change the default key bindings, to make it easier for users to
achieve the desired functionality without having to write their own
functions.

jamie.



[PATCH 4/4] emacs: modify help message for notmuch-search-line-faces to reflect preferred "deleted" tag name.

2012-01-07 Thread Jameson Graef Rollins
No functional change here.  The help message previously referred to
the "delete" tag, but "deleted" is now preferred, so hopefully this
will reduce any potential confusion.
---
 emacs/notmuch.el |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2b860f4..ebdc7d1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -658,12 +658,12 @@ will be excluded from searches."
 Here is an example of how to color search results based on tags.
  (the following text would be placed in your ~/.emacs file):

- (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"
+ (setq notmuch-search-line-faces '((\"deleted\" . (:foreground \"red\"
  :background \"blue\"))
(\"unread\" . (:foreground \"green\"

 The attributes defined for matching tags are merged, with later
-attributes overriding earlier. A message having both \"delete\"
+attributes overriding earlier. A message having both \"deleted\"
 and \"unread\" tags with the above settings would have a green
 foreground and blue background."
   :type '(alist :key-type (string) :value-type (custom-face-edit))
-- 
1.7.7.3



[PATCH 3/4] emacs: add ability to "delete" messages and threads

2012-01-07 Thread Jameson Graef Rollins
This completely mimics the behavior of archiving, but instead of
remove the inbox tag it add the "deleted" tag.  The functionality is
bound to the 'd' key in both search and show mode.

Note: this does *not* actually delete any messages.  That is still
left entirely up to the user to figure out how they want to handle
that.  This *just* adds the "deleted" tag to messages, no more.  If
the notmuch-search-exclude-deleted config variable is set, though,
"deleted" messages will be excluded from search results.
---
 emacs/notmuch-show.el |   15 +++
 emacs/notmuch.el  |   12 
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1e16f05..e1d15f4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -944,6 +944,7 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
(define-key map "+" 'notmuch-show-add-tag)
(define-key map "x" 'notmuch-show-archive-thread-then-exit)
(define-key map "a" 'notmuch-show-archive-thread)
+   (define-key map "d" 'notmuch-show-delete-thread)
(define-key map "N" 'notmuch-show-next-message)
(define-key map "P" 'notmuch-show-previous-message)
(define-key map "n" 'notmuch-show-next-open-message)
@@ -1454,6 +1455,20 @@ buffer."
   (interactive)
   (notmuch-show-tag-thread-internal "-" "inbox" nil))

+(defun notmuch-show-delete-thread ()
+  "Delete each message in thread, then show next thread from search.
+
+Delete each message currently shown by adding the \"deleted\"
+tag to each. Then kill this buffer and show the next thread
+from the search from which this thread was originally shown.
+
+Note: This command is safe from any race condition of new messages
+being delivered to the same thread. It does not archive the
+entire thread, but only the messages shown in the current
+buffer."
+  (interactive)
+  (notmuch-show-tag-thread-internal "+" "deleted" t))
+
 (defun notmuch-show-stash-cc ()
   "Copy CC field of current message to kill-ring."
   (interactive)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c519687..2b860f4 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -218,6 +218,7 @@ For a mouse binding, return nil."
 (define-key map [mouse-1] 'notmuch-search-show-thread)
 (define-key map "*" 'notmuch-search-operate-all)
 (define-key map "a" 'notmuch-search-archive-thread)
+(define-key map "d" 'notmuch-search-delete-thread)
 (define-key map "-" 'notmuch-search-remove-tag)
 (define-key map "+" 'notmuch-search-add-tag)
 (define-key map (kbd "RET") 'notmuch-search-show-thread)
@@ -605,6 +606,17 @@ This function advances the next thread when finished."
   (notmuch-search-remove-tag-thread "inbox")
   (forward-line))

+(defun notmuch-search-delete-thread ()
+  "Delete the currently selected thread (add the \"deleted\" tag).
+
+This function advances the next thread when finished.
+
+If notmuch-search-exclude-deleted is set, \"deleted\" messages
+will be excluded from searches."
+  (interactive)
+  (notmuch-search-add-tag "deleted")
+  (forward-line))
+
 (defvar notmuch-search-process-filter-data nil
   "Data that has not yet been processed.")
 (make-variable-buffer-local 'notmuch-search-process-filter-data)
-- 
1.7.7.3



[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-07 Thread Jameson Graef Rollins
Instead of having a function that is only used for archiving a thread,
we instead make it useful for any tagging operation.  The new
function, notmuch-show-tag-thread-internal, now takes two more
arguments, for the "sign" of the tagging operation ("-" or "+"), and
the tag to be added or removed.  This will allow this function to be
used for any generic thread tagging operation.

The higher level functions that call this function are modified
accordingly.
---
 emacs/notmuch-show.el |   34 --
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..1e16f05 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1414,20 +1414,26 @@ argument, hide all of the messages."
   (interactive)
   (backward-button 1))

-(defun notmuch-show-archive-thread-internal (show-next)
+(defun notmuch-show-tag-thread-internal (sign tag show-next)
   ;; Remove the tag from the current set of messages.
   (goto-char (point-min))
-  (loop do (notmuch-show-remove-tag "inbox")
-   until (not (notmuch-show-goto-message-next)))
-  ;; Move to the next item in the search results, if any.
-  (let ((parent-buffer notmuch-show-parent-buffer))
-(notmuch-kill-this-buffer)
-(if parent-buffer
-   (progn
- (switch-to-buffer parent-buffer)
- (forward-line)
- (if show-next
- (notmuch-search-show-thread))
+  (let ((tag-function))
+(cond
+ ((string= sign "-")
+  (setq tag-function 'notmuch-show-remove-tag))
+ ((string= sign "+")
+  (setq tag-function 'notmuch-show-add-tag)))
+(loop do (funcall tag-function tag)
+ until (not (notmuch-show-goto-message-next)))
+;; Move to the next item in the search results, if any.
+(let ((parent-buffer notmuch-show-parent-buffer))
+  (notmuch-kill-this-buffer)
+  (if parent-buffer
+ (progn
+   (switch-to-buffer parent-buffer)
+   (forward-line)
+   (if show-next
+   (notmuch-search-show-thread)))

 (defun notmuch-show-archive-thread ()
   "Archive each message in thread, then show next thread from search.
@@ -1441,12 +1447,12 @@ being delivered to the same thread. It does not archive 
the
 entire thread, but only the messages shown in the current
 buffer."
   (interactive)
-  (notmuch-show-archive-thread-internal t))
+  (notmuch-show-tag-thread-internal "-" "inbox" t))

 (defun notmuch-show-archive-thread-then-exit ()
   "Archive each message in thread, then exit back to search results."
   (interactive)
-  (notmuch-show-archive-thread-internal nil))
+  (notmuch-show-tag-thread-internal "-" "inbox" nil))

 (defun notmuch-show-stash-cc ()
   "Copy CC field of current message to kill-ring."
-- 
1.7.7.3



[PATCH 1/4] emacs: new customization variable to exclude "deleted" messages from search

2012-01-07 Thread Jameson Graef Rollins
The new customization variable, notmuch-search-exclude-deleted, when
set to t, will exclude any messages with the "deleted" tag from
searches.

Additionally, specifying "tag:deleted" in the search directly will
override the exclusion and will included deleted messages in the
search results.
---
 emacs/notmuch.el   |8 
 test/emacs |   42 
 .../notmuch-search-tag-inbox-deleted-excluded  |   24 +++
 3 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 
test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..c519687 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -905,6 +905,11 @@ PROMPT is the string to prompt with."
   (read-from-minibuffer prompt nil keymap nil
'notmuch-query-history nil nil

+(defcustom notmuch-search-exclude-deleted nil
+  "Exclude deleted messages (with \"deleted\" tag) from search results."
+  :group 'notmuch
+  :type 'boolean)
+
 ;;;###autoload
 (defun notmuch-search (query  oldest-first target-thread target-line 
continuation)
   "Run \"notmuch search\" with the given query string and display results.
@@ -927,6 +932,9 @@ The optional parameters are used as follows:
 (set 'notmuch-search-target-thread target-thread)
 (set 'notmuch-search-target-line target-line)
 (set 'notmuch-search-continuation continuation)
+(when (and notmuch-search-exclude-deleted
+  (not (string-match "tag:deleted[ )]*" query)))
+  (setq query (concat query " and not tag:deleted")))
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
   (if proc
diff --git a/test/emacs b/test/emacs
index a06c223..1d78fbe 100755
--- a/test/emacs
+++ b/test/emacs
@@ -35,6 +35,48 @@ test_emacs '(notmuch-search "tag:inbox")
(test-output)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox

+test_begin_subtest "Exclude \"deleted\" messages from search"
+notmuch tag +deleted id:1258506353-20352-1-git-send-email-stewart at 
flamingspork.com
+# we "delete" a second message that's part of a multi-message thread
+# to make sure the rest of the thread is still returned
+notmuch tag +deleted id:1258471718-6781-1-git-send-email-dottedmag at 
dottedmag.net
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search "tag:inbox")
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted id:1258506353-20352-1-git-send-email-stewart at 
flamingspork.com
+notmuch tag -deleted id:1258471718-6781-1-git-send-email-dottedmag at 
dottedmag.net
+test_expect_equal_file OUTPUT 
$EXPECTED/notmuch-search-tag-inbox-deleted-excluded
+
+test_begin_subtest "Exclude \"deleted\" messages from search, manual override"
+notmuch tag +deleted id:1258506353-20352-1-git-send-email-stewart at 
flamingspork.com
+notmuch tag +deleted id:1258471718-6781-1-git-send-email-dottedmag at 
dottedmag.net
+cat 

another attempt to add delete functionality in emacs

2012-01-07 Thread Jameson Graef Rollins
So, after many stabs at adding the ability to "delete" messages in
emacs [0], and the corresponding heated discussions, I'm throwing
another attempt into the fray.

I try to address the concerns that have come up in previous attempts.
In particular, I include a patch that creates a new customization
variable, notmuch-search-exclude-deleted, that will exclude any
messages with the "deleted" tag from searches.  This actually makes
"deleted" messages appear effectively deleted, which is one of the
things cworth wanted to see, and one of the reasons he kept pushing
back on previous attempts at this functionality.

Also, no tags other than "deleted" are modified.  All tags should be
orthogonal, and should be handled so.

Note: this is all about handling the "deleted" tag.  No actual
deletion of message is involved in this functionality at all.  Actual
deletion of messages should always be left entirely up to the user to
handle as they see fit.

jamie.

[0] id:"1266408746-28549-1-git-send-email-Sebastian at SSpaeth.de"
id:"87sk8qwjlt.fsf at yoom.home.cworth.org"
id:"1271891763-10757-1-git-send-email-hohndel at infradead.org"
id:"1310841600-28281-1-git-send-email-anarcat at koumbit.org"



Info about notmuch database

2012-01-07 Thread boyska
On Thu, Jan 05, 2012 at 05:35:55PM +0100, Thomas Jost wrote:
> On Thu, 5 Jan 2012 16:38:07 +0100, boyska  wrote:
> > > There's a description of the DB "schema" in lib/database.cc in the
> > > notmuch source code. But you may also consider just using libnotmuch
> > > instead, if that's enough for what you want to do.
> > 
> > thanks, found it, much clearer now.
> > But I really can't understand why not just putting these things on a
> > separate file :) atomic consistency issues?
> 
> I doubt it's for consistency (see commit 824dad76), more likely it's
> because people should use libnotmuch rather than directly hacking into
> the DB ;)

Fine; I'll probably keep the whole output of "find" as the data of a
SINGLE entry, instead of one entry for directory. This just seems easier
to me.

> Do you plan to use this addressbook with notmuch-address.el, or will it
> be a standalone program?

It will be a standalone program, meant to be used with mutt-query [1].
So just call "notmany thomas" on commandline, and your email will
appear.
I don't use emacs, so I won't write an emacs tool (nor I know how
notmuch-address.el works), but I am trying to keep library and UI
separate, so writing a wrapper suitable for emacs is possible, and
probably very easy.

[1] http://wiki.mutt.org/?QueryCommand



[PATCH 1/4] cli: fix use of uninitialized variable in "notmuch reply"

2012-01-07 Thread Mark Walters

Hello

I do not get the failure with just 1/4 applied but do with all 4
applied. The trivial patch below fixes it, but it might not be the best
solution.

The failure occurs because Jani's patch changes the behavior of a couple
of emacs/notmuch internal functions: the function
notmuch-search-reply-to-thread is renamed to
notmuch-search-reply-all-to-thread and a new
notmuch-search-reply-to-thread function is added (which does reply to
sender) and a similar change for notmuch-show-reply-.. . Since the
keybindings are also remapped the user will not notice any difference.

However, if the user has any key-bindings etc in their .emacs file the
behaviour could change. It might be preferable to keep the existing
functions as they are and give the new reply-to-sender functions a new
name.

Best wishes

Mark


diff --git a/test/emacs b/test/emacs
index a06c223..5047d46 100755
--- a/test/emacs
+++ b/test/emacs
@@ -258,7 +258,7 @@ test_expect_equal_file OUTPUT EXPECTED
 test_begin_subtest "Reply within emacs"
 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
(notmuch-test-wait)
-   (notmuch-search-reply-to-thread)
+   (notmuch-search-reply-all-to-thread)
(test-output)'
 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: /' OUTPUT
 cat 

[PATCH 0/4] notmuch reply bugfix & reply to sender only

2012-01-07 Thread Mueen Nawaz
Jameson Graef Rollins
 writes:

> On Thu,  5 Jan 2012 22:25:11 +0200, Jani Nikula  wrote:
>> Bikeshedding topic #1: How about making replying to just the sender the 
>> default
>> in "notmuch reply", and having --reply-all option (instead of 
>> --no-reply-all)?
>> 
>> Bikeshedding topic #2: How about binding 'r' to reply to just the sender by
>> default, and making 'R' reply-all (instead of vice versa)?
>
> I personally like both of these suggestions, and would not be bothered
> by the changed default, so I support both of these changes.

I too feel that 'r' should reply only to sender, and 'R' should reply
all. Having reply-all as default is a pain.




[PATCH] restore: Be more liberal in which data to accept.

2012-01-07 Thread Jameson Graef Rollins
On Sat, 07 Jan 2012 09:37:20 -0400, David Bremner  wrote:
> 2) can you share (by private email is a fine) a few of those really
>problematic messages so I can use them to test the new dump/restore code?

I think the better option would be to create a test that runs through
all the horrible message ids we can dream up.

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/20120107/617c21c1/attachment.pgp>


[PATCH] restore: Be more liberal in which data to accept.

2012-01-07 Thread David Bremner
On Sat, 29 Oct 2011 12:40:07 +0200, Thomas Schwinge  
wrote:
> From: Thomas Schwinge 
> 
> There are ``Message-ID''s out in the wild that contain spaces.
> 

> Spammers are quite inventive for creating ``interesting Messages-ID''s.
> Apparently, notmuch handles these fine internally, but it breaks a
> dump/restore cycle:

Two questions.

1) Do you think we should change the current regex as well as provide a
new space tolerant format
(id:"1324214111-32079-1-git-send-email-david at tethera.net")? I guess it
doesn't really hurt. Notmuch is probably already creating dump files
that sup can't read in your case.

2) can you share (by private email is a fine) a few of those really
   problematic messages so I can use them to test the new dump/restore code?




[PATCH 1/4] cli: fix use of uninitialized variable in "notmuch reply"

2012-01-07 Thread Jani Nikula
On Jan 7, 2012 5:52 AM, "David Bremner"  wrote:
>
> On Thu,  5 Jan 2012 22:25:12 +0200, Jani Nikula  wrote:
> > notmuch_show_params_t params is only initialized partially in
> > notmuch_reply_command(). The only field that is used uninitialized is
> > params.decrypt. It is usually non-zero, making "notmuch reply" on
encrypted
> > messages work by coincidence.
>
> Hi Jani;
>
> I get one test failure with this patch on current master:

Can't investigate right now, but did you try with just patch 1/4? (I really
should have separated the bug fix from the rest.)

J.

>
>  FAIL   Reply within emacs
>--- emacs.24.expected   2012-01-07 03:47:50.0 +
>+++ emacs.24.output 2012-01-07 03:47:50.0 +
>@@ -1,5 +1,5 @@
> From: Notmuch Test Suite 
>-To: user at example.com
>+To:
> Subject: Re: Testing message sent via SMTP
> In-Reply-To: 
> Fcc: /tmp/notmuch-dev-bremner/test/tmp.emacs/mail/sent
>
> d
-- next part --
An HTML attachment was scrubbed...
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120107/84f28439/attachment.html>


[PATCH 1/4] cli: fix use of uninitialized variable in "notmuch reply"

2012-01-07 Thread David Bremner
On Sat, 7 Jan 2012 09:31:35 +0200, Jani Nikula  wrote:
> On Jan 7, 2012 5:52 AM, "David Bremner"  wrote:
> >
> > On Thu,  5 Jan 2012 22:25:12 +0200, Jani Nikula  wrote:
> > > notmuch_show_params_t params is only initialized partially in
> > > notmuch_reply_command(). The only field that is used uninitialized is
> > > params.decrypt. It is usually non-zero, making "notmuch reply" on
> encrypted
> > > messages work by coincidence.
> >
> > Hi Jani;
> >
> > I get one test failure with this patch on current master:
> 
> Can't investigate right now, but did you try with just patch 1/4? (I really
> should have separated the bug fix from the rest.)
> 
> J.
> 

Hi Jani;

I _thought_ I was applying just that one patch, but I can't duplicate
the error now, so I might have messed up using dme's new "patch
application wizard". So, nevermind, sorry for the noise.

d


[PATCH v2] emacs: Helpers for notmuch developers.

2012-01-07 Thread David Bremner
On Fri,  6 Jan 2012 10:03:19 +, David Edmondson  wrote:
> ---
> 
> - Prefix the branch name with 'review/'
> - Avoid `shell-command', which also results in better error reporting
>   when 'git-am' fails.
> 

One thing I noticed is that reviewing a patch for the second time fails
because the branch already exists. I'm not sure if this is covered under
"upkeep of the repo" but it is a little inconvenient.


[PATCH] emacs: Helpers for notmuch developers.

2012-01-07 Thread Tomi Ollila
On Wed,  4 Jan 2012 14:01:18 +, David Edmondson  wrote:
> ---
> 
> I've been using this for a few days and decided to share it to get
> feedback. Reviewing patches can be tedious, so I tried to make things
> a little simpler.
> 
> To use this, load the file and then from `notmuch-show-mode' invoke
> `notmuch-dev-show-review-patch'. It assumes that any open messages
> contain patches and attempts to build a repository with the patches
> applied.
> 
> General management (i.e. keeping up to date) of the repository it uses
> is your responsibility, as is cleaning out old branches. You can, of
> course, just delete the temporary repository after using it - the code
> will re-create it next time.
> 
> If you have a slow network connection then a local copy of the main
> repository can be specified by changing
> `notmuch-dev-master-repository'.
> 
> Comments?

I think this is great. I've worked on something related but the emacs MUA
"integration" makes patching simpler (My thing worked on shell and would
require a 'recipe' file to describe HEAD commit and patch message id:s).

What I've done differently is that I already have cloned notmuch repository
somewhere which I attempt to keep up-to-date. For repository which I'm
going to patch I first do:

git clone --local --shared --no-checkout /path/to/notmuch/repo notmuch-dev-$USER
git --git-dir notmuch-dev-$USER/.git' config --unset remote.origin.url
cd notmuch-dev-$USER
git checkout -b patched $commit

I.e.

1) I created a local repository clone, sharing objects without initial checkout.
2) removed "remote" origin so accidental pushes are not possible
3) checkout out tree from some commit (possible not remote HEAD) 

And this is done every time before new patchset is applied -- always on top
of clean working directory.

What do you think of this approach related to your way cloning the repo and
then deleting/creating the branch. Just that developer may mess with the
repository contents and then there is tedious working tree cleanup to be
done (especially those who are not so fluent using git).


Tomi



[PATCH 2/2] lib: add 'safe' setting for flags

2012-01-07 Thread Jani Nikula
On Sat, 16 Jul 2011 23:56:13 -0400, Antoine Beaupr?  
wrote:
> the 'safe' setting needs to be 'true' for flags to be manipulated by
> notmuch new/tag/restore.
> 
> for now, only the (T)rash tag is configurable and set to false (by
> default) but this could be extended to allow the user to configure which
> flags are allowed to be synchronized.
> 
> the reason why only T is configurable is because (a) it's the the only
> one that is actually dangerous and (b) I couldn't figure out how to
> properly configure multiple settings like this.
> ---
>  lib/message.cc|   40 +---
>  lib/notmuch.h |   20 
>  notmuch-new.c |1 +
>  notmuch-restore.c |1 +
>  notmuch-tag.c |1 +
>  5 files changed, 44 insertions(+), 19 deletions(-)
> 
> diff --git a/lib/message.cc b/lib/message.cc
> index f633887..f812648 100644
> --- a/lib/message.cc
> +++ b/lib/message.cc
> @@ -50,16 +50,17 @@ struct maildir_flag_tag {
>  char flag;
>  const char *tag;
>  bool inverse;
> +bool safe;
>  };
>  
>  /* ASCII ordered table of Maildir flags and associated tags */
>  static struct maildir_flag_tag flag2tag[] = {
> -{ 'D', "draft",   false},
> -{ 'F', "flagged", false},
> -{ 'P', "passed",  false},
> -{ 'R', "replied", false},
> -{ 'S', "unread",  true },
> -{ 'T', "deleted", false},
> +{ 'D', "draft",   false, true},
> +{ 'F', "flagged", false, true},
> +{ 'P', "passed",  false, true},
> +{ 'R', "replied", false, true},
> +{ 'S', "unread",  true , true},
> +{ 'T', "deleted", false, false},
>  };
>  
>  /* We end up having to call the destructor explicitly because we had
> @@ -994,7 +995,6 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t 
> *message)
>  char *combined_flags = talloc_strdup (message, "");
>  unsigned i;
>  int seen_maildir_info = 0;
> -notmuch_bool_t reckless_trash;
>  
>  for (filenames = notmuch_message_get_filenames (message);
>notmuch_filenames_valid (filenames);
> @@ -1022,15 +1022,8 @@ notmuch_message_maildir_flags_to_tags 
> (notmuch_message_t *message)
>  if (status)
>   return status;
>  
> -// TODO: this should probably be moved up in the stack to avoid
> -// opening the config file on every message (!)
> -config = notmuch_config_open (ctx, NULL, NULL);
> -if (config == NULL)
> - return 1;
> -reckless_trash = notmuch_config_get_maildir_reckless_trash (config);
> -

Antoine -

You do *not* send a patch 1/2 that adds features and then 2/2 that takes
them away. I feel like I totally wasted my time reviewing the first.


Jani.



>  for (i = 0; i < ARRAY_SIZE(flag2tag); i++) {
> - if (flag2tag[i].flag == 'T' && !reckless_trash) {
> + if (!flag2tag[i].safe) {
>   continue;
>   }
>   if ((strchr (combined_flags, flag2tag[i].flag) != NULL)
> @@ -1119,6 +1112,9 @@ _get_maildir_flag_actions (notmuch_message_t *message,
>   tag = notmuch_tags_get (tags);
>  
>   for (i = 0; i < ARRAY_SIZE (flag2tag); i++) {
> + if (!flag2tag[i].safe) {
> + continue;
> + }
>   if (strcmp (tag, flag2tag[i].tag) == 0) {
>   if (flag2tag[i].inverse)
>   to_clear = talloc_asprintf_append (to_clear,
> @@ -1134,6 +1130,9 @@ _get_maildir_flag_actions (notmuch_message_t *message,
>  
>  /* Then, find the flags for all tags not present. */
>  for (i = 0; i < ARRAY_SIZE (flag2tag); i++) {
> + if (!flag2tag[i].safe) {
> + continue;
> + }
>   if (flag2tag[i].inverse) {
>   if (strchr (to_clear, flag2tag[i].flag) == NULL)
>   to_set = talloc_asprintf_append (to_set, "%c", 
> flag2tag[i].flag);
> @@ -1256,6 +1255,17 @@ _new_maildir_filename (void *ctx,
>  return filename_new;
>  }
>  
> +void
> +notmuch_message_set_flag_safety (char flag, notmuch_bool_t safe)
> +{
> +unsigned i;
> +for (i = 0; i < ARRAY_SIZE (flag2tag); i++) {
> +if (flag2tag[i].flag == flag) {
> +flag2tag[i].safe = safe;
> +}
> +}
> +}
> +
>  notmuch_status_t
>  notmuch_message_tags_to_maildir_flags (notmuch_message_t *message)
>  {
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index f0c1b67..475e75a 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -922,8 +922,7 @@ notmuch_message_remove_all_tags (notmuch_message_t 
> *message);
>   *   'P' Adds the "passed" tag to the message
>   *   'R' Adds the "replied" tag to the message
>   *   'S' Removes the "unread" tag from the message
> - *   'T' Adds the "deleted" tag to the message and
> - *   state->reckless_trash is TRUE.
> + *   'T' Adds the "deleted" tag to the message
>   *
>   * For each flag that is not present, the opposite action (add/remove)
>   * is performed for the corresponding tags.
> @@ -941,6 +940,9 @@ notmuch_message_remove_all_tags (notmuch_message_t 
> *message);
>   * 

[PATCH 1/2] lib: Add back the synchronization of 'T' flag with deleted tag.

2012-01-07 Thread Jani Nikula
On Sat, 16 Jul 2011 23:56:12 -0400, Antoine Beaupr?  
wrote:
> This adds a special configuration, off by default, that allows notmuch
> to synchronize the T flag again. The configuration is named
> maildir_reckless_trash and quite clearly indicates that it could be
> dangerous to use in the context described in commit 2c26204, which I
> could actually reproduce.

Thanks for the commit reference.

Please find some comments below.

> In contexts where notmuch is the only mail client used, this is actually
> safe to use. Besides, (T)rashed messages are not necessarily immediately
> expunged from the Maildir by the client or the IMAP server.
> 
> Signed-off-by: Antoine Beaupr? 
> ---
>  lib/message.cc   |   14 +-
>  lib/notmuch.h|4 
>  notmuch-client.h |7 +++
>  notmuch-config.c |   50 +++---
>  4 files changed, 71 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/message.cc b/lib/message.cc
> index d993cde..f633887 100644
> --- a/lib/message.cc
> +++ b/lib/message.cc
> @@ -58,7 +58,8 @@ static struct maildir_flag_tag flag2tag[] = {
>  { 'F', "flagged", false},
>  { 'P', "passed",  false},
>  { 'R', "replied", false},
> -{ 'S', "unread",  true }
> +{ 'S', "unread",  true },
> +{ 'T', "deleted", false},
>  };
>  
>  /* We end up having to call the destructor explicitly because we had
> @@ -993,6 +994,7 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t 
> *message)
>  char *combined_flags = talloc_strdup (message, "");
>  unsigned i;
>  int seen_maildir_info = 0;
> +notmuch_bool_t reckless_trash;
>  
>  for (filenames = notmuch_message_get_filenames (message);
>notmuch_filenames_valid (filenames);
> @@ -1020,7 +1022,17 @@ notmuch_message_maildir_flags_to_tags 
> (notmuch_message_t *message)
>  if (status)
>   return status;
>  
> +// TODO: this should probably be moved up in the stack to avoid
> +// opening the config file on every message (!)
> +config = notmuch_config_open (ctx, NULL, NULL);

The config file is for notmuch the command line tool, *not* for the
lib. You can't call the cli from from the lib. The config (or command
line argument) should be passed as argument, but that would require
changing the lib interface.

> +if (config == NULL)
> + return 1;
> +reckless_trash = notmuch_config_get_maildir_reckless_trash (config);
> +
>  for (i = 0; i < ARRAY_SIZE(flag2tag); i++) {
> + if (flag2tag[i].flag == 'T' && !reckless_trash) {
> + continue;
> + }
>   if ((strchr (combined_flags, flag2tag[i].flag) != NULL)
>   ^ 
>   flag2tag[i].inverse)
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 974be8d..f0c1b67 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -922,6 +922,8 @@ notmuch_message_remove_all_tags (notmuch_message_t 
> *message);
>   *   'P' Adds the "passed" tag to the message
>   *   'R' Adds the "replied" tag to the message
>   *   'S' Removes the "unread" tag from the message
> + *   'T' Adds the "deleted" tag to the message and
> + *   state->reckless_trash is TRUE.
>   *
>   * For each flag that is not present, the opposite action (add/remove)
>   * is performed for the corresponding tags.
> @@ -962,6 +964,8 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t 
> *message);
>   *   'P' iff the message has the "passed" tag
>   *   'R' iff the message has the "replied" tag
>   *   'S' iff the message does not have the "unread" tag
> + *   'T' iff the message has the "trashed" tag and
> + *   state->reckless_trash is TRUE.

"trashed" tag?

The comment (and the commit message) is incorrect. You only check for
reckless_trash in maildir_flags_to_tags, not tags_to_maildir_flags.
With this patch, one-way syncing from tags to flags would be done
unconditionally. And if I understand the problem correctly, you're
fixing the less critical one of the two!

I am wondering (but I'm too tired to check) if the original problem
could be avoided by simply refusing to sync "deleted" tag to 'T' flag if
there are more than one file for that message.

This is a dangerous feature, which is why it was originally
disabled. Accidentally deleting mail is not something people take
lightly. They'll be amused by "reckless trash" - until it recklessly
deletes an important mail.

However, something like this might be a useful feature to have for
people who want to delete mail. It would need good tests to accompany
it, though.


BR,
Jani.


>   *
>   * Any existing flags unmentioned in the list above will be preserved
>   * in the renaming.
> diff --git a/notmuch-client.h b/notmuch-client.h
> index 63be337..62d1e0e 100644
> --- a/notmuch-client.h
> +++ b/notmuch-client.h
> @@ -235,6 +235,13 @@ notmuch_config_set_maildir_synchronize_flags 
> (notmuch_config_t *config,
> notmuch_bool_t synchronize_flags);
>  
>  notmuch_bool_t
> 

[PATCH 0/4] notmuch reply bugfix & reply to sender only

2012-01-07 Thread Tomi Ollila
On Thu, 5 Jan 2012 17:01:44 -0700, Adam Wolfe Gordon  
wrote:
> On Thu, Jan 5, 2012 at 13:25, Jani Nikula  wrote:
> > Bikeshedding topic #1: How about making replying to just the sender the 
> > default
> > in "notmuch reply", and having --reply-all option (instead of 
> > --no-reply-all)?
> >
> > Bikeshedding topic #2: How about binding 'r' to reply to just the sender by
> > default, and making 'R' reply-all (instead of vice versa)?
> 
> I like both these suggestions.  This would bring the notmuch behavior
> in line with gmail, which is what I tend to expect.

I'd like that. I've already once sent a 'group reply' when I intended
to sent to only one.

+1 for changing 'r' reply sender and 'R' reply all in emacs MUA.

> Mark Walters brings up a good point, that there is a question of what
> to do when the user tries to reply to their own email.  When I do
> this, what I intend is to send another email to the last person I
> emailed in the thread, so I think the suggested heuristic of looking
> at other headers would work.  But, maybe others have a different
> expectation in this case?

Hmm, let's see there was 'Some User(TM)' sending email, and I reply all
to that. If I reply (to sender) to the email I just sent, The recipient
could be 'Some User(TM)' instead of me. Interesting possibility.

Tomi


Re: Info about notmuch database

2012-01-07 Thread boyska
On Thu, Jan 05, 2012 at 05:35:55PM +0100, Thomas Jost wrote:
 On Thu, 5 Jan 2012 16:38:07 +0100, boyska piutto...@logorroici.org wrote:
   There's a description of the DB schema in lib/database.cc in the
   notmuch source code. But you may also consider just using libnotmuch
   instead, if that's enough for what you want to do.
  
  thanks, found it, much clearer now.
  But I really can't understand why not just putting these things on a
  separate file :) atomic consistency issues?
 
 I doubt it's for consistency (see commit 824dad76), more likely it's
 because people should use libnotmuch rather than directly hacking into
 the DB ;)

Fine; I'll probably keep the whole output of find as the data of a
SINGLE entry, instead of one entry for directory. This just seems easier
to me.

 Do you plan to use this addressbook with notmuch-address.el, or will it
 be a standalone program?

It will be a standalone program, meant to be used with mutt-query [1].
So just call notmany thomas on commandline, and your email will
appear.
I don't use emacs, so I won't write an emacs tool (nor I know how
notmuch-address.el works), but I am trying to keep library and UI
separate, so writing a wrapper suitable for emacs is possible, and
probably very easy.

[1] http://wiki.mutt.org/?QueryCommand

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


Re: [PATCH 1/4] cli: fix use of uninitialized variable in notmuch reply

2012-01-07 Thread Mark Walters

Hello

I do not get the failure with just 1/4 applied but do with all 4
applied. The trivial patch below fixes it, but it might not be the best
solution.

The failure occurs because Jani's patch changes the behavior of a couple
of emacs/notmuch internal functions: the function
notmuch-search-reply-to-thread is renamed to
notmuch-search-reply-all-to-thread and a new
notmuch-search-reply-to-thread function is added (which does reply to
sender) and a similar change for notmuch-show-reply-.. . Since the
keybindings are also remapped the user will not notice any difference.

However, if the user has any key-bindings etc in their .emacs file the
behaviour could change. It might be preferable to keep the existing
functions as they are and give the new reply-to-sender functions a new
name.

Best wishes

Mark


diff --git a/test/emacs b/test/emacs
index a06c223..5047d46 100755
--- a/test/emacs
+++ b/test/emacs
@@ -258,7 +258,7 @@ test_expect_equal_file OUTPUT EXPECTED
 test_begin_subtest Reply within emacs
 test_emacs '(notmuch-search subject:\testing message sent via SMTP\)
(notmuch-test-wait)
-   (notmuch-search-reply-to-thread)
+   (notmuch-search-reply-all-to-thread)
(test-output)'
 sed -i -e 's/^In-Reply-To: .*$/In-Reply-To: XXX/' OUTPUT
 cat EOF EXPECTED



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


Re: [PATCH 1/4] cli: fix use of uninitialized variable in notmuch reply

2012-01-07 Thread David Bremner
On Sat, 7 Jan 2012 09:31:35 +0200, Jani Nikula j...@nikula.org wrote:
 On Jan 7, 2012 5:52 AM, David Bremner da...@tethera.net wrote:
 
  On Thu,  5 Jan 2012 22:25:12 +0200, Jani Nikula j...@nikula.org wrote:
   notmuch_show_params_t params is only initialized partially in
   notmuch_reply_command(). The only field that is used uninitialized is
   params.decrypt. It is usually non-zero, making notmuch reply on
 encrypted
   messages work by coincidence.
 
  Hi Jani;
 
  I get one test failure with this patch on current master:
 
 Can't investigate right now, but did you try with just patch 1/4? (I really
 should have separated the bug fix from the rest.)
 
 J.
 

Hi Jani;

I _thought_ I was applying just that one patch, but I can't duplicate
the error now, so I might have messed up using dme's new patch
application wizard. So, nevermind, sorry for the noise.

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


Re: [PATCH] restore: Be more liberal in which data to accept.

2012-01-07 Thread David Bremner
On Sat, 29 Oct 2011 12:40:07 +0200, Thomas Schwinge tho...@schwinge.name 
wrote:
 From: Thomas Schwinge tho...@schwinge.name
 
 There are ``Message-ID''s out in the wild that contain spaces.
 

 Spammers are quite inventive for creating ``interesting Messages-ID''s.
 Apparently, notmuch handles these fine internally, but it breaks a
 dump/restore cycle:

Two questions.

1) Do you think we should change the current regex as well as provide a
new space tolerant format
(id:1324214111-32079-1-git-send-email-da...@tethera.net)? I guess it
doesn't really hurt. Notmuch is probably already creating dump files
that sup can't read in your case.

2) can you share (by private email is a fine) a few of those really
   problematic messages so I can use them to test the new dump/restore code?


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


Re: [PATCH] restore: Be more liberal in which data to accept.

2012-01-07 Thread Jameson Graef Rollins
On Sat, 07 Jan 2012 09:37:20 -0400, David Bremner da...@tethera.net wrote:
 2) can you share (by private email is a fine) a few of those really
problematic messages so I can use them to test the new dump/restore code?

I think the better option would be to create a test that runs through
all the horrible message ids we can dream up.

jamie.


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


Re: [PATCH 0/4] notmuch reply bugfix reply to sender only

2012-01-07 Thread Mueen Nawaz
Jameson Graef Rollins
jroll...@finestructure.net writes:

 On Thu,  5 Jan 2012 22:25:11 +0200, Jani Nikula j...@nikula.org wrote:
 Bikeshedding topic #1: How about making replying to just the sender the 
 default
 in notmuch reply, and having --reply-all option (instead of 
 --no-reply-all)?
 
 Bikeshedding topic #2: How about binding 'r' to reply to just the sender by
 default, and making 'R' reply-all (instead of vice versa)?

 I personally like both of these suggestions, and would not be bothered
 by the changed default, so I support both of these changes.

I too feel that 'r' should reply only to sender, and 'R' should reply
all. Having reply-all as default is a pain.


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


another attempt to add delete functionality in emacs

2012-01-07 Thread Jameson Graef Rollins
So, after many stabs at adding the ability to delete messages in
emacs [0], and the corresponding heated discussions, I'm throwing
another attempt into the fray.

I try to address the concerns that have come up in previous attempts.
In particular, I include a patch that creates a new customization
variable, notmuch-search-exclude-deleted, that will exclude any
messages with the deleted tag from searches.  This actually makes
deleted messages appear effectively deleted, which is one of the
things cworth wanted to see, and one of the reasons he kept pushing
back on previous attempts at this functionality.

Also, no tags other than deleted are modified.  All tags should be
orthogonal, and should be handled so.

Note: this is all about handling the deleted tag.  No actual
deletion of message is involved in this functionality at all.  Actual
deletion of messages should always be left entirely up to the user to
handle as they see fit.

jamie.

[0] id:1266408746-28549-1-git-send-email-sebast...@sspaeth.de
id:87sk8qwjlt@yoom.home.cworth.org
id:1271891763-10757-1-git-send-email-hohn...@infradead.org
id:1310841600-28281-1-git-send-email-anar...@koumbit.org

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


[PATCH 4/4] emacs: modify help message for notmuch-search-line-faces to reflect preferred deleted tag name.

2012-01-07 Thread Jameson Graef Rollins
No functional change here.  The help message previously referred to
the delete tag, but deleted is now preferred, so hopefully this
will reduce any potential confusion.
---
 emacs/notmuch.el |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2b860f4..ebdc7d1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -658,12 +658,12 @@ will be excluded from searches.
 Here is an example of how to color search results based on tags.
  (the following text would be placed in your ~/.emacs file):
 
- (setq notmuch-search-line-faces '((\delete\ . (:foreground \red\
+ (setq notmuch-search-line-faces '((\deleted\ . (:foreground \red\
  :background \blue\))
(\unread\ . (:foreground \green\
 
 The attributes defined for matching tags are merged, with later
-attributes overriding earlier. A message having both \delete\
+attributes overriding earlier. A message having both \deleted\
 and \unread\ tags with the above settings would have a green
 foreground and blue background.
   :type '(alist :key-type (string) :value-type (custom-face-edit))
-- 
1.7.7.3

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


[PATCH 2/4] emacs: repurpose notmuch-show-archive-thread-internal function for general thread tagging

2012-01-07 Thread Jameson Graef Rollins
Instead of having a function that is only used for archiving a thread,
we instead make it useful for any tagging operation.  The new
function, notmuch-show-tag-thread-internal, now takes two more
arguments, for the sign of the tagging operation (- or +), and
the tag to be added or removed.  This will allow this function to be
used for any generic thread tagging operation.

The higher level functions that call this function are modified
accordingly.
---
 emacs/notmuch-show.el |   34 --
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5502efd..1e16f05 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1414,20 +1414,26 @@ argument, hide all of the messages.
   (interactive)
   (backward-button 1))
 
-(defun notmuch-show-archive-thread-internal (show-next)
+(defun notmuch-show-tag-thread-internal (sign tag show-next)
   ;; Remove the tag from the current set of messages.
   (goto-char (point-min))
-  (loop do (notmuch-show-remove-tag inbox)
-   until (not (notmuch-show-goto-message-next)))
-  ;; Move to the next item in the search results, if any.
-  (let ((parent-buffer notmuch-show-parent-buffer))
-(notmuch-kill-this-buffer)
-(if parent-buffer
-   (progn
- (switch-to-buffer parent-buffer)
- (forward-line)
- (if show-next
- (notmuch-search-show-thread))
+  (let ((tag-function))
+(cond
+ ((string= sign -)
+  (setq tag-function 'notmuch-show-remove-tag))
+ ((string= sign +)
+  (setq tag-function 'notmuch-show-add-tag)))
+(loop do (funcall tag-function tag)
+ until (not (notmuch-show-goto-message-next)))
+;; Move to the next item in the search results, if any.
+(let ((parent-buffer notmuch-show-parent-buffer))
+  (notmuch-kill-this-buffer)
+  (if parent-buffer
+ (progn
+   (switch-to-buffer parent-buffer)
+   (forward-line)
+   (if show-next
+   (notmuch-search-show-thread)))
 
 (defun notmuch-show-archive-thread ()
   Archive each message in thread, then show next thread from search.
@@ -1441,12 +1447,12 @@ being delivered to the same thread. It does not archive 
the
 entire thread, but only the messages shown in the current
 buffer.
   (interactive)
-  (notmuch-show-archive-thread-internal t))
+  (notmuch-show-tag-thread-internal - inbox t))
 
 (defun notmuch-show-archive-thread-then-exit ()
   Archive each message in thread, then exit back to search results.
   (interactive)
-  (notmuch-show-archive-thread-internal nil))
+  (notmuch-show-tag-thread-internal - inbox nil))
 
 (defun notmuch-show-stash-cc ()
   Copy CC field of current message to kill-ring.
-- 
1.7.7.3

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


[PATCH 3/4] emacs: add ability to delete messages and threads

2012-01-07 Thread Jameson Graef Rollins
This completely mimics the behavior of archiving, but instead of
remove the inbox tag it add the deleted tag.  The functionality is
bound to the 'd' key in both search and show mode.

Note: this does *not* actually delete any messages.  That is still
left entirely up to the user to figure out how they want to handle
that.  This *just* adds the deleted tag to messages, no more.  If
the notmuch-search-exclude-deleted config variable is set, though,
deleted messages will be excluded from search results.
---
 emacs/notmuch-show.el |   15 +++
 emacs/notmuch.el  |   12 
 2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 1e16f05..e1d15f4 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -944,6 +944,7 @@ thread id.  If a prefix is given, crypto processing is 
toggled.
(define-key map + 'notmuch-show-add-tag)
(define-key map x 'notmuch-show-archive-thread-then-exit)
(define-key map a 'notmuch-show-archive-thread)
+   (define-key map d 'notmuch-show-delete-thread)
(define-key map N 'notmuch-show-next-message)
(define-key map P 'notmuch-show-previous-message)
(define-key map n 'notmuch-show-next-open-message)
@@ -1454,6 +1455,20 @@ buffer.
   (interactive)
   (notmuch-show-tag-thread-internal - inbox nil))
 
+(defun notmuch-show-delete-thread ()
+  Delete each message in thread, then show next thread from search.
+
+Delete each message currently shown by adding the \deleted\
+tag to each. Then kill this buffer and show the next thread
+from the search from which this thread was originally shown.
+
+Note: This command is safe from any race condition of new messages
+being delivered to the same thread. It does not archive the
+entire thread, but only the messages shown in the current
+buffer.
+  (interactive)
+  (notmuch-show-tag-thread-internal + deleted t))
+
 (defun notmuch-show-stash-cc ()
   Copy CC field of current message to kill-ring.
   (interactive)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c519687..2b860f4 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -218,6 +218,7 @@ For a mouse binding, return nil.
 (define-key map [mouse-1] 'notmuch-search-show-thread)
 (define-key map * 'notmuch-search-operate-all)
 (define-key map a 'notmuch-search-archive-thread)
+(define-key map d 'notmuch-search-delete-thread)
 (define-key map - 'notmuch-search-remove-tag)
 (define-key map + 'notmuch-search-add-tag)
 (define-key map (kbd RET) 'notmuch-search-show-thread)
@@ -605,6 +606,17 @@ This function advances the next thread when finished.
   (notmuch-search-remove-tag-thread inbox)
   (forward-line))
 
+(defun notmuch-search-delete-thread ()
+  Delete the currently selected thread (add the \deleted\ tag).
+
+This function advances the next thread when finished.
+
+If notmuch-search-exclude-deleted is set, \deleted\ messages
+will be excluded from searches.
+  (interactive)
+  (notmuch-search-add-tag deleted)
+  (forward-line))
+
 (defvar notmuch-search-process-filter-data nil
   Data that has not yet been processed.)
 (make-variable-buffer-local 'notmuch-search-process-filter-data)
-- 
1.7.7.3

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


[PATCH 1/4] emacs: new customization variable to exclude deleted messages from search

2012-01-07 Thread Jameson Graef Rollins
The new customization variable, notmuch-search-exclude-deleted, when
set to t, will exclude any messages with the deleted tag from
searches.

Additionally, specifying tag:deleted in the search directly will
override the exclusion and will included deleted messages in the
search results.
---
 emacs/notmuch.el   |8 
 test/emacs |   42 
 .../notmuch-search-tag-inbox-deleted-excluded  |   24 +++
 3 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644 
test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index fde2377..c519687 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -905,6 +905,11 @@ PROMPT is the string to prompt with.
   (read-from-minibuffer prompt nil keymap nil
'notmuch-query-history nil nil
 
+(defcustom notmuch-search-exclude-deleted nil
+  Exclude deleted messages (with \deleted\ tag) from search results.
+  :group 'notmuch
+  :type 'boolean)
+
 ;;;###autoload
 (defun notmuch-search (query optional oldest-first target-thread target-line 
continuation)
   Run \notmuch search\ with the given query string and display results.
@@ -927,6 +932,9 @@ The optional parameters are used as follows:
 (set 'notmuch-search-target-thread target-thread)
 (set 'notmuch-search-target-line target-line)
 (set 'notmuch-search-continuation continuation)
+(when (and notmuch-search-exclude-deleted
+  (not (string-match tag:deleted[ )]* query)))
+  (setq query (concat query  and not tag:deleted)))
 (let ((proc (get-buffer-process (current-buffer)))
  (inhibit-read-only t))
   (if proc
diff --git a/test/emacs b/test/emacs
index a06c223..1d78fbe 100755
--- a/test/emacs
+++ b/test/emacs
@@ -35,6 +35,48 @@ test_emacs '(notmuch-search tag:inbox)
(test-output)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
 
+test_begin_subtest Exclude \deleted\ messages from search
+notmuch tag +deleted 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+# we delete a second message that's part of a multi-message thread
+# to make sure the rest of the thread is still returned
+notmuch tag +deleted 
id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search tag:inbox)
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+notmuch tag -deleted 
id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net
+test_expect_equal_file OUTPUT 
$EXPECTED/notmuch-search-tag-inbox-deleted-excluded
+
+test_begin_subtest Exclude \deleted\ messages from search, manual override
+notmuch tag +deleted 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+notmuch tag +deleted 
id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net
+cat EOF EXPECTED
+  2009-11-18 [1/1]   Stewart Smith[notmuch] [PATCH] Fix linking with 
gcc to use g++ to link in C++ libs. (deleted inbox unread)
+  2009-11-17 [1/5]   Mikhail Gusarov, Carl Worth, Keith Packard  [notmuch] 
[PATCH 1/2] Close message file after parsing message headers (deleted inbox 
unread)
+End of search results.
+EOF
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search tag:inbox and tag:deleted)
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+notmuch tag -deleted 
id:1258471718-6781-1-git-send-email-dotted...@dottedmag.net
+test_expect_equal_file OUTPUT EXPECTED
+
+test_begin_subtest Exclude \deleted\ messages from search, but not 
\deleted*\
+notmuch tag +deleted-patch 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+cat EOF EXPECTED
+  2009-11-18 [1/1]   Stewart Smith[notmuch] [PATCH] Fix linking with 
gcc to use g++ to link in C++ libs. (deleted-patch inbox unread)
+End of search results.
+EOF
+test_emacs '(let ((notmuch-search-exclude-deleted t))
+ (notmuch-search tag:inbox and tag:deleted-patch)
+ (notmuch-test-wait)
+ (test-output))'
+notmuch tag -deleted-patch 
id:1258506353-20352-1-git-send-email-stew...@flamingspork.com
+test_expect_equal_file OUTPUT EXPECTED
+
 test_begin_subtest Navigation of notmuch-hello to search results
 test_emacs '(notmuch-hello)
(goto-char (point-min))
diff --git 
a/test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded 
b/test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded
new file mode 100644
index 000..39b4c51
--- /dev/null
+++ b/test/emacs.expected-output/notmuch-search-tag-inbox-deleted-excluded
@@ -0,0 +1,24 @@
+  2010-12-29 [1/1]   François Boulogne[aur-general] Guidelines: cp, mkdir 
vs install (inbox unread)
+  

[RFC PATCH 0/9] -std=c99 / -std=c++0x -pedantic

2012-01-07 Thread Jani Nikula
Hi all, this series was borne of curiousity about compiling the notmuch codebase
using -std=c99 / -std=c++0x -pedantic options. The C part is split into separate
patches to make it easier to see each warning and fix; with C++ I didn't bother
so much.

Turns out there are a few specific issues, but overall it's not too bad. However
my gut feeling is that some of the fixes to get standards compliance are uglier
than just using the GCC extensions. The question is, do we care about anything
other than GCC?

Comments and discussion welcome; that was the whole point here rather than any
serious effort for merging these. (But that can follow if people think this is
worth it.)

BR,
Jani.



Jani Nikula (9):
  build: use -std=c99 -pedantic for C source
  xutil: #define _POSIX_C_SOURCE to get strdup()
  lib: fix messages.c build warn
  lib: HACK: avoid warnings from talloc_steal()
  cli: fix warning about variadic macros
  cli: fix another warning about variadic macros
  util: fix warning about variadic macros
  lib: use -std=c++0x -pedantic
  test: smtp-dummy: fixes for -std=c99 -pedantic

 configure |4 ++--
 lib/database.cc   |3 +--
 lib/message.cc|2 +-
 lib/messages.c|6 --
 lib/notmuch-private.h |8 +---
 lib/tags.c|5 -
 lib/thread.cc |2 +-
 notmuch-client.h  |9 ++---
 notmuch-setup.c   |7 +--
 test/smtp-dummy.c |4 +++-
 util/error_util.h |8 +---
 util/xutil.c  |2 ++
 12 files changed, 39 insertions(+), 21 deletions(-)

-- 
1.7.5.4

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


[RFC PATCH 2/9] xutil: #define _POSIX_C_SOURCE to get strdup()

2012-01-07 Thread Jani Nikula
strdup() is not standard C99. #define _POSIX_C_SOURCE 200809L to use it.

This fixes -std=c99 -pedantic warning:

util/xutil.c: In function ‘xstrdup’:
util/xutil.c:74:5: warning: implicit declaration of function ‘strdup’ 
[-Wimplicit-function-declaration]
util/xutil.c:74:9: warning: assignment makes pointer from integer without a 
cast [enabled by default]

Signed-off-by: Jani Nikula j...@nikula.org
---
 util/xutil.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/util/xutil.c b/util/xutil.c
index ac496da..55b818b 100644
--- a/util/xutil.c
+++ b/util/xutil.c
@@ -18,6 +18,8 @@
  * Author: Carl Worth cwo...@cworth.org
  */
 
+#define _POSIX_C_SOURCE 200809L /* for strdup() */
+
 #include stdio.h
 #include string.h
 
-- 
1.7.5.4

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


[RFC PATCH 3/9] lib: fix messages.c build warn

2012-01-07 Thread Jani Nikula
lib/messages.c: In function ‘notmuch_messages_move_to_next’:
lib/messages.c:131:2: warning: ISO C forbids ‘return’ with expression, in 
function returning void [-pedantic]

Signed-off-by: Jani Nikula j...@nikula.org
---
 lib/messages.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/messages.c b/lib/messages.c
index 7bcd1ab..1121864 100644
--- a/lib/messages.c
+++ b/lib/messages.c
@@ -127,8 +127,10 @@ notmuch_messages_get (notmuch_messages_t *messages)
 void
 notmuch_messages_move_to_next (notmuch_messages_t *messages)
 {
-if (! messages-is_of_list_type)
-   return _notmuch_mset_messages_move_to_next (messages);
+if (! messages-is_of_list_type) {
+   _notmuch_mset_messages_move_to_next (messages);
+   return;
+}
 
 if (messages-iterator == NULL)
return;
-- 
1.7.5.4

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


[RFC PATCH 5/9] cli: fix warning about variadic macros

2012-01-07 Thread Jani Nikula
notmuch-restore.c: In function ‘notmuch_restore_command’:
notmuch-restore.c:87:54: warning: ISO C99 requires rest arguments to be used 
[enabled by default]

and elsewhere. ##__VA_ARGS__ is a GCC CPP extension.

Signed-off-by: Jani Nikula j...@nikula.org
---
 notmuch-client.h |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index 517c010..3f4751a 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -93,14 +93,17 @@ typedef struct notmuch_show_params {
  *
  * Note that __location__ comes from talloc.h.
  */
-#define INTERNAL_ERROR(format, ...)\
+
+#define _INTERNAL_ERROR(format, ...)   \
 do {   \
fprintf(stderr, \
-   Internal error:  format  (%s)\n,\
-   ##__VA_ARGS__, __location__);   \
+   Internal error:  format %s (%s)\n,  \
+   __VA_ARGS__, __location__); \
exit (1);   \
 } while (0)
 
+#define INTERNAL_ERROR(...) _INTERNAL_ERROR(__VA_ARGS__, )
+
 #define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
 
 #define STRNCMP_LITERAL(var, literal) \
-- 
1.7.5.4

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


[RFC PATCH 6/9] cli: fix another warning about variadic macros

2012-01-07 Thread Jani Nikula
notmuch-setup.c: In function ‘notmuch_setup_command’:
notmuch-setup.c:144:62: warning: ISO C99 requires rest arguments to be used 
[enabled by default]
notmuch-setup.c:174:18: warning: ISO C99 requires rest arguments to be used 
[enabled by default]

Signed-off-by: Jani Nikula j...@nikula.org
---
 notmuch-setup.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/notmuch-setup.c b/notmuch-setup.c
index c3ea937..7b25680 100644
--- a/notmuch-setup.c
+++ b/notmuch-setup.c
@@ -102,9 +102,9 @@ notmuch_setup_command (unused (void *ctx),
 const char **new_tags;
 size_t new_tags_len;
 
-#define prompt(format, ...)\
+#define __prompt(format, ...)  \
 do {   \
-   printf (format, ##__VA_ARGS__); \
+   printf (format, __VA_ARGS__);   \
fflush (stdout);\
if (getline (response, response_size, stdin)  0) {   \
printf (Exiting.\n);  \
@@ -113,6 +113,9 @@ notmuch_setup_command (unused (void *ctx),
chomp_newline (response);   \
 } while (0)
 
+#define _prompt(format, ...) __prompt(format %s, __VA_ARGS__)
+#define prompt(...) _prompt(__VA_ARGS__, )
+
 config = notmuch_config_open (ctx, NULL, is_new);
 
 if (is_new)
-- 
1.7.5.4

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


[RFC PATCH 7/9] util: fix warning about variadic macros

2012-01-07 Thread Jani Nikula
lib/string-list.c: In function ‘_notmuch_string_list_sort’:
lib/string-list.c:81:59: warning: ISO C99 requires rest arguments to be used 
[enabled by default]

lib/message-file.c: In function ‘notmuch_message_file_restrict_headersv’:
lib/message-file.c:147:90: warning: ISO C99 requires rest arguments to be used 
[enabled by default]

Signed-off-by: Jani Nikula j...@nikula.org
---
 util/error_util.h |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/util/error_util.h b/util/error_util.h
index bb15822..75709da 100644
--- a/util/error_util.h
+++ b/util/error_util.h
@@ -38,8 +38,10 @@ _internal_error (const char *format, ...) PRINTF_ATTRIBUTE 
(1, 2);
  *
  * Note that __location__ comes from talloc.h.
  */
-#define INTERNAL_ERROR(format, ...)\
-_internal_error (format  (%s).\n,\
-##__VA_ARGS__, __location__)
+#define _INTERNAL_ERROR(format, ...)   \
+_internal_error (format %s (%s).\n,  \
+__VA_ARGS__, __location__)
+
+#define INTERNAL_ERROR(...) _INTERNAL_ERROR(__VA_ARGS__, )
 
 #endif
-- 
1.7.5.4

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


[RFC PATCH 9/9] test: smtp-dummy: fixes for -std=c99 -pedantic

2012-01-07 Thread Jani Nikula
Signed-off-by: Jani Nikula j...@nikula.org
---
 test/smtp-dummy.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c
index 3801a5e..1c29a7d 100644
--- a/test/smtp-dummy.c
+++ b/test/smtp-dummy.c
@@ -33,6 +33,8 @@
  * have been warned.
  */
 
+#define _POSIX_C_SOURCE 200809L /* for getline() and fdopen() */
+
 #include stdio.h
 #include stdlib.h
 #include string.h
@@ -162,7 +164,7 @@ main (int argc, char *argv[])
memset (addr, 0, sizeof (addr));
addr.sin_family = AF_INET;
addr.sin_port = htons (25025);
-   addr.sin_addr = *(struct in_addr *) hostinfo-h_addr;
+   addr.sin_addr = *(struct in_addr *) hostinfo-h_addr_list[0];
err = bind (sock, (struct sockaddr *) addr, sizeof(addr));
if (err) {
fprintf (stderr, Error: bind() failed: %s\n,
-- 
1.7.5.4

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


[RFC PATCH 8/9] lib: use -std=c++0x -pedantic

2012-01-07 Thread Jani Nikula
Introduces warnings such as:

In file included from /usr/include/gmime-2.4/gmime/gmime.h:39:0,
 from lib/database.cc:31:
/usr/include/gmime-2.4/gmime/gmime-message.h:57:26: warning: comma at end of 
enumerator list [-pedantic]

Signed-off-by: Jani Nikula j...@nikula.org
---
 configure |2 +-
 lib/database.cc   |3 +--
 lib/message.cc|2 +-
 lib/notmuch-private.h |8 +---
 lib/thread.cc |2 +-
 5 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index f84262d..30831f3 100755
--- a/configure
+++ b/configure
@@ -26,7 +26,7 @@ fi
 CC=${CC:-gcc}
 CXX=${CXX:-g++}
 CFLAGS=${CFLAGS:--O2 -std=c99 -pedantic}
-CXXFLAGS=${CXXFLAGS:--O2}
+CXXFLAGS=${CXXFLAGS:--O2 -std=c++0x -pedantic}
 LDFLAGS=${LDFLAGS:-}
 XAPIAN_CONFIG=${XAPIAN_CONFIG:-xapian-config}
 
diff --git a/lib/database.cc b/lib/database.cc
index 8103bd9..b59497b 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -1352,8 +1352,7 @@ _resolve_message_id_to_thread_id (notmuch_database_t 
*notmuch,
return status;
 
 if (message) {
-   *thread_id_ret = talloc_steal (ctx,
-  notmuch_message_get_thread_id (message));
+   *thread_id_ret = (const char *) _talloc_steal_loc (ctx, 
notmuch_message_get_thread_id (message), __location__);
 
notmuch_message_destroy (message);
 
diff --git a/lib/message.cc b/lib/message.cc
index 0075425..ed7398a 100644
--- a/lib/message.cc
+++ b/lib/message.cc
@@ -220,7 +220,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t 
*notmuch,

message_id,

message);
 if (message)
-   return talloc_steal (notmuch, message);
+   return (notmuch_message_t *) _talloc_steal_loc (notmuch, message, 
__location__);
 else if (*status_ret)
return NULL;
 
diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
index 60a932f..7694705 100644
--- a/lib/notmuch-private.h
+++ b/lib/notmuch-private.h
@@ -137,15 +137,17 @@ typedef enum _notmuch_private_status {
  * that the caller has previously handled any expected
  * notmuch_private_status_t values.)
  */
-#define COERCE_STATUS(private_status, format, ...) \
+#define _COERCE_STATUS(private_status, format, ...)\
 ((private_status = (notmuch_private_status_t) NOTMUCH_STATUS_LAST_STATUS)\
  ? \
- (notmuch_status_t) _internal_error (format  (%s).\n,\
- ##__VA_ARGS__,
\
+ (notmuch_status_t) _internal_error (format %s (%s).\n,  \
+ __VA_ARGS__,  \
  __location__) \
  : \
  (notmuch_status_t) private_status)
 
+#define COERCE_STATUS(private_status, ...) _COERCE_STATUS(private_status, 
__VA_ARGS__, )
+
 typedef struct _notmuch_doc_id_set notmuch_doc_id_set_t;
 
 /* database.cc */
diff --git a/lib/thread.cc b/lib/thread.cc
index 0435ee6..e8f169c 100644
--- a/lib/thread.cc
+++ b/lib/thread.cc
@@ -224,7 +224,7 @@ _thread_add_message (notmuch_thread_t *thread,
 char *clean_author;
 
 _notmuch_message_list_add_message (thread-message_list,
-  talloc_steal (thread, message));
+  (notmuch_message_t *) _talloc_steal_loc 
(thread, message, __location__));
 thread-total_messages++;
 
 g_hash_table_insert (thread-message_hash,
-- 
1.7.5.4

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


Re: [RFC PATCH 3/9] lib: fix messages.c build warn

2012-01-07 Thread Austin Clements
I don't have much opinion on the other patches in this series (the C99
variadic macro stuff is unfortunate), but this one should go in.

Quoth Jani Nikula on Jan 08 at  1:26 am:
 lib/messages.c: In function ‘notmuch_messages_move_to_next’:
 lib/messages.c:131:2: warning: ISO C forbids ‘return’ with expression, in 
 function returning void [-pedantic]
 
 Signed-off-by: Jani Nikula j...@nikula.org
 ---
  lib/messages.c |6 --
  1 files changed, 4 insertions(+), 2 deletions(-)
 
 diff --git a/lib/messages.c b/lib/messages.c
 index 7bcd1ab..1121864 100644
 --- a/lib/messages.c
 +++ b/lib/messages.c
 @@ -127,8 +127,10 @@ notmuch_messages_get (notmuch_messages_t *messages)
  void
  notmuch_messages_move_to_next (notmuch_messages_t *messages)
  {
 -if (! messages-is_of_list_type)
 - return _notmuch_mset_messages_move_to_next (messages);
 +if (! messages-is_of_list_type) {
 + _notmuch_mset_messages_move_to_next (messages);
 + return;
 +}
  
  if (messages-iterator == NULL)
   return;
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] emacs: add option to notmuch-show-next-open-message to pop out to parent buffer if at end

2012-01-07 Thread Jameson Graef Rollins
This will allow for keybindings that achieve a smoother message
processing flow by reducing the number of key presses needed for most
common operations.
---
 emacs/notmuch-show.el |   12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8bb052e..e7bb958 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1264,17 +1264,23 @@ any effects from previous calls to
   (notmuch-show-mark-read)
   (notmuch-show-message-adjust))
 
-(defun notmuch-show-next-open-message ()
+(defun notmuch-show-next-open-message (optional pop-at-end)
   Show the next message.
   (interactive)
-  (let (r)
+  (let ((r)
+   (parent-buffer notmuch-show-parent-buffer))
 (while (and (setq r (notmuch-show-goto-message-next))
(not (notmuch-show-message-visible-p
 (if r
(progn
  (notmuch-show-mark-read)
  (notmuch-show-message-adjust))
-  (goto-char (point-max)
+  (if (and parent-buffer pop-at-end)
+ (progn
+   (kill-this-buffer)
+   (switch-to-buffer parent-buffer)
+   (forward-line 1))
+   (goto-char (point-max))
 
 (defun notmuch-show-previous-open-message ()
   Show the previous message.
-- 
1.7.7.3

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


[PATCH 3/4] emacs: modify the default show-mode key bindings for archiving/deleting

2012-01-07 Thread Jameson Graef Rollins
This changes the default key bindings for the 'a' and 'd' keys in
notmuch-show mode.  Instead of archiving/deleting the entire thread,
they now just archive/delete the current message, and then advance to
the next open message.

'A' and 'D' are rebound to the previous archive/delete-thread
functions.
---
 emacs/notmuch-show.el |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e7bb958..4c2b507 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -943,8 +943,10 @@ thread id.  If a prefix is given, crypto processing is 
toggled.
(define-key map - 'notmuch-show-remove-tag)
(define-key map + 'notmuch-show-add-tag)
(define-key map x 'notmuch-show-archive-thread-then-exit)
-   (define-key map a 'notmuch-show-archive-thread)
-   (define-key map d 'notmuch-show-delete-thread)
+   (define-key map a 'notmuch-show-archive-message)
+   (define-key map A 'notmuch-show-archive-thread)
+   (define-key map d 'notmuch-show-delete-message)
+   (define-key map D 'notmuch-show-delete-thread)
(define-key map N 'notmuch-show-next-message)
(define-key map P 'notmuch-show-previous-message)
(define-key map n 'notmuch-show-next-open-message)
-- 
1.7.7.3

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


[PATCH 4/4] emacs: use pop-at-end functionality in archive/delete-message functions

2012-01-07 Thread Jameson Graef Rollins
This provides a smoother message processing flow by reducing the
number of key presses needed for these common operations.
---
 emacs/notmuch-show.el |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 4c2b507..7103c23 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1454,7 +1454,7 @@ thread.
 
 (interactive)
 (notmuch-show-remove-tag inbox)
-(notmuch-show-next-open-message)))
+(notmuch-show-next-open-message t)))
 
 (defun notmuch-show-archive-thread ()
   Archive each message in thread, then show next thread from search.
@@ -1485,7 +1485,7 @@ thread.
 
 (interactive)
 (notmuch-show-add-tag deleted)
-(notmuch-show-next-open-message)))
+(notmuch-show-next-open-message t)))
 
 (defun notmuch-show-delete-thread ()
   Delete each message in thread, then show next thread from search.
-- 
1.7.7.3

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


change to default archive/delete key bindings

2012-01-07 Thread Jameson Graef Rollins
While working on the delete message handling patches, I was reminded
how much I really dislike the default show-mode key bindings.  Why
can't I just archive/delete the current message, without archiving the
entire thread?  It doesn't make any sense.

Here we add two new functions to archive and delete just the single
message, and then move to the next open message.  We also add an
option to the -next-open-message function so that it will pop back out
to the parent search buffer when reaching the end of the thread.  This
should make message processing flow much smoother.

Patches 1,2 and 4 can be applied even if the consensus is to not
change the default key bindings, to make it easier for users to
achieve the desired functionality without having to write their own
functions.

jamie.

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


[PATCH 1/4] emacs: add show-mode functions to archive/delete only current message

2012-01-07 Thread Jameson Graef Rollins
This adds two new function, notmuch-show-{archive,delete}-message,
that archive/delete the current message, and then move to the next
open one.
---
 emacs/notmuch-show.el |   24 
 1 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e1d15f4..8bb052e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1436,6 +1436,18 @@ argument, hide all of the messages.
(if show-next
(notmuch-search-show-thread)))
 
+(defun notmuch-show-archive-message ()
+  Archive the current message and advance.
+
+After the last message is reached, either the buffer will be
+closed and the cursor will move to the search result if
+available, or the cursor will move to the end of the current
+thread.
+
+(interactive)
+(notmuch-show-remove-tag inbox)
+(notmuch-show-next-open-message)))
+
 (defun notmuch-show-archive-thread ()
   Archive each message in thread, then show next thread from search.
 
@@ -1455,6 +1467,18 @@ buffer.
   (interactive)
   (notmuch-show-tag-thread-internal - inbox nil))
 
+(defun notmuch-show-delete-message ()
+  Delete the current message and advance.
+
+After the last message is reached, either the buffer will be
+closed and the cursor will move to the search result if
+available, or the cursor will move to the end of the current
+thread.
+
+(interactive)
+(notmuch-show-add-tag deleted)
+(notmuch-show-next-open-message)))
+
 (defun notmuch-show-delete-thread ()
   Delete each message in thread, then show next thread from search.
 
-- 
1.7.7.3

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


[PATCH 0/4] Quoting HTML-only emails in replies redux

2012-01-07 Thread Adam Wolfe Gordon
From: Adam Wolfe Gordon a...@xvx.ca

Hi everyone,

This is a rework of my previous patch series adding support for replying to HTML
email in the emacs interface
(id:1322671241-23438-1-git-send-email-awg+notm...@xvx.ca).

It was suggested on IRC that a more general solution would be to add a JSON
format to notmuch reply, and then have the emacs client parse the JSON to create
an appropriate reply. This patchset implements that.

The previous patches had an issue with emails that contained both HTML and
plaintext parts, where all the parts would end up quoted. This version avoids
that problem, since the emacs interface can easily check whether there are
plaintext parts and avoid quoting HTML parts if there are.

There should probably be some customize variables for this in emacs, to control
(for example) whether to quote HTML parts and whether to prefer HTML or
plaintext parts for quoting. Any suggestions for what should be customizable
would be appreciated.

I know Jani is currently working on some reply-related patches (the reply-all
vs. reply-one set). These changes probably won't merge cleanly with those
changes, so some care might be required. If his changes are pushed first, I'll
happily rebase and send a new set.

Thanks in advance for any reviews.

Adam Wolfe Gordon (4):
  test: Add broken test for the new JSON reply format.
  reply: Add a JSON reply format.
  man: Update notmuch-reply man page for JSON format.
  emacs: Use the new JSON reply format.

 emacs/notmuch-mua.el |   62 +---
 man/man1/notmuch-reply.1 |5 +
 notmuch-reply.c  |  269 +++---
 test/emacs   |1 +
 test/multipart   |7 ++
 5 files changed, 292 insertions(+), 52 deletions(-)

-- 
1.7.5.4

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


[PATCH 1/4] test: Add broken test for the new JSON reply format.

2012-01-07 Thread Adam Wolfe Gordon
From: Adam Wolfe Gordon a...@xvx.ca

---
 test/multipart |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/test/multipart b/test/multipart
index f83526b..f5ebf04 100755
--- a/test/multipart
+++ b/test/multipart
@@ -589,6 +589,13 @@ Non-text part: text/html
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
+test_begin_subtest 'notmuch reply' to a multipart message with json format
+notmuch reply --format=json 'id:87liy5ap00@yoom.home.cworth.org' OUTPUT
+cat EOF EXPECTED
+[{ reply: { headers: { from: Notmuch Test Suite 
test_su...@notmuchmail.org, to: Carl Worth cwo...@cworth.org, 
cwo...@cworth.org, subject: Re: Multipart message, in-reply-to: 
87liy5ap00@yoom.home.cworth.org, references:  
87liy5ap00@yoom.home.cworth.org} }, original: { headers: { from: 
Carl Worth cwo...@cworth.org, to: cwo...@cworth.org, cc: , 
subject: Multipart message, date: Fri, 05 Jan 2001 15:43:57 +, 
in-reply-to: , references:  }, body: [ { content-type: text/html, 
content: pThis is an embedded message, with a multipart/alternative 
part./p\n}, { content-type: text/plain, content: This is an embedded 
message, with a multipart/alternative part.\n}, { content-type: 
text/plain, content: And this message is signed.\n\n-Carl\n}, {} ] } }, 
{} ]
+EOF
+test_expect_equal_file OUTPUT EXPECTED
+
 test_begin_subtest 'notmuch show --part' does not corrupt a part with CRLF 
pair
 notmuch show --format=raw --part=3 id:base64-part-with-crlf  crlf.out
 echo -n -e \xEF\x0D\x0A  crlf.expected
-- 
1.7.5.4

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


[PATCH 3/4] man: Update notmuch-reply man page for JSON format.

2012-01-07 Thread Adam Wolfe Gordon
From: Adam Wolfe Gordon a...@xvx.ca

---
 man/man1/notmuch-reply.1 |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1
index 099d808..240dfed 100644
--- a/man/man1/notmuch-reply.1
+++ b/man/man1/notmuch-reply.1
@@ -41,6 +41,11 @@ include
 .BR default
 Includes subject and quoted message body.
 .TP
+.BR json
+Produces JSON output containing headers for a reply message and the
+headers and text parts of the original message. This output can be used
+by a client to create a reply message intelligently.
+.TP
 .BR headers\-only
 Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
 .RE
-- 
1.7.5.4

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


[PATCH 2/4] reply: Add a JSON reply format.

2012-01-07 Thread Adam Wolfe Gordon
From: Adam Wolfe Gordon a...@xvx.ca

This new JSON format for replies includes headers generated for a reply
message as well as the headers and all text parts of the original message.
Using this data, a client can intelligently create a reply. For example,
the emacs client will be able to create replies with quoted HTML parts by
parsing the HTML parts using w3m.
---
 notmuch-reply.c |  269 +++
 1 files changed, 230 insertions(+), 39 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index f8d5f64..82df396 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -30,6 +30,15 @@ reply_headers_message_part (GMimeMessage *message);
 static void
 reply_part_content (GMimeObject *part);
 
+static void
+reply_part_start_json (GMimeObject *part, int *part_count);
+
+static void
+reply_part_content_json (GMimeObject *part);
+
+static void
+reply_part_end_json (GMimeObject *part);
+
 static const notmuch_show_format_t format_reply = {
 ,
, NULL,
@@ -46,6 +55,22 @@ static const notmuch_show_format_t format_reply = {
 
 };
 
+static const notmuch_show_format_t format_json = {
+,
+   , NULL,
+   , NULL, NULL, ,
+   ,
+   reply_part_start_json,
+   NULL,
+   NULL,
+   reply_part_content_json,
+   reply_part_end_json,
+   ,
+   ,
+   , ,
+
+};
+
 static void
 show_reply_headers (GMimeMessage *message)
 {
@@ -147,6 +172,78 @@ reply_part_content (GMimeObject *part)
 }
 }
 
+static void
+reply_part_start_json (GMimeObject *part, unused(int *part_count))
+{
+GMimeContentType *content_type = g_mime_object_get_content_type 
(GMIME_OBJECT (part));
+GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (part);
+
+if (g_mime_content_type_is_type (content_type, text, *) 
+   (!disposition ||
+strcmp (disposition-disposition, GMIME_DISPOSITION_INLINE) == 0))
+{
+   printf({ );
+}
+}
+
+static void
+reply_part_end_json (GMimeObject *part)
+{
+GMimeContentType *content_type = g_mime_object_get_content_type 
(GMIME_OBJECT (part));
+GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (part);
+
+if (g_mime_content_type_is_type (content_type, text, *) 
+   (!disposition ||
+strcmp (disposition-disposition, GMIME_DISPOSITION_INLINE) == 0))
+   printf (}, );
+}
+
+static void
+reply_part_content_json (GMimeObject *part)
+{
+GMimeContentType *content_type = g_mime_object_get_content_type 
(GMIME_OBJECT (part));
+GMimeContentDisposition *disposition = 
g_mime_object_get_content_disposition (part);
+
+void *ctx = talloc_new (NULL);
+
+/* We only care about inline text parts for reply purposes */
+if (g_mime_content_type_is_type (content_type, text, *) 
+   (!disposition ||
+strcmp (disposition-disposition, GMIME_DISPOSITION_INLINE) == 0))
+{
+   GMimeStream *stream_memory = NULL, *stream_filter = NULL;
+   GMimeDataWrapper *wrapper;
+   GByteArray *part_content;
+   const char *charset;
+
+   printf(\content-type\: %s, \content\: ,
+  json_quote_str(ctx, 
g_mime_content_type_to_string(content_type)));
+
+   charset = g_mime_object_get_content_type_parameter (part, charset);
+   stream_memory = g_mime_stream_mem_new ();
+   if (stream_memory) {
+   stream_filter = g_mime_stream_filter_new(stream_memory);
+   if (charset) {
+   g_mime_stream_filter_add(GMIME_STREAM_FILTER(stream_filter),
+g_mime_filter_charset_new(charset, 
UTF-8));
+   }
+   }
+   wrapper = g_mime_part_get_content_object (GMIME_PART (part));
+   if (wrapper  stream_filter)
+   g_mime_data_wrapper_write_to_stream (wrapper, stream_filter);
+   part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM 
(stream_memory));
+
+   printf(%s, json_quote_chararray(ctx, (char *) part_content-data, 
part_content-len));
+
+   if (stream_filter)
+   g_object_unref(stream_filter);
+   if (stream_memory)
+   g_object_unref(stream_memory);
+}
+
+talloc_free (ctx);
+}
+
 /* Is the given address configured as one of the user's personal or
  * other addresses. */
 static int
@@ -476,6 +573,59 @@ guess_from_received_header (notmuch_config_t *config, 
notmuch_message_t *message
 return NULL;
 }
 
+static GMimeMessage *
+create_reply_message(void *ctx,
+notmuch_config_t *config,
+notmuch_message_t *message)
+{
+const char *subject, *from_addr = NULL;
+const char *in_reply_to, *orig_references, *references;
+
+/* The 1 means we want headers in a pretty order. */
+GMimeMessage *reply = g_mime_message_new (1);
+if (reply == NULL) {
+   fprintf (stderr, Out of memory\n);
+   return NULL;
+}
+
+subject = 

[PATCH 4/4] emacs: Use the new JSON reply format.

2012-01-07 Thread Adam Wolfe Gordon
From: Adam Wolfe Gordon a...@xvx.ca

Using the new JSON reply format allows emacs to quote HTML parts
nicely by first parsing them with w3m, then quoting them. This is
very useful for users who regularly receive HTML-only email.

The behavior for messages that contain plain text parts should be
unchanged, except that an additional quoted line is added to the end
of the reply message.  The test has been updated to reflect this.
---
 emacs/notmuch-mua.el |   62 +++--
 test/emacs   |1 +
 2 files changed, 50 insertions(+), 13 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 7114e48..7f894cb 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -19,6 +19,7 @@
 ;;
 ;; Authors: David Edmondson d...@dme.org
 
+(require 'json)
 (require 'message)
 
 (require 'notmuch-lib)
@@ -71,27 +72,62 @@ list.
(push header message-hidden-headers)))
notmuch-mua-hidden-headers))
 
+(defun w3m-region (start end)) ;; From `w3m.el'.
+(defun notmuch-mua-quote-part (part)
+  (with-temp-buffer
+(insert part)
+(message-mode)
+(fill-region (point-min) (point-max))
+(goto-char (point-min))
+(perform-replace ^   nil t nil)
+(set-buffer-modified-p nil)
+(buffer-substring (point-min) (point-max
+(defun notmuch-mua-parse-html-part (part)
+  (with-temp-buffer
+(insert part)
+(w3m-region (point-min) (point-max))
+(set-buffer-modified-p nil)
+(buffer-substring (point-min) (point-max
 (defun notmuch-mua-reply (query-string optional sender)
-  (let (headers
+  (let (reply
+   original
+   headers
body
-   (args '(reply)))
+   (args '(reply --format=json)))
 (if notmuch-show-process-crypto
(setq args (append args '(--decrypt
 (setq args (append args (list query-string)))
-;; This make assumptions about the output of `notmuch reply', but
-;; really only that the headers come first followed by a blank
-;; line and then the body.
+;; Get the reply object as JSON, and parse it into an elisp object.
 (with-temp-buffer
   (apply 'call-process (append (list notmuch-command nil (list t t) nil) 
args))
   (goto-char (point-min))
-  (if (re-search-forward ^$ nil t)
- (save-excursion
-   (save-restriction
- (narrow-to-region (point-min) (point))
- (goto-char (point-min))
- (setq headers (mail-header-extract)
-  (forward-line 1)
-  (setq body (buffer-substring (point) (point-max
+  (setq reply (aref (json-read) 0)))
+
+;; Get the list of headers
+(setq headers (cdr (assq 'headers (assq 'reply reply
+;; Construct the body of the reply.
+(setq original (cdr (assq 'original reply)))
+
+;; Start with the prelude, based on the headers of the original message.
+(let ((original-headers (cdr (assq 'headers original
+  (setq body (format On %s, %s wrote:\n
+(cdr (assq 'date original-headers))
+(cdr (assq 'from original-headers)
+
+;; Extract the body parts and construct a reasonable quoted body.
+(let* ((body-parts (cdr (assq 'body original)))
+  (find-parts (lambda (type) (delq nil (mapcar (lambda (part)
+ (if (string= (cdr 
(assq 'content-type part)) type)
+ (cdr (assq 
'content part
+   body-parts
+  (plain-parts (apply find-parts '(text/plain)))
+  (html-parts (apply find-parts '(text/html
+  
+  (if (not (null plain-parts))
+ (mapc (lambda (part) (setq body (concat body (notmuch-mua-quote-part 
part plain-parts)
+   (mapc (lambda (part) (setq body (concat body (notmuch-mua-quote-part 
(notmuch-mua-parse-html-part part) html-parts)))
+(setq body (concat body \n))
+   
 ;; If sender is non-nil, set the From: header to its value.
 (when sender
   (mail-header-set 'from sender headers))
diff --git a/test/emacs b/test/emacs
index a06c223..fe501da 100755
--- a/test/emacs
+++ b/test/emacs
@@ -270,6 +270,7 @@ Fcc: $(pwd)/mail/sent
 --text follows this line--
 On 01 Jan 2000 12:00:00 -, Notmuch Test Suite test_su...@notmuchmail.org 
wrote:
  This is a test that messages are sent via SMTP
+ 
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
-- 
1.7.5.4

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