[PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:33:35 +0400, Dmitry Kurochkin  wrote:
> On Fri, 24 Feb 2012 14:30:29 +0400, Dmitry Kurochkin  gmail.com> wrote:
> > On Fri, 24 Feb 2012 00:07:27 +0100, Pieter Praet  
> > wrote:
> > > On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  
> > > wrote:
> > > > On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin  > > > at gmail.com> wrote:
> > > > > Changes:
> > > > > 
> > > > > v4:
> > > > > 
> > > > > * rebased on master, no conflicts so no need for another review
> > > > > 
> > > > 
> > > > I pushed this series.  
> > > > 
> > > > Maybe this was discussed already, but I think ideally * would apply only
> > > > to open messages. So consider that a feature request if someone is
> > > > looking for a project.
> > > >
> > > 
> > > How about if '*' applies to all messages (as it currently does),
> > > but 'C-u *' only to open messages?  That would make more sense IMHO.
> > > 
> > > But, conforming to your original request, I've implemented the inverse.
> > > 
> > 
> > I personally do like '*' as is and do not want to change it's behavior.
> > Though I am not against adding a prefix argument for it.
> > 
> 
> Also can you please send new patches (and patch series) in a new
> separate thread?  If they are related to another thread, you can add a
> reference.  But having multiple patch series with multiple versions in a
> single thread is very confusing IMO.
>

Since I've already soiled this thread with my initial series,
I've sent v2 [1] in reply to David's request as well, but will
make sure to start a fresh thread from now on.


> Regards,
>   Dmitry
> 
> > Regards,
> >   Dmitry
> > 
> > > Patches follow.
> > > 
> > > 
> > > > d
> > > > ___
> > > > notmuch mailing list
> > > > notmuch at notmuchmail.org
> > > > http://notmuchmail.org/mailman/listinfo/notmuch
> > > 
> > > 
> > > Peace
> > > 
> > > -- 
> > > Pieter

Thanks for all your comments!


Peace

-- 
Pieter

[1] id:"1330122640-18895-1-git-send-email-pieter at praet.org"


[PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:30:29 +0400, Dmitry Kurochkin  wrote:
> On Fri, 24 Feb 2012 00:07:27 +0100, Pieter Praet  wrote:
> > On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  
> > wrote:
> > > On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin  > > gmail.com> wrote:
> > > > Changes:
> > > > 
> > > > v4:
> > > > 
> > > > * rebased on master, no conflicts so no need for another review
> > > > 
> > > 
> > > I pushed this series.  
> > > 
> > > Maybe this was discussed already, but I think ideally * would apply only
> > > to open messages. So consider that a feature request if someone is
> > > looking for a project.
> > >
> > 
> > How about if '*' applies to all messages (as it currently does),
> > but 'C-u *' only to open messages?  That would make more sense IMHO.
> > 
> > But, conforming to your original request, I've implemented the inverse.
> > 
> 
> I personally do like '*' as is and do not want to change it's behavior.
> Though I am not against adding a prefix argument for it.
>

Same here.  In v2 [1], '*' tags all and 'C-u *' tags only open.

One can always swap the keybindings if so inclined.


> Regards,
>   Dmitry
> 
> > Patches follow.
> > 
> > 
> > > d
> > > ___
> > > notmuch mailing list
> > > notmuch at notmuchmail.org
> > > http://notmuchmail.org/mailman/listinfo/notmuch
> > 
> > 
> > Peace
> > 
> > -- 
> > Pieter
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter

[1] id:"1330122640-18895-1-git-send-email-pieter at praet.org"


[PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags open messages

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:47:30 +0400, Dmitry Kurochkin  wrote:
> On Fri, 24 Feb 2012 00:09:14 +0100, Pieter Praet  wrote:
> > * emacs/notmuch-show.el
> > 
> >   (notmuch-show-get-messages-ids):
> > New optional argument ONLY-OPEN.  If non-nil, only return
> > Message-Id's for messages which are currently visible.
> > 
> >   (notmuch-show-tag-all):
> > New optional argument IGNORE-VISIBILITY, of which the inverse is
> > passed as ONLY-OPEN argument to `notmuch-show-get-messages-ids':
> > If called with a prefix arg, affect *all* messages in the current
> > buffer.  Otherwise, only change tags of visible messages.
> > 
> >   (notmuch-show-archive-thread):
> > Update wrt changes to `notmuch-show-tag-all'.
> > 
> > * test/emacs
> > 
> >   - Subtest "notmuch-show: change tags of open messages in current buffer"
> > is no longer broken.
> > ---
> >  emacs/notmuch-show.el |   28 
> >  test/emacs|1 -
> >  2 files changed, 20 insertions(+), 9 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 4b37c77..4499fcd 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1334,13 +1334,17 @@ (defun notmuch-show-get-message-id ()
> >"Return the message id of the current message."
> >(concat "id:\"" (notmuch-show-get-prop :id) "\""))
> >  
> > -(defun notmuch-show-get-messages-ids (&optional separator)
> > +(defun notmuch-show-get-messages-ids (&optional only-open separator)
> >"Return a list of Message-Id's of all messages in the current buffer.
> >  
> > +If optional argument ONLY-OPEN is non-nil, only return
> > +Message-Id's for messages which are currently visible.
> > +
> >  If provided with optional argument SEPARATOR, return a string
> >  instead, consisting of all Message-Id's separated by SEPARATOR."
> >(let ((message-ids))
> > -(notmuch-show-mapc t
> > +(notmuch-show-mapc
> > + `(if only-open (notmuch-show-message-visible-p) t)
> 
> How about changing ONLY-OPEN to a general optional PREDICATE argument
> and pass it as is to `notmuch-show-mapc'?  Please make it the last
> argument.
>

Done.


> Regards,
>   Dmitry
> 
> >   (lambda () (push (notmuch-show-get-message-id) message-ids)))
> >  (if separator
> > (mapconcat 'identity message-ids separator)
> > @@ -1628,13 +1632,21 @@ (defun notmuch-show-tag (&optional initial-input)
> >   initial-input (notmuch-show-get-message-id
> >  (apply 'notmuch-show-tag-message tag-changes)))
> >  
> > -(defun notmuch-show-tag-all (&rest tag-changes)
> > -  "Change tags for all messages in the current thread.
> > +(defun notmuch-show-tag-all (&optional ignore-visibility &rest tag-changes)
> > +  "Change tags of all open messages in the current buffer.
> > +
> > +If optional arg IGNORE-VISIBILITY is non-nil, change tags of
> > +*all* messages in the current buffer, independent of their
> > +visibility.
> >  
> >  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> > -  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> > -  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
> > -  (notmuch-show-mapc t
> > +  (interactive (cons current-prefix-arg
> > +(notmuch-read-tag-changes nil notmuch-show-thread-id)))
> > +  (apply 'notmuch-tag
> > +(notmuch-show-get-messages-ids (not ignore-visibility) " or ")
> > +tag-changes)
> > +  (notmuch-show-mapc
> > +   `(if ignore-visibility t (notmuch-show-message-visible-p))
> > (lambda ()
> >   (let* ((current-tags (notmuch-show-get-tags))
> > (new-tags (notmuch-update-tags current-tags tag-changes)))
> > @@ -1719,7 +1731,7 @@ (defun notmuch-show-archive-thread (&optional 
> > unarchive)
> >  buffer."
> >(interactive "P")
> >(let ((op (if unarchive "+" "-")))
> > -(notmuch-show-tag-all (concat op "inbox"
> > +(notmuch-show-tag-all t (concat op "inbox"
> >  
> >  (defun notmuch-show-archive-thread-then-next ()
> >"Archive each message in thread, then show next thread from search."
> > diff --git a/test/emacs b/test/emacs
> > index 644ef59..c286ff5 100755
> > --- a/test/emacs
> > +++ b/test/emacs
> > @@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # 
> > revert tag changes
> >  test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
> > TOTAL
> >  
> >  test_begin_subtest "notmuch-show: change tags of open messages in current 
> > buffer"
> > -test_subtest_known_broken
> >  query="$os_x_darwin_thread"
> >  filter="from:Jiang"
> >  add_tag="notmuch-show-tag-all"
> > -- 
> > 1.7.8.1
> > 


Peace

-- 
Pieter


[RFC PATCH 1/3] emacs: selection-menu.el

2012-02-24 Thread Mark Walters
On Thu, 23 Feb 2012 17:10:15 +0200, Tomi Ollila  wrote:
> RFC/Idea for "improving" some selections made (in notmuch or elsewhere)
> In the hope that this will be useful, and to get some improvement advice.
> 
> I've found it somewhat difficult to use completing-read (i also tried ido-)
> to complete email addresses for mail recipients (not only due to the
> large selection of choises provided by nottoomuch-addresses.sh ;)
> and have tried to find alternatives.
> 
> The buffer selection systems (electric-buffer-list, bs-show, etc) have been
> pretty useful but I haven't found anything general.
> 
> After some 3 iterations I've come up with something like those but for
> arbitraty strings and so-far named that tool 'selection-menu'
> 
> This works by popping up buffer with all the choices shown in separate
> lines. arrow keys (and c-p/c-n) can be used to choose string and
> RET/SPC to select that. Any other key will abort the selection (ESC
> mentioned spesifically as it never "unreads" any events).
> 
> If requested user not choosing anything but pressing some key that
> key is "unread" so that the parent buffer will get it. I did that
> as in first tests I wanted to continue writing If I did not choose
> anything... More tests will show If really didn't want to loose that
> event).

Hi 

I have played with this and I like the feel of it: it is much more
informative than completing-read and much less cluttered than
ido-completing-read. 

I have some queries though:

In some uses the user might want to choose something that is not offered
(not relevant for this particular use, but maybe relevant for other
notmuch uses like selecting a from address). Is this a design choice?

I think I would like to be able to type in the buffer it shows,
e.g. page down to page through lots of addresses, maybe ctrl-s for
searching. Another possibility would be for the selection to narrow as
extra characters are typed. Though in fact maybe your choice of leaving
the character is exactly right: then the caller can take the extra
character and call selection-menu again. (I had something which almost
worked and it seemed quite nice).

Finally, does this solution mean there is no "history" available?

Best wishes

Mark



[PATCH 5/6] emacs: simplify `notmuch-show-get-messages-ids{, -search}'

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:42:53 +0400, Dmitry Kurochkin  wrote:
> On Fri, 24 Feb 2012 00:09:13 +0100, Pieter Praet  wrote:
> > * emacs/notmuch-show.el
> > 
> >   (notmuch-show-get-messages-ids):
> > If provided with optional arg SEPARATOR, return a string consisting
> > of all Message-Id's, separated by SEPARATOR.  Also improve original
> > docstring wrt default return value.
> > 
> >   (notmuch-show-get-messages-ids-search):
> > Removed, as its functionality is now in `notmuch-show-get-messages-ids'.
> > 
> >   (notmuch-show-tag-all):
> > Call `notmuch-show-get-messages-ids' with SEPARATOR arg instead of
> > `notmuch-show-get-messages-ids-search'.
> > ---
> 
> There is another similar case in notmuch.el:
> `notmuch-show-get-messages-ids' and
> `notmuch-show-get-messages-ids-search'.  There may be more.
> 
> Please change them as well.
>

You mean `notmuch-search-find-thread-id-region{,-search}' ?

They aren't relevant to this series, so I'll submit a separate patch
for that (later).  A quick `rgrep' doesn't reveal any others, but if
you happen to stumble across any, feel free to point them out.

> Regards,
>   Dmitry
> 
> >  emacs/notmuch-show.el |   18 +-
> >  1 files changed, 9 insertions(+), 9 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 5fc0e43..4b37c77 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1334,17 +1334,17 @@ (defun notmuch-show-get-message-id ()
> >"Return the message id of the current message."
> >(concat "id:\"" (notmuch-show-get-prop :id) "\""))
> >  
> > -(defun notmuch-show-get-messages-ids ()
> > -  "Return all message ids of messages in the current thread."
> > +(defun notmuch-show-get-messages-ids (&optional separator)
> > +  "Return a list of Message-Id's of all messages in the current buffer.
> > +
> > +If provided with optional argument SEPARATOR, return a string
> > +instead, consisting of all Message-Id's separated by SEPARATOR."
> >(let ((message-ids))
> >  (notmuch-show-mapc t
> >   (lambda () (push (notmuch-show-get-message-id) message-ids)))
> > -message-ids))
> > -
> > -(defun notmuch-show-get-messages-ids-search ()
> > -  "Return a search string for all message ids of messages in the
> > -current thread."
> > -  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
> > +(if separator
> > +   (mapconcat 'identity message-ids separator)
> > +  message-ids)))
> >  
> >  ;; dme: Would it make sense to use a macro for many of these?
> >  
> > @@ -1633,7 +1633,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
> >  
> >  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> >(interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> > -  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> > +  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
> >(notmuch-show-mapc t
> > (lambda ()
> >   (let* ((current-tags (notmuch-show-get-tags))
> > -- 
> > 1.7.8.1
> > 


Peace

-- 
Pieter


[PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:39:41 +0400, Dmitry Kurochkin  wrote:
> On Fri, 24 Feb 2012 00:09:12 +0100, Pieter Praet  wrote:
> > * emacs/notmuch-show.el
> > 
> >   (notmuch-show-mapc):
> > Only call FUNCTION if new argument PREDICATE is satisfied.
> > Also correct original docstring: 's/thread/buffer/'.
> > 
> >   (notmuch-show-get-messages-ids):
> > Update wrt changes to `notmuch-show-mapc'.
> > 
> >   (notmuch-show-tag-all):
> > Update wrt changes to `notmuch-show-mapc'.
> > ---
> >  emacs/notmuch-show.el |   15 ---
> >  1 files changed, 8 insertions(+), 7 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index aa9ccee..5fc0e43 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1272,13 +1272,14 @@ (defun notmuch-show-goto-message-previous ()
> >  (notmuch-show-move-to-message-top)
> >  t))
> >  
> > -(defun notmuch-show-mapc (function)
> > -  "Iterate through all messages in the current thread with
> > -`notmuch-show-goto-message-next' and call FUNCTION for side
> > -effects."
> > +(defun notmuch-show-mapc (predicate function)
> 
> Please make PREDICATE optional to avoid giving t when it is not needed.
>

Done.

> I would expect PREDICATE to be a function, [...]

Well, it *can* be a function actually (see later usage in e.g.
`notmuch-show-get-messages-ids' [1]), but should be provided
as a form instead of as a quoted symbol.

> [...] but perhaps the way you
> implemented it is common in Emacs.
>

Far from it, apparently.  I did it that way to prevent `funcall' from
choking on t/nil, which -in retrospect- was rather shortsighted...

I've used a more sensible approach in v2 [2].

> Regards,
>   Dmitry
> 
> > +  "Iterate through all messages in the current buffer with
> > +`notmuch-show-goto-message-next'.  If PREDICATE is satisfied,
> > +call FUNCTION for side effects."
> >(save-excursion
> >  (goto-char (point-min))
> > -(loop do (funcall function)
> > +(loop do (if (eval predicate)
> > +(funcall function))
> >   while (notmuch-show-goto-message-next
> >  
> >  ;; Functions relating to the visibility of messages and their
> > @@ -1336,7 +1337,7 @@ (defun notmuch-show-get-message-id ()
> >  (defun notmuch-show-get-messages-ids ()
> >"Return all message ids of messages in the current thread."
> >(let ((message-ids))
> > -(notmuch-show-mapc
> > +(notmuch-show-mapc t
> >   (lambda () (push (notmuch-show-get-message-id) message-ids)))
> >  message-ids))
> >  
> > @@ -1633,7 +1634,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
> >  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> >(interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> >(apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> > -  (notmuch-show-mapc
> > +  (notmuch-show-mapc t
> > (lambda ()
> >   (let* ((current-tags (notmuch-show-get-tags))
> > (new-tags (notmuch-update-tags current-tags tag-changes)))
> > -- 
> > 1.7.8.1
> > 


Peace

-- 
Pieter

[1] id:"1330038554-10347-6-git-send-email-pieter at praet.org"
[2] id:"1330122640-18895-5-git-send-email-pieter at praet.org"


[PATCH 1/2] Convert non-UTF-8 parts to UTF-8 before indexing them

2012-02-24 Thread Austin Clements
LGTM.  I'm assuming this interacts with the uuencoding filter in the
right order (I don't see how any other order could be correct), but
don't actually know.

Quoth Michal Sojka on Feb 24 at  8:36 am:
> This fixes a bug that didn't allow to search for non-ASCII words such
> parts. The code here was copied from show_text_part_content(), because
> the show command already does the needed conversion when showing the
> message.
> ---
>  lib/index.cc |   15 +++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/lib/index.cc b/lib/index.cc
> index d8f8b2b..e377732 100644
> --- a/lib/index.cc
> +++ b/lib/index.cc
> @@ -315,6 +315,7 @@ _index_mime_part (notmuch_message_t *message,
>  GByteArray *byte_array;
>  GMimeContentDisposition *disposition;
>  char *body;
> +const char *charset;
>  
>  if (! part) {
>   fprintf (stderr, "Warning: Not indexing empty mime part.\n");
> @@ -390,6 +391,20 @@ _index_mime_part (notmuch_message_t *message,
>  g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),
> discard_uuencode_filter);
>  
> +charset = g_mime_object_get_content_type_parameter (part, "charset");
> +if (charset) {
> + GMimeFilter *charset_filter;
> + charset_filter = g_mime_filter_charset_new (charset, "UTF-8");
> + /* This result can be NULL for things like "unknown-8bit".
> +  * Don't set a NULL filter as that makes GMime print
> +  * annoying assertion-failure messages on stderr. */
> + if (charset_filter) {
> + g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),
> +   charset_filter);
> + g_object_unref (charset_filter);
> + }
> +}
> +
>  wrapper = g_mime_part_get_content_object (GMIME_PART (part));
>  if (wrapper)
>   g_mime_data_wrapper_write_to_stream (wrapper, filter);


[PATCH 1/6] test: emacs: new tests "notmuch-show: {add, remove} multiple tags {to, from} single message"

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:35:22 +0400, Dmitry Kurochkin  wrote:
> On Fri, 24 Feb 2012 00:09:09 +0100, Pieter Praet  wrote:
> > * test/emacs:
> > 
> >   - Rename subtests "{Add,Remove} tag from notmuch-show view" to
> > "notmuch-show: {add,remove} single tag {to,from} single message"
> > to be consistent with the following tests.
> > 
> >   - New subtest "notmuch-show: add multiple tags to single message":
> > `notmuch-show-add-tag' ("+") can add multiple tags to a message.
> > 
> >   - New subtest "notmuch-show: remove multiple tags from single message":
> > `notmuch-show-remove-tag' ("-") can remove multiple tags from a message.
> > ---
> 
> Would be nice to have another patch that moves notmuch-show tests to
> emacs-show file.
>

TL;DR: It's on my todo list.

Yeah, the Emacs test series *as a whole* desperately needs some
reorganizing, not in the least because it's still severely
lacking in coverage.

Some more structure/consistency would considerably increase the
feasibility (or at least reduce the PITAness...)  of filling in
the numerous blanks and reducing duplication of effort (regarding
both hard- and wetware based cycles), as well as increasing the
likelihood that developers (not looking in any specific direction)
serve their code with a side dish of tests.

Ideally (IMHO), it would be split up into separate files by mode,
i.e. `notmuch-hello', `notmuch-search', `notmuch-show',
`notmuch-{message,mua}', and those can be further divided into
sections like navigation, tagging, visibility stuff, hooks, ...

There's probably quite a number of implicit interdependencies that
need to be taken care of though, and I (as well as others) still
have a bunch of tests waiting to be applied, so we might want to do
this gradually.


> Regards,
>   Dmitry
> 
> >  test/emacs |   16 ++--
> >  1 files changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/test/emacs b/test/emacs
> > index b74cfa9..ec1dbb0 100755
> > --- a/test/emacs
> > +++ b/test/emacs
> > @@ -112,18 +112,30 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
> >  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> >  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox unread)"
> >  
> > -test_begin_subtest "Add tag from notmuch-show view"
> > +test_begin_subtest "notmuch-show: add single tag to single message"
> >  test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> > (execute-kbd-macro \"+tag-from-show-view\")"
> >  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> >  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox tag-from-show-view unread)"
> >  
> > -test_begin_subtest "Remove tag from notmuch-show view"
> > +test_begin_subtest "notmuch-show: remove single tag from single message"
> >  test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> > (execute-kbd-macro \"-tag-from-show-view\")"
> >  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> >  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox unread)"
> >  
> > +test_begin_subtest "notmuch-show: add multiple tags to single message"
> > +test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> > +   (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
> > +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> > +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox tag1-from-show-view tag2-from-show-view unread)"
> > +
> > +test_begin_subtest "notmuch-show: remove multiple tags from single message"
> > +test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> > +   (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
> > +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> > +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox unread)"
> > +
> >  test_begin_subtest "Message with .. in Message-Id:"
> >  add_message [id]=123..456 at example '[subject]="Message with .. in 
> > Message-Id"'
> >  test_emacs '(notmuch-search "id:\"123..456 at example\"")
> > -- 
> > 1.7.8.1
> > 


Peace

-- 
Pieter


[PATCH v2 6/6] emacs: `notmuch-show-tag-all' with prefix arg only tags open messages

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el

  (notmuch-show-get-messages-ids):
If provided with optional argument PREDICATE, only return
Message-Id's of messages for which PREDICATE returns non-nil.

  (notmuch-show-tag-all):
New argument ONLY-OPEN (set to `current-prefix-arg' if running
interactively): if non-nil, only change tags of *open* messages.
Also correct original docstring: 's/thread/buffer/'.

  (notmuch-show-archive-thread):
Update wrt changes to `notmuch-show-tag-all'.

* test/emacs

  - Subtest "notmuch-show: change tags of open messages in current buffer"
is no longer broken...
---
 emacs/notmuch-show.el |   33 -
 test/emacs|1 -
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 05606fc..4bd1a7c 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1339,14 +1339,18 @@ (defun notmuch-show-get-message-id ()
   "Return the message id of the current message."
   (concat "id:\"" (notmuch-show-get-prop :id) "\""))

-(defun notmuch-show-get-messages-ids (&optional separator)
+(defun notmuch-show-get-messages-ids (&optional separator predicate)
   "Return a list of Message-Id's of all messages in the current buffer.

 If provided with optional argument SEPARATOR, return a string
-instead, consisting of all Message-Id's separated by SEPARATOR."
+instead, consisting of all Message-Id's separated by SEPARATOR.
+
+If provided with optional argument PREDICATE, only return
+Message-Id's of messages for which PREDICATE returns non-nil."
   (let ((message-ids))
 (notmuch-show-mapc
- (lambda () (push (notmuch-show-get-message-id) message-ids)))
+ (lambda () (push (notmuch-show-get-message-id) message-ids))
+ predicate)
 (if separator
(mapconcat 'identity message-ids separator)
   message-ids)))
@@ -1633,18 +1637,29 @@ (defun notmuch-show-tag (&optional initial-input)
  initial-input (notmuch-show-get-message-id
 (apply 'notmuch-show-tag-message tag-changes)))

-(defun notmuch-show-tag-all (&rest tag-changes)
-  "Change tags for all messages in the current thread.
+(defun notmuch-show-tag-all (only-open &rest tag-changes)
+  "Change tags of all messages in the current buffer.
+
+If ONLY-OPEN is non-nil, only change tags of *open* messages in
+the current buffer.

 TAG-CHANGES is a list of tag operations for `notmuch-tag'."
-  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
-  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
+  (interactive (cons current-prefix-arg
+(notmuch-read-tag-changes nil notmuch-show-thread-id)))
+  (apply 'notmuch-tag
+(notmuch-show-get-messages-ids
+ " or "
+ `(lambda ()
+,(if only-open '(notmuch-show-message-visible-p) t)))
+tag-changes)
   (notmuch-show-mapc
(lambda ()
  (let* ((current-tags (notmuch-show-get-tags))
(new-tags (notmuch-update-tags current-tags tag-changes)))
(unless (equal current-tags new-tags)
-(notmuch-show-set-tags new-tags))
+(notmuch-show-set-tags new-tags
+   `(lambda ()
+  ,(if only-open '(notmuch-show-message-visible-p) t

 (defun notmuch-show-add-tag ()
   "Same as `notmuch-show-tag' but sets initial input to '+'."
@@ -1724,7 +1739,7 @@ (defun notmuch-show-archive-thread (&optional unarchive)
 buffer."
   (interactive "P")
   (let ((op (if unarchive "+" "-")))
-(notmuch-show-tag-all (concat op "inbox"
+(notmuch-show-tag-all nil (concat op "inbox"

 (defun notmuch-show-archive-thread-then-next ()
   "Archive each message in thread, then show next thread from search."
diff --git a/test/emacs b/test/emacs
index 9088ced..e6b0503 100755
--- a/test/emacs
+++ b/test/emacs
@@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert 
tag changes
 test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL

 test_begin_subtest "notmuch-show: change tags of open messages in current 
buffer"
-test_subtest_known_broken
 query="$os_x_darwin_thread"
 filter="from:Jiang"
 add_tag="notmuch-show-tag-all"
-- 
1.7.8.1



[PATCH v2 5/6] emacs: simplify `notmuch-show-get-messages-ids{, -search}'

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el

  (notmuch-show-get-messages-ids):
If provided with optional arg SEPARATOR, return a string consisting
of all Message-Id's, separated by SEPARATOR.  Also improve original
docstring wrt default return value.

  (notmuch-show-get-messages-ids-search):
Removed, as its functionality is now in `notmuch-show-get-messages-ids'.

  (notmuch-show-tag-all):
Call `notmuch-show-get-messages-ids' with SEPARATOR arg instead of
`notmuch-show-get-messages-ids-search'.
---
 emacs/notmuch-show.el |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6adbdc0..05606fc 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1339,17 +1339,17 @@ (defun notmuch-show-get-message-id ()
   "Return the message id of the current message."
   (concat "id:\"" (notmuch-show-get-prop :id) "\""))

-(defun notmuch-show-get-messages-ids ()
-  "Return all message ids of messages in the current thread."
+(defun notmuch-show-get-messages-ids (&optional separator)
+  "Return a list of Message-Id's of all messages in the current buffer.
+
+If provided with optional argument SEPARATOR, return a string
+instead, consisting of all Message-Id's separated by SEPARATOR."
   (let ((message-ids))
 (notmuch-show-mapc
  (lambda () (push (notmuch-show-get-message-id) message-ids)))
-message-ids))
-
-(defun notmuch-show-get-messages-ids-search ()
-  "Return a search string for all message ids of messages in the
-current thread."
-  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
+(if separator
+   (mapconcat 'identity message-ids separator)
+  message-ids)))

 ;; dme: Would it make sense to use a macro for many of these?

@@ -1638,7 +1638,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)

 TAG-CHANGES is a list of tag operations for `notmuch-tag'."
   (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
-  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
+  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
   (notmuch-show-mapc
(lambda ()
  (let* ((current-tags (notmuch-show-get-tags))
-- 
1.7.8.1



[PATCH v2 4/6] emacs: add optional predicate arg to `notmuch-show-mapc'

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el (notmuch-show-mapc):

  If provided with optional argument PREDICATE, only call
  FUNCTION if calling PREDICATE returns non-nil.

  Also correct original docstring: 's/thread/buffer/'.
---
 emacs/notmuch-show.el |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index aa9ccee..6adbdc0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1272,13 +1272,19 @@ (defun notmuch-show-goto-message-previous ()
 (notmuch-show-move-to-message-top)
 t))

-(defun notmuch-show-mapc (function)
-  "Iterate through all messages in the current thread with
+(defun notmuch-show-mapc (function &optional predicate)
+  "Iterate through all messages in the current buffer with
 `notmuch-show-goto-message-next' and call FUNCTION for side
-effects."
+effects.
+
+If provided with optional argument PREDICATE, only call
+FUNCTION if calling PREDICATE returns non-nil."
   (save-excursion
 (goto-char (point-min))
-(loop do (funcall function)
+(loop do (if predicate
+(if (funcall predicate)
+(funcall function))
+  (funcall function))
  while (notmuch-show-goto-message-next

 ;; Functions relating to the visibility of messages and their
-- 
1.7.8.1



[PATCH v2 3/6] test: emacs: `notmuch-show-tag-all' with prefix arg should only tag open messages

2012-02-24 Thread Pieter Praet
* test/emacs:

  - New subtest "notmuch-show: change tags of open messages in current buffer":
When called with a prefix arg, `notmuch-show-tag-all' ("*") should only
change the tags of *open* messages.  Currently broken, fix follows later.
---
 test/emacs |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index d2dbafc..9088ced 100755
--- a/test/emacs
+++ b/test/emacs
@@ -151,6 +151,22 @@ count_changed=$(notmuch count -- "$query" AND 
tag:"$add_tag" AND NOT tag:"$del_t
 notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
 test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL

+test_begin_subtest "notmuch-show: change tags of open messages in current 
buffer"
+test_subtest_known_broken
+query="$os_x_darwin_thread"
+filter="from:Jiang"
+add_tag="notmuch-show-tag-all"
+del_tag="inbox"
+count_total=$(notmuch count -- "$query")   # = 4
+count_match=$(notmuch count -- "$query" AND "$filter") # = 2
+test_emacs "(notmuch-search \"$query AND $filter\")
+(notmuch-test-wait)
+(notmuch-search-show-thread)
+(execute-kbd-macro \"*+$add_tag -$del_tag\")"
+count_changed=$(notmuch count -- "$query" AND tag:"$add_tag" AND NOT 
tag:"$del_tag")
+notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
+test_expect_equal "$count_changed" "$count_match" # assert that CHANGED == 
MATCHING
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456 at example '[subject]="Message with .. in 
Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456 at example\"")
-- 
1.7.8.1



[PATCH v2 2/6] test: emacs: new test "notmuch-show: change tags of all messages in current buffer"

2012-02-24 Thread Pieter Praet
* test/emacs:

  New subtest "notmuch-show: change tags of all messages in current buffer":
  `notmuch-show-tag-all' ("*") changes tags of *all* messages in current buffer.
---
 test/emacs |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index ec1dbb0..d2dbafc 100755
--- a/test/emacs
+++ b/test/emacs
@@ -136,6 +136,21 @@ test_emacs "(notmuch-show \"$os_x_darwin_thread\")
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"

+test_begin_subtest "notmuch-show: change tags of all messages in current 
buffer"
+query="$os_x_darwin_thread"
+filter="from:Jiang"
+add_tag="notmuch-show-tag-all"
+del_tag="inbox"
+count_total=$(notmuch count -- "$query")   # = 4
+count_match=$(notmuch count -- "$query" AND "$filter") # = 2
+test_emacs "(notmuch-search \"$query AND $filter\")
+(notmuch-test-wait)
+(notmuch-search-show-thread)
+(execute-kbd-macro \"*+$add_tag -$del_tag\")"
+count_changed=$(notmuch count -- "$query" AND tag:"$add_tag" AND NOT 
tag:"$del_tag")
+notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
+test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456 at example '[subject]="Message with .. in 
Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456 at example\"")
-- 
1.7.8.1



[PATCH v2 1/6] test: emacs: new tests "notmuch-show: {add, remove} multiple tags {to, from} single message"

2012-02-24 Thread Pieter Praet
* test/emacs:

  - Rename subtests "{Add,Remove} tag from notmuch-show view" to
"notmuch-show: {add,remove} single tag {to,from} single message"
to be consistent with the following tests.

  - New subtest "notmuch-show: add multiple tags to single message":
`notmuch-show-add-tag' ("+") can add multiple tags to a message.

  - New subtest "notmuch-show: remove multiple tags from single message":
`notmuch-show-remove-tag' ("-") can remove multiple tags from a message.
---
 test/emacs |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/test/emacs b/test/emacs
index b74cfa9..ec1dbb0 100755
--- a/test/emacs
+++ b/test/emacs
@@ -112,18 +112,30 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"

-test_begin_subtest "Add tag from notmuch-show view"
+test_begin_subtest "notmuch-show: add single tag to single message"
 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
(execute-kbd-macro \"+tag-from-show-view\")"
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
tag-from-show-view unread)"

-test_begin_subtest "Remove tag from notmuch-show view"
+test_begin_subtest "notmuch-show: remove single tag from single message"
 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
(execute-kbd-macro \"-tag-from-show-view\")"
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"

+test_begin_subtest "notmuch-show: add multiple tags to single message"
+test_emacs "(notmuch-show \"$os_x_darwin_thread\")
+   (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
+output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
tag1-from-show-view tag2-from-show-view unread)"
+
+test_begin_subtest "notmuch-show: remove multiple tags from single message"
+test_emacs "(notmuch-show \"$os_x_darwin_thread\")
+   (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
+output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456 at example '[subject]="Message with .. in 
Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456 at example\"")
-- 
1.7.8.1



[PATCH v2 0/6] `notmuch-show-tag-all' with prefix arg only tags open messages

2012-02-24 Thread Pieter Praet
Addresses Dmitry's comments [1,2,3], save for the ones that aren't
directly related to this series [4,5] and will be dealt with later.

Also made `notmuch-show-tag-all's ONLY-OPEN arg non-optional.
Otherwise it would cause issues when running non-interactively.


Peace

-- 
Pieter

[1] id:"87fwe0jz0y.fsf at gmail.com"
[2] id:"87aa48jynx.fsf at gmail.com"
[3] id:"87obsojzga.fsf at gmail.com"
[4] id:"87ipiwjz85.fsf at gmail.com"
[5] id:"87d394jyvm.fsf at gmail.com"



[PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Jani Nikula
On Fri, 24 Feb 2012 14:33:35 +0400, Dmitry Kurochkin  wrote:
> Also can you please send new patches (and patch series) in a new
> separate thread?  If they are related to another thread, you can add a
> reference.  But having multiple patch series with multiple versions in a
> single thread is very confusing IMO.

IMHO the same thread is okay if the new versions are in-reply-to the
cover letter of the first version.

Jani.


[RFC PATCH v5 00/11] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> This is v5 of the exclude flag series. (v4 was at 
> id:"874nv9rv79.fsf at qmul.ac.uk")
> 
> This email has 4 sections, an overview of what the patch set is 
> trying to achieve, a summary of the changes from v4, some comments on 
> the status of the patches in the series and some remaining queries.
> 
> OVERVIEW
> 
> The current implementation of exclude-tags does not use excludes in
> notmuch-show.c (and thus not in notmuch-show.el). Thus when selecting 
> a thread in the search view claiming one matched message you may get 
> several matches in show all but one of which are tagged excluded.
> 
> The trivial change of adding excludes to show does not work as easily 
> as one would like. For example if you try notmuch-show 
> id: you get no results (see 
> id:"871uqvgrnm.fsf at qmul.ac.uk" for more discussion).
> 
> This set moves in a different direction. It returns all the results 
> but marks excluded messages with a new flag 
> (NOTMUCH_MESSAGE_FLAG_EXCLUDED) and lets the consumer decide what to 
> do with them. For example it could start with the message closed in 
> emacs show view, it could colour the headerline differently etc.
> 
> CHANGES:
> This has been rebased on top of Jani's notmuch-show command line 
> parsing patch.
> 
> The function notmuch_thread_get_flag_messages function added in v4
> has been removed. Unfortunately (as Austin pointed out) that patch 
> broke binary compatibility so should be deferred until we wish to 
> bump the library version.
> 
> I also fixed a minor bug and a style comment in the emacs part of 
> the patch.
> 
> STATUS:
> The first 3 patches in the series just add a --no-exclude option
> to notmuch-search.c and notmuch-count.c to "turn off" the excluding.
> (The 3 patches are one for the C code, one for the man pages and 
> one for the tests.) I think this change is desirable independently 
> of the rest of the series (and indeed Jameson had a use for it
> id:"878vk943ci.fsf at servo.finestructure.net").
> 
> QUERIES
> 
> 1) As with v4 the api notmuch_query_set_omit_excluded_messages
> remains: without it I can't see how a user can pass a 
> notmuch_messages_t object around which does not contain the 
> excluded messages. See id:"87fweusabh.fsf at qmul.ac.uk". 

This does seem like a useful simplification.  Another possibility
(which may not work in practice) would be to have a utility function
in the CLI that iterated a notmuch_messages_t to the next non-excluded
message.  This would push the knowledge of whether or not a format can
represent excluded messages into that format, but I can't see how to
do things like "count" this way.

> 2)  If we have a query which overrides the excludes such as "blah and
> tag:deleted" should the tag:deleted messages still be marked excluded?
> The current implementation does mark them excluded but my preference 
> would be not to. What do people think? At the moment 2 tests fail but 
> the correct output depends on the above so I will leave them until we
> have a decision on this.

I could go either way on this, but I think it should still be marked
excluded since it is, after all, excluded.

> There are some other queries mentioned in v4 but the two above are
> the significant ones.
> 
> Best wishes
> 
> Mark
> 
> 
> 
> Mark Walters (11):
>   cli: add --no-exclude option to count and search.
>   cli: Add --no-exclude to the man pages for search and count
>   test: add tests for new cli --no-exclude option
>   lib: Rearrange the exclude code in query.cc
>   lib: Make notmuch_query_search_messages set the exclude flag
>   lib: Add the exclude flag to notmuch_query_search_threads
>   cli: Make notmuch-show respect excludes.
>   man: update manpage for notmuch-show --no-exclude option
>   test: update tests to reflect the exclude flag
>   cli: omit excluded messages in results where appropriate.
>   emacs: show: recognize the exclude flag.
> 
>  emacs/notmuch-show.el |   19 +++-
>  lib/notmuch-private.h |8 -
>  lib/notmuch.h |   16 --
>  lib/query.cc  |   74 ++--
>  lib/thread.cc |   18 +--
>  man/man1/notmuch-count.1  |7 
>  man/man1/notmuch-search.1 |7 
>  man/man1/notmuch-show.1   |7 
>  notmuch-count.c   |   19 
>  notmuch-search.c  |   26 
>  notmuch-show.c|   31 --
>  test/count|   21 +
>  test/crypto   |9 +-
>  test/encoding |2 +-
>  test/json |6 ++--
>  test/maildir-sync |1 +
>  test/multipart|4 +-
>  test/search   |5 +++
>  test/thread-naming|   16 +-
>  19 files changed, 246 insertions(+), 50 deletions(-)


[RFC PATCH v5 09/11] test: update tests to reflect the exclude flag

2012-02-24 Thread Austin Clements
Did you mean to put this one right after the show format update,
rather than having the man update between the two?  (I would argue
that this should go in the same patch as the show format update so
that the tests never fail, but people seem to disagree about this.)

Quoth Mark Walters on Feb 15 at  9:03 am:
> notmuch show outputs the exclude flag so many tests using notmuch
> show failed. This commit adds "excluded:0" or "excluded: false" to
> the expected outputs. After this commit there should be no failing
> tests.
> ---
>  test/crypto|9 -
>  test/encoding  |2 +-
>  test/json  |6 +++---
>  test/maildir-sync  |1 +
>  test/multipart |4 ++--
>  test/thread-naming |   16 
>  6 files changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/test/crypto b/test/crypto
> index 1dbb60a..564cf9a 100755
> --- a/test/crypto
> +++ b/test/crypto
> @@ -43,6 +43,7 @@ output=$(notmuch show --format=json --verify subject:"test 
> signed message 001" \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -77,6 +78,7 @@ output=$(notmuch show --format=json --verify subject:"test 
> signed message 001" \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -113,6 +115,7 @@ output=$(notmuch show --format=json --verify 
> subject:"test signed message 001" \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -153,7 +156,7 @@ test_begin_subtest "decryption, --format=text"
>  output=$(notmuch show --format=text --decrypt subject:"test encrypted 
> message 001" \
>  | notmuch_show_sanitize_all \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
> -expected='message{ id:X depth:0 match:1 filename:X
> +expected='message{ id:X depth:0 match:1 excluded:0 filename:X
>  header{
>  Notmuch Test Suite  (2000-01-01) (encrypted 
> inbox)
>  Subject: test encrypted message 001
> @@ -187,6 +190,7 @@ output=$(notmuch show --format=json --decrypt 
> subject:"test encrypted message 00
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -242,6 +246,7 @@ output=$(notmuch show --format=json --decrypt 
> subject:"test encrypted message 00
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -277,6 +282,7 @@ output=$(notmuch show --format=json --decrypt 
> subject:"test encrypted message 00
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -332,6 +338,7 @@ output=$(notmuch show --format=json --verify 
> subject:"test signed message 001" \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> diff --git a/test/encoding b/test/encoding
> index 33259c1..a872345 100755
> --- a/test/encoding
> +++ b/test/encoding
> @@ -6,7 +6,7 @@ test_begin_subtest "Message with text of unknown charset"
>  add_message '[content-type]="text/plain; charset=unknown-8bit"' \
>   "[body]=irrelevant"
>  output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)
> -test_expect_equal "$output" "message{ id:msg-001 at notmuch-test-suite 
> depth:0 match:1 filename:/XXX/mail/msg-001
> +test_expect_equal "$output" "message{ id:msg-001 at notmuch-test-suite 
> depth:0 match:1 excluded:0 filename:/XXX/mail/msg-001
>  header{
>  Notmuch Test Suite  (2001-01-05) (inbox 
> unread)
>  Subject: Test message #1
> diff --git a/test/json b/test/json
> index 7df4380..f95fcf8 100755
> --- a/test/json
> +++ b/test/json
> @@ -5,7 +5,7 @@ test_description="--format=json output"
>  test_begin_subtest "Show message: json"
>  add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
> 12:00:00 -\"" "[body]=\"json-show-message\""
>  output=$(notmuch show --format=json "json-show-message")
> -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, 
> \"filename\": \"${gen_msg_fi

[RFC PATCH v5 08/11] man: update manpage for notmuch-show --no-exclude option

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> ---
>  man/man1/notmuch-show.1 |7 +++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1
> index b2301d8..f743a53 100644
> --- a/man/man1/notmuch-show.1
> +++ b/man/man1/notmuch-show.1
> @@ -128,6 +128,13 @@ multipart/encrypted part will be replaced by the 
> decrypted
>  content.
>  .RE
>  
> +.RS 4
> +.TP 4
> +.B \-\-no-exclude
> +
> +Do not exclude the messages matching search_exclude_tags in the config file.

search.exclude_tags

> +.RE
> +
>  A common use of
>  .B notmuch show
>  is to display a single thread of email messages. For this, use a


[RFC PATCH v5 05/11] lib: Make notmuch_query_search_messages set the exclude flag

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> Add a flag NOTMUCH_MESSAGE_FLAG_EXCLUDED which is set by
> notmuch_query_search_messages for excluded messages. Also add an
> option omit_excluded_messages to the search that we do not want the
> excludes at all.
> 
> This exclude flag will be added to notmuch_query_search threads in the
> next patch.
> ---
>  lib/notmuch-private.h |1 +
>  lib/notmuch.h |   10 -
>  lib/query.cc  |   52 +---
>  3 files changed, 58 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
> index 7bf153e..e791bb0 100644
> --- a/lib/notmuch-private.h
> +++ b/lib/notmuch-private.h
> @@ -401,6 +401,7 @@ typedef struct _notmuch_message_list {
>   */
>  struct visible _notmuch_messages {
>  notmuch_bool_t is_of_list_type;
> +notmuch_doc_id_set_t *excluded_doc_ids;
>  notmuch_message_node_t *iterator;
>  };
>  
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 7929fe7..f75afae 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -449,6 +449,13 @@ typedef enum {
>  const char *
>  notmuch_query_get_query_string (notmuch_query_t *query);
>  
> +/* Specify whether to results should omit the excluded results rather
> + * than just marking them excluded. This is useful for passing a
> + * notmuch_messages_t not containing the excluded messages to other
> + * functions. */
> +void
> +notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
> notmuch_bool_t omit);
> +
>  /* Specify the sorting desired for this query. */
>  void
>  notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
> @@ -895,7 +902,8 @@ notmuch_message_get_filenames (notmuch_message_t 
> *message);
>  
>  /* Message flags */
>  typedef enum _notmuch_message_flag {
> -NOTMUCH_MESSAGE_FLAG_MATCH
> +NOTMUCH_MESSAGE_FLAG_MATCH,
> +NOTMUCH_MESSAGE_FLAG_EXCLUDED
>  } notmuch_message_flag_t;
>  
>  /* Get a value of a flag for the email corresponding to 'message'. */
> diff --git a/lib/query.cc b/lib/query.cc
> index c25b301..90a71a1 100644
> --- a/lib/query.cc
> +++ b/lib/query.cc
> @@ -28,6 +28,7 @@ struct _notmuch_query {
>  const char *query_string;
>  notmuch_sort_t sort;
>  notmuch_string_list_t *exclude_terms;
> +notmuch_bool_t omit_excluded_messages;
>  };
>  
>  typedef struct _notmuch_mset_messages {
> @@ -57,6 +58,12 @@ struct visible _notmuch_threads {
>  notmuch_doc_id_set_t match_set;
>  };
>  
> +/* We need this in the message functions so forward declare. */
> +static notmuch_bool_t
> +_notmuch_doc_id_set_init (void *ctx,
> +   notmuch_doc_id_set_t *doc_ids,
> +   GArray *arr);
> +
>  notmuch_query_t *
>  notmuch_query_create (notmuch_database_t *notmuch,
> const char *query_string)
> @@ -79,6 +86,8 @@ notmuch_query_create (notmuch_database_t *notmuch,
>  
>  query->exclude_terms = _notmuch_string_list_create (query);
>  
> +query->omit_excluded_messages = FALSE;
> +
>  return query;
>  }
>  
> @@ -89,6 +98,12 @@ notmuch_query_get_query_string (notmuch_query_t *query)
>  }
>  
>  void
> +notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
> notmuch_bool_t omit)
> +{
> +query->omit_excluded_messages = omit;
> +}
> +
> +void
>  notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort)
>  {
>  query->sort = sort;
> @@ -173,6 +188,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
>  "mail"));
>   Xapian::Query string_query, final_query, exclude_query;
>   Xapian::MSet mset;
> + Xapian::MSetIterator iterator;
>   unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
> Xapian::QueryParser::FLAG_PHRASE |
> Xapian::QueryParser::FLAG_LOVEHATE |
> @@ -190,11 +206,35 @@ notmuch_query_search_messages (notmuch_query_t *query)
>   final_query = Xapian::Query (Xapian::Query::OP_AND,
>mail_query, string_query);
>   }
> + messages->base.excluded_doc_ids = NULL;
> +
> + if (query->exclude_terms) {
> + exclude_query = _notmuch_exclude_tags (query, final_query);
> + exclude_query = Xapian::Query (Xapian::Query::OP_AND,
> +exclude_query, final_query);
> +
> + if (query->omit_excluded_messages)
> + final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
> +  final_query, exclude_query);
> + else {
> + enquire.set_weighting_scheme (Xapian::BoolWeight());
> + enquire.set_query (exclude_query);
> +
> + mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount 
> ());
> +
> + GArray *excluded_doc_ids = g_array_new (FALSE, FALSE, sizeof 
> (unsigned int));
> +
> + for (iterator = mset.

[RFC PATCH v5 02/11] cli: Add --no-exclude to the man pages for search and count

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> ---
>  man/man1/notmuch-count.1  |7 +++
>  man/man1/notmuch-search.1 |7 +++
>  2 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1
> index 25fe329..413b405 100644
> --- a/man/man1/notmuch-count.1
> +++ b/man/man1/notmuch-count.1
> @@ -38,6 +38,13 @@ Output the number of matching messages. This is the 
> default.
>  Output the number of matching threads.
>  .RE
>  .RE
> +
> +.RS 4
> +.TP 4
> +.BR \-\-no\-exclude
> +
> +Do not exclude the messages matching search_exclude_tags in the config file.

Should be search.exclude_tags, since search_exclude_tags is just the
internal variable name.

> +.RE
>  .RE
>  .RE
>  
> diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1
> index 0bc3f40..bc54b4d 100644
> --- a/man/man1/notmuch-search.1
> +++ b/man/man1/notmuch-search.1
> @@ -112,6 +112,13 @@ result from the end.
>  Limit the number of displayed results to N.
>  .RE
>  
> +.RS 4
> +.TP 4
> +.BR \-\-no\-exclude
> +
> +Do not exclude the messages matching search_exclude_tags in the config file.

Same.

> +.RE
> +
>  .SH SEE ALSO
>  
>  \fBnotmuch\fR(1), \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1),


[RFC PATCH v5 01/11] cli: add --no-exclude option to count and search.

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> This option turns off the exclusion so all matching messages are
> returned. We do not need to add this to notmuch-show as that does not
> (yet) exclude.
> ---
>  notmuch-count.c  |   17 +++--
>  notmuch-search.c |   17 +++--
>  2 files changed, 22 insertions(+), 12 deletions(-)
> 
> diff --git a/notmuch-count.c b/notmuch-count.c
> index 63459fb..5364507 100644
> --- a/notmuch-count.c
> +++ b/notmuch-count.c
> @@ -35,8 +35,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
>  char *query_str;
>  int opt_index;
>  int output = OUTPUT_MESSAGES;
> -const char **search_exclude_tags;
> -size_t search_exclude_tags_length;
> +notmuch_bool_t no_exclude = FALSE;
>  unsigned int i;
>  
>  notmuch_opt_desc_t options[] = {
> @@ -44,6 +43,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
> (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
> { "messages", OUTPUT_MESSAGES },
> { 0, 0 } } },
> + { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
>   { 0, 0, 0, 0, 0 }
>  };
>  
> @@ -78,10 +78,15 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
>   return 1;
>  }
>  
> -search_exclude_tags = notmuch_config_get_search_exclude_tags
> - (config, &search_exclude_tags_length);
> -for (i = 0; i < search_exclude_tags_length; i++)
> - notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> +if (!no_exclude) {
> + const char **search_exclude_tags;
> + size_t search_exclude_tags_length;
> +
> + search_exclude_tags = notmuch_config_get_search_exclude_tags
> + (config, &search_exclude_tags_length);
> + for (i = 0; i < search_exclude_tags_length; i++)
> + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> +}
>  
>  switch (output) {
>  case OUTPUT_MESSAGES:
> diff --git a/notmuch-search.c b/notmuch-search.c
> index d504051..43ec90b 100644
> --- a/notmuch-search.c
> +++ b/notmuch-search.c
> @@ -423,8 +423,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
>  output_t output = OUTPUT_SUMMARY;
>  int offset = 0;
>  int limit = -1; /* unlimited */
> -const char **search_exclude_tags;
> -size_t search_exclude_tags_length;
> +notmuch_bool_t no_exclude = FALSE;
>  unsigned int i;
>  
>  enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
> @@ -446,6 +445,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
> { "files", OUTPUT_FILES },
> { "tags", OUTPUT_TAGS },
> { 0, 0 } } },
> +{ NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },

Indentation error.  Otherwise this patch LGTM.

>   { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },
>   { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },
>   { 0, 0, 0, 0, 0 }
> @@ -493,10 +493,15 @@ notmuch_search_command (void *ctx, int argc, char 
> *argv[])
>  
>  notmuch_query_set_sort (query, sort);
>  
> -search_exclude_tags = notmuch_config_get_search_exclude_tags
> - (config, &search_exclude_tags_length);
> -for (i = 0; i < search_exclude_tags_length; i++)
> - notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> +if (!no_exclude) {
> + const char **search_exclude_tags;
> + size_t search_exclude_tags_length;
> +
> + search_exclude_tags = notmuch_config_get_search_exclude_tags
> + (config, &search_exclude_tags_length);
> + for (i = 0; i < search_exclude_tags_length; i++)
> + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> +}
>  
>  switch (output) {
>  default:


Re: [PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 23:38:20 +0100, Pieter Praet  wrote:
> [...]
> Same here.  In v2 [1], '*' tags all and 'C-u *' tags only open.
> 
> One can always swap the keybindings if so inclined.
>

Did I really say that?

There's only a single keybinding, so swap it with *what* ?!?  Itself ?

This should work though:

  #+begin_src emacs-lisp
(define-key notmuch-show-mode-map "*"
  (lambda (prefix &rest tag-changes)
(interactive
 (cons
  (not current-prefix-arg)
  (notmuch-read-tag-changes nil notmuch-show-thread-id)))
(apply 'notmuch-show-tag-all prefix tag-changes)))
  #+end_src

> [...]


Peace

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


Re: [RFC PATCH v5 00/11] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> This is v5 of the exclude flag series. (v4 was at 
> id:"874nv9rv79@qmul.ac.uk")
> 
> This email has 4 sections, an overview of what the patch set is 
> trying to achieve, a summary of the changes from v4, some comments on 
> the status of the patches in the series and some remaining queries.
> 
> OVERVIEW
> 
> The current implementation of exclude-tags does not use excludes in
> notmuch-show.c (and thus not in notmuch-show.el). Thus when selecting 
> a thread in the search view claiming one matched message you may get 
> several matches in show all but one of which are tagged excluded.
> 
> The trivial change of adding excludes to show does not work as easily 
> as one would like. For example if you try notmuch-show 
> id: you get no results (see 
> id:"871uqvgrnm@qmul.ac.uk" for more discussion).
> 
> This set moves in a different direction. It returns all the results 
> but marks excluded messages with a new flag 
> (NOTMUCH_MESSAGE_FLAG_EXCLUDED) and lets the consumer decide what to 
> do with them. For example it could start with the message closed in 
> emacs show view, it could colour the headerline differently etc.
> 
> CHANGES:
> This has been rebased on top of Jani's notmuch-show command line 
> parsing patch.
> 
> The function notmuch_thread_get_flag_messages function added in v4
> has been removed. Unfortunately (as Austin pointed out) that patch 
> broke binary compatibility so should be deferred until we wish to 
> bump the library version.
> 
> I also fixed a minor bug and a style comment in the emacs part of 
> the patch.
> 
> STATUS:
> The first 3 patches in the series just add a --no-exclude option
> to notmuch-search.c and notmuch-count.c to "turn off" the excluding.
> (The 3 patches are one for the C code, one for the man pages and 
> one for the tests.) I think this change is desirable independently 
> of the rest of the series (and indeed Jameson had a use for it
> id:"878vk943ci@servo.finestructure.net").
> 
> QUERIES
> 
> 1) As with v4 the api notmuch_query_set_omit_excluded_messages
> remains: without it I can't see how a user can pass a 
> notmuch_messages_t object around which does not contain the 
> excluded messages. See id:"87fweusabh@qmul.ac.uk". 

This does seem like a useful simplification.  Another possibility
(which may not work in practice) would be to have a utility function
in the CLI that iterated a notmuch_messages_t to the next non-excluded
message.  This would push the knowledge of whether or not a format can
represent excluded messages into that format, but I can't see how to
do things like "count" this way.

> 2)  If we have a query which overrides the excludes such as "blah and
> tag:deleted" should the tag:deleted messages still be marked excluded?
> The current implementation does mark them excluded but my preference 
> would be not to. What do people think? At the moment 2 tests fail but 
> the correct output depends on the above so I will leave them until we
> have a decision on this.

I could go either way on this, but I think it should still be marked
excluded since it is, after all, excluded.

> There are some other queries mentioned in v4 but the two above are
> the significant ones.
> 
> Best wishes
> 
> Mark
> 
> 
> 
> Mark Walters (11):
>   cli: add --no-exclude option to count and search.
>   cli: Add --no-exclude to the man pages for search and count
>   test: add tests for new cli --no-exclude option
>   lib: Rearrange the exclude code in query.cc
>   lib: Make notmuch_query_search_messages set the exclude flag
>   lib: Add the exclude flag to notmuch_query_search_threads
>   cli: Make notmuch-show respect excludes.
>   man: update manpage for notmuch-show --no-exclude option
>   test: update tests to reflect the exclude flag
>   cli: omit excluded messages in results where appropriate.
>   emacs: show: recognize the exclude flag.
> 
>  emacs/notmuch-show.el |   19 +++-
>  lib/notmuch-private.h |8 -
>  lib/notmuch.h |   16 --
>  lib/query.cc  |   74 ++--
>  lib/thread.cc |   18 +--
>  man/man1/notmuch-count.1  |7 
>  man/man1/notmuch-search.1 |7 
>  man/man1/notmuch-show.1   |7 
>  notmuch-count.c   |   19 
>  notmuch-search.c  |   26 
>  notmuch-show.c|   31 --
>  test/count|   21 +
>  test/crypto   |9 +-
>  test/encoding |2 +-
>  test/json |6 ++--
>  test/maildir-sync |1 +
>  test/multipart|4 +-
>  test/search   |5 +++
>  test/thread-naming|   16 +-
>  19 files changed, 246 insertions(+), 50 deletions(-)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/not

Re: [RFC PATCH v5 09/11] test: update tests to reflect the exclude flag

2012-02-24 Thread Austin Clements
Did you mean to put this one right after the show format update,
rather than having the man update between the two?  (I would argue
that this should go in the same patch as the show format update so
that the tests never fail, but people seem to disagree about this.)

Quoth Mark Walters on Feb 15 at  9:03 am:
> notmuch show outputs the exclude flag so many tests using notmuch
> show failed. This commit adds "excluded:0" or "excluded: false" to
> the expected outputs. After this commit there should be no failing
> tests.
> ---
>  test/crypto|9 -
>  test/encoding  |2 +-
>  test/json  |6 +++---
>  test/maildir-sync  |1 +
>  test/multipart |4 ++--
>  test/thread-naming |   16 
>  6 files changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/test/crypto b/test/crypto
> index 1dbb60a..564cf9a 100755
> --- a/test/crypto
> +++ b/test/crypto
> @@ -43,6 +43,7 @@ output=$(notmuch show --format=json --verify subject:"test 
> signed message 001" \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -77,6 +78,7 @@ output=$(notmuch show --format=json --verify subject:"test 
> signed message 001" \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -113,6 +115,7 @@ output=$(notmuch show --format=json --verify 
> subject:"test signed message 001" \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -153,7 +156,7 @@ test_begin_subtest "decryption, --format=text"
>  output=$(notmuch show --format=text --decrypt subject:"test encrypted 
> message 001" \
>  | notmuch_show_sanitize_all \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
> -expected='message{ id:X depth:0 match:1 filename:X
> +expected='message{ id:X depth:0 match:1 excluded:0 filename:X
>  header{
>  Notmuch Test Suite  (2000-01-01) (encrypted 
> inbox)
>  Subject: test encrypted message 001
> @@ -187,6 +190,7 @@ output=$(notmuch show --format=json --decrypt 
> subject:"test encrypted message 00
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -242,6 +246,7 @@ output=$(notmuch show --format=json --decrypt 
> subject:"test encrypted message 00
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -277,6 +282,7 @@ output=$(notmuch show --format=json --decrypt 
> subject:"test encrypted message 00
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> @@ -332,6 +338,7 @@ output=$(notmuch show --format=json --verify 
> subject:"test signed message 001" \
>  | sed -e 's|"created": [1234567890]*|"created": 946728000|')
>  expected='[[[{"id": "X",
>   "match": true,
> + "excluded": false,
>   "filename": "Y",
>   "timestamp": 946728000,
>   "date_relative": "2000-01-01",
> diff --git a/test/encoding b/test/encoding
> index 33259c1..a872345 100755
> --- a/test/encoding
> +++ b/test/encoding
> @@ -6,7 +6,7 @@ test_begin_subtest "Message with text of unknown charset"
>  add_message '[content-type]="text/plain; charset=unknown-8bit"' \
>   "[body]=irrelevant"
>  output=$(notmuch show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)
> -test_expect_equal "$output" "message{ id:msg-001@notmuch-test-suite depth:0 
> match:1 filename:/XXX/mail/msg-001
> +test_expect_equal "$output" "message{ id:msg-001@notmuch-test-suite depth:0 
> match:1 excluded:0 filename:/XXX/mail/msg-001
>  header{
>  Notmuch Test Suite  (2001-01-05) (inbox unread)
>  Subject: Test message #1
> diff --git a/test/json b/test/json
> index 7df4380..f95fcf8 100755
> --- a/test/json
> +++ b/test/json
> @@ -5,7 +5,7 @@ test_description="--format=json output"
>  test_begin_subtest "Show message: json"
>  add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 
> 12:00:00 -\"" "[body]=\"json-show-message\""
>  output=$(notmuch show --format=json "json-show-message")
> -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, 
> \"filename\": \"${gen_msg_filename}\"

Re: [RFC PATCH v5 08/11] man: update manpage for notmuch-show --no-exclude option

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> ---
>  man/man1/notmuch-show.1 |7 +++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/man/man1/notmuch-show.1 b/man/man1/notmuch-show.1
> index b2301d8..f743a53 100644
> --- a/man/man1/notmuch-show.1
> +++ b/man/man1/notmuch-show.1
> @@ -128,6 +128,13 @@ multipart/encrypted part will be replaced by the 
> decrypted
>  content.
>  .RE
>  
> +.RS 4
> +.TP 4
> +.B \-\-no-exclude
> +
> +Do not exclude the messages matching search_exclude_tags in the config file.

search.exclude_tags

> +.RE
> +
>  A common use of
>  .B notmuch show
>  is to display a single thread of email messages. For this, use a
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [RFC PATCH v5 05/11] lib: Make notmuch_query_search_messages set the exclude flag

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> Add a flag NOTMUCH_MESSAGE_FLAG_EXCLUDED which is set by
> notmuch_query_search_messages for excluded messages. Also add an
> option omit_excluded_messages to the search that we do not want the
> excludes at all.
> 
> This exclude flag will be added to notmuch_query_search threads in the
> next patch.
> ---
>  lib/notmuch-private.h |1 +
>  lib/notmuch.h |   10 -
>  lib/query.cc  |   52 +---
>  3 files changed, 58 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
> index 7bf153e..e791bb0 100644
> --- a/lib/notmuch-private.h
> +++ b/lib/notmuch-private.h
> @@ -401,6 +401,7 @@ typedef struct _notmuch_message_list {
>   */
>  struct visible _notmuch_messages {
>  notmuch_bool_t is_of_list_type;
> +notmuch_doc_id_set_t *excluded_doc_ids;
>  notmuch_message_node_t *iterator;
>  };
>  
> diff --git a/lib/notmuch.h b/lib/notmuch.h
> index 7929fe7..f75afae 100644
> --- a/lib/notmuch.h
> +++ b/lib/notmuch.h
> @@ -449,6 +449,13 @@ typedef enum {
>  const char *
>  notmuch_query_get_query_string (notmuch_query_t *query);
>  
> +/* Specify whether to results should omit the excluded results rather
> + * than just marking them excluded. This is useful for passing a
> + * notmuch_messages_t not containing the excluded messages to other
> + * functions. */
> +void
> +notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
> notmuch_bool_t omit);
> +
>  /* Specify the sorting desired for this query. */
>  void
>  notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
> @@ -895,7 +902,8 @@ notmuch_message_get_filenames (notmuch_message_t 
> *message);
>  
>  /* Message flags */
>  typedef enum _notmuch_message_flag {
> -NOTMUCH_MESSAGE_FLAG_MATCH
> +NOTMUCH_MESSAGE_FLAG_MATCH,
> +NOTMUCH_MESSAGE_FLAG_EXCLUDED
>  } notmuch_message_flag_t;
>  
>  /* Get a value of a flag for the email corresponding to 'message'. */
> diff --git a/lib/query.cc b/lib/query.cc
> index c25b301..90a71a1 100644
> --- a/lib/query.cc
> +++ b/lib/query.cc
> @@ -28,6 +28,7 @@ struct _notmuch_query {
>  const char *query_string;
>  notmuch_sort_t sort;
>  notmuch_string_list_t *exclude_terms;
> +notmuch_bool_t omit_excluded_messages;
>  };
>  
>  typedef struct _notmuch_mset_messages {
> @@ -57,6 +58,12 @@ struct visible _notmuch_threads {
>  notmuch_doc_id_set_t match_set;
>  };
>  
> +/* We need this in the message functions so forward declare. */
> +static notmuch_bool_t
> +_notmuch_doc_id_set_init (void *ctx,
> +   notmuch_doc_id_set_t *doc_ids,
> +   GArray *arr);
> +
>  notmuch_query_t *
>  notmuch_query_create (notmuch_database_t *notmuch,
> const char *query_string)
> @@ -79,6 +86,8 @@ notmuch_query_create (notmuch_database_t *notmuch,
>  
>  query->exclude_terms = _notmuch_string_list_create (query);
>  
> +query->omit_excluded_messages = FALSE;
> +
>  return query;
>  }
>  
> @@ -89,6 +98,12 @@ notmuch_query_get_query_string (notmuch_query_t *query)
>  }
>  
>  void
> +notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
> notmuch_bool_t omit)
> +{
> +query->omit_excluded_messages = omit;
> +}
> +
> +void
>  notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort)
>  {
>  query->sort = sort;
> @@ -173,6 +188,7 @@ notmuch_query_search_messages (notmuch_query_t *query)
>  "mail"));
>   Xapian::Query string_query, final_query, exclude_query;
>   Xapian::MSet mset;
> + Xapian::MSetIterator iterator;
>   unsigned int flags = (Xapian::QueryParser::FLAG_BOOLEAN |
> Xapian::QueryParser::FLAG_PHRASE |
> Xapian::QueryParser::FLAG_LOVEHATE |
> @@ -190,11 +206,35 @@ notmuch_query_search_messages (notmuch_query_t *query)
>   final_query = Xapian::Query (Xapian::Query::OP_AND,
>mail_query, string_query);
>   }
> + messages->base.excluded_doc_ids = NULL;
> +
> + if (query->exclude_terms) {
> + exclude_query = _notmuch_exclude_tags (query, final_query);
> + exclude_query = Xapian::Query (Xapian::Query::OP_AND,
> +exclude_query, final_query);
> +
> + if (query->omit_excluded_messages)
> + final_query = Xapian::Query (Xapian::Query::OP_AND_NOT,
> +  final_query, exclude_query);
> + else {
> + enquire.set_weighting_scheme (Xapian::BoolWeight());
> + enquire.set_query (exclude_query);
> +
> + mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount 
> ());
> +
> + GArray *excluded_doc_ids = g_array_new (FALSE, FALSE, sizeof 
> (unsigned int));
> +
> + for (iterator = mset.

Re: [RFC PATCH 1/3] emacs: selection-menu.el

2012-02-24 Thread Mark Walters
On Thu, 23 Feb 2012 17:10:15 +0200, Tomi Ollila  wrote:
> RFC/Idea for "improving" some selections made (in notmuch or elsewhere)
> In the hope that this will be useful, and to get some improvement advice.
> 
> I've found it somewhat difficult to use completing-read (i also tried ido-)
> to complete email addresses for mail recipients (not only due to the
> large selection of choises provided by nottoomuch-addresses.sh ;)
> and have tried to find alternatives.
> 
> The buffer selection systems (electric-buffer-list, bs-show, etc) have been
> pretty useful but I haven't found anything general.
> 
> After some 3 iterations I've come up with something like those but for
> arbitraty strings and so-far named that tool 'selection-menu'
> 
> This works by popping up buffer with all the choices shown in separate
> lines. arrow keys (and c-p/c-n) can be used to choose string and
> RET/SPC to select that. Any other key will abort the selection (ESC
> mentioned spesifically as it never "unreads" any events).
> 
> If requested user not choosing anything but pressing some key that
> key is "unread" so that the parent buffer will get it. I did that
> as in first tests I wanted to continue writing If I did not choose
> anything... More tests will show If really didn't want to loose that
> event).

Hi 

I have played with this and I like the feel of it: it is much more
informative than completing-read and much less cluttered than
ido-completing-read. 

I have some queries though:

In some uses the user might want to choose something that is not offered
(not relevant for this particular use, but maybe relevant for other
notmuch uses like selecting a from address). Is this a design choice?

I think I would like to be able to type in the buffer it shows,
e.g. page down to page through lots of addresses, maybe ctrl-s for
searching. Another possibility would be for the selection to narrow as
extra characters are typed. Though in fact maybe your choice of leaving
the character is exactly right: then the caller can take the extra
character and call selection-menu again. (I had something which almost
worked and it seemed quite nice).

Finally, does this solution mean there is no "history" available?

Best wishes

Mark

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


Re: [RFC PATCH v5 02/11] cli: Add --no-exclude to the man pages for search and count

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> ---
>  man/man1/notmuch-count.1  |7 +++
>  man/man1/notmuch-search.1 |7 +++
>  2 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/man/man1/notmuch-count.1 b/man/man1/notmuch-count.1
> index 25fe329..413b405 100644
> --- a/man/man1/notmuch-count.1
> +++ b/man/man1/notmuch-count.1
> @@ -38,6 +38,13 @@ Output the number of matching messages. This is the 
> default.
>  Output the number of matching threads.
>  .RE
>  .RE
> +
> +.RS 4
> +.TP 4
> +.BR \-\-no\-exclude
> +
> +Do not exclude the messages matching search_exclude_tags in the config file.

Should be search.exclude_tags, since search_exclude_tags is just the
internal variable name.

> +.RE
>  .RE
>  .RE
>  
> diff --git a/man/man1/notmuch-search.1 b/man/man1/notmuch-search.1
> index 0bc3f40..bc54b4d 100644
> --- a/man/man1/notmuch-search.1
> +++ b/man/man1/notmuch-search.1
> @@ -112,6 +112,13 @@ result from the end.
>  Limit the number of displayed results to N.
>  .RE
>  
> +.RS 4
> +.TP 4
> +.BR \-\-no\-exclude
> +
> +Do not exclude the messages matching search_exclude_tags in the config file.

Same.

> +.RE
> +
>  .SH SEE ALSO
>  
>  \fBnotmuch\fR(1), \fBnotmuch-config\fR(1), \fBnotmuch-count\fR(1),
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [RFC PATCH v5 01/11] cli: add --no-exclude option to count and search.

2012-02-24 Thread Austin Clements
Quoth Mark Walters on Feb 15 at  9:03 am:
> This option turns off the exclusion so all matching messages are
> returned. We do not need to add this to notmuch-show as that does not
> (yet) exclude.
> ---
>  notmuch-count.c  |   17 +++--
>  notmuch-search.c |   17 +++--
>  2 files changed, 22 insertions(+), 12 deletions(-)
> 
> diff --git a/notmuch-count.c b/notmuch-count.c
> index 63459fb..5364507 100644
> --- a/notmuch-count.c
> +++ b/notmuch-count.c
> @@ -35,8 +35,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
>  char *query_str;
>  int opt_index;
>  int output = OUTPUT_MESSAGES;
> -const char **search_exclude_tags;
> -size_t search_exclude_tags_length;
> +notmuch_bool_t no_exclude = FALSE;
>  unsigned int i;
>  
>  notmuch_opt_desc_t options[] = {
> @@ -44,6 +43,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
> (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
> { "messages", OUTPUT_MESSAGES },
> { 0, 0 } } },
> + { NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },
>   { 0, 0, 0, 0, 0 }
>  };
>  
> @@ -78,10 +78,15 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
>   return 1;
>  }
>  
> -search_exclude_tags = notmuch_config_get_search_exclude_tags
> - (config, &search_exclude_tags_length);
> -for (i = 0; i < search_exclude_tags_length; i++)
> - notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> +if (!no_exclude) {
> + const char **search_exclude_tags;
> + size_t search_exclude_tags_length;
> +
> + search_exclude_tags = notmuch_config_get_search_exclude_tags
> + (config, &search_exclude_tags_length);
> + for (i = 0; i < search_exclude_tags_length; i++)
> + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> +}
>  
>  switch (output) {
>  case OUTPUT_MESSAGES:
> diff --git a/notmuch-search.c b/notmuch-search.c
> index d504051..43ec90b 100644
> --- a/notmuch-search.c
> +++ b/notmuch-search.c
> @@ -423,8 +423,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
>  output_t output = OUTPUT_SUMMARY;
>  int offset = 0;
>  int limit = -1; /* unlimited */
> -const char **search_exclude_tags;
> -size_t search_exclude_tags_length;
> +notmuch_bool_t no_exclude = FALSE;
>  unsigned int i;
>  
>  enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
> @@ -446,6 +445,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[])
> { "files", OUTPUT_FILES },
> { "tags", OUTPUT_TAGS },
> { 0, 0 } } },
> +{ NOTMUCH_OPT_BOOLEAN, &no_exclude, "no-exclude", 'd', 0 },

Indentation error.  Otherwise this patch LGTM.

>   { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },
>   { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },
>   { 0, 0, 0, 0, 0 }
> @@ -493,10 +493,15 @@ notmuch_search_command (void *ctx, int argc, char 
> *argv[])
>  
>  notmuch_query_set_sort (query, sort);
>  
> -search_exclude_tags = notmuch_config_get_search_exclude_tags
> - (config, &search_exclude_tags_length);
> -for (i = 0; i < search_exclude_tags_length; i++)
> - notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> +if (!no_exclude) {
> + const char **search_exclude_tags;
> + size_t search_exclude_tags_length;
> +
> + search_exclude_tags = notmuch_config_get_search_exclude_tags
> + (config, &search_exclude_tags_length);
> + for (i = 0; i < search_exclude_tags_length; i++)
> + notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> +}
>  
>  switch (output) {
>  default:
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags open messages

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:09:14 +0100, Pieter Praet  wrote:
> * emacs/notmuch-show.el
> 
>   (notmuch-show-get-messages-ids):
> New optional argument ONLY-OPEN.  If non-nil, only return
> Message-Id's for messages which are currently visible.
> 
>   (notmuch-show-tag-all):
> New optional argument IGNORE-VISIBILITY, of which the inverse is
> passed as ONLY-OPEN argument to `notmuch-show-get-messages-ids':
> If called with a prefix arg, affect *all* messages in the current
> buffer.  Otherwise, only change tags of visible messages.
> 
>   (notmuch-show-archive-thread):
> Update wrt changes to `notmuch-show-tag-all'.
> 
> * test/emacs
> 
>   - Subtest "notmuch-show: change tags of open messages in current buffer"
> is no longer broken.
> ---
>  emacs/notmuch-show.el |   28 
>  test/emacs|1 -
>  2 files changed, 20 insertions(+), 9 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 4b37c77..4499fcd 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1334,13 +1334,17 @@ (defun notmuch-show-get-message-id ()
>"Return the message id of the current message."
>(concat "id:\"" (notmuch-show-get-prop :id) "\""))
>  
> -(defun notmuch-show-get-messages-ids (&optional separator)
> +(defun notmuch-show-get-messages-ids (&optional only-open separator)
>"Return a list of Message-Id's of all messages in the current buffer.
>  
> +If optional argument ONLY-OPEN is non-nil, only return
> +Message-Id's for messages which are currently visible.
> +
>  If provided with optional argument SEPARATOR, return a string
>  instead, consisting of all Message-Id's separated by SEPARATOR."
>(let ((message-ids))
> -(notmuch-show-mapc t
> +(notmuch-show-mapc
> + `(if only-open (notmuch-show-message-visible-p) t)

How about changing ONLY-OPEN to a general optional PREDICATE argument
and pass it as is to `notmuch-show-mapc'?  Please make it the last
argument.

Regards,
  Dmitry

>   (lambda () (push (notmuch-show-get-message-id) message-ids)))
>  (if separator
>   (mapconcat 'identity message-ids separator)
> @@ -1628,13 +1632,21 @@ (defun notmuch-show-tag (&optional initial-input)
> initial-input (notmuch-show-get-message-id
>  (apply 'notmuch-show-tag-message tag-changes)))
>  
> -(defun notmuch-show-tag-all (&rest tag-changes)
> -  "Change tags for all messages in the current thread.
> +(defun notmuch-show-tag-all (&optional ignore-visibility &rest tag-changes)
> +  "Change tags of all open messages in the current buffer.
> +
> +If optional arg IGNORE-VISIBILITY is non-nil, change tags of
> +*all* messages in the current buffer, independent of their
> +visibility.
>  
>  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> -  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> -  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
> -  (notmuch-show-mapc t
> +  (interactive (cons current-prefix-arg
> +  (notmuch-read-tag-changes nil notmuch-show-thread-id)))
> +  (apply 'notmuch-tag
> +  (notmuch-show-get-messages-ids (not ignore-visibility) " or ")
> +  tag-changes)
> +  (notmuch-show-mapc
> +   `(if ignore-visibility t (notmuch-show-message-visible-p))
> (lambda ()
>   (let* ((current-tags (notmuch-show-get-tags))
>   (new-tags (notmuch-update-tags current-tags tag-changes)))
> @@ -1719,7 +1731,7 @@ (defun notmuch-show-archive-thread (&optional unarchive)
>  buffer."
>(interactive "P")
>(let ((op (if unarchive "+" "-")))
> -(notmuch-show-tag-all (concat op "inbox"
> +(notmuch-show-tag-all t (concat op "inbox"
>  
>  (defun notmuch-show-archive-thread-then-next ()
>"Archive each message in thread, then show next thread from search."
> diff --git a/test/emacs b/test/emacs
> index 644ef59..c286ff5 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert 
> tag changes
>  test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
> TOTAL
>  
>  test_begin_subtest "notmuch-show: change tags of open messages in current 
> buffer"
> -test_subtest_known_broken
>  query="$os_x_darwin_thread"
>  filter="from:Jiang"
>  add_tag="notmuch-show-tag-all"
> -- 
> 1.7.8.1
> 


Re: [PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:33:35 +0400, Dmitry Kurochkin 
 wrote:
> On Fri, 24 Feb 2012 14:30:29 +0400, Dmitry Kurochkin 
>  wrote:
> > On Fri, 24 Feb 2012 00:07:27 +0100, Pieter Praet  wrote:
> > > On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  
> > > wrote:
> > > > On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin 
> > > >  wrote:
> > > > > Changes:
> > > > > 
> > > > > v4:
> > > > > 
> > > > > * rebased on master, no conflicts so no need for another review
> > > > > 
> > > > 
> > > > I pushed this series.  
> > > > 
> > > > Maybe this was discussed already, but I think ideally * would apply only
> > > > to open messages. So consider that a feature request if someone is
> > > > looking for a project.
> > > >
> > > 
> > > How about if '*' applies to all messages (as it currently does),
> > > but 'C-u *' only to open messages?  That would make more sense IMHO.
> > > 
> > > But, conforming to your original request, I've implemented the inverse.
> > > 
> > 
> > I personally do like '*' as is and do not want to change it's behavior.
> > Though I am not against adding a prefix argument for it.
> > 
> 
> Also can you please send new patches (and patch series) in a new
> separate thread?  If they are related to another thread, you can add a
> reference.  But having multiple patch series with multiple versions in a
> single thread is very confusing IMO.
>

Since I've already soiled this thread with my initial series,
I've sent v2 [1] in reply to David's request as well, but will
make sure to start a fresh thread from now on.


> Regards,
>   Dmitry
> 
> > Regards,
> >   Dmitry
> > 
> > > Patches follow.
> > > 
> > > 
> > > > d
> > > > ___
> > > > notmuch mailing list
> > > > notmuch@notmuchmail.org
> > > > http://notmuchmail.org/mailman/listinfo/notmuch
> > > 
> > > 
> > > Peace
> > > 
> > > -- 
> > > Pieter

Thanks for all your comments!


Peace

-- 
Pieter

[1] id:"1330122640-18895-1-git-send-email-pie...@praet.org"
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 5/6] emacs: simplify `notmuch-show-get-messages-ids{, -search}'

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:09:13 +0100, Pieter Praet  wrote:
> * emacs/notmuch-show.el
> 
>   (notmuch-show-get-messages-ids):
> If provided with optional arg SEPARATOR, return a string consisting
> of all Message-Id's, separated by SEPARATOR.  Also improve original
> docstring wrt default return value.
> 
>   (notmuch-show-get-messages-ids-search):
> Removed, as its functionality is now in `notmuch-show-get-messages-ids'.
> 
>   (notmuch-show-tag-all):
> Call `notmuch-show-get-messages-ids' with SEPARATOR arg instead of
> `notmuch-show-get-messages-ids-search'.
> ---

There is another similar case in notmuch.el:
`notmuch-show-get-messages-ids' and
`notmuch-show-get-messages-ids-search'.  There may be more.

Please change them as well.

Regards,
  Dmitry

>  emacs/notmuch-show.el |   18 +-
>  1 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5fc0e43..4b37c77 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1334,17 +1334,17 @@ (defun notmuch-show-get-message-id ()
>"Return the message id of the current message."
>(concat "id:\"" (notmuch-show-get-prop :id) "\""))
>  
> -(defun notmuch-show-get-messages-ids ()
> -  "Return all message ids of messages in the current thread."
> +(defun notmuch-show-get-messages-ids (&optional separator)
> +  "Return a list of Message-Id's of all messages in the current buffer.
> +
> +If provided with optional argument SEPARATOR, return a string
> +instead, consisting of all Message-Id's separated by SEPARATOR."
>(let ((message-ids))
>  (notmuch-show-mapc t
>   (lambda () (push (notmuch-show-get-message-id) message-ids)))
> -message-ids))
> -
> -(defun notmuch-show-get-messages-ids-search ()
> -  "Return a search string for all message ids of messages in the
> -current thread."
> -  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
> +(if separator
> + (mapconcat 'identity message-ids separator)
> +  message-ids)))
>  
>  ;; dme: Would it make sense to use a macro for many of these?
>  
> @@ -1633,7 +1633,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
>  
>  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
>(interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> -  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> +  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
>(notmuch-show-mapc t
> (lambda ()
>   (let* ((current-tags (notmuch-show-get-tags))
> -- 
> 1.7.8.1
> 


Re: [PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:30:29 +0400, Dmitry Kurochkin 
 wrote:
> On Fri, 24 Feb 2012 00:07:27 +0100, Pieter Praet  wrote:
> > On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  wrote:
> > > On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin 
> > >  wrote:
> > > > Changes:
> > > > 
> > > > v4:
> > > > 
> > > > * rebased on master, no conflicts so no need for another review
> > > > 
> > > 
> > > I pushed this series.  
> > > 
> > > Maybe this was discussed already, but I think ideally * would apply only
> > > to open messages. So consider that a feature request if someone is
> > > looking for a project.
> > >
> > 
> > How about if '*' applies to all messages (as it currently does),
> > but 'C-u *' only to open messages?  That would make more sense IMHO.
> > 
> > But, conforming to your original request, I've implemented the inverse.
> > 
> 
> I personally do like '*' as is and do not want to change it's behavior.
> Though I am not against adding a prefix argument for it.
>

Same here.  In v2 [1], '*' tags all and 'C-u *' tags only open.

One can always swap the keybindings if so inclined.


> Regards,
>   Dmitry
> 
> > Patches follow.
> > 
> > 
> > > d
> > > ___
> > > notmuch mailing list
> > > notmuch@notmuchmail.org
> > > http://notmuchmail.org/mailman/listinfo/notmuch
> > 
> > 
> > Peace
> > 
> > -- 
> > Pieter
> ___
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter

[1] id:"1330122640-18895-1-git-send-email-pie...@praet.org"
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:09:12 +0100, Pieter Praet  wrote:
> * emacs/notmuch-show.el
> 
>   (notmuch-show-mapc):
> Only call FUNCTION if new argument PREDICATE is satisfied.
> Also correct original docstring: 's/thread/buffer/'.
> 
>   (notmuch-show-get-messages-ids):
> Update wrt changes to `notmuch-show-mapc'.
> 
>   (notmuch-show-tag-all):
> Update wrt changes to `notmuch-show-mapc'.
> ---
>  emacs/notmuch-show.el |   15 ---
>  1 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index aa9ccee..5fc0e43 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1272,13 +1272,14 @@ (defun notmuch-show-goto-message-previous ()
>  (notmuch-show-move-to-message-top)
>  t))
>  
> -(defun notmuch-show-mapc (function)
> -  "Iterate through all messages in the current thread with
> -`notmuch-show-goto-message-next' and call FUNCTION for side
> -effects."
> +(defun notmuch-show-mapc (predicate function)

Please make PREDICATE optional to avoid giving t when it is not needed.

I would expect PREDICATE to be a function, but perhaps the way you
implemented it is common in Emacs.

Regards,
  Dmitry

> +  "Iterate through all messages in the current buffer with
> +`notmuch-show-goto-message-next'.  If PREDICATE is satisfied,
> +call FUNCTION for side effects."
>(save-excursion
>  (goto-char (point-min))
> -(loop do (funcall function)
> +(loop do (if (eval predicate)
> +  (funcall function))
> while (notmuch-show-goto-message-next
>  
>  ;; Functions relating to the visibility of messages and their
> @@ -1336,7 +1337,7 @@ (defun notmuch-show-get-message-id ()
>  (defun notmuch-show-get-messages-ids ()
>"Return all message ids of messages in the current thread."
>(let ((message-ids))
> -(notmuch-show-mapc
> +(notmuch-show-mapc t
>   (lambda () (push (notmuch-show-get-message-id) message-ids)))
>  message-ids))
>  
> @@ -1633,7 +1634,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
>  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
>(interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
>(apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> -  (notmuch-show-mapc
> +  (notmuch-show-mapc t
> (lambda ()
>   (let* ((current-tags (notmuch-show-get-tags))
>   (new-tags (notmuch-update-tags current-tags tag-changes)))
> -- 
> 1.7.8.1
> 


Re: [PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags open messages

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:47:30 +0400, Dmitry Kurochkin 
 wrote:
> On Fri, 24 Feb 2012 00:09:14 +0100, Pieter Praet  wrote:
> > * emacs/notmuch-show.el
> > 
> >   (notmuch-show-get-messages-ids):
> > New optional argument ONLY-OPEN.  If non-nil, only return
> > Message-Id's for messages which are currently visible.
> > 
> >   (notmuch-show-tag-all):
> > New optional argument IGNORE-VISIBILITY, of which the inverse is
> > passed as ONLY-OPEN argument to `notmuch-show-get-messages-ids':
> > If called with a prefix arg, affect *all* messages in the current
> > buffer.  Otherwise, only change tags of visible messages.
> > 
> >   (notmuch-show-archive-thread):
> > Update wrt changes to `notmuch-show-tag-all'.
> > 
> > * test/emacs
> > 
> >   - Subtest "notmuch-show: change tags of open messages in current buffer"
> > is no longer broken.
> > ---
> >  emacs/notmuch-show.el |   28 
> >  test/emacs|1 -
> >  2 files changed, 20 insertions(+), 9 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 4b37c77..4499fcd 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1334,13 +1334,17 @@ (defun notmuch-show-get-message-id ()
> >"Return the message id of the current message."
> >(concat "id:\"" (notmuch-show-get-prop :id) "\""))
> >  
> > -(defun notmuch-show-get-messages-ids (&optional separator)
> > +(defun notmuch-show-get-messages-ids (&optional only-open separator)
> >"Return a list of Message-Id's of all messages in the current buffer.
> >  
> > +If optional argument ONLY-OPEN is non-nil, only return
> > +Message-Id's for messages which are currently visible.
> > +
> >  If provided with optional argument SEPARATOR, return a string
> >  instead, consisting of all Message-Id's separated by SEPARATOR."
> >(let ((message-ids))
> > -(notmuch-show-mapc t
> > +(notmuch-show-mapc
> > + `(if only-open (notmuch-show-message-visible-p) t)
> 
> How about changing ONLY-OPEN to a general optional PREDICATE argument
> and pass it as is to `notmuch-show-mapc'?  Please make it the last
> argument.
>

Done.


> Regards,
>   Dmitry
> 
> >   (lambda () (push (notmuch-show-get-message-id) message-ids)))
> >  (if separator
> > (mapconcat 'identity message-ids separator)
> > @@ -1628,13 +1632,21 @@ (defun notmuch-show-tag (&optional initial-input)
> >   initial-input (notmuch-show-get-message-id
> >  (apply 'notmuch-show-tag-message tag-changes)))
> >  
> > -(defun notmuch-show-tag-all (&rest tag-changes)
> > -  "Change tags for all messages in the current thread.
> > +(defun notmuch-show-tag-all (&optional ignore-visibility &rest tag-changes)
> > +  "Change tags of all open messages in the current buffer.
> > +
> > +If optional arg IGNORE-VISIBILITY is non-nil, change tags of
> > +*all* messages in the current buffer, independent of their
> > +visibility.
> >  
> >  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> > -  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> > -  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
> > -  (notmuch-show-mapc t
> > +  (interactive (cons current-prefix-arg
> > +(notmuch-read-tag-changes nil notmuch-show-thread-id)))
> > +  (apply 'notmuch-tag
> > +(notmuch-show-get-messages-ids (not ignore-visibility) " or ")
> > +tag-changes)
> > +  (notmuch-show-mapc
> > +   `(if ignore-visibility t (notmuch-show-message-visible-p))
> > (lambda ()
> >   (let* ((current-tags (notmuch-show-get-tags))
> > (new-tags (notmuch-update-tags current-tags tag-changes)))
> > @@ -1719,7 +1731,7 @@ (defun notmuch-show-archive-thread (&optional 
> > unarchive)
> >  buffer."
> >(interactive "P")
> >(let ((op (if unarchive "+" "-")))
> > -(notmuch-show-tag-all (concat op "inbox"
> > +(notmuch-show-tag-all t (concat op "inbox"
> >  
> >  (defun notmuch-show-archive-thread-then-next ()
> >"Archive each message in thread, then show next thread from search."
> > diff --git a/test/emacs b/test/emacs
> > index 644ef59..c286ff5 100755
> > --- a/test/emacs
> > +++ b/test/emacs
> > @@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # 
> > revert tag changes
> >  test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
> > TOTAL
> >  
> >  test_begin_subtest "notmuch-show: change tags of open messages in current 
> > buffer"
> > -test_subtest_known_broken
> >  query="$os_x_darwin_thread"
> >  filter="from:Jiang"
> >  add_tag="notmuch-show-tag-all"
> > -- 
> > 1.7.8.1
> > 


Peace

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


Re: [PATCH 5/6] emacs: simplify `notmuch-show-get-messages-ids{, -search}'

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:42:53 +0400, Dmitry Kurochkin 
 wrote:
> On Fri, 24 Feb 2012 00:09:13 +0100, Pieter Praet  wrote:
> > * emacs/notmuch-show.el
> > 
> >   (notmuch-show-get-messages-ids):
> > If provided with optional arg SEPARATOR, return a string consisting
> > of all Message-Id's, separated by SEPARATOR.  Also improve original
> > docstring wrt default return value.
> > 
> >   (notmuch-show-get-messages-ids-search):
> > Removed, as its functionality is now in `notmuch-show-get-messages-ids'.
> > 
> >   (notmuch-show-tag-all):
> > Call `notmuch-show-get-messages-ids' with SEPARATOR arg instead of
> > `notmuch-show-get-messages-ids-search'.
> > ---
> 
> There is another similar case in notmuch.el:
> `notmuch-show-get-messages-ids' and
> `notmuch-show-get-messages-ids-search'.  There may be more.
> 
> Please change them as well.
>

You mean `notmuch-search-find-thread-id-region{,-search}' ?

They aren't relevant to this series, so I'll submit a separate patch
for that (later).  A quick `rgrep' doesn't reveal any others, but if
you happen to stumble across any, feel free to point them out.

> Regards,
>   Dmitry
> 
> >  emacs/notmuch-show.el |   18 +-
> >  1 files changed, 9 insertions(+), 9 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index 5fc0e43..4b37c77 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1334,17 +1334,17 @@ (defun notmuch-show-get-message-id ()
> >"Return the message id of the current message."
> >(concat "id:\"" (notmuch-show-get-prop :id) "\""))
> >  
> > -(defun notmuch-show-get-messages-ids ()
> > -  "Return all message ids of messages in the current thread."
> > +(defun notmuch-show-get-messages-ids (&optional separator)
> > +  "Return a list of Message-Id's of all messages in the current buffer.
> > +
> > +If provided with optional argument SEPARATOR, return a string
> > +instead, consisting of all Message-Id's separated by SEPARATOR."
> >(let ((message-ids))
> >  (notmuch-show-mapc t
> >   (lambda () (push (notmuch-show-get-message-id) message-ids)))
> > -message-ids))
> > -
> > -(defun notmuch-show-get-messages-ids-search ()
> > -  "Return a search string for all message ids of messages in the
> > -current thread."
> > -  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
> > +(if separator
> > +   (mapconcat 'identity message-ids separator)
> > +  message-ids)))
> >  
> >  ;; dme: Would it make sense to use a macro for many of these?
> >  
> > @@ -1633,7 +1633,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
> >  
> >  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> >(interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> > -  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> > +  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
> >(notmuch-show-mapc t
> > (lambda ()
> >   (let* ((current-tags (notmuch-show-get-tags))
> > -- 
> > 1.7.8.1
> > 


Peace

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


Re: [PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:39:41 +0400, Dmitry Kurochkin 
 wrote:
> On Fri, 24 Feb 2012 00:09:12 +0100, Pieter Praet  wrote:
> > * emacs/notmuch-show.el
> > 
> >   (notmuch-show-mapc):
> > Only call FUNCTION if new argument PREDICATE is satisfied.
> > Also correct original docstring: 's/thread/buffer/'.
> > 
> >   (notmuch-show-get-messages-ids):
> > Update wrt changes to `notmuch-show-mapc'.
> > 
> >   (notmuch-show-tag-all):
> > Update wrt changes to `notmuch-show-mapc'.
> > ---
> >  emacs/notmuch-show.el |   15 ---
> >  1 files changed, 8 insertions(+), 7 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index aa9ccee..5fc0e43 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1272,13 +1272,14 @@ (defun notmuch-show-goto-message-previous ()
> >  (notmuch-show-move-to-message-top)
> >  t))
> >  
> > -(defun notmuch-show-mapc (function)
> > -  "Iterate through all messages in the current thread with
> > -`notmuch-show-goto-message-next' and call FUNCTION for side
> > -effects."
> > +(defun notmuch-show-mapc (predicate function)
> 
> Please make PREDICATE optional to avoid giving t when it is not needed.
>

Done.

> I would expect PREDICATE to be a function, [...]

Well, it *can* be a function actually (see later usage in e.g.
`notmuch-show-get-messages-ids' [1]), but should be provided
as a form instead of as a quoted symbol.

> [...] but perhaps the way you
> implemented it is common in Emacs.
>

Far from it, apparently.  I did it that way to prevent `funcall' from
choking on t/nil, which -in retrospect- was rather shortsighted...

I've used a more sensible approach in v2 [2].

> Regards,
>   Dmitry
> 
> > +  "Iterate through all messages in the current buffer with
> > +`notmuch-show-goto-message-next'.  If PREDICATE is satisfied,
> > +call FUNCTION for side effects."
> >(save-excursion
> >  (goto-char (point-min))
> > -(loop do (funcall function)
> > +(loop do (if (eval predicate)
> > +(funcall function))
> >   while (notmuch-show-goto-message-next
> >  
> >  ;; Functions relating to the visibility of messages and their
> > @@ -1336,7 +1337,7 @@ (defun notmuch-show-get-message-id ()
> >  (defun notmuch-show-get-messages-ids ()
> >"Return all message ids of messages in the current thread."
> >(let ((message-ids))
> > -(notmuch-show-mapc
> > +(notmuch-show-mapc t
> >   (lambda () (push (notmuch-show-get-message-id) message-ids)))
> >  message-ids))
> >  
> > @@ -1633,7 +1634,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
> >  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> >(interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> >(apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> > -  (notmuch-show-mapc
> > +  (notmuch-show-mapc t
> > (lambda ()
> >   (let* ((current-tags (notmuch-show-get-tags))
> > (new-tags (notmuch-update-tags current-tags tag-changes)))
> > -- 
> > 1.7.8.1
> > 


Peace

-- 
Pieter

[1] id:"1330038554-10347-6-git-send-email-pie...@praet.org"
[2] id:"1330122640-18895-5-git-send-email-pie...@praet.org"
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/6] test: emacs: new tests "notmuch-show: {add, remove} multiple tags {to, from} single message"

2012-02-24 Thread Pieter Praet
On Fri, 24 Feb 2012 14:35:22 +0400, Dmitry Kurochkin 
 wrote:
> On Fri, 24 Feb 2012 00:09:09 +0100, Pieter Praet  wrote:
> > * test/emacs:
> > 
> >   - Rename subtests "{Add,Remove} tag from notmuch-show view" to
> > "notmuch-show: {add,remove} single tag {to,from} single message"
> > to be consistent with the following tests.
> > 
> >   - New subtest "notmuch-show: add multiple tags to single message":
> > `notmuch-show-add-tag' ("+") can add multiple tags to a message.
> > 
> >   - New subtest "notmuch-show: remove multiple tags from single message":
> > `notmuch-show-remove-tag' ("-") can remove multiple tags from a message.
> > ---
> 
> Would be nice to have another patch that moves notmuch-show tests to
> emacs-show file.
>

TL;DR: It's on my todo list.

Yeah, the Emacs test series *as a whole* desperately needs some
reorganizing, not in the least because it's still severely
lacking in coverage.

Some more structure/consistency would considerably increase the
feasibility (or at least reduce the PITAness...)  of filling in
the numerous blanks and reducing duplication of effort (regarding
both hard- and wetware based cycles), as well as increasing the
likelihood that developers (not looking in any specific direction)
serve their code with a side dish of tests.

Ideally (IMHO), it would be split up into separate files by mode,
i.e. `notmuch-hello', `notmuch-search', `notmuch-show',
`notmuch-{message,mua}', and those can be further divided into
sections like navigation, tagging, visibility stuff, hooks, ...

There's probably quite a number of implicit interdependencies that
need to be taken care of though, and I (as well as others) still
have a bunch of tests waiting to be applied, so we might want to do
this gradually.


> Regards,
>   Dmitry
> 
> >  test/emacs |   16 ++--
> >  1 files changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/test/emacs b/test/emacs
> > index b74cfa9..ec1dbb0 100755
> > --- a/test/emacs
> > +++ b/test/emacs
> > @@ -112,18 +112,30 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
> >  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> >  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox unread)"
> >  
> > -test_begin_subtest "Add tag from notmuch-show view"
> > +test_begin_subtest "notmuch-show: add single tag to single message"
> >  test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> > (execute-kbd-macro \"+tag-from-show-view\")"
> >  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> >  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox tag-from-show-view unread)"
> >  
> > -test_begin_subtest "Remove tag from notmuch-show view"
> > +test_begin_subtest "notmuch-show: remove single tag from single message"
> >  test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> > (execute-kbd-macro \"-tag-from-show-view\")"
> >  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> >  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox unread)"
> >  
> > +test_begin_subtest "notmuch-show: add multiple tags to single message"
> > +test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> > +   (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
> > +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> > +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox tag1-from-show-view tag2-from-show-view unread)"
> > +
> > +test_begin_subtest "notmuch-show: remove multiple tags from single message"
> > +test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> > +   (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
> > +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> > +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> > Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues 
> > (inbox unread)"
> > +
> >  test_begin_subtest "Message with .. in Message-Id:"
> >  add_message [id]=123..456@example '[subject]="Message with .. in 
> > Message-Id"'
> >  test_emacs '(notmuch-search "id:\"123..456@example\"")
> > -- 
> > 1.7.8.1
> > 


Peace

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


[PATCH 1/6] test: emacs: new tests "notmuch-show: {add, remove} multiple tags {to, from} single message"

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:09:09 +0100, Pieter Praet  wrote:
> * test/emacs:
> 
>   - Rename subtests "{Add,Remove} tag from notmuch-show view" to
> "notmuch-show: {add,remove} single tag {to,from} single message"
> to be consistent with the following tests.
> 
>   - New subtest "notmuch-show: add multiple tags to single message":
> `notmuch-show-add-tag' ("+") can add multiple tags to a message.
> 
>   - New subtest "notmuch-show: remove multiple tags from single message":
> `notmuch-show-remove-tag' ("-") can remove multiple tags from a message.
> ---

Would be nice to have another patch that moves notmuch-show tests to
emacs-show file.

Regards,
  Dmitry

>  test/emacs |   16 ++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/test/emacs b/test/emacs
> index b74cfa9..ec1dbb0 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -112,18 +112,30 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
>  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
>  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> unread)"
>  
> -test_begin_subtest "Add tag from notmuch-show view"
> +test_begin_subtest "notmuch-show: add single tag to single message"
>  test_emacs "(notmuch-show \"$os_x_darwin_thread\")
>   (execute-kbd-macro \"+tag-from-show-view\")"
>  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
>  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> tag-from-show-view unread)"
>  
> -test_begin_subtest "Remove tag from notmuch-show view"
> +test_begin_subtest "notmuch-show: remove single tag from single message"
>  test_emacs "(notmuch-show \"$os_x_darwin_thread\")
>   (execute-kbd-macro \"-tag-from-show-view\")"
>  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
>  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> unread)"
>  
> +test_begin_subtest "notmuch-show: add multiple tags to single message"
> +test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> + (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
> +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> tag1-from-show-view tag2-from-show-view unread)"
> +
> +test_begin_subtest "notmuch-show: remove multiple tags from single message"
> +test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> + (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
> +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> unread)"
> +
>  test_begin_subtest "Message with .. in Message-Id:"
>  add_message [id]=123..456 at example '[subject]="Message with .. in 
> Message-Id"'
>  test_emacs '(notmuch-search "id:\"123..456 at example\"")
> -- 
> 1.7.8.1
> 


[PATCH v2 1/6] test: emacs: new tests "notmuch-show: {add, remove} multiple tags {to, from} single message"

2012-02-24 Thread Pieter Praet
* test/emacs:

  - Rename subtests "{Add,Remove} tag from notmuch-show view" to
"notmuch-show: {add,remove} single tag {to,from} single message"
to be consistent with the following tests.

  - New subtest "notmuch-show: add multiple tags to single message":
`notmuch-show-add-tag' ("+") can add multiple tags to a message.

  - New subtest "notmuch-show: remove multiple tags from single message":
`notmuch-show-remove-tag' ("-") can remove multiple tags from a message.
---
 test/emacs |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/test/emacs b/test/emacs
index b74cfa9..ec1dbb0 100755
--- a/test/emacs
+++ b/test/emacs
@@ -112,18 +112,30 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"
 
-test_begin_subtest "Add tag from notmuch-show view"
+test_begin_subtest "notmuch-show: add single tag to single message"
 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
(execute-kbd-macro \"+tag-from-show-view\")"
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
tag-from-show-view unread)"
 
-test_begin_subtest "Remove tag from notmuch-show view"
+test_begin_subtest "notmuch-show: remove single tag from single message"
 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
(execute-kbd-macro \"-tag-from-show-view\")"
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"
 
+test_begin_subtest "notmuch-show: add multiple tags to single message"
+test_emacs "(notmuch-show \"$os_x_darwin_thread\")
+   (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
+output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
tag1-from-show-view tag2-from-show-view unread)"
+
+test_begin_subtest "notmuch-show: remove multiple tags from single message"
+test_emacs "(notmuch-show \"$os_x_darwin_thread\")
+   (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
+output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456@example\"")
-- 
1.7.8.1

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


[PATCH v2 6/6] emacs: `notmuch-show-tag-all' with prefix arg only tags open messages

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el

  (notmuch-show-get-messages-ids):
If provided with optional argument PREDICATE, only return
Message-Id's of messages for which PREDICATE returns non-nil.

  (notmuch-show-tag-all):
New argument ONLY-OPEN (set to `current-prefix-arg' if running
interactively): if non-nil, only change tags of *open* messages.
Also correct original docstring: 's/thread/buffer/'.

  (notmuch-show-archive-thread):
Update wrt changes to `notmuch-show-tag-all'.

* test/emacs

  - Subtest "notmuch-show: change tags of open messages in current buffer"
is no longer broken...
---
 emacs/notmuch-show.el |   33 -
 test/emacs|1 -
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 05606fc..4bd1a7c 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1339,14 +1339,18 @@ (defun notmuch-show-get-message-id ()
   "Return the message id of the current message."
   (concat "id:\"" (notmuch-show-get-prop :id) "\""))
 
-(defun notmuch-show-get-messages-ids (&optional separator)
+(defun notmuch-show-get-messages-ids (&optional separator predicate)
   "Return a list of Message-Id's of all messages in the current buffer.
 
 If provided with optional argument SEPARATOR, return a string
-instead, consisting of all Message-Id's separated by SEPARATOR."
+instead, consisting of all Message-Id's separated by SEPARATOR.
+
+If provided with optional argument PREDICATE, only return
+Message-Id's of messages for which PREDICATE returns non-nil."
   (let ((message-ids))
 (notmuch-show-mapc
- (lambda () (push (notmuch-show-get-message-id) message-ids)))
+ (lambda () (push (notmuch-show-get-message-id) message-ids))
+ predicate)
 (if separator
(mapconcat 'identity message-ids separator)
   message-ids)))
@@ -1633,18 +1637,29 @@ (defun notmuch-show-tag (&optional initial-input)
  initial-input (notmuch-show-get-message-id
 (apply 'notmuch-show-tag-message tag-changes)))
 
-(defun notmuch-show-tag-all (&rest tag-changes)
-  "Change tags for all messages in the current thread.
+(defun notmuch-show-tag-all (only-open &rest tag-changes)
+  "Change tags of all messages in the current buffer.
+
+If ONLY-OPEN is non-nil, only change tags of *open* messages in
+the current buffer.
 
 TAG-CHANGES is a list of tag operations for `notmuch-tag'."
-  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
-  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
+  (interactive (cons current-prefix-arg
+(notmuch-read-tag-changes nil notmuch-show-thread-id)))
+  (apply 'notmuch-tag
+(notmuch-show-get-messages-ids
+ " or "
+ `(lambda ()
+,(if only-open '(notmuch-show-message-visible-p) t)))
+tag-changes)
   (notmuch-show-mapc
(lambda ()
  (let* ((current-tags (notmuch-show-get-tags))
(new-tags (notmuch-update-tags current-tags tag-changes)))
(unless (equal current-tags new-tags)
-(notmuch-show-set-tags new-tags))
+(notmuch-show-set-tags new-tags
+   `(lambda ()
+  ,(if only-open '(notmuch-show-message-visible-p) t
 
 (defun notmuch-show-add-tag ()
   "Same as `notmuch-show-tag' but sets initial input to '+'."
@@ -1724,7 +1739,7 @@ (defun notmuch-show-archive-thread (&optional unarchive)
 buffer."
   (interactive "P")
   (let ((op (if unarchive "+" "-")))
-(notmuch-show-tag-all (concat op "inbox"
+(notmuch-show-tag-all nil (concat op "inbox"
 
 (defun notmuch-show-archive-thread-then-next ()
   "Archive each message in thread, then show next thread from search."
diff --git a/test/emacs b/test/emacs
index 9088ced..e6b0503 100755
--- a/test/emacs
+++ b/test/emacs
@@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert 
tag changes
 test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL
 
 test_begin_subtest "notmuch-show: change tags of open messages in current 
buffer"
-test_subtest_known_broken
 query="$os_x_darwin_thread"
 filter="from:Jiang"
 add_tag="notmuch-show-tag-all"
-- 
1.7.8.1

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


[PATCH v2 5/6] emacs: simplify `notmuch-show-get-messages-ids{, -search}'

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el

  (notmuch-show-get-messages-ids):
If provided with optional arg SEPARATOR, return a string consisting
of all Message-Id's, separated by SEPARATOR.  Also improve original
docstring wrt default return value.

  (notmuch-show-get-messages-ids-search):
Removed, as its functionality is now in `notmuch-show-get-messages-ids'.

  (notmuch-show-tag-all):
Call `notmuch-show-get-messages-ids' with SEPARATOR arg instead of
`notmuch-show-get-messages-ids-search'.
---
 emacs/notmuch-show.el |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 6adbdc0..05606fc 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1339,17 +1339,17 @@ (defun notmuch-show-get-message-id ()
   "Return the message id of the current message."
   (concat "id:\"" (notmuch-show-get-prop :id) "\""))
 
-(defun notmuch-show-get-messages-ids ()
-  "Return all message ids of messages in the current thread."
+(defun notmuch-show-get-messages-ids (&optional separator)
+  "Return a list of Message-Id's of all messages in the current buffer.
+
+If provided with optional argument SEPARATOR, return a string
+instead, consisting of all Message-Id's separated by SEPARATOR."
   (let ((message-ids))
 (notmuch-show-mapc
  (lambda () (push (notmuch-show-get-message-id) message-ids)))
-message-ids))
-
-(defun notmuch-show-get-messages-ids-search ()
-  "Return a search string for all message ids of messages in the
-current thread."
-  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
+(if separator
+   (mapconcat 'identity message-ids separator)
+  message-ids)))
 
 ;; dme: Would it make sense to use a macro for many of these?
 
@@ -1638,7 +1638,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
 
 TAG-CHANGES is a list of tag operations for `notmuch-tag'."
   (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
-  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
+  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
   (notmuch-show-mapc
(lambda ()
  (let* ((current-tags (notmuch-show-get-tags))
-- 
1.7.8.1

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


[PATCH v2 4/6] emacs: add optional predicate arg to `notmuch-show-mapc'

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el (notmuch-show-mapc):

  If provided with optional argument PREDICATE, only call
  FUNCTION if calling PREDICATE returns non-nil.

  Also correct original docstring: 's/thread/buffer/'.
---
 emacs/notmuch-show.el |   14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index aa9ccee..6adbdc0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1272,13 +1272,19 @@ (defun notmuch-show-goto-message-previous ()
 (notmuch-show-move-to-message-top)
 t))
 
-(defun notmuch-show-mapc (function)
-  "Iterate through all messages in the current thread with
+(defun notmuch-show-mapc (function &optional predicate)
+  "Iterate through all messages in the current buffer with
 `notmuch-show-goto-message-next' and call FUNCTION for side
-effects."
+effects.
+
+If provided with optional argument PREDICATE, only call
+FUNCTION if calling PREDICATE returns non-nil."
   (save-excursion
 (goto-char (point-min))
-(loop do (funcall function)
+(loop do (if predicate
+(if (funcall predicate)
+(funcall function))
+  (funcall function))
  while (notmuch-show-goto-message-next
 
 ;; Functions relating to the visibility of messages and their
-- 
1.7.8.1

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


[PATCH v2 3/6] test: emacs: `notmuch-show-tag-all' with prefix arg should only tag open messages

2012-02-24 Thread Pieter Praet
* test/emacs:

  - New subtest "notmuch-show: change tags of open messages in current buffer":
When called with a prefix arg, `notmuch-show-tag-all' ("*") should only
change the tags of *open* messages.  Currently broken, fix follows later.
---
 test/emacs |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index d2dbafc..9088ced 100755
--- a/test/emacs
+++ b/test/emacs
@@ -151,6 +151,22 @@ count_changed=$(notmuch count -- "$query" AND 
tag:"$add_tag" AND NOT tag:"$del_t
 notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
 test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL
 
+test_begin_subtest "notmuch-show: change tags of open messages in current 
buffer"
+test_subtest_known_broken
+query="$os_x_darwin_thread"
+filter="from:Jiang"
+add_tag="notmuch-show-tag-all"
+del_tag="inbox"
+count_total=$(notmuch count -- "$query")   # = 4
+count_match=$(notmuch count -- "$query" AND "$filter") # = 2
+test_emacs "(notmuch-search \"$query AND $filter\")
+(notmuch-test-wait)
+(notmuch-search-show-thread)
+(execute-kbd-macro \"*+$add_tag -$del_tag\")"
+count_changed=$(notmuch count -- "$query" AND tag:"$add_tag" AND NOT 
tag:"$del_tag")
+notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
+test_expect_equal "$count_changed" "$count_match" # assert that CHANGED == 
MATCHING
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456@example\"")
-- 
1.7.8.1

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


[PATCH v2 2/6] test: emacs: new test "notmuch-show: change tags of all messages in current buffer"

2012-02-24 Thread Pieter Praet
* test/emacs:

  New subtest "notmuch-show: change tags of all messages in current buffer":
  `notmuch-show-tag-all' ("*") changes tags of *all* messages in current buffer.
---
 test/emacs |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index ec1dbb0..d2dbafc 100755
--- a/test/emacs
+++ b/test/emacs
@@ -136,6 +136,21 @@ test_emacs "(notmuch-show \"$os_x_darwin_thread\")
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"
 
+test_begin_subtest "notmuch-show: change tags of all messages in current 
buffer"
+query="$os_x_darwin_thread"
+filter="from:Jiang"
+add_tag="notmuch-show-tag-all"
+del_tag="inbox"
+count_total=$(notmuch count -- "$query")   # = 4
+count_match=$(notmuch count -- "$query" AND "$filter") # = 2
+test_emacs "(notmuch-search \"$query AND $filter\")
+(notmuch-test-wait)
+(notmuch-search-show-thread)
+(execute-kbd-macro \"*+$add_tag -$del_tag\")"
+count_changed=$(notmuch count -- "$query" AND tag:"$add_tag" AND NOT 
tag:"$del_tag")
+notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
+test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456@example\"")
-- 
1.7.8.1

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


[PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 14:30:29 +0400, Dmitry Kurochkin  wrote:
> On Fri, 24 Feb 2012 00:07:27 +0100, Pieter Praet  wrote:
> > On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  
> > wrote:
> > > On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin  > > gmail.com> wrote:
> > > > Changes:
> > > > 
> > > > v4:
> > > > 
> > > > * rebased on master, no conflicts so no need for another review
> > > > 
> > > 
> > > I pushed this series.  
> > > 
> > > Maybe this was discussed already, but I think ideally * would apply only
> > > to open messages. So consider that a feature request if someone is
> > > looking for a project.
> > >
> > 
> > How about if '*' applies to all messages (as it currently does),
> > but 'C-u *' only to open messages?  That would make more sense IMHO.
> > 
> > But, conforming to your original request, I've implemented the inverse.
> > 
> 
> I personally do like '*' as is and do not want to change it's behavior.
> Though I am not against adding a prefix argument for it.
> 

Also can you please send new patches (and patch series) in a new
separate thread?  If they are related to another thread, you can add a
reference.  But having multiple patch series with multiple versions in a
single thread is very confusing IMO.

Regards,
  Dmitry

> Regards,
>   Dmitry
> 
> > Patches follow.
> > 
> > 
> > > d
> > > ___
> > > notmuch mailing list
> > > notmuch at notmuchmail.org
> > > http://notmuchmail.org/mailman/listinfo/notmuch
> > 
> > 
> > Peace
> > 
> > -- 
> > Pieter


[PATCH v2 0/6] `notmuch-show-tag-all' with prefix arg only tags open messages

2012-02-24 Thread Pieter Praet
Addresses Dmitry's comments [1,2,3], save for the ones that aren't
directly related to this series [4,5] and will be dealt with later.

Also made `notmuch-show-tag-all's ONLY-OPEN arg non-optional.
Otherwise it would cause issues when running non-interactively.


Peace

-- 
Pieter

[1] id:"87fwe0jz0y@gmail.com"
[2] id:"87aa48jynx@gmail.com"
[3] id:"87obsojzga@gmail.com"
[4] id:"87ipiwjz85@gmail.com"
[5] id:"87d394jyvm@gmail.com"

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


[PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:07:27 +0100, Pieter Praet  wrote:
> On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  
> wrote:
> > On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin  > gmail.com> wrote:
> > > Changes:
> > > 
> > > v4:
> > > 
> > > * rebased on master, no conflicts so no need for another review
> > > 
> > 
> > I pushed this series.  
> > 
> > Maybe this was discussed already, but I think ideally * would apply only
> > to open messages. So consider that a feature request if someone is
> > looking for a project.
> >
> 
> How about if '*' applies to all messages (as it currently does),
> but 'C-u *' only to open messages?  That would make more sense IMHO.
> 
> But, conforming to your original request, I've implemented the inverse.
> 

I personally do like '*' as is and do not want to change it's behavior.
Though I am not against adding a prefix argument for it.

Regards,
  Dmitry

> Patches follow.
> 
> 
> > d
> > ___
> > notmuch mailing list
> > notmuch at notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
> 
> 
> Peace
> 
> -- 
> Pieter


[PATCH] test: Add test for searching of uncommonly encoded messages

2012-02-24 Thread Serge Z

Quoting Michal Sojka (2012-02-24 11:00:02)
>On Fri, 24 Feb 2012, Serge Z wrote:
>> 
>> Quoting Michal Sojka (2012-02-24 04:33:15)
>> >Emails that are encoded differently than as ASCII or UTF-8 are not
>> >indexed properly by notmuch. It is not possible to search for non-ASCII
>> >words within those messages.
>> 
>> Ok. But we can preprocess each incoming message right after 'getmail' to
>> convert it from html to text and to utf8 encoding. One solution is to create 
>> a
>> seperate script for this and make gmail pipe all messages to this script, and
>> then to notmuch. But It would be better if maildir contains original messages
>> only, so the question is: can we make nomuch indexing engine to index
>> preprocessed message while maildir will contain original message - as it was
>> obtained?
>
>Hi,
>
>I'm not big fan of adding "preprocessor". First, I thing that both
>reasons you mention are actually bugs and it would be better to fix them
>for everybody than requiring each user to configure some preprocessor.
>Second, depending on what and how would your preprocessor do, the
>initial mail indexing could be a way slower, which is also nothing that
>people want.
>
>Do you have any other use case for the preprocessor besides utf8 and
>html->text conversions?
>
>Cheers,
>-Michal

Well, I don't want to add any external preprocessor too.

This may be considered as an architectural decision: search engine should not
access messages directly, but through some preprocessing layer which would
handle the case of different encodings in body and headers, RFC2047-encoded
headers (if this is not handled yet) etc.

Anyway, this solution imho would be nice to be concluded inside a separate
library which would be useful for notmuch clients as well as other mail
indexing engines. Or an existing library should be looked for.



Re: [PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Jani Nikula
On Fri, 24 Feb 2012 14:33:35 +0400, Dmitry Kurochkin 
 wrote:
> Also can you please send new patches (and patch series) in a new
> separate thread?  If they are related to another thread, you can add a
> reference.  But having multiple patch series with multiple versions in a
> single thread is very confusing IMO.

IMHO the same thread is okay if the new versions are in-reply-to the
cover letter of the first version.

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


[PATCH] test: Add test for searching of uncommonly encoded messages

2012-02-24 Thread Michal Sojka
On Fri, 24 Feb 2012, Serge Z wrote:
> 
> Quoting Michal Sojka (2012-02-24 11:00:02)
> >I'm not big fan of adding "preprocessor". First, I thing that both
> >reasons you mention are actually bugs and it would be better to fix them
> >for everybody than requiring each user to configure some preprocessor.
> >Second, depending on what and how would your preprocessor do, the
> >initial mail indexing could be a way slower, which is also nothing that
> >people want.
> >
> >Do you have any other use case for the preprocessor besides utf8 and
> >html->text conversions?
> >
> >Cheers,
> >-Michal
> 
> Well, I don't want to add any external preprocessor too.
> 
> This may be considered as an architectural decision: search engine should not
> access messages directly, but through some preprocessing layer which would
> handle the case of different encodings in body and headers, RFC2047-encoded
> headers (if this is not handled yet) etc.
> 
> Anyway, this solution imho would be nice to be concluded inside a separate
> library

Yes, this library is called gmime and notmuch already make use of it.

-Michal


[PATCH 2/2] test: Remove 'broken' flag from encoding test

2012-02-24 Thread Michal Sojka
---
 test/encoding |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/test/encoding b/test/encoding
index 3992b5c..f0d073c 100755
--- a/test/encoding
+++ b/test/encoding
@@ -22,7 +22,6 @@ irrelevant
 message}"

 test_begin_subtest "Search for ISO-8859-2 encoded message"
-test_subtest_known_broken
 add_message '[content-type]="text/plain; charset=iso-8859-2"' \
 '[content-transfer-encoding]=8bit' \
 '[subject]="ISO-8859-2 encoded message"' \
-- 
1.7.9.1



[PATCH 1/2] Convert non-UTF-8 parts to UTF-8 before indexing them

2012-02-24 Thread Michal Sojka
This fixes a bug that didn't allow to search for non-ASCII words such
parts. The code here was copied from show_text_part_content(), because
the show command already does the needed conversion when showing the
message.
---
 lib/index.cc |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/lib/index.cc b/lib/index.cc
index d8f8b2b..e377732 100644
--- a/lib/index.cc
+++ b/lib/index.cc
@@ -315,6 +315,7 @@ _index_mime_part (notmuch_message_t *message,
 GByteArray *byte_array;
 GMimeContentDisposition *disposition;
 char *body;
+const char *charset;

 if (! part) {
fprintf (stderr, "Warning: Not indexing empty mime part.\n");
@@ -390,6 +391,20 @@ _index_mime_part (notmuch_message_t *message,
 g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),
  discard_uuencode_filter);

+charset = g_mime_object_get_content_type_parameter (part, "charset");
+if (charset) {
+   GMimeFilter *charset_filter;
+   charset_filter = g_mime_filter_charset_new (charset, "UTF-8");
+   /* This result can be NULL for things like "unknown-8bit".
+* Don't set a NULL filter as that makes GMime print
+* annoying assertion-failure messages on stderr. */
+   if (charset_filter) {
+   g_mime_stream_filter_add (GMIME_STREAM_FILTER (filter),
+ charset_filter);
+   g_object_unref (charset_filter);
+   }
+}
+
 wrapper = g_mime_part_get_content_object (GMIME_PART (part));
 if (wrapper)
g_mime_data_wrapper_write_to_stream (wrapper, filter);
-- 
1.7.9.1



[PATCH] test: Add test for searching of uncommonly encoded messages

2012-02-24 Thread Serge Z

Quoting Michal Sojka (2012-02-24 04:33:15)
>Emails that are encoded differently than as ASCII or UTF-8 are not
>indexed properly by notmuch. It is not possible to search for non-ASCII
>words within those messages.

Ok. But we can preprocess each incoming message right after 'getmail' to
convert it from html to text and to utf8 encoding. One solution is to create a
seperate script for this and make gmail pipe all messages to this script, and
then to notmuch. But It would be better if maildir contains original messages
only, so the question is: can we make nomuch indexing engine to index
preprocessed message while maildir will contain original message - as it was
obtained?



[PATCH] test: Add test for searching of uncommonly encoded messages

2012-02-24 Thread Michal Sojka
On Fri, 24 Feb 2012, Serge Z wrote:
> 
> Quoting Michal Sojka (2012-02-24 04:33:15)
> >Emails that are encoded differently than as ASCII or UTF-8 are not
> >indexed properly by notmuch. It is not possible to search for non-ASCII
> >words within those messages.
> 
> Ok. But we can preprocess each incoming message right after 'getmail' to
> convert it from html to text and to utf8 encoding. One solution is to create a
> seperate script for this and make gmail pipe all messages to this script, and
> then to notmuch. But It would be better if maildir contains original messages
> only, so the question is: can we make nomuch indexing engine to index
> preprocessed message while maildir will contain original message - as it was
> obtained?

Hi,

I'm not big fan of adding "preprocessor". First, I thing that both
reasons you mention are actually bugs and it would be better to fix them
for everybody than requiring each user to configure some preprocessor.
Second, depending on what and how would your preprocessor do, the
initial mail indexing could be a way slower, which is also nothing that
people want.

Do you have any other use case for the preprocessor besides utf8 and
html->text conversions?

Cheers,
-Michal


Re: [PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags open messages

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:09:14 +0100, Pieter Praet  wrote:
> * emacs/notmuch-show.el
> 
>   (notmuch-show-get-messages-ids):
> New optional argument ONLY-OPEN.  If non-nil, only return
> Message-Id's for messages which are currently visible.
> 
>   (notmuch-show-tag-all):
> New optional argument IGNORE-VISIBILITY, of which the inverse is
> passed as ONLY-OPEN argument to `notmuch-show-get-messages-ids':
> If called with a prefix arg, affect *all* messages in the current
> buffer.  Otherwise, only change tags of visible messages.
> 
>   (notmuch-show-archive-thread):
> Update wrt changes to `notmuch-show-tag-all'.
> 
> * test/emacs
> 
>   - Subtest "notmuch-show: change tags of open messages in current buffer"
> is no longer broken.
> ---
>  emacs/notmuch-show.el |   28 
>  test/emacs|1 -
>  2 files changed, 20 insertions(+), 9 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 4b37c77..4499fcd 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1334,13 +1334,17 @@ (defun notmuch-show-get-message-id ()
>"Return the message id of the current message."
>(concat "id:\"" (notmuch-show-get-prop :id) "\""))
>  
> -(defun notmuch-show-get-messages-ids (&optional separator)
> +(defun notmuch-show-get-messages-ids (&optional only-open separator)
>"Return a list of Message-Id's of all messages in the current buffer.
>  
> +If optional argument ONLY-OPEN is non-nil, only return
> +Message-Id's for messages which are currently visible.
> +
>  If provided with optional argument SEPARATOR, return a string
>  instead, consisting of all Message-Id's separated by SEPARATOR."
>(let ((message-ids))
> -(notmuch-show-mapc t
> +(notmuch-show-mapc
> + `(if only-open (notmuch-show-message-visible-p) t)

How about changing ONLY-OPEN to a general optional PREDICATE argument
and pass it as is to `notmuch-show-mapc'?  Please make it the last
argument.

Regards,
  Dmitry

>   (lambda () (push (notmuch-show-get-message-id) message-ids)))
>  (if separator
>   (mapconcat 'identity message-ids separator)
> @@ -1628,13 +1632,21 @@ (defun notmuch-show-tag (&optional initial-input)
> initial-input (notmuch-show-get-message-id
>  (apply 'notmuch-show-tag-message tag-changes)))
>  
> -(defun notmuch-show-tag-all (&rest tag-changes)
> -  "Change tags for all messages in the current thread.
> +(defun notmuch-show-tag-all (&optional ignore-visibility &rest tag-changes)
> +  "Change tags of all open messages in the current buffer.
> +
> +If optional arg IGNORE-VISIBILITY is non-nil, change tags of
> +*all* messages in the current buffer, independent of their
> +visibility.
>  
>  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
> -  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> -  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
> -  (notmuch-show-mapc t
> +  (interactive (cons current-prefix-arg
> +  (notmuch-read-tag-changes nil notmuch-show-thread-id)))
> +  (apply 'notmuch-tag
> +  (notmuch-show-get-messages-ids (not ignore-visibility) " or ")
> +  tag-changes)
> +  (notmuch-show-mapc
> +   `(if ignore-visibility t (notmuch-show-message-visible-p))
> (lambda ()
>   (let* ((current-tags (notmuch-show-get-tags))
>   (new-tags (notmuch-update-tags current-tags tag-changes)))
> @@ -1719,7 +1731,7 @@ (defun notmuch-show-archive-thread (&optional unarchive)
>  buffer."
>(interactive "P")
>(let ((op (if unarchive "+" "-")))
> -(notmuch-show-tag-all (concat op "inbox"
> +(notmuch-show-tag-all t (concat op "inbox"
>  
>  (defun notmuch-show-archive-thread-then-next ()
>"Archive each message in thread, then show next thread from search."
> diff --git a/test/emacs b/test/emacs
> index 644ef59..c286ff5 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert 
> tag changes
>  test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
> TOTAL
>  
>  test_begin_subtest "notmuch-show: change tags of open messages in current 
> buffer"
> -test_subtest_known_broken
>  query="$os_x_darwin_thread"
>  filter="from:Jiang"
>  add_tag="notmuch-show-tag-all"
> -- 
> 1.7.8.1
> 
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 5/6] emacs: simplify `notmuch-show-get-messages-ids{, -search}'

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:09:13 +0100, Pieter Praet  wrote:
> * emacs/notmuch-show.el
> 
>   (notmuch-show-get-messages-ids):
> If provided with optional arg SEPARATOR, return a string consisting
> of all Message-Id's, separated by SEPARATOR.  Also improve original
> docstring wrt default return value.
> 
>   (notmuch-show-get-messages-ids-search):
> Removed, as its functionality is now in `notmuch-show-get-messages-ids'.
> 
>   (notmuch-show-tag-all):
> Call `notmuch-show-get-messages-ids' with SEPARATOR arg instead of
> `notmuch-show-get-messages-ids-search'.
> ---

There is another similar case in notmuch.el:
`notmuch-show-get-messages-ids' and
`notmuch-show-get-messages-ids-search'.  There may be more.

Please change them as well.

Regards,
  Dmitry

>  emacs/notmuch-show.el |   18 +-
>  1 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 5fc0e43..4b37c77 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1334,17 +1334,17 @@ (defun notmuch-show-get-message-id ()
>"Return the message id of the current message."
>(concat "id:\"" (notmuch-show-get-prop :id) "\""))
>  
> -(defun notmuch-show-get-messages-ids ()
> -  "Return all message ids of messages in the current thread."
> +(defun notmuch-show-get-messages-ids (&optional separator)
> +  "Return a list of Message-Id's of all messages in the current buffer.
> +
> +If provided with optional argument SEPARATOR, return a string
> +instead, consisting of all Message-Id's separated by SEPARATOR."
>(let ((message-ids))
>  (notmuch-show-mapc t
>   (lambda () (push (notmuch-show-get-message-id) message-ids)))
> -message-ids))
> -
> -(defun notmuch-show-get-messages-ids-search ()
> -  "Return a search string for all message ids of messages in the
> -current thread."
> -  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
> +(if separator
> + (mapconcat 'identity message-ids separator)
> +  message-ids)))
>  
>  ;; dme: Would it make sense to use a macro for many of these?
>  
> @@ -1633,7 +1633,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
>  
>  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
>(interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
> -  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> +  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
>(notmuch-show-mapc t
> (lambda ()
>   (let* ((current-tags (notmuch-show-get-tags))
> -- 
> 1.7.8.1
> 
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:09:12 +0100, Pieter Praet  wrote:
> * emacs/notmuch-show.el
> 
>   (notmuch-show-mapc):
> Only call FUNCTION if new argument PREDICATE is satisfied.
> Also correct original docstring: 's/thread/buffer/'.
> 
>   (notmuch-show-get-messages-ids):
> Update wrt changes to `notmuch-show-mapc'.
> 
>   (notmuch-show-tag-all):
> Update wrt changes to `notmuch-show-mapc'.
> ---
>  emacs/notmuch-show.el |   15 ---
>  1 files changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index aa9ccee..5fc0e43 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1272,13 +1272,14 @@ (defun notmuch-show-goto-message-previous ()
>  (notmuch-show-move-to-message-top)
>  t))
>  
> -(defun notmuch-show-mapc (function)
> -  "Iterate through all messages in the current thread with
> -`notmuch-show-goto-message-next' and call FUNCTION for side
> -effects."
> +(defun notmuch-show-mapc (predicate function)

Please make PREDICATE optional to avoid giving t when it is not needed.

I would expect PREDICATE to be a function, but perhaps the way you
implemented it is common in Emacs.

Regards,
  Dmitry

> +  "Iterate through all messages in the current buffer with
> +`notmuch-show-goto-message-next'.  If PREDICATE is satisfied,
> +call FUNCTION for side effects."
>(save-excursion
>  (goto-char (point-min))
> -(loop do (funcall function)
> +(loop do (if (eval predicate)
> +  (funcall function))
> while (notmuch-show-goto-message-next
>  
>  ;; Functions relating to the visibility of messages and their
> @@ -1336,7 +1337,7 @@ (defun notmuch-show-get-message-id ()
>  (defun notmuch-show-get-messages-ids ()
>"Return all message ids of messages in the current thread."
>(let ((message-ids))
> -(notmuch-show-mapc
> +(notmuch-show-mapc t
>   (lambda () (push (notmuch-show-get-message-id) message-ids)))
>  message-ids))
>  
> @@ -1633,7 +1634,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
>  TAG-CHANGES is a list of tag operations for `notmuch-tag'."
>(interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
>(apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
> -  (notmuch-show-mapc
> +  (notmuch-show-mapc t
> (lambda ()
>   (let* ((current-tags (notmuch-show-get-tags))
>   (new-tags (notmuch-update-tags current-tags tag-changes)))
> -- 
> 1.7.8.1
> 
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/6] test: emacs: new tests "notmuch-show: {add, remove} multiple tags {to, from} single message"

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:09:09 +0100, Pieter Praet  wrote:
> * test/emacs:
> 
>   - Rename subtests "{Add,Remove} tag from notmuch-show view" to
> "notmuch-show: {add,remove} single tag {to,from} single message"
> to be consistent with the following tests.
> 
>   - New subtest "notmuch-show: add multiple tags to single message":
> `notmuch-show-add-tag' ("+") can add multiple tags to a message.
> 
>   - New subtest "notmuch-show: remove multiple tags from single message":
> `notmuch-show-remove-tag' ("-") can remove multiple tags from a message.
> ---

Would be nice to have another patch that moves notmuch-show tests to
emacs-show file.

Regards,
  Dmitry

>  test/emacs |   16 ++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/test/emacs b/test/emacs
> index b74cfa9..ec1dbb0 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -112,18 +112,30 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
>  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
>  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> unread)"
>  
> -test_begin_subtest "Add tag from notmuch-show view"
> +test_begin_subtest "notmuch-show: add single tag to single message"
>  test_emacs "(notmuch-show \"$os_x_darwin_thread\")
>   (execute-kbd-macro \"+tag-from-show-view\")"
>  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
>  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> tag-from-show-view unread)"
>  
> -test_begin_subtest "Remove tag from notmuch-show view"
> +test_begin_subtest "notmuch-show: remove single tag from single message"
>  test_emacs "(notmuch-show \"$os_x_darwin_thread\")
>   (execute-kbd-macro \"-tag-from-show-view\")"
>  output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
>  test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> unread)"
>  
> +test_begin_subtest "notmuch-show: add multiple tags to single message"
> +test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> + (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
> +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> tag1-from-show-view tag2-from-show-view unread)"
> +
> +test_begin_subtest "notmuch-show: remove multiple tags from single message"
> +test_emacs "(notmuch-show \"$os_x_darwin_thread\")
> + (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
> +output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
> +test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
> Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
> unread)"
> +
>  test_begin_subtest "Message with .. in Message-Id:"
>  add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
>  test_emacs '(notmuch-search "id:\"123..456@example\"")
> -- 
> 1.7.8.1
> 
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 14:30:29 +0400, Dmitry Kurochkin 
 wrote:
> On Fri, 24 Feb 2012 00:07:27 +0100, Pieter Praet  wrote:
> > On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  wrote:
> > > On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin 
> > >  wrote:
> > > > Changes:
> > > > 
> > > > v4:
> > > > 
> > > > * rebased on master, no conflicts so no need for another review
> > > > 
> > > 
> > > I pushed this series.  
> > > 
> > > Maybe this was discussed already, but I think ideally * would apply only
> > > to open messages. So consider that a feature request if someone is
> > > looking for a project.
> > >
> > 
> > How about if '*' applies to all messages (as it currently does),
> > but 'C-u *' only to open messages?  That would make more sense IMHO.
> > 
> > But, conforming to your original request, I've implemented the inverse.
> > 
> 
> I personally do like '*' as is and do not want to change it's behavior.
> Though I am not against adding a prefix argument for it.
> 

Also can you please send new patches (and patch series) in a new
separate thread?  If they are related to another thread, you can add a
reference.  But having multiple patch series with multiple versions in a
single thread is very confusing IMO.

Regards,
  Dmitry

> Regards,
>   Dmitry
> 
> > Patches follow.
> > 
> > 
> > > d
> > > ___
> > > notmuch mailing list
> > > notmuch@notmuchmail.org
> > > http://notmuchmail.org/mailman/listinfo/notmuch
> > 
> > 
> > Peace
> > 
> > -- 
> > Pieter
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Dmitry Kurochkin
On Fri, 24 Feb 2012 00:07:27 +0100, Pieter Praet  wrote:
> On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  wrote:
> > On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin 
> >  wrote:
> > > Changes:
> > > 
> > > v4:
> > > 
> > > * rebased on master, no conflicts so no need for another review
> > > 
> > 
> > I pushed this series.  
> > 
> > Maybe this was discussed already, but I think ideally * would apply only
> > to open messages. So consider that a feature request if someone is
> > looking for a project.
> >
> 
> How about if '*' applies to all messages (as it currently does),
> but 'C-u *' only to open messages?  That would make more sense IMHO.
> 
> But, conforming to your original request, I've implemented the inverse.
> 

I personally do like '*' as is and do not want to change it's behavior.
Though I am not against adding a prefix argument for it.

Regards,
  Dmitry

> Patches follow.
> 
> 
> > d
> > ___
> > notmuch mailing list
> > notmuch@notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
> 
> 
> Peace
> 
> -- 
> Pieter
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


notmuch as a shared object aka library knigge

2012-02-24 Thread Justus Winter
Quoting David Bremner (2012-02-24 01:33:20)
>On Thu, 23 Feb 2012 23:22:00 +0100, Justus Winter <4winter at 
>informatik.uni-hamburg.de> wrote:
>
>> I've got a lot of ideas how to improve the python bindings and have
>> been refactoring it in the past few days. And while doing so I came
>> across a few problems in the library, one of which was so easy to fix
>> that I did just that.
>
>BTW, it would be nice if some of the non-trivial patches were sent to
>the list. I'm not suggesting any particular workflow, but there are
>certainly others interested in the Python bindings, and who might have
>useful comments.

Sure, I'll do that before doing any invasive changes. So far I've been
breaking the code apart and did mostly doc fixes, wrapped one more
function, fixing bugs here and there.

Justus


notmuch as a shared object aka library knigge

2012-02-24 Thread Justus Winter
Quoting David Bremner (2012-02-24 01:29:36)
>On Thu, 23 Feb 2012 23:22:00 +0100, Justus Winter <4winter at 
>informatik.uni-hamburg.de> wrote:
>
>> That wasn't meant to sound as harsh as it probably did. I seriously
>> hope that someone is around who enjoys to hack on the c/c++ part of
>> the library and is willing fix problems in it.
>
>Luckily I deleted my snarky reply ;).

*phew* ;)

>> And I worked around the two functions (that I know of) that call
>> exit(3) by conditionally raising exceptions in the python bindings,
>> but this is only meant as a intermediate fix, a hack that should be
>> removed as soon as the library is fixed.
>
>Can you make test cases to document exactly when internal errors are
>occuring in the library? Somehow it seems like the CLI is not triggering
>them. It might help clarify the discussion and/or motivate people to fix
>them.

I did ;) I provided a python program in my original mail for
Database.get_directory aka notmuch_database_get_directory and the one
for Database.find_message_by_filename aka
notmuch_database_find_message_by_filename can be trivially derived
from it (though you need a path to a mail within your maildir). It
should be straight forward to port those to c if you want to.

Justus


[PATCH] test: Add test for searching of uncommonly encoded messages

2012-02-24 Thread Michal Sojka
Emails that are encoded differently than as ASCII or UTF-8 are not
indexed properly by notmuch. It is not possible to search for non-ASCII
words within those messages.
---
 test/encoding|9 +
 test/test-lib.sh |5 +
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/test/encoding b/test/encoding
index 33259c1..3992b5c 100755
--- a/test/encoding
+++ b/test/encoding
@@ -21,4 +21,13 @@ irrelevant
 body}
 message}"

+test_begin_subtest "Search for ISO-8859-2 encoded message"
+test_subtest_known_broken
+add_message '[content-type]="text/plain; charset=iso-8859-2"' \
+'[content-transfer-encoding]=8bit' \
+'[subject]="ISO-8859-2 encoded message"' \
+"[body]=$'Czech word tu\350\362\341\350\350\355 means 
pinguin\'s.'" # ISO-8859-2 characters are generated by shell's escape sequences
+output=$(notmuch search tu?? 2>&1 | notmuch_show_sanitize)
+test_expect_equal "$output" "thread:0002   2001-01-05 [1/1] 
Notmuch Test Suite; ISO-8859-2 encoded message (inbox unread)"
+
 test_done
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 063a2b2..2781506 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -356,6 +356,11 @@ ${additional_headers}"
 ${additional_headers}"
 fi

+if [ ! -z "${template[content-transfer-encoding]}" ]; then
+   additional_headers="Content-Transfer-Encoding: 
${template[content-transfer-encoding]}
+${additional_headers}"
+fi
+
 # Note that in the way we're setting it above and using it below,
 # `additional_headers' will also serve as the header / body separator
 # (empty line in between).
-- 
1.7.9.1



Searching through different charsets

2012-02-24 Thread Michal Sojka
On Wed, 22 Feb 2012, Serge Z wrote:
> 
> Hello!
> 
> I've got the following problem: fetched emails can be in different encodings.
> And searching a term typed in one encoding (system default) does not match the
> same term in another encoding.
> 
> The solution, as I see, can be in preprocessing each incoming email to
> "normalize" it and its encoding so that indexer will handle emails in system
> encoding only. Could you please suggest something?

I can confirm this issue and sending a patch with test case (marked as
broken) for this. I expect the fix to be quite simple because all
encoding/docoding stuff is already implemented in gmime which is used by
notmuch when indexing.

> 
> Another issue (not so much wanted but wanted too) is searching through html
> messages without matching html tags.

I don't know whether somebody works on this or nor.

> This problem looks to be solvable by properly configured run-mailcap. Is there
> such solution anywhere?

I don't think that run-mailcap has anything to do with notmuch.

-Michal


Re: [PATCH] test: Add test for searching of uncommonly encoded messages

2012-02-24 Thread Michal Sojka
On Fri, 24 Feb 2012, Serge Z wrote:
> 
> Quoting Michal Sojka (2012-02-24 11:00:02)
> >I'm not big fan of adding "preprocessor". First, I thing that both
> >reasons you mention are actually bugs and it would be better to fix them
> >for everybody than requiring each user to configure some preprocessor.
> >Second, depending on what and how would your preprocessor do, the
> >initial mail indexing could be a way slower, which is also nothing that
> >people want.
> >
> >Do you have any other use case for the preprocessor besides utf8 and
> >html->text conversions?
> >
> >Cheers,
> >-Michal
> 
> Well, I don't want to add any external preprocessor too.
> 
> This may be considered as an architectural decision: search engine should not
> access messages directly, but through some preprocessing layer which would
> handle the case of different encodings in body and headers, RFC2047-encoded
> headers (if this is not handled yet) etc.
> 
> Anyway, this solution imho would be nice to be concluded inside a separate
> library

Yes, this library is called gmime and notmuch already make use of it.

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


[PATCH 6/6] emacs: `notmuch-show-tag-all' sans prefix arg only tags open messages

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el

  (notmuch-show-get-messages-ids):
New optional argument ONLY-OPEN.  If non-nil, only return
Message-Id's for messages which are currently visible.

  (notmuch-show-tag-all):
New optional argument IGNORE-VISIBILITY, of which the inverse is
passed as ONLY-OPEN argument to `notmuch-show-get-messages-ids':
If called with a prefix arg, affect *all* messages in the current
buffer.  Otherwise, only change tags of visible messages.

  (notmuch-show-archive-thread):
Update wrt changes to `notmuch-show-tag-all'.

* test/emacs

  - Subtest "notmuch-show: change tags of open messages in current buffer"
is no longer broken.
---
 emacs/notmuch-show.el |   28 
 test/emacs|1 -
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 4b37c77..4499fcd 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1334,13 +1334,17 @@ (defun notmuch-show-get-message-id ()
   "Return the message id of the current message."
   (concat "id:\"" (notmuch-show-get-prop :id) "\""))

-(defun notmuch-show-get-messages-ids (&optional separator)
+(defun notmuch-show-get-messages-ids (&optional only-open separator)
   "Return a list of Message-Id's of all messages in the current buffer.

+If optional argument ONLY-OPEN is non-nil, only return
+Message-Id's for messages which are currently visible.
+
 If provided with optional argument SEPARATOR, return a string
 instead, consisting of all Message-Id's separated by SEPARATOR."
   (let ((message-ids))
-(notmuch-show-mapc t
+(notmuch-show-mapc
+ `(if only-open (notmuch-show-message-visible-p) t)
  (lambda () (push (notmuch-show-get-message-id) message-ids)))
 (if separator
(mapconcat 'identity message-ids separator)
@@ -1628,13 +1632,21 @@ (defun notmuch-show-tag (&optional initial-input)
  initial-input (notmuch-show-get-message-id
 (apply 'notmuch-show-tag-message tag-changes)))

-(defun notmuch-show-tag-all (&rest tag-changes)
-  "Change tags for all messages in the current thread.
+(defun notmuch-show-tag-all (&optional ignore-visibility &rest tag-changes)
+  "Change tags of all open messages in the current buffer.
+
+If optional arg IGNORE-VISIBILITY is non-nil, change tags of
+*all* messages in the current buffer, independent of their
+visibility.

 TAG-CHANGES is a list of tag operations for `notmuch-tag'."
-  (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
-  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
-  (notmuch-show-mapc t
+  (interactive (cons current-prefix-arg
+(notmuch-read-tag-changes nil notmuch-show-thread-id)))
+  (apply 'notmuch-tag
+(notmuch-show-get-messages-ids (not ignore-visibility) " or ")
+tag-changes)
+  (notmuch-show-mapc
+   `(if ignore-visibility t (notmuch-show-message-visible-p))
(lambda ()
  (let* ((current-tags (notmuch-show-get-tags))
(new-tags (notmuch-update-tags current-tags tag-changes)))
@@ -1719,7 +1731,7 @@ (defun notmuch-show-archive-thread (&optional unarchive)
 buffer."
   (interactive "P")
   (let ((op (if unarchive "+" "-")))
-(notmuch-show-tag-all (concat op "inbox"
+(notmuch-show-tag-all t (concat op "inbox"

 (defun notmuch-show-archive-thread-then-next ()
   "Archive each message in thread, then show next thread from search."
diff --git a/test/emacs b/test/emacs
index 644ef59..c286ff5 100755
--- a/test/emacs
+++ b/test/emacs
@@ -152,7 +152,6 @@ notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert 
tag changes
 test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL

 test_begin_subtest "notmuch-show: change tags of open messages in current 
buffer"
-test_subtest_known_broken
 query="$os_x_darwin_thread"
 filter="from:Jiang"
 add_tag="notmuch-show-tag-all"
-- 
1.7.8.1



[PATCH 5/6] emacs: simplify `notmuch-show-get-messages-ids{, -search}'

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el

  (notmuch-show-get-messages-ids):
If provided with optional arg SEPARATOR, return a string consisting
of all Message-Id's, separated by SEPARATOR.  Also improve original
docstring wrt default return value.

  (notmuch-show-get-messages-ids-search):
Removed, as its functionality is now in `notmuch-show-get-messages-ids'.

  (notmuch-show-tag-all):
Call `notmuch-show-get-messages-ids' with SEPARATOR arg instead of
`notmuch-show-get-messages-ids-search'.
---
 emacs/notmuch-show.el |   18 +-
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 5fc0e43..4b37c77 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1334,17 +1334,17 @@ (defun notmuch-show-get-message-id ()
   "Return the message id of the current message."
   (concat "id:\"" (notmuch-show-get-prop :id) "\""))

-(defun notmuch-show-get-messages-ids ()
-  "Return all message ids of messages in the current thread."
+(defun notmuch-show-get-messages-ids (&optional separator)
+  "Return a list of Message-Id's of all messages in the current buffer.
+
+If provided with optional argument SEPARATOR, return a string
+instead, consisting of all Message-Id's separated by SEPARATOR."
   (let ((message-ids))
 (notmuch-show-mapc t
  (lambda () (push (notmuch-show-get-message-id) message-ids)))
-message-ids))
-
-(defun notmuch-show-get-messages-ids-search ()
-  "Return a search string for all message ids of messages in the
-current thread."
-  (mapconcat 'identity (notmuch-show-get-messages-ids) " or "))
+(if separator
+   (mapconcat 'identity message-ids separator)
+  message-ids)))

 ;; dme: Would it make sense to use a macro for many of these?

@@ -1633,7 +1633,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)

 TAG-CHANGES is a list of tag operations for `notmuch-tag'."
   (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
-  (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
+  (apply 'notmuch-tag (notmuch-show-get-messages-ids " or ") tag-changes)
   (notmuch-show-mapc t
(lambda ()
  (let* ((current-tags (notmuch-show-get-tags))
-- 
1.7.8.1



[PATCH 4/6] emacs: add predicate arg to `notmuch-show-mapc'

2012-02-24 Thread Pieter Praet
* emacs/notmuch-show.el

  (notmuch-show-mapc):
Only call FUNCTION if new argument PREDICATE is satisfied.
Also correct original docstring: 's/thread/buffer/'.

  (notmuch-show-get-messages-ids):
Update wrt changes to `notmuch-show-mapc'.

  (notmuch-show-tag-all):
Update wrt changes to `notmuch-show-mapc'.
---
 emacs/notmuch-show.el |   15 ---
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index aa9ccee..5fc0e43 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1272,13 +1272,14 @@ (defun notmuch-show-goto-message-previous ()
 (notmuch-show-move-to-message-top)
 t))

-(defun notmuch-show-mapc (function)
-  "Iterate through all messages in the current thread with
-`notmuch-show-goto-message-next' and call FUNCTION for side
-effects."
+(defun notmuch-show-mapc (predicate function)
+  "Iterate through all messages in the current buffer with
+`notmuch-show-goto-message-next'.  If PREDICATE is satisfied,
+call FUNCTION for side effects."
   (save-excursion
 (goto-char (point-min))
-(loop do (funcall function)
+(loop do (if (eval predicate)
+(funcall function))
  while (notmuch-show-goto-message-next

 ;; Functions relating to the visibility of messages and their
@@ -1336,7 +1337,7 @@ (defun notmuch-show-get-message-id ()
 (defun notmuch-show-get-messages-ids ()
   "Return all message ids of messages in the current thread."
   (let ((message-ids))
-(notmuch-show-mapc
+(notmuch-show-mapc t
  (lambda () (push (notmuch-show-get-message-id) message-ids)))
 message-ids))

@@ -1633,7 +1634,7 @@ (defun notmuch-show-tag-all (&rest tag-changes)
 TAG-CHANGES is a list of tag operations for `notmuch-tag'."
   (interactive (notmuch-read-tag-changes nil notmuch-show-thread-id))
   (apply 'notmuch-tag (notmuch-show-get-messages-ids-search) tag-changes)
-  (notmuch-show-mapc
+  (notmuch-show-mapc t
(lambda ()
  (let* ((current-tags (notmuch-show-get-tags))
(new-tags (notmuch-update-tags current-tags tag-changes)))
-- 
1.7.8.1



[PATCH 3/6] test: emacs: `notmuch-show-tag-all' sans prefix arg should only tag open messages

2012-02-24 Thread Pieter Praet
* test/emacs:

  - Alter subtest "notmuch-show: change tags of all messages in current buffer":
Pass a prefix arg to `notmuch-show-tag-all' ("*").

  - New subtest "notmuch-show: change tags of open messages in current buffer":
When called *without* a prefix arg, `notmuch-show-tag-all' ("*") should only
change the tags of *open* messages.  Currently broken, fix follows later.
---
 test/emacs |   18 +-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/test/emacs b/test/emacs
index d2dbafc..644ef59 100755
--- a/test/emacs
+++ b/test/emacs
@@ -146,11 +146,27 @@ count_match=$(notmuch count -- "$query" AND "$filter") # 
= 2
 test_emacs "(notmuch-search \"$query AND $filter\")
 (notmuch-test-wait)
 (notmuch-search-show-thread)
-(execute-kbd-macro \"*+$add_tag -$del_tag\")"
+(execute-kbd-macro \"*+$add_tag -$del_tag\")"
 count_changed=$(notmuch count -- "$query" AND tag:"$add_tag" AND NOT 
tag:"$del_tag")
 notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
 test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL

+test_begin_subtest "notmuch-show: change tags of open messages in current 
buffer"
+test_subtest_known_broken
+query="$os_x_darwin_thread"
+filter="from:Jiang"
+add_tag="notmuch-show-tag-all"
+del_tag="inbox"
+count_total=$(notmuch count -- "$query")   # = 4
+count_match=$(notmuch count -- "$query" AND "$filter") # = 2
+test_emacs "(notmuch-search \"$query AND $filter\")
+(notmuch-test-wait)
+(notmuch-search-show-thread)
+(execute-kbd-macro \"*+$add_tag -$del_tag\")"
+count_changed=$(notmuch count -- "$query" AND tag:"$add_tag" AND NOT 
tag:"$del_tag")
+notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
+test_expect_equal "$count_changed" "$count_match" # assert that CHANGED == 
MATCHING
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456 at example '[subject]="Message with .. in 
Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456 at example\"")
-- 
1.7.8.1



[PATCH 2/6] test: emacs: new test "notmuch-show: change tags of all messages in current buffer"

2012-02-24 Thread Pieter Praet
* test/emacs:

  New subtest "notmuch-show: change tags of all messages in current buffer":
  `notmuch-show-tag-all' ("*") changes tags of *all* messages in current buffer.
---
 test/emacs |   15 +++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/test/emacs b/test/emacs
index ec1dbb0..d2dbafc 100755
--- a/test/emacs
+++ b/test/emacs
@@ -136,6 +136,21 @@ test_emacs "(notmuch-show \"$os_x_darwin_thread\")
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"

+test_begin_subtest "notmuch-show: change tags of all messages in current 
buffer"
+query="$os_x_darwin_thread"
+filter="from:Jiang"
+add_tag="notmuch-show-tag-all"
+del_tag="inbox"
+count_total=$(notmuch count -- "$query")   # = 4
+count_match=$(notmuch count -- "$query" AND "$filter") # = 2
+test_emacs "(notmuch-search \"$query AND $filter\")
+(notmuch-test-wait)
+(notmuch-search-show-thread)
+(execute-kbd-macro \"*+$add_tag -$del_tag\")"
+count_changed=$(notmuch count -- "$query" AND tag:"$add_tag" AND NOT 
tag:"$del_tag")
+notmuch tag +"$del_tag" -"$add_tag" -- "$query" # revert tag changes
+test_expect_equal "$count_changed" "$count_total" # assert that CHANGED == 
TOTAL
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456 at example '[subject]="Message with .. in 
Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456 at example\"")
-- 
1.7.8.1



[PATCH 1/6] test: emacs: new tests "notmuch-show: {add, remove} multiple tags {to, from} single message"

2012-02-24 Thread Pieter Praet
* test/emacs:

  - Rename subtests "{Add,Remove} tag from notmuch-show view" to
"notmuch-show: {add,remove} single tag {to,from} single message"
to be consistent with the following tests.

  - New subtest "notmuch-show: add multiple tags to single message":
`notmuch-show-add-tag' ("+") can add multiple tags to a message.

  - New subtest "notmuch-show: remove multiple tags from single message":
`notmuch-show-remove-tag' ("-") can remove multiple tags from a message.
---
 test/emacs |   16 ++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/test/emacs b/test/emacs
index b74cfa9..ec1dbb0 100755
--- a/test/emacs
+++ b/test/emacs
@@ -112,18 +112,30 @@ test_emacs "(notmuch-search \"$os_x_darwin_thread\")
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"

-test_begin_subtest "Add tag from notmuch-show view"
+test_begin_subtest "notmuch-show: add single tag to single message"
 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
(execute-kbd-macro \"+tag-from-show-view\")"
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
tag-from-show-view unread)"

-test_begin_subtest "Remove tag from notmuch-show view"
+test_begin_subtest "notmuch-show: remove single tag from single message"
 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
(execute-kbd-macro \"-tag-from-show-view\")"
 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"

+test_begin_subtest "notmuch-show: add multiple tags to single message"
+test_emacs "(notmuch-show \"$os_x_darwin_thread\")
+   (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
+output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
tag1-from-show-view tag2-from-show-view unread)"
+
+test_begin_subtest "notmuch-show: remove multiple tags from single message"
+test_emacs "(notmuch-show \"$os_x_darwin_thread\")
+   (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
+output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
+test_expect_equal "$output" "thread:XXX   2009-11-18 [4/4] Jjgod Jiang, 
Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox 
unread)"
+
 test_begin_subtest "Message with .. in Message-Id:"
 add_message [id]=123..456 at example '[subject]="Message with .. in 
Message-Id"'
 test_emacs '(notmuch-search "id:\"123..456 at example\"")
-- 
1.7.8.1



[PATCH v5 00/12] emacs: more flexible and consistent tagging operations

2012-02-24 Thread Pieter Praet
On Wed, 08 Feb 2012 11:58:32 -0400, David Bremner  wrote:
> On Sun,  5 Feb 2012 11:13:41 +0400, Dmitry Kurochkin  gmail.com> wrote:
> > Changes:
> > 
> > v4:
> > 
> > * rebased on master, no conflicts so no need for another review
> > 
> 
> I pushed this series.  
> 
> Maybe this was discussed already, but I think ideally * would apply only
> to open messages. So consider that a feature request if someone is
> looking for a project.
>

How about if '*' applies to all messages (as it currently does),
but 'C-u *' only to open messages?  That would make more sense IMHO.

But, conforming to your original request, I've implemented the inverse.

Patches follow.


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


Peace

-- 
Pieter