[PATCH 6/6] emacs: add support for reversing notmuch-show-mark-read tag changes

2012-09-02 Thread Jani Nikula
Since marking a message as read can now be a user customized set of
tag changes, make reversing this easier. Allow a prefix argument to
notmuch-show-mark-read to reverse the marking as read, similar to the
unarchiving in notmuch-show-archive-message.

While at it, update the relevant documentation to match that of other
automatic tagging (i.e. archive and reply).
---
 emacs/notmuch-show.el |   25 -
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index e701aec..1c1cf9c 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -184,8 +184,15 @@ provided with an MLA argument nor `completing-read' input."
   :group 'notmuch-show)

 (defcustom notmuch-show-mark-read-tags '("-unread")
-  "List of tags to apply when message is read, ie. shown in notmuch-show
-buffer."
+  "List of tag changes to apply to a message when it is marked as read.
+
+Tags starting with \"+\" (or not starting with either \"+\" or
+\"-\") in the list will be added, and tags starting with \"-\"
+will be removed from the message being marked as read.
+
+For example, if you wanted to remove an \"unread\" tag and add a
+\"read\" tag (which would make little sense), you would set:
+(\"-unread\" \"+read\")"
   :type '(repeat string)
   :group 'notmuch-show)

@@ -1390,10 +1397,18 @@ current thread."
   "Are the headers of the current message visible?"
   (notmuch-show-get-prop :headers-visible))

-(defun notmuch-show-mark-read ()
-  "Apply `notmuch-show-mark-read-tags' to the message."
+(defun notmuch-show-mark-read ( unread)
+  "Mark the current message as read.
+
+Mark the current message as read by applying the tag changes in
+`notmuch-show-mark-read-tags' to it (remove the \"unread\" tag by
+default). If a prefix argument is given, the message will be
+marked as unread, i.e. the tag changes in
+`notmuch-show-mark-read-tags' will be reversed."
+  (interactive "P")
   (when notmuch-show-mark-read-tags
-(apply 'notmuch-show-tag-message notmuch-show-mark-read-tags)))
+(apply 'notmuch-show-tag-message
+  (notmuch-tag-change-list notmuch-show-mark-read-tags unread

 ;; Functions for getting attributes of several messages in the current
 ;; thread.
-- 
1.7.9.5



[PATCH 5/6] emacs: add support for reversing notmuch-search-archive-thread tag changes

2012-09-02 Thread Jani Nikula
Since archiving a thread can now be a user customized set of tag
changes, make reversing this easier. Allow a prefix argument to
notmuch-search-archive-thread to reverse the archiving, similar to the
unarchiving in notmuch-show-archive-message.
---
 emacs/notmuch.el |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 64caa3e..a8a85ce 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -593,7 +593,7 @@ See `notmuch-tag' for information on the format of 
TAG-CHANGES."
   (interactive)
   (notmuch-search-tag "-"))

-(defun notmuch-search-archive-thread ()
+(defun notmuch-search-archive-thread ( unarchive)
   "Archive the currently selected thread.

 Archive each message in the currently selected thread by applying
@@ -603,10 +603,10 @@ messages will be \"unarchived\" (i.e. the tag changes in
 `notmuch-archive-tags' will be reversed).

 This function advances the next thread when finished."
-  (interactive)
+  (interactive "P")
   (when notmuch-archive-tags
 (notmuch-search-tag
- (notmuch-tag-change-list notmuch-archive-tags)))
+ (notmuch-tag-change-list notmuch-archive-tags unarchive)))
   (notmuch-search-next-thread))

 (defun notmuch-search-update-result (result  pos)
-- 
1.7.9.5



[PATCH 4/6] emacs: add support for custom tag changes on message/thread archive

2012-09-02 Thread Jani Nikula
Add support for customization of the tag changes that are applied when
a message or a thread is archived. Instead of hard-coded removal of
the "inbox" tag, the user can now specify a list of tag changes to
perform.
---
 emacs/notmuch-lib.el  |   14 ++
 emacs/notmuch-show.el |   29 +
 emacs/notmuch.el  |   12 ++--
 3 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 900235b..20d990d 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -82,6 +82,20 @@
   :type '(alist :key-type string :value-type string)
   :group 'notmuch-hello)

+(defcustom notmuch-archive-tags '("-inbox")
+  "List of tag changes to apply to a message or a thread when it is archived.
+
+Tags starting with \"+\" (or not starting with either \"+\" or
+\"-\") in the list will be added, and tags starting with \"-\"
+will be removed from the message or thread being archived.
+
+For example, if you wanted to remove an \"inbox\" tag and add an
+\"archived\" tag, you would set:
+(\"-inbox\" \"+archived\")"
+  :type '(repeat string)
+  :group 'notmuch-search
+  :group 'notmuch-show)
+
 (defvar notmuch-folders nil
   "Deprecated name for what is now known as `notmuch-saved-searches'.")

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ce5ea6f..e701aec 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1748,18 +1748,20 @@ argument, hide all of the messages."
 (defun notmuch-show-archive-thread ( unarchive)
   "Archive each message in thread.

-Archive each message currently shown by removing the \"inbox\"
-tag from each.  If a prefix argument is given, the messages will
-be \"unarchived\" (ie. the \"inbox\" tag will be added instead of
-removed).
+Archive each message currently shown by applying the tag changes
+in `notmuch-archive-tags' to each (remove the \"inbox\" tag by
+default). If a prefix argument is given, the messages will be
+\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
+will be reversed.

 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 "P")
-  (let ((op (if unarchive "+" "-")))
-(notmuch-show-tag-all (concat op "inbox"
+  (when notmuch-archive-tags
+(notmuch-show-tag-all
+ (notmuch-tag-change-list notmuch-archive-tags unarchive

 (defun notmuch-show-archive-thread-then-next ()
   "Archive all messages in the current buffer, then show next thread from 
search."
@@ -1774,14 +1776,17 @@ buffer."
   (notmuch-show-next-thread))

 (defun notmuch-show-archive-message ( unarchive)
-  "Archive the current message (remove \"inbox\" tag).
+  "Archive the current message.

-If a prefix argument is given, the message will be
-\"unarchived\" (ie. the \"inbox\" tag will be added instead of
-removed)."
+Archive the current message by applying the tag changes in
+`notmuch-archive-tags' to it (remove the \"inbox\" tag by
+default). If a prefix argument is given, the message will be
+\"unarchived\", i.e. the tag changes in `notmuch-archive-tags'
+will be reversed."
   (interactive "P")
-  (let ((op (if unarchive "+" "-")))
-(notmuch-show-tag-message (concat op "inbox"
+  (when notmuch-archive-tags
+(apply 'notmuch-show-tag-message
+  (notmuch-tag-change-list notmuch-archive-tags unarchive

 (defun notmuch-show-archive-message-then-next-or-exit ()
   "Archive the current message, then show the next open message in the current 
thread.
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 1c43d3e..64caa3e 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -594,11 +594,19 @@ See `notmuch-tag' for information on the format of 
TAG-CHANGES."
   (notmuch-search-tag "-"))

 (defun notmuch-search-archive-thread ()
-  "Archive the currently selected thread (remove its \"inbox\" tag).
+  "Archive the currently selected thread.
+
+Archive each message in the currently selected thread by applying
+the tag changes in `notmuch-archive-tags' to each (remove the
+\"inbox\" tag by default). If a prefix argument is given, the
+messages will be \"unarchived\" (i.e. the tag changes in
+`notmuch-archive-tags' will be reversed).

 This function advances the next thread when finished."
   (interactive)
-  (notmuch-search-tag '("-inbox"))
+  (when notmuch-archive-tags
+(notmuch-search-tag
+ (notmuch-tag-change-list notmuch-archive-tags)))
   (notmuch-search-next-thread))

 (defun notmuch-search-update-result (result  pos)
-- 
1.7.9.5



[PATCH 3/6] emacs: use new tag change helper to mark messages as replied

2012-09-02 Thread Jani Nikula
Clarify documentation while at it.
---
 emacs/notmuch-message.el |   24 ++--
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index 3798046..4dc4883 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -23,14 +23,16 @@
 (require 'notmuch-tag)
 (require 'notmuch-mua)

-(defcustom notmuch-message-replied-tags '("replied")
-  "Tags to be automatically added to or removed from a message when it is 
replied to.
-Any tag in the list will be added to a replied message or,
-if it is prefaced with a \"-\", removed.
+(defcustom notmuch-message-replied-tags '("+replied")
+  "List of tag changes to apply to a message when it has been replied to.
+
+Tags starting with \"+\" (or not starting with either \"+\" or
+\"-\") in the list will be added, and tags starting with \"-\"
+will be removed from the message being replied to.

 For example, if you wanted to add a \"replied\" tag and remove
-the \"inbox\" and \"todo\", you would set
-(\"replied\" \"-inbox\" \"-todo\"\)"
+the \"inbox\" and \"todo\" tags, you would set:
+(\"+replied\" \"-inbox\" \"-todo\"\)"
   :type '(repeat string)
   :group 'notmuch-send)

@@ -38,14 +40,8 @@ the \"inbox\" and \"todo\", you would set
   ;; get the in-reply-to header and parse it for the message id.
   (let ((rep (mail-header-parse-addresses (message-field-value 
"In-Reply-To"
 (when (and notmuch-message-replied-tags rep)
-  ;; add a "+" to any tag that is doesn't already begin with a "+"
-  ;; or "-"
-  (let ((tags (mapcar (lambda (str)
-   (if (not (string-match "^[+-]" str))
-   (concat "+" str)
- str))
- notmuch-message-replied-tags)))
-   (funcall 'notmuch-tag (notmuch-id-to-query (car (car rep))) tags)
+  (funcall 'notmuch-tag (notmuch-id-to-query (car (car rep)))
+  (notmuch-tag-change-list notmuch-message-replied-tags)

 (add-hook 'message-send-hook 'notmuch-message-mark-replied)

-- 
1.7.9.5



[PATCH 2/6] emacs: fix notmuch-message-replied-tags defcustom type

2012-09-02 Thread Jani Nikula
---
 emacs/notmuch-message.el |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index d3738bf..3798046 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -31,7 +31,7 @@ if it is prefaced with a \"-\", removed.
 For example, if you wanted to add a \"replied\" tag and remove
 the \"inbox\" and \"todo\", you would set
 (\"replied\" \"-inbox\" \"-todo\"\)"
-  :type 'list
+  :type '(repeat string)
   :group 'notmuch-send)

 (defun notmuch-message-mark-replied ()
-- 
1.7.9.5



[PATCH 1/6] emacs: add helper for tag change list manipulation

2012-09-02 Thread Jani Nikula
Add a helper to create (and optionally reverse) a list of tag changes.
---
 emacs/notmuch-tag.el |   17 +
 1 file changed, 17 insertions(+)

diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el
index 0c0fc87..c1aeb99 100644
--- a/emacs/notmuch-tag.el
+++ b/emacs/notmuch-tag.el
@@ -140,6 +140,23 @@ notmuch-after-tag-hook will be run."
   ;; in all cases we return tag-changes as a list
   tag-changes)

+(defun notmuch-tag-change-list (tags  reverse)
+  "Convert TAGS into a list of tag changes.
+
+Add a \"+\" prefix to any tag in TAGS list that doesn't already
+begin with a \"+\" or a \"-\". If REVERSE is non-nil, replace all
+\"+\" prefixes with \"-\" and vice versa in the result."
+  (mapcar (lambda (str)
+   (let ((s (if (not (string-match "^[+-]" str))
+(concat "+" str)
+  str)))
+ (if reverse
+ (concat (if (= (string-to-char s) ?-) "+" "-")
+ (substring s 1))
+   s)))
+ tags))
+
+
 ;;

 (provide 'notmuch-tag)
-- 
1.7.9.5



[PATCH 0/6] emacs: customization for tag changes on archive

2012-09-02 Thread Jani Nikula
Hi all, Michal Nazarewicz added customization for tag changes on marking
messages as read (commit 1f30f7d2). This series does the same for
archiving, with some cleanups and minor refactoring. As the tag changes
may now be more complicated than simple "-inbox" or "-unread", add
support for "unarchiving" and "unreading" as well.

After this, all the tags recognized and treated special by the emacs
interface can be customized.

An interesting by-product is that you can filter your mail into multiple
different inboxes, each with their own inbox tag, and (after you setup
`notmuch-archive-tags') you can read and archive each inbox separately
with built-in archiving functions.

BR,
Jani.


Jani Nikula (6):
  emacs: add helper for tag change list manipulation
  emacs: fix notmuch-message-replied-tags defcustom type
  emacs: use new tag change helper to mark messages as replied
  emacs: add support for custom tag changes on message/thread archive
  emacs: add support for reversing notmuch-search-archive-thread tag
changes
  emacs: add support for reversing notmuch-show-mark-read tag changes

 emacs/notmuch-lib.el |   14 
 emacs/notmuch-message.el |   26 ++
 emacs/notmuch-show.el|   54 +++---
 emacs/notmuch-tag.el |   17 +++
 emacs/notmuch.el |   16 ++
 5 files changed, 91 insertions(+), 36 deletions(-)

-- 
1.7.9.5



[PATCH v2 0/5] emacs: notmuch-hello status message refresh hook, etc

2012-09-02 Thread Tomi Ollila
On Sun, Sep 02 2012, Jani Nikula  wrote:

> Hi all, v2 of [1] addressing review comments: added NEWS, improved
> documentation, made the query customizable.

Hi Jani

Just today I was looking these older patches below and was about to
comment those when these arrived.

I think the idea is great, but there is just something in the integration...

> [1] id:"37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani at 
> nikula.org"

I see hooks a great way to extend some functionality outside of that
package instead of touching it. Also, maybe I've been using emacs too
much as these hooks as defcustom seems little weird. Yet as I grepped
'defcustom.*hook' through emacs-24.2/lisp/*.el and I got many hits --
and some of those even added some ":options" to those (but most those
I looked did not specify anything to choose from).

That said, I am not _personally_ very thilled about the idea of defining
functions inside notmuch and then that work via a hook...

Therefore I'd like to propose an alternative way to do this:

Integrate this change status information to the notmuch-hello-insert-header ()
function, disabled by default -- and add customization variable which
can be used to enable it. like:

 Welcome to notmuch. You have 22 195 messages.

 Welcome to notmuch. You have 22 185 messages (-10).
 Welcome to notmuch. You have 22 205 messages (+20).

or second line for the status info.


I would enable this feature if implemented this way. Also I would enable
this implemented like this patch series if this is to be applied (I just 
give +-0). But this could also be implemented as a hook outside of notmuch
relying that variable no-display is available in dynamic scope -- but without
promising the variable will be there.

> BR,
> Jani.

Finally, I hope my comment does not silence the audience but that this
sparks more comment and good solution is used for this useful feature.

Tomi

>
> Jani Nikula (5):
>   emacs: document the notmuch-hello no-display argument
>   emacs: add no-display arg to notmuch-hello-refresh-hook
>   test: fix hook-counter to accept the new no-display param
>   emacs: add notmuch hello refresh hook to display message count change
>   NEWS: notmuch-hello refresh hook changes
>
>  NEWS   |   18 ++
>  emacs/notmuch-hello.el |   46 --
>  test/test-lib.el   |2 +-
>  3 files changed, 63 insertions(+), 3 deletions(-)
>
> -- 
> 1.7.9.5
>
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH v2 3/5] test: fix hook-counter to accept the new no-display param

2012-09-02 Thread Jani Nikula
notmuch-hello-refresh-hook is now called with no-display param. Accept
(and ignore) it in hook-counter.
---
 test/test-lib.el |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test-lib.el b/test/test-lib.el
index fa3380c..864780c 100644
--- a/test/test-lib.el
+++ b/test/test-lib.el
@@ -84,7 +84,7 @@ running, quit if it terminated."
   (kill-emacs)
 (run-at-time "1 min" nil 'orphan-watchdog pid)))

-(defun hook-counter (hook)
+(defun hook-counter (hook  no-display)
   "Count how many times a hook is called.  Increments
 `hook'-counter variable value if it is bound, otherwise does
 nothing."
-- 
1.7.9.5



[PATCH v2 2/5] emacs: add no-display arg to notmuch-hello-refresh-hook

2012-09-02 Thread Jani Nikula
Add no-display arg to notmuch-hello-refresh-hook to allow each hook to
decide what is appropriate when no-display is t, i.e. when not
switching to the notmuch-hello buffer.

This breaks existing hooks people might have, which will now need to
accept the argument.

Signed-off-by: Jani Nikula 
---
 emacs/notmuch-hello.el |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 4dfe5d2..fa14443 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -816,7 +816,7 @@ it (i.e. use `set-buffer' rather than `switch-to-buffer')."
   (unless (widget-at)
(when notmuch-hello-search-pos
  (goto-char notmuch-hello-search-pos)
-  (run-hooks 'notmuch-hello-refresh-hook)
+  (run-hook-with-args 'notmuch-hello-refresh-hook no-display)
   (setq notmuch-hello-first-run nil))

 (defun notmuch-folder ()
-- 
1.7.9.5



[PATCH v2 0/5] emacs: notmuch-hello status message refresh hook, etc

2012-09-02 Thread Jani Nikula
Hi all, v2 of [1] addressing review comments: added NEWS, improved
documentation, made the query customizable.

[1] id:"37899e28dbf67e4620a53279a869be3174c02d6f.1339775602.git.jani at 
nikula.org"

BR,
Jani.

Jani Nikula (5):
  emacs: document the notmuch-hello no-display argument
  emacs: add no-display arg to notmuch-hello-refresh-hook
  test: fix hook-counter to accept the new no-display param
  emacs: add notmuch hello refresh hook to display message count change
  NEWS: notmuch-hello refresh hook changes

 NEWS   |   18 ++
 emacs/notmuch-hello.el |   46 --
 test/test-lib.el   |2 +-
 3 files changed, 63 insertions(+), 3 deletions(-)

-- 
1.7.9.5



[PATCH v2 (Draft)] emacs: split async json parser into utility function

2012-09-02 Thread David Bremner
Mark Walters  writes:

> Split out the json parser into a utility function.
> ---
>
> Most of this patch is code movement: but I don't see how to arrange the
> patch to show that.
>

"git gui blame notmuch.el" gives some clues, although it isn't perfect.
Maybe you could explain in the commit message what is _not_ code
movement?

> +(defvar notmuch-json-parser nil
> +  "Incremental JSON parser.")

This docstring needs expanding. I suppose that this is for internal use,
but it isn't clear from the docstring.



[PATCH 1/5] emacs: compile and load notmuch-pick.el if present.

2012-09-02 Thread David Bremner
Tomi Ollila  writes:
> I think it would be better to provide a shell script in 
> notmuch-pick directory which byte-compiles and installs notmuch-pick
> in case user wants to install/update notmuch-pick. Whenever notmuch-pick
> is good enough to be shipped inside $(dir) above then the aboce conditional
> is not needed (at all).

I just tried notmuch-pick for the first time, and at least on this
relatively beefy machine, it runs fine uncompiled. 

I'm not sure if it is worth complicating the mainline install. Which
means I guess I am agreeing with Tomi.  It could also be in independant
Makefile rather than a script.

I don't think it's crucial to install notmuch-pick into the main lisp
context of (Debian) packaging I don't think that will work very well.
The way org-mode works is that it ships a seperate contrib lisp
directory; on Debian this is in /usr/share/org-mode/contrib. Then people
who want to use a contrib piece of lisp would just add the following to
their .emacs:

(add-to-list 'load-path "/usr/share/notmuch/contrib/emacs-lisp")
(require 'notmuch-pick)

at least given the changes that Tomi proposes below.
The path is obviously just an example.

> (require 'notmuch-hello)
> (require 'notmuch-show)
> (require 'notmuch) ;; XXX ATM, as notmuch-search-mode-map is defined here
>
> And, at the end, before (provide 'notmuch-pick), execute the lines
> what currenty are contained in (notmuch-pick-init).

Yes, this sounds about right to me. require should also take care of the
"only run this once" part.

FWIW, I'm currently running pick from the source tree as:

(add-to-list 'load-path
 (expand-file-name "~/blah"))
(when (locate-library "notmuch-pick")
  (eval-after-load 'notmuch
'(progn 
   (require 'notmuch-pick)
   (notmuch-pick-init

it's a bit overengineered, but this way it doesn't crap out on machines
where notmuch-pick is not installed.


[PATCH 06/11] lib: store thread recipients in thread structure

2012-09-02 Thread Mark Walters

On Mon, 20 Aug 2012, Jameson Graef Rollins  
wrote:
> This utilizes the new thread addresses struct to store thread
> recipients, again in parallel to authors.
>
> Since message recipients are not stored in the database, including
> recipients in the thread structure exacts a significant overhead as
> the recipients are retrieved from the original message files.  Because
> of this, a new boolean argument, include_recipients, is added to the
> necessary functions (_notmuch_thread_create, _thread_add_message and
> _thread_add_matched_message) that controls whether the recipients are
> fetched and included.  If message recipients are ever stored in the
> database this new argument could probably be removed.
> ---

Hi

I have briefly looked through the series and overall it looks good.

>  lib/notmuch-private.h |3 +-
>  lib/notmuch.h |   14 +
>  lib/query.cc  |3 +-
>  lib/thread.cc |   77 
> +
>  4 files changed, 76 insertions(+), 21 deletions(-)
>
> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
> index 27a41b6..32d1523 100644
> --- a/lib/notmuch-private.h
> +++ b/lib/notmuch-private.h
> @@ -232,7 +232,8 @@ _notmuch_thread_create (void *ctx,
>   unsigned int seed_doc_id,
>   notmuch_doc_id_set_t *match_set,
>   notmuch_string_list_t *excluded_terms,
> - notmuch_sort_t sort);
> + notmuch_sort_t sort,
> + notmuch_bool_t include_recipients);
>  
>  /* message.cc */
>  
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 6acd38d..f9e71c1 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -759,6 +759,20 @@ notmuch_thread_get_matched_messages (notmuch_thread_t 
> *thread);
>  const char *
>  notmuch_thread_get_authors (notmuch_thread_t *thread);
>  
> +/* Get the recipients of 'thread'
> + *
> + * The returned string is a comma-separated list of the names of the
> + * recipients of mail messages in the query results that belong to this
> + * thread.
> + *
> + * The returned string belongs to 'thread' and as such, should not be
> + * modified by the caller and will only be valid for as long as the
> + * thread is valid, (which is until notmuch_thread_destroy or until
> + * the query from which it derived is destroyed).
> + */
> +const char *
> +notmuch_thread_get_recipients (notmuch_thread_t *thread);
> +
>  /* Get the subject of 'thread'
>   *
>   * The subject is taken from the first message (according to the query
> diff --git a/lib/query.cc b/lib/query.cc
> index e9c1a2d..54833a7 100644
> --- a/lib/query.cc
> +++ b/lib/query.cc
> @@ -486,7 +486,8 @@ notmuch_threads_get (notmuch_threads_t *threads)
>  doc_id,
>  >match_set,
>  threads->query->exclude_terms,
> -threads->query->sort);
> +threads->query->sort,
> +FALSE);
>  }
>  
>  void
> diff --git a/lib/thread.cc b/lib/thread.cc
> index 757e143..baf07c2 100644
> --- a/lib/thread.cc
> +++ b/lib/thread.cc
> @@ -37,6 +37,7 @@ struct visible _notmuch_thread {
>  char *thread_id;
>  char *subject;
>  notmuch_thread_addresses_t *authors;
> +notmuch_thread_addresses_t *recipients;
>  GHashTable *tags;
>  
>  notmuch_message_list_t *message_list;
> @@ -63,6 +64,7 @@ static int
>  _notmuch_thread_destructor (notmuch_thread_t *thread)
>  {
>  _notmuch_thread_addresses_destructor (thread->authors);
> +_notmuch_thread_addresses_destructor (thread->recipients);
>  g_hash_table_unref (thread->tags);
>  g_hash_table_unref (thread->message_hash);
>  return 0;
> @@ -204,14 +206,17 @@ _thread_cleanup_address (notmuch_thread_t *thread,
>  static void
>  _thread_add_message (notmuch_thread_t *thread,
>notmuch_message_t *message,
> -  notmuch_string_list_t *exclude_terms)
> +  notmuch_string_list_t *exclude_terms,
> +  notmuch_bool_t include_recipients)
>  {
>  notmuch_tags_t *tags;
>  const char *tag;
> -InternetAddressList *list = NULL;
> +InternetAddressList *from_list = NULL;
> +InternetAddressList *to_list = NULL;
>  InternetAddress *address;
>  const char *from, *author;
> -char *clean_author;
> +const char *to, *recipient;
> +char *clean_address;
>  
>  _notmuch_message_list_add_message (thread->message_list,
>  talloc_steal (thread, message));
> @@ -223,10 +228,9 @@ _thread_add_message (notmuch_thread_t *thread,
>  
>  from = notmuch_message_get_header (message, "from");
>  if (from)
> - list = internet_address_list_parse_string (from);
> -
> -if (list) {
> - address = internet_address_list_get_address (list, 0);
> + from_list = 

[PATCH v2 0/9] FreeBSD Support Patches

2012-09-02 Thread David Bremner
Mike Kelly  writes:

> Hi,
>
> Here's a second attempt at adding FreeBSD support. Hopefully most of the
> concerns raised about the initial patch set have been addressed.

I pushed (finally) patches 1,2,4,5,6 and 8. The others either no longer
apply, or there were some outstanding issues in the discussion on the
list.

d


[PATCH] test: make test_expect_equal_file() arguments flexible

2012-09-02 Thread David Bremner
Dmitry Kurochkin  writes:

> Before the change, test_expect_equal_file() function treated the first
> argument as "actual output file" and the second argument as "expected
> output file".  When the test fails, the files are copied for later
> inspection.  The first files was copied to "$testname.output" and the
> second file to "$testname.expected".  The argument order for
> test_expect_equal_file() is often wrong which results in confusing
> diff output and incorrectly named files.

pushed, 

d


[PATCH] emacs: correct `notmuch-search-mode's docstring wrt `notmuch-search-tag-all'

2012-09-02 Thread David Bremner
Pieter Praet  writes:

> * emacs/notmuch.el (notmuch-search-mode):
>   `notmuch-search-tag-all' currently uses the current query string
>   instead of `notmuch-search-find-thread-id-region-search', which
>   might cause a race condition.

pushed, finally.

d


[PATCH v2] cli: make the command line parser's errors more informative.

2012-09-02 Thread David Bremner
Mark Walters  writes:

> Previously, the cli parser was a little erratic in what errors it
> reported and would fail silently in many cases (for example, when no
> argument was passed to an integer option). This was particularly
> annoying as the user could not (easily) tell whether the command
> failed or just there were no search results.

pushed,

d


[PATCH 1/3] lib: fix NULL checks for filenames iterators

2012-09-02 Thread David Bremner
Sascha Silbe  writes:

> The API documentation (notmuch.h) states that the parameter may be NULL,
> but the implementation only checked the current element, potentially
> dereferencing a NULL pointer in the process.
>

Pushed this one patch.

d


[PATCH 2/5] emacs: make notmuch-show return its buffer

2012-09-02 Thread David Bremner
Mark Walters  writes:

> notmuch-pick uses the returned buffer to try and make sure it does not
> close the wrong buffer.

Pushed this one patch,

d


[PATCH] contrib/nmbug/nmbug-status: if realname empty, use part of mailaddr

2012-09-02 Thread David Bremner
Tomi Ollila  writes:

> When the From: field in patch email does not contain 'realname'
> field, the patch listing does not show anything as patch sender.
> In this case use the part before '@' in mail address as the sender
> identification in patch listing.

pushed, 

d


[PATCH v2 1/5] emacs: document the notmuch-hello no-display argument

2012-09-02 Thread Jani Nikula
---
 emacs/notmuch-hello.el |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 684bedc..4dfe5d2 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -751,7 +751,11 @@ following:
 
 ;;;###autoload
 (defun notmuch-hello (optional no-display)
-  Run notmuch and display saved searches, known tags, etc.
+  Run notmuch and display saved searches, known tags, etc.
+
+If the optional NO-DISPLAY argument is non-nil, only update the
+notmuch-hello buffer if it already exists, without switching to
+it (i.e. use `set-buffer' rather than `switch-to-buffer').
   (interactive)
 
   ;; Jump through a hoop to get this value from the deprecated variable
-- 
1.7.9.5

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


[PATCH v2 5/5] NEWS: notmuch-hello refresh hook changes

2012-09-02 Thread Jani Nikula
---
 NEWS |   18 ++
 1 file changed, 18 insertions(+)

diff --git a/NEWS b/NEWS
index 2b50ba3..435a1ab 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,21 @@
+Notmuch 0.15 (-MM-DD)
+=
+
+Emacs Interface
+---
+
+`notmuch-hello-refresh-hook` argument change
+
+  The `no-display` argument of `notmuch-hello` is now passed on to the
+  `notmuch-hello-refresh-hook`. Custom hooks need to be changed to accept the
+  argument.
+
+Status message on `notmuch-hello` refresh
+
+  A hook to display a status message about the change in the message count in
+  the database on `notmuch-hello` refresh is provided. The hook can be enabled
+  by customizing `notmuch-hello-refresh-hook`.
+
 Notmuch 0.14 (2012-08-20)
 =
 
-- 
1.7.9.5

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


[PATCH v2 4/5] emacs: add notmuch hello refresh hook to display message count change

2012-09-02 Thread Jani Nikula
Add a notmuch hello refresh hook to display a message about change in
message count in the database since the notmuch-hello buffer was last
refreshed manually (no-display is nil).

Signed-off-by: Jani Nikula j...@nikula.org
---
 emacs/notmuch-hello.el |   38 ++
 1 file changed, 38 insertions(+)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index fa14443..f7a3c95 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -148,6 +148,7 @@ International Bureau of Weights and Measures.
 (defcustom notmuch-hello-refresh-hook nil
   Functions called after updating a `notmuch-hello' buffer.
   :type 'hook
+  :options '(notmuch-hello-refresh-status-message)
   :group 'notmuch-hello
   :group 'notmuch-hooks)
 
@@ -749,6 +750,43 @@ following:
 (let ((fill-column (- (window-width) notmuch-hello-indent)))
   (center-region start (point)
 
+(defcustom notmuch-hello-refresh-status-query *
+  Query to use for `notmuch-hello-refresh-status-message' hook.
+  :type '(choice (const :tag All messages *)
+(string :tag Custom query
+:value tag:inbox))
+  :group 'notmuch-hello)
+
+(defvar notmuch-hello-refresh-count 0
+  Number of matching messages when `notmuch-hello' was last run.
+
+Used internally by `notmuch-hello-refresh-status-message'.)
+
+(defun notmuch-hello-refresh-status-message (no-display)
+  Hook to display a status message when refreshing notmuch-hello buffer.
+
+Display a status message about the difference in message count
+matching `notmuch-hello-refresh-status-query' since the last time
+notmuch-hello was refreshed. Only takes into account explicit
+refreshes (NO-DISPLAY is nil).
+  (unless no-display
+(let* ((new-count
+   (string-to-number
+(car (process-lines notmuch-command count
+notmuch-hello-refresh-status-query
+  (diff-count (- new-count notmuch-hello-refresh-count)))
+  (cond
+   ((= notmuch-hello-refresh-count 0)
+   (message You have %s messages.
+(notmuch-hello-nice-number new-count)))
+   (( diff-count 0)
+   (message You have %s more messages since last refresh.
+(notmuch-hello-nice-number diff-count)))
+   (( diff-count 0)
+   (message You have %s fewer messages since last refresh.
+(notmuch-hello-nice-number (- diff-count)
+  (setq notmuch-hello-refresh-count new-count
+
 ;;;###autoload
 (defun notmuch-hello (optional no-display)
   Run notmuch and display saved searches, known tags, etc.
-- 
1.7.9.5

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


[PATCH 2/6] emacs: fix notmuch-message-replied-tags defcustom type

2012-09-02 Thread Jani Nikula
---
 emacs/notmuch-message.el |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/notmuch-message.el b/emacs/notmuch-message.el
index d3738bf..3798046 100644
--- a/emacs/notmuch-message.el
+++ b/emacs/notmuch-message.el
@@ -31,7 +31,7 @@ if it is prefaced with a \-\, removed.
 For example, if you wanted to add a \replied\ tag and remove
 the \inbox\ and \todo\, you would set
 (\replied\ \-inbox\ \-todo\\)
-  :type 'list
+  :type '(repeat string)
   :group 'notmuch-send)
 
 (defun notmuch-message-mark-replied ()
-- 
1.7.9.5

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


[PATCH 5/6] emacs: add support for reversing notmuch-search-archive-thread tag changes

2012-09-02 Thread Jani Nikula
Since archiving a thread can now be a user customized set of tag
changes, make reversing this easier. Allow a prefix argument to
notmuch-search-archive-thread to reverse the archiving, similar to the
unarchiving in notmuch-show-archive-message.
---
 emacs/notmuch.el |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 64caa3e..a8a85ce 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -593,7 +593,7 @@ See `notmuch-tag' for information on the format of 
TAG-CHANGES.
   (interactive)
   (notmuch-search-tag -))
 
-(defun notmuch-search-archive-thread ()
+(defun notmuch-search-archive-thread (optional unarchive)
   Archive the currently selected thread.
 
 Archive each message in the currently selected thread by applying
@@ -603,10 +603,10 @@ messages will be \unarchived\ (i.e. the tag changes in
 `notmuch-archive-tags' will be reversed).
 
 This function advances the next thread when finished.
-  (interactive)
+  (interactive P)
   (when notmuch-archive-tags
 (notmuch-search-tag
- (notmuch-tag-change-list notmuch-archive-tags)))
+ (notmuch-tag-change-list notmuch-archive-tags unarchive)))
   (notmuch-search-next-thread))
 
 (defun notmuch-search-update-result (result optional pos)
-- 
1.7.9.5

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