[PATCH 3/5] emacs: Allow the indentation of content to be toggled.

2012-01-31 Thread Mark Walters
On Tue, 31 Jan 2012 16:23:32 +, David Edmondson  wrote:
> On Tue, 31 Jan 2012 16:15:11 +, Mark Walters  gmail.com> wrote:
> > Hi I have reviewed the patch series within the limits of my lisp
> > knowledge.  Patch 1: is rather beyond my lisp so I won't comment on that
> > (and I have never tried crypto): Patches 2-5 look fine with one
> > bikeshed and one query for my own understanding.
> 
> Thanks.
> 
> > The bikeshed is that I agree with Jani in
> > id:"CAB+hUn8KhXHTRCdrLe0cT=8mdtz9ZntPFf13mq0iCo4CX=B-Jg at mail.gmail.com"
> > that I would prefer to reserve '>' for saving a file.
> 
> '<' is 'remove indent', or 'look to the left'.
> '>' is 'toggle truncation', or 'look to the right'.
> 
> (I'm not overly worried about this - would 't' be more acceptable?)

I personally would prefer 't' but it is easy to remap so it really isn't
important.

Best wishes

Mark



[RFC PATCH v2] emacs: make show view a/A/x/X key bindings more consistent

2012-01-31 Thread Jani Nikula
Modify the show view key bindings as follows to make them more
consistent:

'a' = Archive current message, then move to next message, or show next
thread from search if at the last message in thread.

'A' = Archive each message in thread, then show next thread from
search.

'x' = Archive current message, then move to next message, or exit back
to search results if at the last message in thread.

'X' = Archive each message in thread, then exit back to search
results.

The changes make the key bindings more consistent in two ways:
1) 'a'/'A' both advance to the next thread like 'a' used to.
2) 'x' operates on messages and 'X' on threads like 'a'/'A'.

---

The original proposal with some discussion is at
http://titanpad.com/SA39EbNezU.

This v2 is merely a slightly polished version of the original. There
will be no further contributions on the subject from me.
---
 emacs/notmuch-show.el |   28 ++--
 1 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index de9421e..57830b6 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1075,9 +1075,10 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
(define-key map "h" 'notmuch-show-toggle-headers)
(define-key map "-" 'notmuch-show-remove-tag)
(define-key map "+" 'notmuch-show-add-tag)
-   (define-key map "x" 'notmuch-show-archive-thread-then-exit)
-   (define-key map "a" 'notmuch-show-archive-message-then-next)
+   (define-key map "X" 'notmuch-show-archive-thread-then-exit)
+   (define-key map "x" 'notmuch-show-archive-message-then-next-or-exit)
(define-key map "A" 'notmuch-show-archive-thread-then-next)
+   (define-key map "a" 
'notmuch-show-archive-message-then-next-or-next-thread)
(define-key map "N" 'notmuch-show-next-message)
(define-key map "P" 'notmuch-show-previous-message)
(define-key map "n" 'notmuch-show-next-open-message)
@@ -1417,7 +1418,8 @@ thread, navigate to the next thread in the parent search 
buffer."

 If a prefix argument is given and this is the last open message
 in the thread, navigate to the next thread in the parent search
-buffer."
+buffer. Return t if there was a next open message in the thread
+to show, nil otherwise."
   (interactive "P")
   (let (r)
 (while (and (setq r (notmuch-show-goto-message-next))
@@ -1428,7 +1430,8 @@ buffer."
  (notmuch-show-message-adjust))
   (if pop-at-end
  (notmuch-show-next-thread)
-   (goto-char (point-max))
+   (goto-char (point-max
+r))

 (defun notmuch-show-previous-open-message ()
   "Show the previous open message."
@@ -1645,12 +1648,25 @@ removed)."
   (notmuch-show-add-tag "inbox")
 (notmuch-show-remove-tag "inbox")))

-(defun notmuch-show-archive-message-then-next ()
-  "Archive the current message, then show the next open message in the current 
thread."
+(defun notmuch-show-archive-message-then-next-or-exit ()
+  "Archive the current message, then show the next open message in the current 
thread.
+
+If at the last open message in the current thread, then exit back
+to search results."
   (interactive)
   (notmuch-show-archive-message)
   (notmuch-show-next-open-message t))

+(defun notmuch-show-archive-message-then-next-or-next-thread ()
+  "Archive the current message, then show the next open message in the current 
thread.
+
+If at the last open message in the current thread, then show next
+thread from search."
+  (interactive)
+  (notmuch-show-archive-message)
+  (unless (notmuch-show-next-open-message)
+(notmuch-show-next-thread t)))
+
 (defun notmuch-show-stash-cc ()
   "Copy CC field of current message to kill-ring."
   (interactive)
-- 
1.7.5.4



[PATCH] added support for user-specified files & directories to ignore

2012-01-31 Thread Tomi Ollila
A new configuration key 'new.ignore' is used to determine which
files and directories user wants not to be scanned as new mails.

This work merges my previous attempts and Andreas Amann's work
in id:"ylp7hi23mw8.fsf at tyndall.ie"

See notes in id:"20120131-new-ignore-1-git-send-email-too at iki.fi"
---
Notes

1) Currently there is comment for new.ignore in newly created configuration
file but as the list is initially empty there will be not tag in place.

2) Whenever some already existing directory is added to the exclude list
and the parent directory timestamp has not changed, notmuch new will not
notice the directory has gone (as it still is there), user needs to 'touch'
the parent directory before next 'notmuch new' no make notmuch notice.

2012-01-26: could notmuch track mtime of the configuration file and if
that changes, ignore mail directory timestamps ?


3) in id:"1327572718-13411-2-git-send-email-tomi.ollila at iki.fi" dropped...

 notmuch-client.h |8 
 notmuch-config.c |   35 +--
 notmuch-new.c|   45 +
 3 files changed, 74 insertions(+), 14 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index e0eb594..c62ce78 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -250,6 +250,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
 const char *new_tags[],
 size_t length);

+const char **
+notmuch_config_get_new_ignore (notmuch_config_t *config,
+  size_t *length);
+void
+notmuch_config_set_new_ignore (notmuch_config_t *config,
+  const char *new_ignore[],
+  size_t length);
+
 notmuch_bool_t
 notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);

diff --git a/notmuch-config.c b/notmuch-config.c
index a124e34..f1cc5c2 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -44,7 +44,10 @@ static const char new_config_comment[] =
 " The following options are supported here:\n"
 "\n"
 "\ttagsA list (separated by ';') of the tags that will be\n"
-"\tadded to all messages incorporated by \"notmuch new\".\n";
+"\tadded to all messages incorporated by \"notmuch new\".\n"
+"\n"
+"\tignore  A list (separated by ';') of files and directories that"
+"\twill not be searched for messages by \"notmuch new\".\n";

 static const char user_config_comment[] =
 " User configuration\n"
@@ -105,6 +108,8 @@ struct _notmuch_config {
 size_t user_other_email_length;
 const char **new_tags;
 size_t new_tags_length;
+const char **new_ignore;
+size_t new_ignore_length;
 notmuch_bool_t maildir_synchronize_flags;
 const char **search_exclude_tags;
 size_t search_exclude_tags_length;
@@ -264,6 +269,8 @@ notmuch_config_open (void *ctx,
 config->user_other_email_length = 0;
 config->new_tags = NULL;
 config->new_tags_length = 0;
+config->new_ignore = NULL;
+config->new_ignore_length = 0;
 config->maildir_synchronize_flags = TRUE;
 config->search_exclude_tags = NULL;
 config->search_exclude_tags_length = 0;
@@ -360,7 +367,11 @@ notmuch_config_open (void *ctx,
 const char *tags[] = { "unread", "inbox" };
notmuch_config_set_new_tags (config, tags, 2);
 }
-
+#if 0 /* No point setting empty list -- it's not written */
+if (notmuch_config_get_new_ignore (config, ) == NULL) {
+   notmuch_config_set_new_ignore (config, NULL, 0);
+}
+#endif
 if (notmuch_config_get_search_exclude_tags (config, ) == NULL) {
if (is_new) {
const char *tags[] = { "deleted", "spam" };
@@ -609,6 +620,15 @@ notmuch_config_get_new_tags (notmuch_config_t *config,   
size_t *length)
 &(config->new_tags_length), length);
 }

+const char **
+notmuch_config_get_new_ignore (notmuch_config_t *config,   size_t *length)
+{
+return _config_get_list (config, "new", "ignore",
+&(config->new_ignore),
+&(config->new_ignore_length), length);
+}
+
+
 void
 notmuch_config_set_user_other_email (notmuch_config_t *config,
 const char *list[],
@@ -627,6 +647,17 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
 &(config->new_tags));
 }

+#if 0 /* UNNEEDED SO FAR */
+void
+notmuch_config_set_new_ignore (notmuch_config_t *config,
+  const char *list[],
+  size_t length)
+{
+_config_set_list (config, "new", "ignore", list, length,
+   

[RFC PATCH] emacs: make show view a/A/x/X key bindings more consistent

2012-01-31 Thread Jani Nikula
Proposal for show view a/A/x/X key bindings, according to
http://titanpad.com/SA39EbNezU and IRC discussion:

'a' = Archive current message, then move to next message, or show next
thread from search if at the last message in thread.

'A' = Archive each message in thread, then show next thread from
search.

'x' = Archive current message, then move to next message, or exit back
to search results if at the last message in thread.

'X' = Archive each message in thread, then exit back to search
results.

IMHO these changes would make the current implementation more
consistent in two ways: 1) 'a'/'A' would advance to next thread like
'a' used to do, 2) 'x' would operate on messages and 'X' on threads
like 'a'/'A' do now.

The implementation here is hacky at best, and I agree with dme that
notmuch-show.el could use some code cleanup and provide
non-interactive primitives. However I won't have the time and energy
for that right now.
---
 emacs/notmuch-show.el |   26 --
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index de9421e..62f3664 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1075,9 +1075,10 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
(define-key map "h" 'notmuch-show-toggle-headers)
(define-key map "-" 'notmuch-show-remove-tag)
(define-key map "+" 'notmuch-show-add-tag)
-   (define-key map "x" 'notmuch-show-archive-thread-then-exit)
-   (define-key map "a" 'notmuch-show-archive-message-then-next)
+   (define-key map "X" 'notmuch-show-archive-thread-then-exit)
+   (define-key map "x" 'notmuch-show-archive-message-then-next-then-exit)
(define-key map "A" 'notmuch-show-archive-thread-then-next)
+   (define-key map "a" 'notmuch-show-archive-message-then-next-then-next)
(define-key map "N" 'notmuch-show-next-message)
(define-key map "P" 'notmuch-show-previous-message)
(define-key map "n" 'notmuch-show-next-open-message)
@@ -1425,10 +1426,12 @@ buffer."
 (if r
(progn
  (notmuch-show-mark-read)
- (notmuch-show-message-adjust))
+ (notmuch-show-message-adjust)
+ t)
   (if pop-at-end
  (notmuch-show-next-thread)
-   (goto-char (point-max))
+   (goto-char (point-max))
+   nil

 (defun notmuch-show-previous-open-message ()
   "Show the previous open message."
@@ -1645,12 +1648,23 @@ removed)."
   (notmuch-show-add-tag "inbox")
 (notmuch-show-remove-tag "inbox")))

-(defun notmuch-show-archive-message-then-next ()
-  "Archive the current message, then show the next open message in the current 
thread."
+(defun notmuch-show-archive-message-then-next-then-exit ()
+  "Archive the current message, then show the next open message in the current 
thread.
+
+If at the last message in thread, then exit back to search results."
   (interactive)
   (notmuch-show-archive-message)
   (notmuch-show-next-open-message t))

+(defun notmuch-show-archive-message-then-next-then-next ()
+  "Archive the current message, then show the next open message in the current 
thread.
+
+If at the last message in thread, then show next thread from search."
+  (interactive)
+  (notmuch-show-archive-message)
+  (unless (notmuch-show-next-open-message)
+(notmuch-show-next-thread t)))
+
 (defun notmuch-show-stash-cc ()
   "Copy CC field of current message to kill-ring."
   (interactive)
-- 
1.7.5.4



[PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 08:31:26 -0800, Jameson Graef Rollins  wrote:
> On Tue, 31 Jan 2012 08:09:08 +, David Edmondson  wrote:
> > On Mon, 30 Jan 2012 09:47:34 -0800, Jameson Graef Rollins  > finestructure.net> wrote:
> > > One thing I've noticed, which isn't actually part of this patch, is that
> > > the long-line truncation doesn't respect the indentation, which makes
> > > things look strange.
> > 
> > Which lines are getting wrapped in a way that you don't like? The header
> > line? The headers? The body?
> 
> Header lines, such as Subject, To, Cc, etc.

You could try out id:"1327565871-19729-3-git-send-email-dme at dme.org".

> > > But honestly I still don't like our method of displaying threads as a
> > > giant chain of concatenated messages with indentation.  But that's for
> > > later work.
> > 
> > It's inherited from sup, and is surely part of the "raison de notmuch"
> > :-)
> 
> Inheritance is not a good justification for anything, much less
> questionable UI choices (I seem to have inherited baldness from my dad.
> Thanks dad).

I didn't suggest that inheritance was justification. Whether it's a
questionable UI choice is largely a matter of personal preference. When
Carl started the project he chose to follow sup's example in this
respect. (Though sup is more aggressive in scrolling the display to the
left to accommodate deep threads.)

> Problems I have with the current approach:
> 
> - thread structure is opaque.  This is especially true with long
>   threads, where it can be next to impossible to see which messages are
>   replies to what.  This is by far my biggest pet peeve with the current
>   format.

A collapsed view of the current `notmuch-show-mode' buffer is not very
different to a mutt index view.

> - navigation through the thread is difficult.  This is related to above.
>   There's no way to simultaneously see the current message and the
>   thread structure, which again, makes it very difficult to find
>   children and parents.  This could possibly be fixed by having key
>   bindings that would navigate through parents, children and siblings of
>   the current message, but that might be tricky to implement.

It would be relatively simple to add the bindings you describe, based on
the computed thread depth of messages. So far I haven't particularly
missed being able to do it.

> - indentation of the entire message body is a really bad way to indicate
>   thread depth. I don't like how messages start to walk off screen as
>   threads get longer, or how copying regions of the body brings the
>   indentation with it.  Your indentation toggling will improve this a
>   bit, though, but I still think it's a bandaid on the larger issue.

The indentation works well until threads are more than about ten levels
deep, I find. It becomes unworkable after about twenty levels (but
conversations that deep tend to stress both the UI and myself in other
ways as well).

I don't copy regions of the `notmuch-show-mode' buffer, so that hasn't
been a problem.

> I must say that the approach I've been longing for is a modified version
> of what mutt has: a top pain that is just the thread structure (with
> nice branching lines), and a bottom pain that displays the current
> message.  I think that would be a much cleaner approach.

Nothing precludes the implementation of what you describe. It's not hard
to see how the two approaches could live side by side.
-- next part ------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/534682e2/attachment.pgp>


[PATCH 3/5] emacs: Allow the indentation of content to be toggled.

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 16:15:11 +, Mark Walters  
wrote:
> Hi I have reviewed the patch series within the limits of my lisp
> knowledge.  Patch 1: is rather beyond my lisp so I won't comment on that
> (and I have never tried crypto): Patches 2-5 look fine with one
> bikeshed and one query for my own understanding.

Thanks.

> The bikeshed is that I agree with Jani in
> id:"CAB+hUn8KhXHTRCdrLe0cT=8mdtz9ZntPFf13mq0iCo4CX=B-Jg at mail.gmail.com"
> that I would prefer to reserve '>' for saving a file.

'<' is 'remove indent', or 'look to the left'.
'>' is 'toggle truncation', or 'look to the right'.

(I'm not overly worried about this - would 't' be more acceptable?)

> The query: in
> 
> > +(props (notmuch-show-get-message-properties))
> > +(indenting notmuch-show-indent-content))
> >  (with-temp-buffer
> >(insert all)
> > -  (indent-rigidly (point-min) (point-max) (- depth))
> > +  (if indenting
> > + (indent-rigidly (point-min) (point-max) (- depth)))
> 
> Is the local variable `indenting' needed because
> notmuch-show-indent-content is buffer local and this is in the
> with-temp-buffer?

Yes.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/5c670fdf/attachment.pgp>


[PATCH 3/5] emacs: Allow the indentation of content to be toggled.

2012-01-31 Thread Mark Walters

Hi I have reviewed the patch series within the limits of my lisp
knowledge.  Patch 1: is rather beyond my lisp so I won't comment on that
(and I have never tried crypto): Patches 2-5 look fine with one
bikeshed and one query for my own understanding.

The bikeshed is that I agree with Jani in
id:"CAB+hUn8KhXHTRCdrLe0cT=8mdtz9ZntPFf13mq0iCo4CX=B-Jg at mail.gmail.com"
that I would prefer to reserve '>' for saving a file.

The query: in

> +  (props (notmuch-show-get-message-properties))
> +  (indenting notmuch-show-indent-content))
>  (with-temp-buffer
>(insert all)
> -  (indent-rigidly (point-min) (point-max) (- depth))
> +  (if indenting
> +   (indent-rigidly (point-min) (point-max) (- depth)))

Is the local variable `indenting' needed because
notmuch-show-indent-content is buffer local and this is in the
with-temp-buffer?

Thanks

Mark




[PATCH] emacs: Move the blank line from the bottom of the headers to the top of the body.

2012-01-31 Thread Dmitry Kurochkin
On Mon, 30 Jan 2012 16:52:20 +, David Edmondson  wrote:
> The blank line doesn't really change position, but is now considered
> to be part of the body rather than part of the headers. This means
> that it is visible when the body is visible rather than when the
> headers are visible.
> ---
> 
> I'm interested in getting feedback on this.
> 
> Unless you run with `notmuch-message-headers-visible' set to `nil' or
> regularly toggle header visibility, you probably don't care.
> 

+1

Regards,
  Dmitry

>  emacs/notmuch-show.el |4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 84ac624..73f73d4 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -854,8 +854,6 @@ current buffer, if possible."
>  ;; compatible with the existing implementation. This just sets it
>  ;; to after the first header.
>  (notmuch-show-insert-headers headers)
> -;; Headers should include a blank line (backwards compatibility).
> -(insert "\n")
>  (save-excursion
>(goto-char content-start)
>;; If the subject of this message is the same as that of the
> @@ -870,6 +868,8 @@ current buffer, if possible."
>  (setq notmuch-show-previous-subject bare-subject)
>  
>  (setq body-start (point-marker))
> +;; A blank line between the headers and the body.
> +(insert "\n")
>  (notmuch-show-insert-body msg (plist-get msg :body) depth)
>  ;; Ensure that the body ends with a newline.
>  (unless (bolp)
> -- 
> 1.7.8.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[RFC PATCH] emacs: make show view a/A/x/X key bindings more consistent

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 17:03:55 +0200, Jani Nikula  wrote:
> 'a' = Archive current message, then move to next message, or show next
> thread from search if at the last message in thread.
> 
> 'A' = Archive each message in thread, then show next thread from
> search.
> 
> 'x' = Archive current message, then move to next message, or exit back
> to search results if at the last message in thread.
> 
> 'X' = Archive each message in thread, then exit back to search
> results.

This seems consistent to me and would be an improvement.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/9b1f6938/attachment.pgp>


[PATCH] emacs: add default value to notmuch-search-line-faces

2012-01-31 Thread Jani Nikula
On Thu, 26 Jan 2012 23:58:51 +0200, Jani Nikula  wrote:
> On Thu, 26 Jan 2012 14:41:46 -0500, Austin Clements  
> wrote:
> > Quoth Jani Nikula on Jan 26 at  9:21 pm:
> > > +("flagged" :foreground "red"))
> > 
> > Red is pretty universally used to indicate danger or a serious
> > condition, while "flagged" is simply supposed to draw attention.  I
> > would say blue as a neutral and distinct indicator, but it also has
> > poor visibility (I used to use blue, but found that when scanning my
> > mail, I would habitually skip over flagged messages because they were
> > dark, which was the opposite of what I wanted).  Personally I've
> > settled on yellow; it's visually distinct enough to be easily
> > noticeable and bright enough that I don't skip over it, though it
> > obviously wouldn't work on a light background.
> 
> Can be yellow, I don't really care that much. But isn't a light
> background the default for emacs in most distros? If that matters,
> *shrug*.

Ugh, yellow is absolutely horrible on a white background... that would
certainly draw people to figure out how to change the settings. Now
shall I send v2 with bold for unread and yellow for flagged, or can this
go in as it is?

BR,
Jani.


[PATCH] emacs: Move the blank line from the bottom of the headers to the top of the body.

2012-01-31 Thread Tomi Ollila
On Tue, 31 Jan 2012 10:32:12 +, David Edmondson  wrote:
> On Mon, 30 Jan 2012 21:25:19 -0800, Jameson Graef Rollins  finestructure.net> wrote:
> > On Mon, 30 Jan 2012 16:52:20 +, David Edmondson  wrote:
> > > The blank line doesn't really change position, but is now considered
> > > to be part of the body rather than part of the headers. This means
> > > that it is visible when the body is visible rather than when the
> > > headers are visible.
> > 
> > This definitely makes sense.  I rarely hide headers anymore, but I never
> > liked that the separation between the headers and the body went away
> > when the headers are hidden.  +1.
> 
> Any objections to changing this?

+1 for changing this.


Tomi


[PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread Tomi Ollila
On Tue, 31 Jan 2012 10:30:20 +, David Edmondson  wrote:
> On Tue, 31 Jan 2012 11:25:36 +0200, Tomi Ollila  wrote:
> > I like David's alternative suggestion (in IRC) where cursor is left at
> > the end of buffer in case last message is archived with 'a'.
> 
> Unless the cursor is already at the end of the buffer, in which case it
> would do the 'next thread' dance (i.e. it behaves like 'space' in that
> respect).

I think I (and Jameson) don't want that behaviour -- therefore we need
functionality (somewhat) analogous to this:

(defun notmuch-show-advance-and-archive ()
"..."
  (interactive)
  (if (notmuch-show-advance)
  (notmuch-show-archive-thread-then-next)))

So we can easily rebind to the version which doesn't 
do the '...then-next' magic...

Tomi




[PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread Dmitry Kurochkin
On Tue, 31 Jan 2012 08:36:27 +, David Edmondson  wrote:
> On Tue, 31 Jan 2012 12:24:27 +0400, Dmitry Kurochkin  gmail.com> wrote:
> > This is why I like big diff contexts...
> 
> Can I set that in my .gitconfig?

Unfortunately, I did not find a way to do that, except for adding an
alias.  But that is a poor solution.  So I add -U20 parameter manually
for some patches.

Regards,
  Dmitry


[PATCH 5/7] cli: Make notmuch-show respect excludes.

2012-01-31 Thread Mark Walters
On Mon, 30 Jan 2012 23:56:24 -0500, Austin Clements  wrote:
> Quoth Mark Walters on Jan 29 at  6:39 pm:
> > This adds the excludes to notmuch-show.c. We do not exclude when only
> > a single message (or part) is requested. notmuch-show will output the
> > exclude information when either text or json format is requested. As
> > this changes the output from notmuch-show it breaks many tests (in a
> > trivial and expected fashion).
> > ---
> >  notmuch-show.c |   26 +-
> >  1 files changed, 21 insertions(+), 5 deletions(-)
> > 
> > diff --git a/notmuch-show.c b/notmuch-show.c
> > index dec799c..681827f 100644
> > --- a/notmuch-show.c
> > +++ b/notmuch-show.c
> > @@ -193,10 +193,12 @@ _get_one_line_summary (const void *ctx, 
> > notmuch_message_t *message)
> >  static void
> >  format_message_text (unused (const void *ctx), notmuch_message_t *message, 
> > int indent)
> >  {
> > -printf ("id:%s depth:%d match:%d filename:%s\n",
> > +/* Could changing this could break users ? */
> 
> I don't think anybody seriously tries to parse the text format, so I
> wouldn't worry about breaking anything.

Right: I will remove the comment.

> > +printf ("id:%s depth:%d match:%d excluded:%d filename:%s\n",
> > notmuch_message_get_message_id (message),
> > indent,
> > -   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
> > +   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 
> > : 0,
> > +   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 
> > 1 : 0,
> > notmuch_message_get_filename (message));
> >  }
> >  
> > @@ -212,9 +214,10 @@ format_message_json (const void *ctx, 
> > notmuch_message_t *message, unused (int in
> >  date = notmuch_message_get_date (message);
> >  relative_date = notmuch_time_relative_date (ctx, date);
> >  
> > -printf ("\"id\": %s, \"match\": %s, \"filename\": %s, \"timestamp\": 
> > %ld, \"date_relative\": \"%s\", \"tags\": [",
> > +printf ("\"id\": %s, \"match\": %s, \"excluded\": %s, \"filename\": 
> > %s, \"timestamp\": %ld, \"date_relative\": \"%s\", \"tags\": [",
> 
> I wonder if it would be better to switch to an array of flag names...
> That obviously would break consumers, but it's worth thinking about in
> the longer term.

Unless you have a strong feeling for this I will leave that for a later
patch.

> > json_quote_str (ctx_quote, notmuch_message_get_message_id 
> > (message)),
> > notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 
> > "true" : "false",
> > +   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 
> > "true" : "false",
> > json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
> > date, relative_date);
> >  
> > @@ -1059,9 +1062,13 @@ notmuch_show_command (void *ctx, unused (int argc), 
> > unused (char *argv[]))
> >  char *opt;
> >  const notmuch_show_format_t *format = _text;
> >  notmuch_show_params_t params;
> > +const char **search_exclude_tags;
> > +size_t search_exclude_tags_length;
> >  int mbox = 0;
> >  int format_specified = 0;
> >  int i;
> > +notmuch_bool_t do_not_exclude = FALSE;
> > +unsigned int j;
> >  
> >  params.entire_thread = 0;
> >  params.raw = 0;
> > @@ -1098,6 +1105,8 @@ notmuch_show_command (void *ctx, unused (int argc), 
> > unused (char *argv[]))
> > params.part = atoi(argv[i] + sizeof ("--part=") - 1);
> > } else if (STRNCMP_LITERAL (argv[i], "--entire-thread") == 0) {
> > params.entire_thread = 1;
> > +   } else if (STRNCMP_LITERAL (argv[i], "--do-not-exclude") == 0) {
> > +   do_not_exclude = TRUE;
> 
> "no-exclude" if you change the others.

See comment on first patch: will make sure they are consistent.

> > } else if ((STRNCMP_LITERAL (argv[i], "--verify") == 0) ||
> >(STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {
> > if (params.cryptoctx == NULL) {
> > @@ -1105,7 +1114,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
> > unused (char *argv[]))
> > /* TODO: GMimePasswordRequestFunc */
> > if (NULL == (params.cryptoctx = g_mime_gpg_context_new(NULL, 
> > "gpg")))
> >  #else
> > -   GMimeSession* session = g_object_new(g_mime_session_get_type(), 
> > NULL);
> > +   GMimeSession* session = 
> > g_object_new(g_mime_session_get_type(), NULL);
> 
> Accidental reindent?

Yes will fix.

> > if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, 
> > "gpg")))
> >  #endif
> > fprintf (stderr, "Failed to construct gpg context.\n");
> > @@ -1167,10 +1176,17 @@ notmuch_show_command (void *ctx, unused (int argc), 
> > unused (char *argv[]))
> >  if (params.raw && params.part < 0)
> > params.part = 0;
> >  
> > +/* if a single message is requested we do not use search_excludes */
> 
> Capital and period.

Will fix.

> >  if 

[PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread Dmitry Kurochkin
On Tue, 31 Jan 2012 08:22:20 +, David Edmondson  wrote:
> On Tue, 31 Jan 2012 12:12:50 +0400, Dmitry Kurochkin  gmail.com> wrote:
> > On Tue, 31 Jan 2012 08:01:54 +, David Edmondson  wrote:
> > > When using the spacebar to scroll through a thread, hitting 'space'
> > > when the bottom of the last message is visible should take the cursor
> > > to the end of the buffer rather than immediately archiving the thread
> > > and moving to the next thread.
> > > ---
> > 
> > I did not notice this change yet, so +0
> > 
> > A style comment below.
> > 
> > >  emacs/notmuch-show.el |5 +
> > >  1 files changed, 5 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > > index ec72ff8..3f54de0 100644
> > > --- a/emacs/notmuch-show.el
> > > +++ b/emacs/notmuch-show.el
> > > @@ -1319,6 +1319,11 @@ current window), advance to the next open message."
> > >;; This is not the last message - move to the next visible one.
> > >(notmuch-show-next-open-message))
> > >  
> > > + ((not (= (point) (point-max)))
> > > +  ;; This is the last message, but the cursor is not at the end of
> > > +  ;; the buffer. Move it there.
> > > +  (goto-char (point-max)))
> > 
> > Perhaps `unless' would be better here?
> 
> It's the CONDITION clause of `cond', so that wouldn't be appropriate.
> 

oh

This is why I like big diff contexts...

Regards,
  Dmitry

> > Regards,
> >   Dmitry
> > 
> > > +
> > >   (t
> > >;; This is the last message - change the return value
> > >(setq ret t)))
> > > -- 
> > > 1.7.8.3
> > > 
> > > ___
> > > notmuch mailing list
> > > notmuch at notmuchmail.org
> > > http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread Dmitry Kurochkin
On Tue, 31 Jan 2012 08:01:54 +, David Edmondson  wrote:
> When using the spacebar to scroll through a thread, hitting 'space'
> when the bottom of the last message is visible should take the cursor
> to the end of the buffer rather than immediately archiving the thread
> and moving to the next thread.
> ---

I did not notice this change yet, so +0

A style comment below.

>  emacs/notmuch-show.el |5 +
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index ec72ff8..3f54de0 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1319,6 +1319,11 @@ current window), advance to the next open message."
>;; This is not the last message - move to the next visible one.
>(notmuch-show-next-open-message))
>  
> + ((not (= (point) (point-max)))
> +  ;; This is the last message, but the cursor is not at the end of
> +  ;; the buffer. Move it there.
> +  (goto-char (point-max)))

Perhaps `unless' would be better here?

Regards,
  Dmitry

> +
>   (t
>;; This is the last message - change the return value
>(setq ret t)))
> -- 
> 1.7.8.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread Dmitry Kurochkin
On Tue, 31 Jan 2012 08:01:53 +, David Edmondson  wrote:
> When archiving the last message in a thread (a), rather than just
> moving the pointer to the next thread in the parent search buffer,
> actually display the next thread.
> ---

+1

Regards,
  Dmitry

>  emacs/notmuch-show.el |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index de9421e..ec72ff8 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1427,7 +1427,7 @@ buffer."
> (notmuch-show-mark-read)
> (notmuch-show-message-adjust))
>(if pop-at-end
> -   (notmuch-show-next-thread)
> +   (notmuch-show-next-thread t)
>   (goto-char (point-max))
>  
>  (defun notmuch-show-previous-open-message ()
> -- 
> 1.7.8.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 4/7] lib: Add the exclude flag to notmuch_query_search_threads

2012-01-31 Thread Mark Walters
On Mon, 30 Jan 2012 23:50:20 -0500, Austin Clements  wrote:
> Quoth Mark Walters on Jan 29 at  6:39 pm:
> > Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to
> > notmuch_query_search_threads. Implemented by inspecting the tags
> > directly in _notmuch_thread_create/_thread_add_message rather than as
> > a Xapian query for speed reasons.
> > ---
> >  lib/notmuch-private.h |   16 ++--
> >  lib/query.cc  |1 +
> >  lib/thread.cc |   18 +++---
> >  3 files changed, 26 insertions(+), 9 deletions(-)
> > 
> > diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
> > index e791bb0..56b87c6 100644
> > --- a/lib/notmuch-private.h
> > +++ b/lib/notmuch-private.h
> > @@ -211,12 +211,8 @@ _notmuch_directory_get_document_id 
> > (notmuch_directory_t *directory);
> >  
> >  /* thread.cc */
> >  
> > -notmuch_thread_t *
> > -_notmuch_thread_create (void *ctx,
> > -   notmuch_database_t *notmuch,
> > -   unsigned int seed_doc_id,
> > -   notmuch_doc_id_set_t *match_set,
> > -   notmuch_sort_t sort);
> > +/* Definition of _notmuch_thread_create moved later since now uses
> > + * string_list_t */
> 
> Naw, leave the definition here along with the other things from
> thread.cc and just add a
> 
>   typedef struct _notmuch_string_list notmuch_string_list_t;
> 
> along with the typedef for notmuch_doc_id_set_t near the top.  (You
> might also have to tweak the typedef of notmuch_string_list_t later so
> it's just the struct definition.)

Will do.

> >  /* message.cc */
> >  
> > @@ -492,6 +488,14 @@ notmuch_filenames_t *
> >  _notmuch_filenames_create (const void *ctx,
> >notmuch_string_list_t *list);
> >  
> > +notmuch_thread_t *
> > +_notmuch_thread_create (void *ctx,
> > +   notmuch_database_t *notmuch,
> > +   unsigned int seed_doc_id,
> > +   notmuch_doc_id_set_t *match_set,
> > +   notmuch_string_list_t *excluded_terms,
> > +   notmuch_sort_t sort);
> > +
> >  #pragma GCC visibility pop
> >  
> >  NOTMUCH_END_DECLS
> > diff --git a/lib/query.cc b/lib/query.cc
> > index 7d165d2..dee7ec0 100644
> > --- a/lib/query.cc
> > +++ b/lib/query.cc
> > @@ -472,6 +472,7 @@ notmuch_threads_get (notmuch_threads_t *threads)
> >threads->query->notmuch,
> >doc_id,
> >>match_set,
> > +  threads->query->exclude_terms,
> >threads->query->sort);
> >  }
> >  
> > diff --git a/lib/thread.cc b/lib/thread.cc
> > index 0435ee6..6d65d52 100644
> > --- a/lib/thread.cc
> > +++ b/lib/thread.cc
> > @@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
> >   */
> >  static void
> >  _thread_add_message (notmuch_thread_t *thread,
> > -notmuch_message_t *message)
> > +notmuch_message_t *message,
> > +notmuch_string_list_t *exclude_terms)
> >  {
> >  notmuch_tags_t *tags;
> >  const char *tag;
> > @@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,
> >  notmuch_tags_move_to_next (tags))
> >  {
> > tag = notmuch_tags_get (tags);
> > +   /* mark excluded messages */
> 
> Capital and period.

Will fix.

> > +   for (notmuch_string_node_t *term = exclude_terms->head; term;
> > +term = term->next) {
> > +   /* we ignore initial 'K' */
> 
> Same.

Will fix

> > +   if (strcmp(tag, (term->string + 1)) == 0) {
> > +   notmuch_message_set_flag (message, 
> > NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
> > +   break;
> > +   }
> > +   }
> > g_hash_table_insert (thread->tags, xstrdup (tag), NULL);
> >  }
> >  }
> > @@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,
> > _thread_set_subject_from_message (thread, message);
> >  }
> >  
> > -thread->matched_messages++;
> > +if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
> > +   thread->matched_messages++;
> 
> I'd still say this warrants a better API.

I agree: I will think about that.

> >  if (g_hash_table_lookup_extended (thread->message_hash,
> > notmuch_message_get_message_id (message), NULL,
> > @@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,
> > notmuch_database_t *notmuch,
> > unsigned int seed_doc_id,
> > notmuch_doc_id_set_t *match_set,
> > +   notmuch_string_list_t *exclude_terms,
> > notmuch_sort_t sort)
> >  {
> >  notmuch_thread_t *thread;
> > @@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,
> > if (doc_id == seed_doc_id)
> > message = seed_message;
> >  
> > -   _thread_add_message (thread, message);
> > +   _thread_add_message (thread, message, exclude_terms);
> >  
> > if ( 

[PATCH 3/7] lib: Make notmuch_query_search_messages set the exclude flag

2012-01-31 Thread Mark Walters
On Mon, 30 Jan 2012 23:43:52 -0500, Austin Clements  wrote:
> Quoth Mark Walters on Jan 29 at  6:39 pm:
> > 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 |8 ++-
> >  lib/query.cc  |   52 
> > +---
> >  3 files changed, 56 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;
> 
> I might be following the diff wrong, but shouldn't this be a field of
> notmuch_mset_messages_t?  (Then it also doesn't have to be a pointer,
> which is really how notmuch_doc_id_set_t was designed to be used.)

I will need to think about that.

> >  notmuch_message_node_t *iterator;
> >  };
> >  
> > diff --git a/lib/notmuch.h b/lib/notmuch.h
> > index 7929fe7..740d005 100644
> > --- a/lib/notmuch.h
> > +++ b/lib/notmuch.h
> > @@ -449,6 +449,11 @@ 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 */
> > +void
> > +notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
> > notmuch_bool_t omit);
> > +
> 
> I don't think we should add this API.  The library behavior will not
> change for library users that don't use excludes and library users
> that do use excludes should by aware of the excluded flag and do the
> appropriate thing.
> 
> I can see why this is handy in some cases, but I don't think it
> provides enough utility to warrant becoming part of the permanent and
> minimal library interface.

This is really a performance improvement: suppose that there are lots of
threads that only match in excluded messages. Then without this flag we
will spend lots of time constructing the thread only for it to be
ignored. (In contrived situations this could be arbitrarily slower.)

Note the benchmarks were against master with the exclude code switched
off so that I was comparing the creation of the same threads. Sorry if I
didn't make that clear.

> >  /* Specify the sorting desired for this query. */
> >  void
> >  notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
> > @@ -895,7 +900,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..7d165d2 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 */
> 
> Comments should start with a capital letter and end with a period.
> (The code isn't completely consistent about this, but it is something
> we're codifying in the upcoming style guide.)

Will fix

> > +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)
> >  

[PATCH 1/7] cli: add --do-not-exclude option to count and search.

2012-01-31 Thread Mark Walters

Thanks for the review. Almost all of it (for all all the patches) I
agree with and will just fix but I do have a couple of queries.

On Mon, 30 Jan 2012 23:17:32 -0500, Austin Clements  wrote:
> Quoth Mark Walters on Jan 29 at  6:39 pm:
> > This option turns off the exclusion so all matching messages are
> > returned. We do not need to add this to show as notmuch-show does not
> > (yet) exclude.
> > ---
> >  notmuch-count.c  |   12 
> >  notmuch-search.c |   12 
> >  2 files changed, 16 insertions(+), 8 deletions(-)
> > 
> > diff --git a/notmuch-count.c b/notmuch-count.c
> > index 63459fb..c88975e 100644
> > --- a/notmuch-count.c
> > +++ b/notmuch-count.c
> > @@ -37,6 +37,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
> >  int output = OUTPUT_MESSAGES;
> >  const char **search_exclude_tags;
> >  size_t search_exclude_tags_length;
> > +notmuch_bool_t do_not_exclude = FALSE;
> >  unsigned int i;
> >  
> >  notmuch_opt_desc_t options[] = {
> > @@ -44,6 +45,7 @@ notmuch_count_command (void *ctx, int argc, char *argv[])
> >   (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
> >   { "messages", OUTPUT_MESSAGES },
> >   { 0, 0 } } },
> > +   { NOTMUCH_OPT_BOOLEAN,  _not_exclude, "do-not-exclude", 'd', 0 },
> 
> Maybe just "no-exclude"?  "do-not-exclude" seems needlessly verbose.

The reason I went for verbose do-not-exclude was to try and avoid the
double negative ambiguity: does no-exclude mean do-not-exclude or
do-note-return-excluded-messages. Possibly I am worrying needlessly, and
obviously I am quite happy to change.

> Also, you have an extra space after the first comma.

Will fix.

> 
> > { 0, 0, 0, 0, 0 }
> >  };
> >  
> > @@ -78,10 +80,12 @@ notmuch_count_command (void *ctx, int argc, char 
> > *argv[])
> > return 1;
> >  }
> >  
> > -search_exclude_tags = notmuch_config_get_search_exclude_tags
> > -   (config, _exclude_tags_length);
> > -for (i = 0; i < search_exclude_tags_length; i++)
> > -   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> > +if (!do_not_exclude) {
> 
> You could move search_exclude_tags and search_exclude_tags_length in
> here now that it's a block (but you don't have to).

Will fix

> > +   search_exclude_tags = notmuch_config_get_search_exclude_tags
> > +   (config, _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..084dd05 100644
> > --- a/notmuch-search.c
> > +++ b/notmuch-search.c
> > @@ -425,6 +425,7 @@ notmuch_search_command (void *ctx, int argc, char 
> > *argv[])
> >  int limit = -1; /* unlimited */
> >  const char **search_exclude_tags;
> >  size_t search_exclude_tags_length;
> > +notmuch_bool_t do_not_exclude = FALSE;
> >  unsigned int i;
> >  
> >  enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT }
> > @@ -446,6 +447,7 @@ notmuch_search_command (void *ctx, int argc, char 
> > *argv[])
> >   { "files", OUTPUT_FILES },
> >   { "tags", OUTPUT_TAGS },
> >   { 0, 0 } } },
> > +{ NOTMUCH_OPT_BOOLEAN,  _not_exclude, "do-not-exclude", 'd', 0 
> > },
> 
> Same.

Will fix

> 
> > { NOTMUCH_OPT_INT, , "offset", 'O', 0 },
> > { NOTMUCH_OPT_INT, , "limit", 'L', 0  },
> > { 0, 0, 0, 0, 0 }
> > @@ -493,10 +495,12 @@ 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, _exclude_tags_length);
> > -for (i = 0; i < search_exclude_tags_length; i++)
> > -   notmuch_query_add_tag_exclude (query, search_exclude_tags[i]);
> > +if (!do_not_exclude) {
> > +   search_exclude_tags = notmuch_config_get_search_exclude_tags
> > +   (config, _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:

Thanks

Mark



[PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread Tomi Ollila
On Tue, 31 Jan 2012 12:51:44 +0400, Dmitry Kurochkin  wrote:
> On Tue, 31 Jan 2012 10:43:10 +0200, Tomi Ollila  wrote:
> > On Tue, 31 Jan 2012 08:01:53 +, David Edmondson  wrote:
> > > When archiving the last message in a thread (a), rather than just
> > > moving the pointer to the next thread in the parent search buffer,
> > > actually display the next thread.
> > > ---
> > 
> > -1. Magic! Rather some customization option which lets user choose
> > consistent behaviour (i.e. 'a' either jumps to search buffer or
> > goes to next thread always (default?)).
> > 
> 
> FWIW this behavior is consistent with how archiving worked before
> earlier today.  For those who uses archiving, the new behavior is a
> surprise.  So I would argue that this patch makes it less "magic".  And
> consistent with the current "A" behavior.

Yes, I had a thinko there. 'a' progresses to next message after archiving
and not back to search buffer...

I like David's alternative suggestion (in IRC) where cursor is left at
the end of buffer in case last message is archived with 'a'.

> Regards,
>   Dmitry

Thanks, 

Tomi



[PATCH 1/7] cli: add --do-not-exclude option to count and search.

2012-01-31 Thread Austin Clements
Quoth Mark Walters on Jan 31 at 11:40 am:
> 
> Thanks for the review. Almost all of it (for all all the patches) I
> agree with and will just fix but I do have a couple of queries.
> 
> On Mon, 30 Jan 2012 23:17:32 -0500, Austin Clements  
> wrote:
> > Quoth Mark Walters on Jan 29 at  6:39 pm:
> > > This option turns off the exclusion so all matching messages are
> > > returned. We do not need to add this to show as notmuch-show does not
> > > (yet) exclude.
> > > ---
> > >  notmuch-count.c  |   12 
> > >  notmuch-search.c |   12 
> > >  2 files changed, 16 insertions(+), 8 deletions(-)
> > > 
> > > diff --git a/notmuch-count.c b/notmuch-count.c
> > > index 63459fb..c88975e 100644
> > > --- a/notmuch-count.c
> > > +++ b/notmuch-count.c
> > > @@ -37,6 +37,7 @@ notmuch_count_command (void *ctx, int argc, char 
> > > *argv[])
> > >  int output = OUTPUT_MESSAGES;
> > >  const char **search_exclude_tags;
> > >  size_t search_exclude_tags_length;
> > > +notmuch_bool_t do_not_exclude = FALSE;
> > >  unsigned int i;
> > >  
> > >  notmuch_opt_desc_t options[] = {
> > > @@ -44,6 +45,7 @@ notmuch_count_command (void *ctx, int argc, char 
> > > *argv[])
> > > (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },
> > > { "messages", OUTPUT_MESSAGES },
> > > { 0, 0 } } },
> > > + { NOTMUCH_OPT_BOOLEAN,  _not_exclude, "do-not-exclude", 'd', 0 },
> > 
> > Maybe just "no-exclude"?  "do-not-exclude" seems needlessly verbose.
> 
> The reason I went for verbose do-not-exclude was to try and avoid the
> double negative ambiguity: does no-exclude mean do-not-exclude or
> do-note-return-excluded-messages. Possibly I am worrying needlessly, and
> obviously I am quite happy to change.

Oh.  Hmm.  --no-exclusions?  --unexcluded?  --all?
--include-excludes?  Maybe --do-not-exclude is best.


[PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread Tomi Ollila
On Tue, 31 Jan 2012 08:01:53 +, David Edmondson  wrote:
> When archiving the last message in a thread (a), rather than just
> moving the pointer to the next thread in the parent search buffer,
> actually display the next thread.
> ---

-1. Magic! Rather some customization option which lets user choose
consistent behaviour (i.e. 'a' either jumps to search buffer or
goes to next thread always (default?)).

Tomi


[PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread Tomi Ollila
On Tue, 31 Jan 2012 08:01:54 +, David Edmondson  wrote:
> When using the spacebar to scroll through a thread, hitting 'space'
> when the bottom of the last message is visible should take the cursor
> to the end of the buffer rather than immediately archiving the thread
> and moving to the next thread.
> ---

+1 !

Tomi


[PATCH] emacs: Move the blank line from the bottom of the headers to the top of the body.

2012-01-31 Thread David Edmondson
On Mon, 30 Jan 2012 21:25:19 -0800, Jameson Graef Rollins  wrote:
> On Mon, 30 Jan 2012 16:52:20 +, David Edmondson  wrote:
> > The blank line doesn't really change position, but is now considered
> > to be part of the body rather than part of the headers. This means
> > that it is visible when the body is visible rather than when the
> > headers are visible.
> 
> This definitely makes sense.  I rarely hide headers anymore, but I never
> liked that the separation between the headers and the body went away
> when the headers are hidden.  +1.

Any objections to changing this?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/544cca85/attachment.pgp>


[PATCH] lib: update notmuch_tags_get example to reflect api change

2012-01-31 Thread Tomi Ollila
On Mon, 30 Jan 2012 15:35:44 -0500, Allan Wind  wrote:
> The function notmuch_database_find_message_by_filename now requires a
> notmuch_message_t and returns a notmuch_status_t.  This
> change was introduced with 02a3076711, LIBNOTMUCH_VERSION_MAJOR = 2,
> version 0.9.

LGTM.

Tomi


[PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 11:25:36 +0200, Tomi Ollila  wrote:
> I like David's alternative suggestion (in IRC) where cursor is left at
> the end of buffer in case last message is archived with 'a'.

Unless the cursor is already at the end of the buffer, in which case it
would do the 'next thread' dance (i.e. it behaves like 'space' in that
respect).
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/efc4a478/attachment.pgp>


[PATCH] emacs: add default value to notmuch-search-line-faces

2012-01-31 Thread Austin Clements
Quoth Jani Nikula on Jan 31 at  3:12 pm:
> On Thu, 26 Jan 2012 23:58:51 +0200, Jani Nikula  wrote:
> > On Thu, 26 Jan 2012 14:41:46 -0500, Austin Clements  
> > wrote:
> > > Quoth Jani Nikula on Jan 26 at  9:21 pm:
> > > > +  ("flagged" :foreground "red"))
> > > 
> > > Red is pretty universally used to indicate danger or a serious
> > > condition, while "flagged" is simply supposed to draw attention.  I
> > > would say blue as a neutral and distinct indicator, but it also has
> > > poor visibility (I used to use blue, but found that when scanning my
> > > mail, I would habitually skip over flagged messages because they were
> > > dark, which was the opposite of what I wanted).  Personally I've
> > > settled on yellow; it's visually distinct enough to be easily
> > > noticeable and bright enough that I don't skip over it, though it
> > > obviously wouldn't work on a light background.
> > 
> > Can be yellow, I don't really care that much. But isn't a light
> > background the default for emacs in most distros? If that matters,
> > *shrug*.
> 
> Ugh, yellow is absolutely horrible on a white background... that would
> certainly draw people to figure out how to change the settings. Now
> shall I send v2 with bold for unread and yellow for flagged, or can this
> go in as it is?

Sorry, I really meant to propose blue for flagged.  The thing about
yellow was meant more as an aside.  Blue is reasonably visible on both
light and dark backgrounds.  It should draw people into customizing
it, while still being a reasonable default.


[RFC PATCH] emacs: make show view a/A/x/X key bindings more consistent

2012-01-31 Thread Austin Clements
Quoth Jani Nikula on Jan 31 at  5:03 pm:
> Proposal for show view a/A/x/X key bindings, according to
> http://titanpad.com/SA39EbNezU and IRC discussion:
> 
> 'a' = Archive current message, then move to next message, or show next
> thread from search if at the last message in thread.
> 
> 'A' = Archive each message in thread, then show next thread from
> search.
> 
> 'x' = Archive current message, then move to next message, or exit back
> to search results if at the last message in thread.
> 
> 'X' = Archive each message in thread, then exit back to search
> results.
> 
> IMHO these changes would make the current implementation more
> consistent in two ways: 1) 'a'/'A' would advance to next thread like
> 'a' used to do, 2) 'x' would operate on messages and 'X' on threads
> like 'a'/'A' do now.

+1 to the proposal.  I don't know the maze of twisty little passages
that implement the show bindings well enough to say if the code is
right.

> The implementation here is hacky at best, and I agree with dme that
> notmuch-show.el could use some code cleanup and provide
> non-interactive primitives. However I won't have the time and energy
> for that right now.
> ---
>  emacs/notmuch-show.el |   26 --
>  1 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index de9421e..62f3664 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1075,9 +1075,10 @@ thread id.  If a prefix is given, crypto processing is 
> toggled."
>   (define-key map "h" 'notmuch-show-toggle-headers)
>   (define-key map "-" 'notmuch-show-remove-tag)
>   (define-key map "+" 'notmuch-show-add-tag)
> - (define-key map "x" 'notmuch-show-archive-thread-then-exit)
> - (define-key map "a" 'notmuch-show-archive-message-then-next)
> + (define-key map "X" 'notmuch-show-archive-thread-then-exit)
> + (define-key map "x" 'notmuch-show-archive-message-then-next-then-exit)
>   (define-key map "A" 'notmuch-show-archive-thread-then-next)
> + (define-key map "a" 'notmuch-show-archive-message-then-next-then-next)

notmuch-show-archive-message-then-next-then-next-thread?  I like the
very explicit names, but "then-next-then-next" is rather opaque.

>   (define-key map "N" 'notmuch-show-next-message)
>   (define-key map "P" 'notmuch-show-previous-message)
>   (define-key map "n" 'notmuch-show-next-open-message)
> @@ -1425,10 +1426,12 @@ buffer."
>  (if r
>   (progn
> (notmuch-show-mark-read)
> -   (notmuch-show-message-adjust))
> +   (notmuch-show-message-adjust)
> +   t)
>(if pop-at-end
> (notmuch-show-next-thread)
> - (goto-char (point-max))
> + (goto-char (point-max))
> + nil
>  
>  (defun notmuch-show-previous-open-message ()
>"Show the previous open message."
> @@ -1645,12 +1648,23 @@ removed)."
>(notmuch-show-add-tag "inbox")
>  (notmuch-show-remove-tag "inbox")))
>  
> -(defun notmuch-show-archive-message-then-next ()
> -  "Archive the current message, then show the next open message in the 
> current thread."
> +(defun notmuch-show-archive-message-then-next-then-exit ()
> +  "Archive the current message, then show the next open message in the 
> current thread.
> +
> +If at the last message in thread, then exit back to search results."
>(interactive)
>(notmuch-show-archive-message)
>(notmuch-show-next-open-message t))
>  
> +(defun notmuch-show-archive-message-then-next-then-next ()
> +  "Archive the current message, then show the next open message in the 
> current thread.
> +
> +If at the last message in thread, then show next thread from search."
> +  (interactive)
> +  (notmuch-show-archive-message)
> +  (unless (notmuch-show-next-open-message)
> +(notmuch-show-next-thread t)))
> +
>  (defun notmuch-show-stash-cc ()
>"Copy CC field of current message to kill-ring."
>(interactive)


[PATCH 0/5 v4] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread David Edmondson
I mangled the "in-reply-to" header, which should be
1327486729-18052-1-git-send-email-dme at dme.org
(i.e. id:"1327486729-18052-1-git-send-email-dme at dme.org").
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/7783f935/attachment.pgp>


[PATCH v4 12/12] NEWS: document Emacs UI tagging operations changes

2012-01-31 Thread Dmitry Kurochkin
---
 NEWS |   18 ++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/NEWS b/NEWS
index 2acdce5..7506d68 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,24 @@ Reply to sender
   and search modes, 'r' has been bound to reply to sender, replacing
   reply to all, which now has key binding 'R'.

+More flexible and consistent tagging operations
+
+  All tagging operations ("+", "-", "*") now accept multiple tags with
+  "+" or "-" prefix, like "*" operation in notmuch-search view before.
+
+  "*" operation (`notmuch-show-tag-all') is now available in
+  notmuch-show view.
+
+  `Notmuch-show-{add,remove}-tag' functions no longer accept tag
+  argument, `notmuch-show-tag-message' should be used instead.  Custom
+  bindings using these functions should be updated, e.g.:
+
+(notmuch-show-remove-tag "unread")
+
+  should be changed to:
+
+(notmuch-show-tag-message "-unread")
+
 Library changes
 ---

-- 
1.7.9



[PATCH v4 11/12] emacs: s/tags/tag-changes/ for arguments of tagging functions

2012-01-31 Thread Dmitry Kurochkin
This makes the argument names more consistent and clear.  The
following functions changed: `notmuch-tag',
`notmuch-search-tag-thread', `notmuch-search-tag-region' and
`notmuch-search-tag-all'.
---
 emacs/notmuch.el |   33 +
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c464c3c..fa62019 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -543,25 +543,26 @@ and will also appear in a buffer named \"*Notmuch 
errors*\"."
(error (buffer-substring beg end))
))

-(defun notmuch-tag (query  tags)
-  "Add/remove tags in TAGS to messages matching QUERY.
+(defun notmuch-tag (query  tag-changes)
+  "Add/remove tags in TAG-CHANGES to messages matching QUERY.

-TAGS should be a list of strings of the form \"+TAG\" or \"-TAG\" and
-QUERY should be a string containing the search-query.
+TAG-CHANGES should be a list of strings of the form \"+tag\" or
+\"-tag\" and QUERY should be a string containing the
+search-query.

 Note: Other code should always use this function alter tags of
 messages instead of running (notmuch-call-notmuch-process \"tag\" ..)
 directly, so that hooks specified in notmuch-before-tag-hook and
 notmuch-after-tag-hook will be run."
   ;; Perform some validation
-  (mapc (lambda (tag)
- (unless (string-match-p "^[-+]\\S-+$" tag)
+  (mapc (lambda (tag-change)
+ (unless (string-match-p "^[-+]\\S-+$" tag-change)
(error "Tag must be of the form `+this_tag' or `-that_tag'")))
-   tags)
-  (unless (null tags)
+   tag-changes)
+  (unless (null tag-changes)
 (run-hooks 'notmuch-before-tag-hook)
 (apply 'notmuch-call-notmuch-process "tag"
-  (append tags (list "--" query)))
+  (append tag-changes (list "--" query)))
 (run-hooks 'notmuch-after-tag-hook)))

 (defcustom notmuch-before-tag-hook nil
@@ -621,26 +622,26 @@ the messages that were tagged"
(forward-line 1))
   output)))

-(defun notmuch-search-tag-thread ( tags)
+(defun notmuch-search-tag-thread ( tag-changes)
   "Change tags for the currently selected thread.

 See `notmuch-search-tag-region' for details."
-  (apply 'notmuch-search-tag-region (point) (point) tags))
+  (apply 'notmuch-search-tag-region (point) (point) tag-changes))

-(defun notmuch-search-tag-region (beg end  tags)
+(defun notmuch-search-tag-region (beg end  tag-changes)
   "Change tags for threads in the given region.

 TAGS is a list of tag operations for `notmuch-tag'.  The tags are
 added or removed for all threads in the region from BEG to END."
   (let ((search-string (notmuch-search-find-thread-id-region-search beg end)))
-(apply 'notmuch-tag search-string tags)
+(apply 'notmuch-tag search-string tag-changes)
 (save-excursion
   (let ((last-line (line-number-at-pos end))
(max-line (- (line-number-at-pos (point-max)) 2)))
(goto-char beg)
(while (<= (line-number-at-pos) (min last-line max-line))
  (notmuch-search-set-tags
-  (notmuch-update-tags (notmuch-search-get-tags) tags))
+  (notmuch-update-tags (notmuch-search-get-tags) tag-changes))
  (forward-line))

 (defun notmuch-search-tag ( initial-input)
@@ -892,7 +893,7 @@ non-authors is found, assume that all of the authors match."
  (goto-char found-target)))
   (delete-process proc

-(defun notmuch-search-tag-all ( actions)
+(defun notmuch-search-tag-all ( tag-changes)
   "Add/remove tags from all matching messages.

 This command adds or removes tags from all messages matching the
@@ -904,7 +905,7 @@ Each character of the tag name may consist of alphanumeric
 characters as well as `_.+-'.
 "
   (interactive (notmuch-read-tag-changes))
-  (apply 'notmuch-tag notmuch-search-query-string actions))
+  (apply 'notmuch-tag notmuch-search-query-string tag-changes))

 (defun notmuch-search-buffer-title (query)
   "Returns the title for a buffer with notmuch search results."
-- 
1.7.9



[PATCH v4 10/12] emacs: accept empty tag list in `notmuch-tag'

2012-01-31 Thread Dmitry Kurochkin
Since `notmuch-tag' is a non-interactive function and hence is meant
to be invoked programmatically, it should accept zero tags.  Also, the
tagging operations (bound to "*", "+", "-") would accept empty input
without an error.
---
 emacs/notmuch.el |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 2332c42..c464c3c 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -554,15 +554,15 @@ messages instead of running (notmuch-call-notmuch-process 
\"tag\" ..)
 directly, so that hooks specified in notmuch-before-tag-hook and
 notmuch-after-tag-hook will be run."
   ;; Perform some validation
-  (when (null tags) (error "No tags given"))
   (mapc (lambda (tag)
  (unless (string-match-p "^[-+]\\S-+$" tag)
(error "Tag must be of the form `+this_tag' or `-that_tag'")))
tags)
-  (run-hooks 'notmuch-before-tag-hook)
-  (apply 'notmuch-call-notmuch-process
-(append (list "tag") tags (list "--" query)))
-  (run-hooks 'notmuch-after-tag-hook))
+  (unless (null tags)
+(run-hooks 'notmuch-before-tag-hook)
+(apply 'notmuch-call-notmuch-process "tag"
+  (append tags (list "--" query)))
+(run-hooks 'notmuch-after-tag-hook)))

 (defcustom notmuch-before-tag-hook nil
   "Hooks that are run before tags of a message are modified.
-- 
1.7.9



[PATCH v4 09/12] emacs: relax tag syntax check in `notmuch-tag' function

2012-01-31 Thread Dmitry Kurochkin
The tag syntax check in `notmuch-tag' function was too strict and did
not allow nmbug tags with "::".  Since the check is done for all
tagging operations in Emacs UI, this basically means that no nmbug
tags can be changed.  The patch relaxes the tag syntax check to allow
any tag names that do not include whitespace characters.
---
 emacs/notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 0a3bd17..2332c42 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -556,7 +556,7 @@ notmuch-after-tag-hook will be run."
   ;; Perform some validation
   (when (null tags) (error "No tags given"))
   (mapc (lambda (tag)
- (unless (string-match-p "^[-+][-+_.[:word:]]+$" tag)
+ (unless (string-match-p "^[-+]\\S-+$" tag)
(error "Tag must be of the form `+this_tag' or `-that_tag'")))
tags)
   (run-hooks 'notmuch-before-tag-hook)
-- 
1.7.9



[PATCH v4 07/12] emacs: add "*" binding for notmuch-show view

2012-01-31 Thread Dmitry Kurochkin
The patch adds `notmuch-show-tag-all' function bound to "*" in
notmuch-show view.  The function is similar to the
`notmuch-search-tag-all' function for the notmuch-search view: it
changes tags for all messages in the current thread.
---
 emacs/notmuch-show.el |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index a0efae7..1cdd23e 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1074,6 +1074,7 @@ thread id.  If a prefix is given, crypto processing is 
toggled."
(define-key map "c" 'notmuch-show-stash-map)
(define-key map "=" 'notmuch-show-refresh-view)
(define-key map "h" 'notmuch-show-toggle-headers)
+   (define-key map "*" 'notmuch-show-tag-all)
(define-key map "-" 'notmuch-show-remove-tag)
(define-key map "+" 'notmuch-show-add-tag)
(define-key map "x" 'notmuch-show-archive-thread-then-exit)
@@ -1171,6 +1172,15 @@ All currently available key bindings:
 (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."
+  (save-excursion
+(goto-char (point-min))
+(loop do (funcall function)
+ while (notmuch-show-goto-message-next
+
 ;; Functions relating to the visibility of messages and their
 ;; components.

@@ -1223,6 +1233,18 @@ Some useful entries are:
   "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."
+  (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 "))
+
 ;; dme: Would it make sense to use a macro for many of these?

 (defun notmuch-show-get-filename ()
@@ -1501,6 +1523,19 @@ TAG-CHANGES is a list of tag operations for 
`notmuch-tag'."
  initial-input (notmuch-show-get-message-id
 (apply 'notmuch-show-tag-message tag-changes)))

+(defun notmuch-show-tag-all ( tag-changes)
+  "Change tags for all messages in the current thread.
+
+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
+   (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))
+
 (defun notmuch-show-add-tag ()
   "Same as `notmuch-show-tag' but sets initial input to '+'."
   (interactive)
-- 
1.7.9



[PATCH v4 05/12] test: fix emacs tests after tagging operations changes

2012-01-31 Thread Dmitry Kurochkin
After the recent tagging operations changes, functions bound to "+"
and "-" in notmuch-search and notmuch-show views always read input
from the minibuffer.  Use kbd macros instead of calling them directly.
---
 test/emacs |   20 ++--
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/test/emacs b/test/emacs
index 8ca4c8a..b9c0e02 100755
--- a/test/emacs
+++ b/test/emacs
@@ -101,26 +101,26 @@ test_begin_subtest "Add tag from search view"
 os_x_darwin_thread=$(notmuch search --output=threads 
id:ddd65cda0911171950o4eea4389v86de9525e46052d3 at mail.gmail.com)
 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
(notmuch-test-wait)
-   (notmuch-search-add-tag \"tag-from-search-view\")"
+   (execute-kbd-macro \"+tag-from-search-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-search-view unread)"

 test_begin_subtest "Remove tag from search view"
 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
(notmuch-test-wait)
-   (notmuch-search-remove-tag \"tag-from-search-view\")"
+   (execute-kbd-macro \"-tag-from-search-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 "Add tag from notmuch-show view"
 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
-   (notmuch-show-add-tag \"tag-from-show-view\")"
+   (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_emacs "(notmuch-show \"$os_x_darwin_thread\")
-   (notmuch-show-remove-tag \"tag-from-show-view\")"
+   (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)"

@@ -128,14 +128,14 @@ 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\"")
(notmuch-test-wait)
-   (notmuch-search-add-tag "search-add")
-   (notmuch-search-add-tag "search-remove")
-   (notmuch-search-remove-tag "search-remove")
+   (execute-kbd-macro "+search-add")
+   (execute-kbd-macro "+search-remove")
+   (execute-kbd-macro "-search-remove")
(notmuch-show "id:\"123..456 at example\"")
(notmuch-test-wait)
-   (notmuch-show-add-tag "show-add")
-   (notmuch-show-add-tag "show-remove")
-   (notmuch-show-remove-tag "show-remove")'
+   (execute-kbd-macro "+show-add")
+   (execute-kbd-macro "+show-remove")
+   (execute-kbd-macro "-show-remove")'
 output=$(notmuch search 'id:"123..456 at example"' | notmuch_search_sanitize)
 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; 
Message with .. in Message-Id (inbox search-add show-add)"

-- 
1.7.9



[PATCH v4 03/12] emacs: make "+" and "-" tagging operations in notmuch-search more flexible

2012-01-31 Thread Dmitry Kurochkin
Before the change, "+" and "-" tagging operations in notmuch-search
view accepted only a single tag.  The patch makes them use the
recently added `notmuch-read-tag-changes' function (renamed
`notmuch-select-tags-with-completion'), which allows to enter multiple
tags with "+" and "-" prefixes.  So after the change, "+" and "-"
bindings in notmuch-search view allow to both add and remove multiple
tags.  The only difference between "+" and "-" is the minibuffer
initial input ("+" and "-" respectively).
---
 emacs/notmuch.el |  163 +++---
 1 files changed, 81 insertions(+), 82 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ff46617..ce8bef6 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -76,38 +76,56 @@ For example:
 (defvar notmuch-query-history nil
   "Variable to store minibuffer history for notmuch queries")

-(defun notmuch-tag-completions ( prefixes search-terms)
-  (let ((tag-list
-(split-string
- (with-output-to-string
-   (with-current-buffer standard-output
- (apply 'call-process notmuch-command nil t
-nil "search-tags" search-terms)))
- "\n+" t)))
-(if (null prefixes)
-   tag-list
-  (apply #'append
-(mapcar (lambda (tag)
-  (mapcar (lambda (prefix)
-(concat prefix tag)) prefixes))
-tag-list)
+(defun notmuch-tag-completions ( search-terms)
+  (split-string
+   (with-output-to-string
+ (with-current-buffer standard-output
+   (apply 'call-process notmuch-command nil t
+ nil "search-tags" search-terms)))
+   "\n+" t))

 (defun notmuch-select-tag-with-completion (prompt  search-terms)
-  (let ((tag-list (notmuch-tag-completions nil search-terms)))
+  (let ((tag-list (notmuch-tag-completions search-terms)))
 (completing-read prompt tag-list)))

-(defun notmuch-select-tags-with-completion (prompt  prefixes  
search-terms)
-  (let ((tag-list (notmuch-tag-completions prefixes search-terms))
-   (crm-separator " ")
-   ;; By default, space is bound to "complete word" function.
-   ;; Re-bind it to insert a space instead.  Note that 
-   ;; still does the completion.
-   (crm-local-completion-map
-(let ((map (make-sparse-keymap)))
-  (set-keymap-parent map crm-local-completion-map)
-  (define-key map " " 'self-insert-command)
-  map)))
-(delete "" (completing-read-multiple prompt tag-list
+(defun notmuch-read-tag-changes ( initial-input  search-terms)
+  (let* ((all-tag-list (notmuch-tag-completions))
+(add-tag-list (mapcar (apply-partially 'concat "+") all-tag-list))
+(remove-tag-list (mapcar (apply-partially 'concat "-")
+ (if (null search-terms)
+ all-tag-list
+   (notmuch-tag-completions search-terms
+(tag-list (append add-tag-list remove-tag-list))
+(crm-separator " ")
+;; By default, space is bound to "complete word" function.
+;; Re-bind it to insert a space instead.  Note that 
+;; still does the completion.
+(crm-local-completion-map
+ (let ((map (make-sparse-keymap)))
+   (set-keymap-parent map crm-local-completion-map)
+   (define-key map " " 'self-insert-command)
+   map)))
+(delete "" (completing-read-multiple "Tags (+add -drop): "
+   tag-list nil nil initial-input
+
+(defun notmuch-update-tags (tags tag-changes)
+  "Return a copy of TAGS with additions and removals from TAG-CHANGES.
+
+TAG-CHANGES must be a list of tags names, each prefixed with
+either a \"+\" to indicate the tag should be added to TAGS if not
+present or a \"-\" to indicate that the tag should be removed
+from TAGS if present."
+  (let ((result-tags (copy-sequence tags)))
+(dolist (tag-change tag-changes)
+  (let ((op (string-to-char tag-change))
+   (tag (unless (string= tag-change "") (substring tag-change 1
+   (case op
+ (?+ (unless (member tag result-tags)
+   (push tag result-tags)))
+ (?- (setq result-tags (delete tag result-tags)))
+ (otherwise
+  (error "Changed tag must be of the form `+this_tag' or 
`-that_tag'")
+(sort result-tags 'string<)))

 (defun notmuch-foreach-mime-part (function mm-handle)
   (cond ((stringp (car mm-handle))
@@ -447,6 +465,10 @@ Complete list of currently available key bindings:
   "Return a list of threads for the current region"
   (notmuch-search-properties-in-region 'notmuch-search-thread-id beg end))

+(defun notmuch-search-find-thread-id-region-search (beg end)
+  "Return a search string for threads for the current region"
+  (mapconcat 'identity (notmuch-search-find-thread-id-region beg end) " or "))
+
 (defun notmuch-search-find-authors ()
   "Return the authors for the 

[PATCH v4 02/12] emacs: remove text properties from `notmuch-search-get-tags' result

2012-01-31 Thread Dmitry Kurochkin
---
 emacs/notmuch.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 84d7d0a..ff46617 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -577,7 +577,7 @@ the messages that were tagged"
 (let ((beg (+ (point) 1)))
   (re-search-forward ")")
   (let ((end (- (point) 1)))
-   (split-string (buffer-substring beg end))
+   (split-string (buffer-substring-no-properties beg end))

 (defun notmuch-search-get-tags-region (beg end)
   (save-excursion
-- 
1.7.9



[PATCH v4 01/12] emacs: move tag format validation to `notmuch-tag' function

2012-01-31 Thread Dmitry Kurochkin
Before the change, tag format validation was done in
`notmuch-search-operate-all' function only.  The patch moves it down
to `notmuch-tag', so that all users of that function get input
validation.
---
 emacs/notmuch.el |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 72f78ed..84d7d0a 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -522,6 +522,12 @@ Note: Other code should always use this function alter 
tags of
 messages instead of running (notmuch-call-notmuch-process \"tag\" ..)
 directly, so that hooks specified in notmuch-before-tag-hook and
 notmuch-after-tag-hook will be run."
+  ;; Perform some validation
+  (when (null tags) (error "No tags given"))
+  (mapc (lambda (tag)
+ (unless (string-match-p "^[-+][-+_.[:word:]]+$" tag)
+   (error "Tag must be of the form `+this_tag' or `-that_tag'")))
+   tags)
   (run-hooks 'notmuch-before-tag-hook)
   (apply 'notmuch-call-notmuch-process
 (append (list "tag") tags (list "--" query)))
@@ -890,12 +896,6 @@ characters as well as `_.+-'.
   (interactive (notmuch-select-tags-with-completion
"Operations (+add -drop): notmuch tag "
'("+" "-")))
-  ;; Perform some validation
-  (when (null actions) (error "No operations given"))
-  (mapc (lambda (action)
- (unless (string-match-p "^[-+][-+_.[:word:]]+$" action)
-   (error "Action must be of the form `+this_tag' or `-that_tag'")))
-   actions)
   (apply 'notmuch-tag notmuch-search-query-string actions))

 (defun notmuch-search-buffer-title (query)
-- 
1.7.9



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

2012-01-31 Thread Dmitry Kurochkin
Changes:

v4:

* rebased on master after Jameson's archiving changes

v3:

* merged 3 `notmuch-show-tag-all'-related patches into one

* add patch to clean up tagging function argument names

* fix other comments from Austin's reviews [5,6]

v2:

* add patch to remove "No tags given" error from `notmuch-tag' as
  suggested by Austin in [1]

* split patch 3 in two (search and show) for easier review

* add patch with NEWS entry

* rename `notmuch-{search,show}-operate-all' to
  `notmuch-{search,show}-tag-all'

* fix other comments from Austin's reviews [2,3,4]

Regards,
  Dmitry

[1] id:"20120129231650.GK17991 at mit.edu"
[2] id:"20120129225710.GG17991 at mit.edu"
[3] id:"20120129230229.GI17991 at mit.edu"
[4] id:"20120129231120.GJ17991 at mit.edu"
[5] id:"20120130044806.GM17991 at mit.edu"
[6] id:"20120130050402.GP17991 at mit.edu"



[PATCH 5/5] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view'.

2012-01-31 Thread David Edmondson
With an argument, record and reply the state of the buffer during
`notmuch-show-refresh-view'.

In this context, "state" is defined as:
 - the open/closed state of each message,
 - the current message.

Traditional use of refresh with the = key does not retain the
state. The recently introduced toggle commands ($, !, < and >) do
retain the state.
---
 emacs/notmuch-show.el |   58 +---
 1 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 28f2148..2f10c42 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -933,7 +933,7 @@ current buffer, if possible."
   (message (if notmuch-show-process-crypto
   "Processing cryptographic MIME parts."
 "Not processing cryptographic MIME parts."))
-  (notmuch-show-refresh-view))
+  (notmuch-show-refresh-view t))

 (defun notmuch-show-toggle-elide-non-matching ()
   "Toggle the display of non-matching messages."
@@ -942,7 +942,7 @@ current buffer, if possible."
   (message (if notmuch-show-elide-non-matching-messages
   "Showing matching messages only."
 "Showing all messages."))
-  (notmuch-show-refresh-view))
+  (notmuch-show-refresh-view t))

 (defun notmuch-show-toggle-thread-indentation ()
   "Toggle the indentation of threads."
@@ -951,7 +951,7 @@ current buffer, if possible."
   (message (if notmuch-show-indent-content
   "Content is indented."
 "Content is not indented."))
-  (notmuch-show-refresh-view))
+  (notmuch-show-refresh-view t))

 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
@@ -1054,15 +1054,55 @@ function is used."

 (notmuch-show-mark-read)))

-(defun notmuch-show-refresh-view ()
+(defun notmuch-show-capture-state ()
+  "Capture the state of the current buffer.
+
+This includes:
+ - the list of open messages,
+ - the current message."
+  (list (notmuch-show-get-message-id) 
(notmuch-show-get-message-ids-for-open-messages)))
+
+(defun notmuch-show-apply-state (state)
+  "Apply STATE to the current buffer.
+
+This includes:
+ - opening the messages previously opened,
+ - closing all other messages,
+ - moving to the correct current message."
+  (let ((current (car state))
+   (open (cadr state)))
+
+;; Open those that were open.
+(goto-char (point-min))
+(loop do (notmuch-show-message-visible 
(notmuch-show-get-message-properties)
+  (member 
(notmuch-show-get-message-id) open))
+ until (not (notmuch-show-goto-message-next)))
+
+;; Go to the previously open message.
+(goto-char (point-min))
+(unless (loop if (string= current (notmuch-show-get-message-id))
+ return t
+ until (not (notmuch-show-goto-message-next)))
+  (goto-char (point-min))
+  (message "Previously current message not found."))
+(notmuch-show-message-adjust)))
+
+(defun notmuch-show-refresh-view ( retain-state)
   "Refresh the current view.

-Refreshes the current view, observing changes in cryptographic preferences."
+Refreshes the current view, observing changes in display
+preferences. If RETAIN-STATE is non-nil then the state of the
+buffer is stored and re-applied after the refresh."
   (interactive)
-  (let ((inhibit-read-only t))
-(erase-buffer))
-  (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
-  notmuch-show-query-context))
+  (let ((inhibit-read-only t)
+   state)
+(if retain-state
+   (setq state (notmuch-show-capture-state)))
+(erase-buffer)
+(notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
+notmuch-show-query-context)
+(if state
+   (notmuch-show-apply-state state

 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
-- 
1.7.8.3



[PATCH 4/5] emacs: Add a binding (>) to toggle the truncation of long lines.

2012-01-31 Thread David Edmondson
---
 emacs/notmuch-show.el |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 789b6d9..28f2148 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1116,6 +1116,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences."
(define-key map "!" 'notmuch-show-toggle-elide-non-matching)
(define-key map "$" 'notmuch-show-toggle-process-crypto)
(define-key map "<" 'notmuch-show-toggle-thread-indentation)
+   (define-key map ">" 'toggle-truncate-lines)
map)
   "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
-- 
1.7.8.3



[PATCH 3/5] emacs: Allow the indentation of content to be toggled.

2012-01-31 Thread David Edmondson
Very deeply indented content is sometimes difficult to
read (particular for something like patches). Allow the indentation of
the content to be toggled with '<'.

Indentation of the header lines is not affected, so it remains
possible to see the structure of the thread.
---
 emacs/notmuch-show.el |   26 ++
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 77ba2dd..789b6d9 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -140,6 +140,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
 (put 'notmuch-show-elide-non-matching-messages 'permanent-local t)

+(defvar notmuch-show-indent-content t)
+(make-variable-buffer-local 'notmuch-show-indent-content)
+(put 'notmuch-show-indent-content 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message ( body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -250,10 +254,12 @@ operation on the contents of the current buffer."
 (all (buffer-substring (notmuch-show-message-top)
(notmuch-show-message-bottom)))

-(props (notmuch-show-get-message-properties)))
+(props (notmuch-show-get-message-properties))
+(indenting notmuch-show-indent-content))
 (with-temp-buffer
   (insert all)
-  (indent-rigidly (point-min) (point-max) (- depth))
+  (if indenting
+ (indent-rigidly (point-min) (point-max) (- depth)))
   ;; Remove the original header.
   (goto-char (point-min))
   (re-search-forward "^$" (point-max) nil)
@@ -881,7 +887,8 @@ current buffer, if possible."
 (setq notmuch-show-previous-subject bare-subject)

 (setq body-start (point-marker))
-(notmuch-show-insert-body msg (plist-get msg :body) depth)
+(notmuch-show-insert-body msg (plist-get msg :body)
+ (if notmuch-show-indent-content depth 0))
 ;; Ensure that the body ends with a newline.
 (unless (bolp)
   (insert "\n"))
@@ -889,7 +896,8 @@ current buffer, if possible."
 (setq content-end (point-marker))

 ;; Indent according to the depth in the thread.
-(indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth))
+(if notmuch-show-indent-content
+   (indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth)))

 (setq message-end (point-max-marker))

@@ -936,6 +944,15 @@ current buffer, if possible."
 "Showing all messages."))
   (notmuch-show-refresh-view))

+(defun notmuch-show-toggle-thread-indentation ()
+  "Toggle the indentation of threads."
+  (interactive)
+  (setq notmuch-show-indent-content (not notmuch-show-indent-content))
+  (message (if notmuch-show-indent-content
+  "Content is indented."
+"Content is not indented."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -1098,6 +1115,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences."
(define-key map "#" 'notmuch-show-print-message)
(define-key map "!" 'notmuch-show-toggle-elide-non-matching)
(define-key map "$" 'notmuch-show-toggle-process-crypto)
+   (define-key map "<" 'notmuch-show-toggle-thread-indentation)
map)
   "Keymap for \"notmuch show\" buffers.")
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
-- 
1.7.8.3



[PATCH 2/5] emacs: Allow `notmuch-show-mode' to display only matching messages.

2012-01-31 Thread David Edmondson
The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
---
 emacs/notmuch-show.el |   18 +-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 35a2809..77ba2dd 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -136,6 +136,10 @@ indentation."
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 (put 'notmuch-show-process-crypto 'permanent-local t)

+(defvar notmuch-show-elide-non-matching-messages nil)
+(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message ( body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -923,11 +927,22 @@ current buffer, if possible."
 "Not processing cryptographic MIME parts."))
   (notmuch-show-refresh-view))

+(defun notmuch-show-toggle-elide-non-matching ()
+  "Toggle the display of non-matching messages."
+  (interactive)
+  (setq notmuch-show-elide-non-matching-messages (not 
notmuch-show-elide-non-matching-messages))
+  (message (if notmuch-show-elide-non-matching-messages
+  "Showing matching messages only."
+"Showing all messages."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
(replies (cadr tree)))
-(notmuch-show-insert-msg msg depth)
+(if (or (not notmuch-show-elide-non-matching-messages)
+   (plist-get msg :match))
+   (notmuch-show-insert-msg msg depth))
 (notmuch-show-insert-thread replies (1+ depth

 (defun notmuch-show-insert-thread (thread depth)
@@ -1081,6 +1096,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences."
(define-key map (kbd "M-RET") 'notmuch-show-open-or-close-all)
(define-key map (kbd "RET") 'notmuch-show-toggle-message)
(define-key map "#" 'notmuch-show-print-message)
+   (define-key map "!" 'notmuch-show-toggle-elide-non-matching)
(define-key map "$" 'notmuch-show-toggle-process-crypto)
map)
   "Keymap for \"notmuch show\" buffers.")
-- 
1.7.8.3



[PATCH 1/5] emacs: Rework crypto switch toggle.

2012-01-31 Thread David Edmondson
Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
---
 emacs/notmuch-show.el |  105 +++-
 emacs/notmuch.el  |7 +--
 2 files changed, 53 insertions(+), 59 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index de9421e..35a2809 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -125,6 +125,17 @@ indentation."
 (const :tag "View interactively"
notmuch-show-interactively-view-part)))

+(defvar notmuch-show-thread-id nil)
+(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar notmuch-show-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar notmuch-show-query-context nil)
+(make-variable-buffer-local 'notmuch-show-query-context)
+
+(defvar notmuch-show-process-crypto nil)
+(make-variable-buffer-local 'notmuch-show-process-crypto)
+(put 'notmuch-show-process-crypto 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message ( body)
   "Evaluate body with current buffer set to the text of current message"
   `(save-excursion
@@ -411,14 +422,11 @@ message at DEPTH in the current thread."

 (defmacro notmuch-with-temp-part-buffer (message-id nth  body)
   (declare (indent 2))
-  (let ((process-crypto (make-symbol "process-crypto")))
-`(let ((,process-crypto notmuch-show-process-crypto))
-   (with-temp-buffer
-(setq notmuch-show-process-crypto ,process-crypto)
-;; Always acquires the part via `notmuch part', even if it is
-;; available in the JSON output.
-(insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
-, at body
+  `(with-temp-buffer
+ ;; Always acquires the part via `notmuch part', even if it is
+ ;; available in the JSON output.
+ (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
+ , at body))

 (defun notmuch-show-save-part (message-id nth  filename content-type)
   (notmuch-with-temp-part-buffer message-id nth
@@ -600,7 +608,7 @@ current buffer, if possible."
   (sigstatus (car (plist-get part :sigstatus
  (notmuch-crypto-insert-sigstatus-button sigstatus from))
   ;; if we're not adding sigstatus, tell the user how they can get it
-  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
process cryptographic mime parts.")))
+  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
process cryptographic MIME parts.")))

   (let ((inner-parts (plist-get part :content))
(start (point)))
@@ -626,7 +634,7 @@ current buffer, if possible."
 (sigstatus (car (plist-get part :sigstatus
(notmuch-crypto-insert-sigstatus-button sigstatus from
   ;; if we're not adding encstatus, tell the user how they can get it
-  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
process cryptographic mime parts.")))
+  (button-put button 'help-echo "Set notmuch-crypto-process-mime to 
process cryptographic MIME parts.")))

   (let ((inner-parts (plist-get part :content))
(start (point)))
@@ -753,8 +761,6 @@ current buffer, if possible."

 ;; Helper for parts which are generally not included in the default
 ;; JSON output.
-;; Uses the buffer-local variable notmuch-show-process-crypto to
-;; determine if parts should be decrypted first.
 (defun notmuch-show-get-bodypart-internal (message-id part-number)
   (let ((args '("show" "--format=raw"))
(part-arg (format "--part=%s" part-number)))
@@ -908,6 +914,15 @@ current buffer, if possible."
 ;; criteria.
 (notmuch-show-message-visible msg (plist-get msg :match

+(defun notmuch-show-toggle-process-crypto ()
+  "Toggle the processing of cryptographic MIME parts."
+  (interactive)
+  (setq notmuch-show-process-crypto (not notmuch-show-process-crypto))
+  (message (if notmuch-show-process-crypto
+  "Processing cryptographic MIME parts."
+"Not processing cryptographic MIME parts."))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   "Insert the message tree TREE at depth DEPTH in the current thread."
   (let ((msg (car tree))
@@ -923,15 +938,6 @@ current buffer, if possible."
   "Insert the forest of threads FOREST."
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))

-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)
-(defvar 

[PATCH 0/5 v4] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread David Edmondson
v4:
- Don't retain the state for '='.
- If refreshing the view removes the previously current message from
  view, leave the cursor at (point-min).
- Adjust the display after refreshing if the previously current
  message is found.

David Edmondson (5):
  emacs: Rework crypto switch toggle.
  emacs: Allow `notmuch-show-mode' to display only matching messages.
  emacs: Allow the indentation of content to be toggled.
  emacs: Add a binding (>) to toggle the truncation of long lines.
  emacs: Optionally retain the state of the buffer during
`notmuch-show-refresh-view'.

 emacs/notmuch-show.el |  190 +---
 emacs/notmuch.el  |7 +-
 2 files changed, 133 insertions(+), 64 deletions(-)

-- 
1.7.8.3



[PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 12:24:27 +0400, Dmitry Kurochkin  wrote:
> This is why I like big diff contexts...

Can I set that in my .gitconfig?
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/d134519d/attachment.pgp>


[PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread Jameson Graef Rollins
On Tue, 31 Jan 2012 08:09:08 +, David Edmondson  wrote:
> On Mon, 30 Jan 2012 09:47:34 -0800, Jameson Graef Rollins  finestructure.net> wrote:
> > One thing I've noticed, which isn't actually part of this patch, is that
> > the long-line truncation doesn't respect the indentation, which makes
> > things look strange.
> 
> Which lines are getting wrapped in a way that you don't like? The header
> line? The headers? The body?

Header lines, such as Subject, To, Cc, etc.

> > But honestly I still don't like our method of displaying threads as a
> > giant chain of concatenated messages with indentation.  But that's for
> > later work.
> 
> It's inherited from sup, and is surely part of the "raison de notmuch"
> :-)

Inheritance is not a good justification for anything, much less
questionable UI choices (I seem to have inherited baldness from my dad.
Thanks dad).  Problems I have with the current approach:

- thread structure is opaque.  This is especially true with long
  threads, where it can be next to impossible to see which messages are
  replies to what.  This is by far my biggest pet peeve with the current
  format.

- navigation through the thread is difficult.  This is related to above.
  There's no way to simultaneously see the current message and the
  thread structure, which again, makes it very difficult to find
  children and parents.  This could possibly be fixed by having key
  bindings that would navigate through parents, children and siblings of
  the current message, but that might be tricky to implement.

- indentation of the entire message body is a really bad way to indicate
  thread depth.  I don't like how messages start to walk off screen as
  threads get longer, or how copying regions of the body brings the
  indentation with it.  Your indentation toggling will improve this a
  bit, though, but I still think it's a bandaid on the larger issue.

I must say that the approach I've been longing for is a modified version
of what mutt has: a top pain that is just the thread structure (with
nice branching lines), and a bottom pain that displays the current
message.  I think that would be a much cleaner approach.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/cc9102e6/attachment-0001.pgp>


[PATCH 1/7] cli: add --do-not-exclude option to count and search.

2012-01-31 Thread Jameson Graef Rollins
On Tue, 31 Jan 2012 11:40:00 +, Mark Walters  
wrote:
> The reason I went for verbose do-not-exclude was to try and avoid the
> double negative ambiguity: does no-exclude mean do-not-exclude or
> do-note-return-excluded-messages. Possibly I am worrying needlessly, and
> obviously I am quite happy to change.

I also think "no-exclude" or "no-excludes" would be more appropriate.
It's not a command that people will likely use that frequently, so as
long as it's well documented it will be fine.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/45079e1a/attachment-0001.pgp>


[PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 12:12:50 +0400, Dmitry Kurochkin  wrote:
> On Tue, 31 Jan 2012 08:01:54 +, David Edmondson  wrote:
> > When using the spacebar to scroll through a thread, hitting 'space'
> > when the bottom of the last message is visible should take the cursor
> > to the end of the buffer rather than immediately archiving the thread
> > and moving to the next thread.
> > ---
> 
> I did not notice this change yet, so +0
> 
> A style comment below.
> 
> >  emacs/notmuch-show.el |5 +
> >  1 files changed, 5 insertions(+), 0 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index ec72ff8..3f54de0 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -1319,6 +1319,11 @@ current window), advance to the next open message."
> >;; This is not the last message - move to the next visible one.
> >(notmuch-show-next-open-message))
> >  
> > + ((not (= (point) (point-max)))
> > +  ;; This is the last message, but the cursor is not at the end of
> > +  ;; the buffer. Move it there.
> > +  (goto-char (point-max)))
> 
> Perhaps `unless' would be better here?

It's the CONDITION clause of `cond', so that wouldn't be appropriate.

> Regards,
>   Dmitry
> 
> > +
> >   (t
> >;; This is the last message - change the return value
> >(setq ret t)))
> > -- 
> > 1.7.8.3
> > 
> > ___
> > notmuch mailing list
> > notmuch at notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/91faac74/attachment.pgp>


[PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread David Edmondson
On Mon, 30 Jan 2012 09:47:34 -0800, Jameson Graef Rollins  wrote:
> One thing I've noticed, which isn't actually part of this patch, is that
> the long-line truncation doesn't respect the indentation, which makes
> things look strange.

Which lines are getting wrapped in a way that you don't like? The header
line? The headers? The body?

> But honestly I still don't like our method of displaying threads as a
> giant chain of concatenated messages with indentation.  But that's for
> later work.

It's inherited from sup, and is surely part of the "raison de notmuch"
:-)
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/100c771c/attachment.pgp>


[PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread David Edmondson
When using the spacebar to scroll through a thread, hitting 'space'
when the bottom of the last message is visible should take the cursor
to the end of the buffer rather than immediately archiving the thread
and moving to the next thread.
---
 emacs/notmuch-show.el |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ec72ff8..3f54de0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1319,6 +1319,11 @@ current window), advance to the next open message."
   ;; This is not the last message - move to the next visible one.
   (notmuch-show-next-open-message))

+ ((not (= (point) (point-max)))
+  ;; This is the last message, but the cursor is not at the end of
+  ;; the buffer. Move it there.
+  (goto-char (point-max)))
+
  (t
   ;; This is the last message - change the return value
   (setq ret t)))
-- 
1.7.8.3



[PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread David Edmondson
When archiving the last message in a thread (a), rather than just
moving the pointer to the next thread in the parent search buffer,
actually display the next thread.
---
 emacs/notmuch-show.el |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index de9421e..ec72ff8 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1427,7 +1427,7 @@ buffer."
  (notmuch-show-mark-read)
  (notmuch-show-message-adjust))
   (if pop-at-end
- (notmuch-show-next-thread)
+ (notmuch-show-next-thread t)
(goto-char (point-max))

 (defun notmuch-show-previous-open-message ()
-- 
1.7.8.3



[PATCH 0/2] adjust the new movement commands

2012-01-31 Thread David Edmondson
After Jameson's recent work the precise behaviour of 'a' and ' ' in
`notmuch-show-mode' changed slightly. Revert to something nearer the
previous behaviour.

David Edmondson (2):
  emacs: If archiving the last message in a thread, show the next
thread.
  emacs: Don't move to the next thread unless the cursor is at the end 
   of the buffer.

 emacs/notmuch-show.el |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

-- 
1.7.8.3



[PATCH 1/3] lib: Don't delete uninitialized pointers

2012-01-31 Thread Dmitry Kurochkin
Hi Austin.

All 3 patches look good to me.

Regards,
  Dmitry


[PATCH 5/5] emacs: Retain the state of the buffer during `notmuch-show-refresh-view'.

2012-01-31 Thread David Edmondson
On Mon, 30 Jan 2012 20:19:23 +, Mark Walters  
wrote:
> The first is that I currently sometimes use = (that is
> notmuch-show-refresh-view) as a way to go back to the original state (ie
> which messages are open and back to the first message) so I am not sure
> the keep state version should completely replace the old one. (Maybe
> there is an alternative way to achieve the same effect that I don't
> know!)

Thinking about it afterwards, I agree. That is:
- '=' should behave as though the buffer was remade anew,
- the toggle commands should retain the state.

> Secondly in
> 
> >  (defun notmuch-show-refresh-view ()
> >"Refresh the current view.
> >  
> >  Refreshes the current view, observing changes in cryptographic 
> > preferences."
> >(interactive)
> > -  (let ((inhibit-read-only t))
> > -(erase-buffer))
> > -  (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
> > -  notmuch-show-query-context))
> > +  (let ((inhibit-read-only t)
> > +   (state (notmuch-show-capture-state)))
> > +(erase-buffer)
> > +(notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
> > +notmuch-show-query-context)
> > +(notmuch-show-apply-state state)))
> 
> how would you feel about a (notmuch-show-message-adjust) at the end?

Agreed.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/3610f74c/attachment.pgp>


[PATCH 1/2 v2] emacs: Stop the `truncate-string-to-width' madness.

2012-01-31 Thread David Edmondson
On Mon, 30 Jan 2012 18:46:55 -0500, Austin Clements  wrote:
> >(message "End of search results."
> 
> Should this instead be an `error'?

It was an error in the past (until
id:"1324370714-28545-1-git-send-email-dme at dme.org"), but I found it to
be very annoying and switched it to use `message' because the error
would fire whenever `notmuch-show-archive-thread-internal' walked past
the last message.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20120131/f1fef699/attachment.pgp>


[PATCH 2/2] show: Simplify new text formatter code

2012-01-31 Thread Dmitry Kurochkin
On Thu, 26 Jan 2012 01:55:26 -0500, Austin Clements  wrote:
> This makes the text formatter take advantage of the new code
> structure.  The previously duplicated header logic is now unified,
> several things that we used to compute repeatedly across different
> callbacks are now computed once, and the code is simpler overall and
> 32% shorter.
> 
> Unifying the header logic causes this to format some dates slightly
> differently, so the two affected test cases are updated.
> ---

Looks good to me.  Two minor comments, which can be freely ignored, are
below.

>  notmuch-show.c |   88 +--
>  test/crypto|2 +-
>  test/thread-naming |   16 +-
>  3 files changed, 32 insertions(+), 74 deletions(-)
> 
> diff --git a/notmuch-show.c b/notmuch-show.c
> index 6a890b2..30f6501 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -727,67 +727,48 @@ format_part_text (const void *ctx, mime_node_t *node,
>  GMimeObject *meta = node->envelope_part ?
>   GMIME_OBJECT (node->envelope_part) : node->part;
>  GMimeContentType *content_type = g_mime_object_get_content_type (meta);
> +const notmuch_bool_t leaf = GMIME_IS_PART (node->part);
> +const char *part_type;
>  int i;
>  
>  if (node->envelope_file) {
>   notmuch_message_t *message = node->envelope_file;
> - const char *headers[] = {
> - "Subject", "From", "To", "Cc", "Bcc", "Date"
> - };
> - const char *name, *value;
> - unsigned int i;
>  
> - printf ("\fmessage{ ");
> - printf ("id:%s depth:%d match:%d filename:%s\n",
> + part_type = "message";
> + printf ("\f%s{ id:%s depth:%d match:%d filename:%s\n",
> + part_type,
>   notmuch_message_get_message_id (message),
>   indent,
>   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
>   notmuch_message_get_filename (message));
> -
> - printf ("\fheader{\n");
> -
> - printf ("%s\n", _get_one_line_summary (ctx, message));
> -
> - for (i = 0; i < ARRAY_SIZE (headers); i++) {
> - name = headers[i];
> - value = notmuch_message_get_header (message, name);
> - if (value && strlen (value))
> - printf ("%s: %s\n", name, value);
> - }
> - printf ("\fheader}\n");
>  } else {
>   GMimeContentDisposition *disposition = 
> g_mime_object_get_content_disposition (meta);
>   const char *cid = g_mime_object_get_content_id (meta);
> + const char *filename = leaf ?
> + g_mime_part_get_filename (GMIME_PART (node->part)) : NULL;
>  
>   if (disposition &&
>   strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 
> 0)
> - {
> - printf ("\fattachment{ ID: %d", node->part_num);
> -
> - } else {
> -
> - printf ("\fpart{ ID: %d", node->part_num);
> - }
> -
> - if (GMIME_IS_PART (node->part))
> - {
> - const char *filename = g_mime_part_get_filename (GMIME_PART 
> (node->part));
> - if (filename)
> - printf (", Filename: %s", filename);
> - }
> + part_type = "attachment";
> + else
> + part_type = "part";

Others may disagree, but I would write this using the (? :) operator.
Not important, feel free to leave it as is.

>  
> + printf ("\f%s{ ID: %d", part_type, node->part_num);
> + if (filename)
> + printf (", Filename: %s", filename);
>   if (cid)
>   printf (", Content-id: %s", cid);
> -
>   printf (", Content-type: %s\n", g_mime_content_type_to_string 
> (content_type));
>  }
>  
> -if (node->envelope_part) {
> +if (GMIME_IS_MESSAGE (node->part)) {
>   GMimeMessage *message = GMIME_MESSAGE (node->part);
>   InternetAddressList *recipients;
>   const char *recipients_string;
>  
>   printf ("\fheader{\n");
> + if (node->envelope_file)
> + printf ("%s\n", _get_one_line_summary (ctx, node->envelope_file));
>   printf ("Subject: %s\n", g_mime_message_get_subject (message));
>   printf ("From: %s\n", g_mime_message_get_sender (message));
>   recipients = g_mime_message_get_recipients (message, 
> GMIME_RECIPIENT_TYPE_TO);
> @@ -800,9 +781,11 @@ format_part_text (const void *ctx, mime_node_t *node,
>   printf ("Cc: %s\n", recipients_string);
>   printf ("Date: %s\n", g_mime_message_get_date_as_string (message));
>   printf ("\fheader}\n");
> +
> + printf ("\fbody{\n");
>  }
>  
> -if (!node->envelope_file) {
> +if (leaf) {
>   if (g_mime_content_type_is_type (content_type, "text", "*") &&
>   !g_mime_content_type_is_type (content_type, "text", "html"))
>   {
> @@ -810,45 +793,20 @@ format_part_text (const void *ctx, mime_node_t *node,
>   g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), 
> FALSE);
>   show_text_part_content (node->part, stream_stdout);
>   

[PATCH 1/2] show: Convert text format to the new self-recursive style

2012-01-31 Thread Dmitry Kurochkin
On Thu, 26 Jan 2012 01:55:25 -0500, Austin Clements  wrote:
> This is all code movement and a smidgen of glue.  This moves the
> existing text formatter code into one self-recursive function, but
> doesn't change any of the logic.  The next patch will actually take
> advantage of what the new structure has to offer.
> 
> Note that this patch retains format_headers_message_part_text because
> it is also used by the raw format.
> ---
>  notmuch-show.c |  270 
> +---
>  1 files changed, 139 insertions(+), 131 deletions(-)
> 
> diff --git a/notmuch-show.c b/notmuch-show.c
> index dec799c..6a890b2 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -21,40 +21,17 @@
>  #include "notmuch-client.h"
>  
>  static void
> -format_message_text (unused (const void *ctx),
> -  notmuch_message_t *message,
> -  int indent);
> -static void
> -format_headers_text (const void *ctx,
> -  notmuch_message_t *message);
> -
> -static void
>  format_headers_message_part_text (GMimeMessage *message);
>  
>  static void
> -format_part_start_text (GMimeObject *part,
> - int *part_count);
> -
> -static void
> -format_part_content_text (GMimeObject *part);
> -
> -static void
> -format_part_end_text (GMimeObject *part);
> +format_part_text (const void *ctx, mime_node_t *node,
> +   int indent, const notmuch_show_params_t *params);
>  
>  static const notmuch_show_format_t format_text = {
> -"", NULL,
> - "\fmessage{ ", format_message_text,
> - "\fheader{\n", format_headers_text, 
> format_headers_message_part_text, "\fheader}\n",
> - "\fbody{\n",
> - format_part_start_text,
> - NULL,
> - NULL,
> - format_part_content_text,
> - format_part_end_text,
> - "",
> - "\fbody}\n",
> - "\fmessage}\n", "",
> -""
> +.message_set_start = "",
> +.part = format_part_text,
> +.message_set_sep = "",
> +.message_set_end = ""

I guess I missed this during the first review.  I think we should
support NULL values for message_set_* members (in a separate patch, I
guess).  This would allow us to explicitly initialize only part member
in the above code.

Looks good otherwise.

Regards,
  Dmitry

>  };
>  
>  static void
> @@ -191,16 +168,6 @@ _get_one_line_summary (const void *ctx, 
> notmuch_message_t *message)
>  }
>  
>  static void
> -format_message_text (unused (const void *ctx), notmuch_message_t *message, 
> int indent)
> -{
> -printf ("id:%s depth:%d match:%d filename:%s\n",
> - notmuch_message_get_message_id (message),
> - indent,
> - notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
> - notmuch_message_get_filename (message));
> -}
> -
> -static void
>  format_message_json (const void *ctx, notmuch_message_t *message, unused 
> (int indent))
>  {
>  notmuch_tags_t *tags;
> @@ -338,26 +305,6 @@ format_message_mbox (const void *ctx,
>  fclose (file);
>  }
>  
> -
> -static void
> -format_headers_text (const void *ctx, notmuch_message_t *message)
> -{
> -const char *headers[] = {
> - "Subject", "From", "To", "Cc", "Bcc", "Date"
> -};
> -const char *name, *value;
> -unsigned int i;
> -
> -printf ("%s\n", _get_one_line_summary (ctx, message));
> -
> -for (i = 0; i < ARRAY_SIZE (headers); i++) {
> - name = headers[i];
> - value = notmuch_message_get_header (message, name);
> - if (value && strlen (value))
> - printf ("%s: %s\n", name, value);
> -}
> -}
> -
>  static void
>  format_headers_message_part_text (GMimeMessage *message)
>  {
> @@ -523,78 +470,6 @@ signer_status_to_string (GMimeSignerStatus x)
>  #endif
>  
>  static void
> -format_part_start_text (GMimeObject *part, int *part_count)
> -{
> -GMimeContentDisposition *disposition = 
> g_mime_object_get_content_disposition (part);
> -
> -if (disposition &&
> - strcmp (disposition->disposition, GMIME_DISPOSITION_ATTACHMENT) == 0)
> -{
> - printf ("\fattachment{ ID: %d", *part_count);
> -
> -} else {
> -
> - printf ("\fpart{ ID: %d", *part_count);
> -}
> -}
> -
> -static void
> -format_part_content_text (GMimeObject *part)
> -{
> -const char *cid = g_mime_object_get_content_id (part);
> -GMimeContentType *content_type = g_mime_object_get_content_type 
> (GMIME_OBJECT (part));
> -
> -if (GMIME_IS_PART (part))
> -{
> - const char *filename = g_mime_part_get_filename (GMIME_PART (part));
> - if (filename)
> - printf (", Filename: %s", filename);
> -}
> -
> -if (cid)
> - printf (", Content-id: %s", cid);
> -
> -printf (", Content-type: %s\n", g_mime_content_type_to_string 
> (content_type));
> -
> -if (g_mime_content_type_is_type (content_type, "text", "*") &&
> - !g_mime_content_type_is_type (content_type, "text", "html"))
> -{
> - 

[PATCH 2/2] test: use subtest name for generated message subject by default

2012-01-31 Thread Dmitry Kurochkin
Before the change, messages generated by generate_message() used "Test
message #N" for default subject where N is the generated messages
counter.  Since message subject is commonly present in expected
results, there is a chance of breaking other tests when a new
generate_message() call is added.  The patch changes default subject
value for generated messages to subtest name if it is available.  If
subtest name is not available (i.e. message is generated during test
initialization), the old default value is used (in this case it is
fine to have the counter in the subject).

Another benefit of this change is a sane default value for subject in
generated messages, which would allow to simplify code like:

  test_begin_subtest "test for a cool feature"
  add_message [subject]="message for test for a cool feature"
---
 test/encoding|2 +-
 test/search-folder-coherence |2 +-
 test/test-lib.sh |6 +-
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/test/encoding b/test/encoding
index 33259c1..dbaceb0 100755
--- a/test/encoding
+++ b/test/encoding
@@ -9,7 +9,7 @@ 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
 header{
 Notmuch Test Suite  (2001-01-05) (inbox unread)
-Subject: Test message #1
+Subject: Message with text of unknown charset
 From: Notmuch Test Suite 
 To: Notmuch Test Suite 
 Date: Fri, 05 Jan 2001 15:43:57 +
diff --git a/test/search-folder-coherence b/test/search-folder-coherence
index f8119cb..3f6ec76 100755
--- a/test/search-folder-coherence
+++ b/test/search-folder-coherence
@@ -32,7 +32,7 @@ test_expect_equal_file OUTPUT EXPECTED

 test_begin_subtest "Test matches folder:spam"
 output=$(notmuch search folder:spam)
-test_expect_equal "$output" "thread:0001   2001-01-05 [1/1] 
Notmuch Test Suite; Test message #1 (inbox unread)"
+test_expect_equal "$output" "thread:0001   2001-01-05 [1/1] 
Notmuch Test Suite; Single new message (inbox unread)"

 test_begin_subtest "Remove folder:spam copy of email"
 rm $dir/spam/$(basename $file_x)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 8158328..94efdc1 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -318,7 +318,11 @@ generate_message ()
 fi

 if [ -z "${template[subject]}" ]; then
-   template[subject]="Test message #${gen_msg_cnt}"
+   if [ -n "$test_subtest_name" ]; then
+   template[subject]="$test_subtest_name"
+   else
+   template[subject]="Test message #${gen_msg_cnt}"
+   fi
 fi

 if [ -z "${template[date]}" ]; then
-- 
1.7.8.3



[PATCH 1/2] test: remove "Generate some messages" test from raw

2012-01-31 Thread Dmitry Kurochkin
Before the change, the first subtest in raw format tests just
generated messages and checked that they are added successfully.  This
is not really a raw format test, it is creating of environment
required for other subtests to run.  The patch removes the first
subtest from raw and replaces it with bare add_message calls, similar
to how it is done in other tests.

TODO: we should check that test environment was created successfully.
Currently, many tests do add_message(), notmuch new and other calls
without checking the results.  We should come up with a general
solution for this, i.e. if any command during test initialization
fails, all tests should be skipped with appropriate error message.
---
 test/raw |7 ++-
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/test/raw b/test/raw
index 0171e64..de0b867 100755
--- a/test/raw
+++ b/test/raw
@@ -3,11 +3,8 @@
 test_description='notmuch show --format=raw'
 . ./test-lib.sh

-test_begin_subtest "Generate some messages"
-generate_message
-generate_message
-output=$(NOTMUCH_NEW)
-test_expect_equal "$output" "Added 2 new messages to the database."
+add_message
+add_message

 test_begin_subtest "Attempt to show multiple raw messages"
 output=$(notmuch show --format=raw "*" 2>&1)
-- 
1.7.8.3



Bug?: notmuch-search-show-thread shows several threads; only one containing matching messages

2012-01-31 Thread Mark Walters
On Mon, 30 Jan 2012 23:34:16 +0100, Gregor Zattler  wrote:
> Hi Mark,
> * Mark Walters  [30. Jan. 2012]:
> > On Mon, 30 Jan 2012 20:04:25 +0100, Gregor Zattler  
> > wrote:
> >> * Pieter Praet  [30. Jan. 2012]:
> >>> On Mon, 30 Jan 2012 00:42:14 +0100, Gregor Zattler  
> >>> wrote:
>  * Pieter Praet  [26. Jan. 2012]:
> > Here's another couple of threads squashed into a single one:
> > - [O] [Use Question] Capture and long lines
> >   - id:"BANLkTikoF4tXuNLLufRzNSD6k2ZYs7sUcg at mail.gmail.com"
> > - [O] Worg update
> >   - id:"m1wrfiz3ch.fsf at tsdye.com"
> > - [O] Table formula to convert hex to dec
> >   - id:"20110724080054.GB16388 at x201"
> > - [O] ICS import?
> >   - id:"20120125173421.GQ3747 at x201"
> > 
> > 
> > AFAICT, none of them share Message-Id's...
>  
>  Do you consider this a bug?
>  
> >>> 
> >>> I do.  No idea what causes it or how to fix it though... :)
> >> 
> >> First I thougt it' not a severe bug since one see's more not less
> >> messages in notmuch show buffer.  But later I realised one also
> >> sees less not more threads in notmuch search buffer and might not
> >> read certain notmuch threads because of "wrong" $Subject: in
> >> notmuch search buffer.
> 
> > I think notmuch links two messages into the same thread if they have an
> > in-reply-to or reference header in common: i.e the messages reference a
> > common parent message.  (See comment in lib/database.cc "Even before a
> > message is added, it's pre-allocated thread ID is useful so that all
> > descendant messages that reference this common parent can be recognized
> > as belonging to the same thread.")
> 
> So in case message a from thread A and message b from B would
> name the same Message c in their In-Reoply-To:/References:
> headers, while c is not (for some reason) in A or B, notmuch
> would assume both threads linked?  Makes sense.
>  
> > As far as I can see your grep tests haven't checked for that. 
> 
> True.
> 
> > Also, could you email me the mbox you had (I think you said that it was
> > a mailing list so all public) and I will take a look?
> 
> Sure, I do so off-list because of the size of the attachment.

Hi 

I have looked at this and I think this is not notmuch's fault: I think
it is a mua doing strange things:

One of the mails has an in-reply-to header which looks like

In-reply-to: Message from Carsten Dominik  of 
   "Tue, 15 Mar 2011 12:18:51 BST."
<17242340-A14F-495A-B144-20C96D52B620 at gmail.com>

and I think notmuch is taking the carsten.dominik at gmail.com as message
id.

A similar in-reply-to header appears in the other thread so notmuch
pairs them up. According to http://www.jwz.org/doc/threading.html this
form of header is not allowed under RFC2822 but was allowed under the
earlier RFC822.

You can see several such messages on the gnu-mailing list site eg

ftp://lists.gnu.org/emacs-orgmode/2011-11 

search for "in-reply-to: M" but they all appear to be from the same
person (running mh-e 8.3 nmh under emacs 24)

In my collection from the linux kernel mailing list I get some examples
of in-reply-to not just being :  but it was only about 200 from
100,000 messages in the second half of 2010 (the most recent archives I
have).

Best wishes

Mark






[RFC PATCH 2/4] Add NOTMUCH_MESSAGE_FLAG_EXCLUDED flag

2012-01-31 Thread Austin Clements
This is looking really good.  I think this overall approach is
significantly better than the initial exclude support and the UI
aspects look like they should be much more pleasant.

Quoth Mark Walters on Jan 29 at  6:36 pm:
> 
> Ok I now have a patch set which might be complete enough to be worth
> reviewing. It is essentially complete and appears to work.
> 
> Things that still need doing: 
>updating the test suite. The series changes notmuch-show to
>output the exclude flag so several tests need updating. Of
>course, the new functionality needs some tests too.
>
>emacs/notmuch.el I think it would be nice to hide (make
>invisible) threads with no matching non-excluded messages (with a
>toggle for visibility) but that is definitely beyond my elisp
>skills.

I'm happy to do that once this goes in.

> The first patch of the series is not really part of the series: it adds
> a --do-not-exclude option to tell the command not to exclude. I think
> this is useful anyway, but it also simplifies behaviour decisions with
> the excludes. For example notmuch count will only count matching
> non-excluded messages but notmuch count --do-not-exclude will count 
> all matching messages excluded or not.
> 
> One outstanding issue is that raised in
> id:"20120124025331.GZ16740 at mit.edu". I will need to think about
> that. 
> 
> Best wishes
> 
> Mark
> 


[PATCH 4/7] lib: Add the exclude flag to notmuch_query_search_threads

2012-01-31 Thread Austin Clements
Quoth Mark Walters on Jan 29 at  6:39 pm:
> Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to
> notmuch_query_search_threads. Implemented by inspecting the tags
> directly in _notmuch_thread_create/_thread_add_message rather than as
> a Xapian query for speed reasons.

Hmm.  Won't the thread sort be influenced by excluded messages?

It's not completely obvious to me if it should or shouldn't be.  If
excluded messages are counted for thread sorting, it would be very
natural to toggle their visibility in the search view; otherwise we
probably need to perform the entire query again with exclusions
disabled.

If we do want to ignore excluded messages for sorting, I think
notmuch_query_search_threads can simply shuffle excluded messages to
the end of doc_ids (which is slightly awkward to implement, but not
too bad).


[PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread David Edmondson
When using the spacebar to scroll through a thread, hitting 'space'
when the bottom of the last message is visible should take the cursor
to the end of the buffer rather than immediately archiving the thread
and moving to the next thread.
---
 emacs/notmuch-show.el |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index ec72ff8..3f54de0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1319,6 +1319,11 @@ current window), advance to the next open message.
   ;; This is not the last message - move to the next visible one.
   (notmuch-show-next-open-message))
 
+ ((not (= (point) (point-max)))
+  ;; This is the last message, but the cursor is not at the end of
+  ;; the buffer. Move it there.
+  (goto-char (point-max)))
+
  (t
   ;; This is the last message - change the return value
   (setq ret t)))
-- 
1.7.8.3

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


[PATCH 0/2] adjust the new movement commands

2012-01-31 Thread David Edmondson
After Jameson's recent work the precise behaviour of 'a' and ' ' in
`notmuch-show-mode' changed slightly. Revert to something nearer the
previous behaviour.

David Edmondson (2):
  emacs: If archiving the last message in a thread, show the next
thread.
  emacs: Don't move to the next thread unless the cursor is at the end 
   of the buffer.

 emacs/notmuch-show.el |7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

-- 
1.7.8.3

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


Re: [PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread David Edmondson
On Mon, 30 Jan 2012 09:47:34 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 One thing I've noticed, which isn't actually part of this patch, is that
 the long-line truncation doesn't respect the indentation, which makes
 things look strange.

Which lines are getting wrapped in a way that you don't like? The header
line? The headers? The body?

 But honestly I still don't like our method of displaying threads as a
 giant chain of concatenated messages with indentation.  But that's for
 later work.

It's inherited from sup, and is surely part of the raison de notmuch
:-)


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


Re: [PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread Dmitry Kurochkin
On Tue, 31 Jan 2012 08:01:53 +, David Edmondson d...@dme.org wrote:
 When archiving the last message in a thread (a), rather than just
 moving the pointer to the next thread in the parent search buffer,
 actually display the next thread.
 ---

+1

Regards,
  Dmitry

  emacs/notmuch-show.el |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index de9421e..ec72ff8 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1427,7 +1427,7 @@ buffer.
 (notmuch-show-mark-read)
 (notmuch-show-message-adjust))
(if pop-at-end
 -   (notmuch-show-next-thread)
 +   (notmuch-show-next-thread t)
   (goto-char (point-max))
  
  (defun notmuch-show-previous-open-message ()
 -- 
 1.7.8.3
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread Dmitry Kurochkin
On Tue, 31 Jan 2012 08:22:20 +, David Edmondson d...@dme.org wrote:
 On Tue, 31 Jan 2012 12:12:50 +0400, Dmitry Kurochkin 
 dmitry.kuroch...@gmail.com wrote:
  On Tue, 31 Jan 2012 08:01:54 +, David Edmondson d...@dme.org wrote:
   When using the spacebar to scroll through a thread, hitting 'space'
   when the bottom of the last message is visible should take the cursor
   to the end of the buffer rather than immediately archiving the thread
   and moving to the next thread.
   ---
  
  I did not notice this change yet, so +0
  
  A style comment below.
  
emacs/notmuch-show.el |5 +
1 files changed, 5 insertions(+), 0 deletions(-)
   
   diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
   index ec72ff8..3f54de0 100644
   --- a/emacs/notmuch-show.el
   +++ b/emacs/notmuch-show.el
   @@ -1319,6 +1319,11 @@ current window), advance to the next open message.
  ;; This is not the last message - move to the next visible one.
  (notmuch-show-next-open-message))

   + ((not (= (point) (point-max)))
   +  ;; This is the last message, but the cursor is not at the end of
   +  ;; the buffer. Move it there.
   +  (goto-char (point-max)))
  
  Perhaps `unless' would be better here?
 
 It's the CONDITION clause of `cond', so that wouldn't be appropriate.
 

oh

This is why I like big diff contexts...

Regards,
  Dmitry

  Regards,
Dmitry
  
   +
 (t
  ;; This is the last message - change the return value
  (setq ret t)))
   -- 
   1.7.8.3
   
   ___
   notmuch mailing list
   notmuch@notmuchmail.org
   http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 2/2] emacs: Don't move to the next thread unless the cursor is at the end of the buffer.

2012-01-31 Thread Tomi Ollila
On Tue, 31 Jan 2012 08:01:54 +, David Edmondson d...@dme.org wrote:
 When using the spacebar to scroll through a thread, hitting 'space'
 when the bottom of the last message is visible should take the cursor
 to the end of the buffer rather than immediately archiving the thread
 and moving to the next thread.
 ---

+1 !

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


[PATCH 4/5] emacs: Add a binding () to toggle the truncation of long lines.

2012-01-31 Thread David Edmondson
---
 emacs/notmuch-show.el |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 789b6d9..28f2148 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1116,6 +1116,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences.
(define-key map ! 'notmuch-show-toggle-elide-non-matching)
(define-key map $ 'notmuch-show-toggle-process-crypto)
(define-key map  'notmuch-show-toggle-thread-indentation)
+   (define-key map  'toggle-truncate-lines)
map)
   Keymap for \notmuch show\ buffers.)
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
-- 
1.7.8.3

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


[PATCH 2/5] emacs: Allow `notmuch-show-mode' to display only matching messages.

2012-01-31 Thread David Edmondson
The current behaviour (all messages shown, non-matching collapsed)
is retained as the default. Type '!' to switch to showing only
the matching messages - non-matching messages are not available.
'!' will switch back to showing everything.
---
 emacs/notmuch-show.el |   18 +-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 35a2809..77ba2dd 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -136,6 +136,10 @@ indentation.
 (make-variable-buffer-local 'notmuch-show-process-crypto)
 (put 'notmuch-show-process-crypto 'permanent-local t)
 
+(defvar notmuch-show-elide-non-matching-messages nil)
+(make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
+(put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (rest body)
   Evaluate body with current buffer set to the text of current message
   `(save-excursion
@@ -923,11 +927,22 @@ current buffer, if possible.
 Not processing cryptographic MIME parts.))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-elide-non-matching ()
+  Toggle the display of non-matching messages.
+  (interactive)
+  (setq notmuch-show-elide-non-matching-messages (not 
notmuch-show-elide-non-matching-messages))
+  (message (if notmuch-show-elide-non-matching-messages
+  Showing matching messages only.
+Showing all messages.))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   Insert the message tree TREE at depth DEPTH in the current thread.
   (let ((msg (car tree))
(replies (cadr tree)))
-(notmuch-show-insert-msg msg depth)
+(if (or (not notmuch-show-elide-non-matching-messages)
+   (plist-get msg :match))
+   (notmuch-show-insert-msg msg depth))
 (notmuch-show-insert-thread replies (1+ depth
 
 (defun notmuch-show-insert-thread (thread depth)
@@ -1081,6 +1096,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences.
(define-key map (kbd M-RET) 'notmuch-show-open-or-close-all)
(define-key map (kbd RET) 'notmuch-show-toggle-message)
(define-key map # 'notmuch-show-print-message)
+   (define-key map ! 'notmuch-show-toggle-elide-non-matching)
(define-key map $ 'notmuch-show-toggle-process-crypto)
map)
   Keymap for \notmuch show\ buffers.)
-- 
1.7.8.3

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


[PATCH 3/5] emacs: Allow the indentation of content to be toggled.

2012-01-31 Thread David Edmondson
Very deeply indented content is sometimes difficult to
read (particular for something like patches). Allow the indentation of
the content to be toggled with ''.

Indentation of the header lines is not affected, so it remains
possible to see the structure of the thread.
---
 emacs/notmuch-show.el |   26 ++
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 77ba2dd..789b6d9 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -140,6 +140,10 @@ indentation.
 (make-variable-buffer-local 'notmuch-show-elide-non-matching-messages)
 (put 'notmuch-show-elide-non-matching-messages 'permanent-local t)
 
+(defvar notmuch-show-indent-content t)
+(make-variable-buffer-local 'notmuch-show-indent-content)
+(put 'notmuch-show-indent-content 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (rest body)
   Evaluate body with current buffer set to the text of current message
   `(save-excursion
@@ -250,10 +254,12 @@ operation on the contents of the current buffer.
 (all (buffer-substring (notmuch-show-message-top)
(notmuch-show-message-bottom)))
 
-(props (notmuch-show-get-message-properties)))
+(props (notmuch-show-get-message-properties))
+(indenting notmuch-show-indent-content))
 (with-temp-buffer
   (insert all)
-  (indent-rigidly (point-min) (point-max) (- depth))
+  (if indenting
+ (indent-rigidly (point-min) (point-max) (- depth)))
   ;; Remove the original header.
   (goto-char (point-min))
   (re-search-forward ^$ (point-max) nil)
@@ -881,7 +887,8 @@ current buffer, if possible.
 (setq notmuch-show-previous-subject bare-subject)
 
 (setq body-start (point-marker))
-(notmuch-show-insert-body msg (plist-get msg :body) depth)
+(notmuch-show-insert-body msg (plist-get msg :body)
+ (if notmuch-show-indent-content depth 0))
 ;; Ensure that the body ends with a newline.
 (unless (bolp)
   (insert \n))
@@ -889,7 +896,8 @@ current buffer, if possible.
 (setq content-end (point-marker))
 
 ;; Indent according to the depth in the thread.
-(indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth))
+(if notmuch-show-indent-content
+   (indent-rigidly content-start content-end (* 
notmuch-show-indent-messages-width depth)))
 
 (setq message-end (point-max-marker))
 
@@ -936,6 +944,15 @@ current buffer, if possible.
 Showing all messages.))
   (notmuch-show-refresh-view))
 
+(defun notmuch-show-toggle-thread-indentation ()
+  Toggle the indentation of threads.
+  (interactive)
+  (setq notmuch-show-indent-content (not notmuch-show-indent-content))
+  (message (if notmuch-show-indent-content
+  Content is indented.
+Content is not indented.))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   Insert the message tree TREE at depth DEPTH in the current thread.
   (let ((msg (car tree))
@@ -1098,6 +1115,7 @@ Refreshes the current view, observing changes in 
cryptographic preferences.
(define-key map # 'notmuch-show-print-message)
(define-key map ! 'notmuch-show-toggle-elide-non-matching)
(define-key map $ 'notmuch-show-toggle-process-crypto)
+   (define-key map  'notmuch-show-toggle-thread-indentation)
map)
   Keymap for \notmuch show\ buffers.)
 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
-- 
1.7.8.3

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


[PATCH 1/5] emacs: Rework crypto switch toggle.

2012-01-31 Thread David Edmondson
Re-work the existing crypto switch toggle to be based on a persistant
buffer-local variable.

To allow this, modify `notmuch-show-refresh-view' to erase and re-draw
in the current buffer rather than killing the current buffer and
creating a new one. (This will also allow more per-buffer behaviour in
future patches.)

Add a binding ('$') to toggle crypto processing of the current buffer
and remove the prefix argument approach that achieves a similar
result.
---
 emacs/notmuch-show.el |  105 +++-
 emacs/notmuch.el  |7 +--
 2 files changed, 53 insertions(+), 59 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index de9421e..35a2809 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -125,6 +125,17 @@ indentation.
 (const :tag View interactively
notmuch-show-interactively-view-part)))
 
+(defvar notmuch-show-thread-id nil)
+(make-variable-buffer-local 'notmuch-show-thread-id)
+(defvar notmuch-show-parent-buffer nil)
+(make-variable-buffer-local 'notmuch-show-parent-buffer)
+(defvar notmuch-show-query-context nil)
+(make-variable-buffer-local 'notmuch-show-query-context)
+
+(defvar notmuch-show-process-crypto nil)
+(make-variable-buffer-local 'notmuch-show-process-crypto)
+(put 'notmuch-show-process-crypto 'permanent-local t)
+
 (defmacro with-current-notmuch-show-message (rest body)
   Evaluate body with current buffer set to the text of current message
   `(save-excursion
@@ -411,14 +422,11 @@ message at DEPTH in the current thread.
 
 (defmacro notmuch-with-temp-part-buffer (message-id nth rest body)
   (declare (indent 2))
-  (let ((process-crypto (make-symbol process-crypto)))
-`(let ((,process-crypto notmuch-show-process-crypto))
-   (with-temp-buffer
-(setq notmuch-show-process-crypto ,process-crypto)
-;; Always acquires the part via `notmuch part', even if it is
-;; available in the JSON output.
-(insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
-,@body
+  `(with-temp-buffer
+ ;; Always acquires the part via `notmuch part', even if it is
+ ;; available in the JSON output.
+ (insert (notmuch-show-get-bodypart-internal ,message-id ,nth))
+ ,@body))
 
 (defun notmuch-show-save-part (message-id nth optional filename content-type)
   (notmuch-with-temp-part-buffer message-id nth
@@ -600,7 +608,7 @@ current buffer, if possible.
   (sigstatus (car (plist-get part :sigstatus
  (notmuch-crypto-insert-sigstatus-button sigstatus from))
   ;; if we're not adding sigstatus, tell the user how they can get it
-  (button-put button 'help-echo Set notmuch-crypto-process-mime to 
process cryptographic mime parts.)))
+  (button-put button 'help-echo Set notmuch-crypto-process-mime to 
process cryptographic MIME parts.)))
 
   (let ((inner-parts (plist-get part :content))
(start (point)))
@@ -626,7 +634,7 @@ current buffer, if possible.
 (sigstatus (car (plist-get part :sigstatus
(notmuch-crypto-insert-sigstatus-button sigstatus from
   ;; if we're not adding encstatus, tell the user how they can get it
-  (button-put button 'help-echo Set notmuch-crypto-process-mime to 
process cryptographic mime parts.)))
+  (button-put button 'help-echo Set notmuch-crypto-process-mime to 
process cryptographic MIME parts.)))
 
   (let ((inner-parts (plist-get part :content))
(start (point)))
@@ -753,8 +761,6 @@ current buffer, if possible.
 
 ;; Helper for parts which are generally not included in the default
 ;; JSON output.
-;; Uses the buffer-local variable notmuch-show-process-crypto to
-;; determine if parts should be decrypted first.
 (defun notmuch-show-get-bodypart-internal (message-id part-number)
   (let ((args '(show --format=raw))
(part-arg (format --part=%s part-number)))
@@ -908,6 +914,15 @@ current buffer, if possible.
 ;; criteria.
 (notmuch-show-message-visible msg (plist-get msg :match
 
+(defun notmuch-show-toggle-process-crypto ()
+  Toggle the processing of cryptographic MIME parts.
+  (interactive)
+  (setq notmuch-show-process-crypto (not notmuch-show-process-crypto))
+  (message (if notmuch-show-process-crypto
+  Processing cryptographic MIME parts.
+Not processing cryptographic MIME parts.))
+  (notmuch-show-refresh-view))
+
 (defun notmuch-show-insert-tree (tree depth)
   Insert the message tree TREE at depth DEPTH in the current thread.
   (let ((msg (car tree))
@@ -923,15 +938,6 @@ current buffer, if possible.
   Insert the forest of threads FOREST.
   (mapc (lambda (thread) (notmuch-show-insert-thread thread 0)) forest))
 
-(defvar notmuch-show-thread-id nil)
-(make-variable-buffer-local 'notmuch-show-thread-id)
-(defvar notmuch-show-parent-buffer nil)
-(make-variable-buffer-local 'notmuch-show-parent-buffer)
-(defvar notmuch-show-query-context nil)

[PATCH 5/5] emacs: Optionally retain the state of the buffer during `notmuch-show-refresh-view'.

2012-01-31 Thread David Edmondson
With an argument, record and reply the state of the buffer during
`notmuch-show-refresh-view'.

In this context, state is defined as:
 - the open/closed state of each message,
 - the current message.

Traditional use of refresh with the = key does not retain the
state. The recently introduced toggle commands ($, !,  and ) do
retain the state.
---
 emacs/notmuch-show.el |   58 +---
 1 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 28f2148..2f10c42 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -933,7 +933,7 @@ current buffer, if possible.
   (message (if notmuch-show-process-crypto
   Processing cryptographic MIME parts.
 Not processing cryptographic MIME parts.))
-  (notmuch-show-refresh-view))
+  (notmuch-show-refresh-view t))
 
 (defun notmuch-show-toggle-elide-non-matching ()
   Toggle the display of non-matching messages.
@@ -942,7 +942,7 @@ current buffer, if possible.
   (message (if notmuch-show-elide-non-matching-messages
   Showing matching messages only.
 Showing all messages.))
-  (notmuch-show-refresh-view))
+  (notmuch-show-refresh-view t))
 
 (defun notmuch-show-toggle-thread-indentation ()
   Toggle the indentation of threads.
@@ -951,7 +951,7 @@ current buffer, if possible.
   (message (if notmuch-show-indent-content
   Content is indented.
 Content is not indented.))
-  (notmuch-show-refresh-view))
+  (notmuch-show-refresh-view t))
 
 (defun notmuch-show-insert-tree (tree depth)
   Insert the message tree TREE at depth DEPTH in the current thread.
@@ -1054,15 +1054,55 @@ function is used.
 
 (notmuch-show-mark-read)))
 
-(defun notmuch-show-refresh-view ()
+(defun notmuch-show-capture-state ()
+  Capture the state of the current buffer.
+
+This includes:
+ - the list of open messages,
+ - the current message.
+  (list (notmuch-show-get-message-id) 
(notmuch-show-get-message-ids-for-open-messages)))
+
+(defun notmuch-show-apply-state (state)
+  Apply STATE to the current buffer.
+
+This includes:
+ - opening the messages previously opened,
+ - closing all other messages,
+ - moving to the correct current message.
+  (let ((current (car state))
+   (open (cadr state)))
+
+;; Open those that were open.
+(goto-char (point-min))
+(loop do (notmuch-show-message-visible 
(notmuch-show-get-message-properties)
+  (member 
(notmuch-show-get-message-id) open))
+ until (not (notmuch-show-goto-message-next)))
+
+;; Go to the previously open message.
+(goto-char (point-min))
+(unless (loop if (string= current (notmuch-show-get-message-id))
+ return t
+ until (not (notmuch-show-goto-message-next)))
+  (goto-char (point-min))
+  (message Previously current message not found.))
+(notmuch-show-message-adjust)))
+
+(defun notmuch-show-refresh-view (optional retain-state)
   Refresh the current view.
 
-Refreshes the current view, observing changes in cryptographic preferences.
+Refreshes the current view, observing changes in display
+preferences. If RETAIN-STATE is non-nil then the state of the
+buffer is stored and re-applied after the refresh.
   (interactive)
-  (let ((inhibit-read-only t))
-(erase-buffer))
-  (notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
-  notmuch-show-query-context))
+  (let ((inhibit-read-only t)
+   state)
+(if retain-state
+   (setq state (notmuch-show-capture-state)))
+(erase-buffer)
+(notmuch-show-worker notmuch-show-thread-id notmuch-show-parent-buffer
+notmuch-show-query-context)
+(if state
+   (notmuch-show-apply-state state
 
 (defvar notmuch-show-stash-map
   (let ((map (make-sparse-keymap)))
-- 
1.7.8.3

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


Re: [PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread Dmitry Kurochkin
On Tue, 31 Jan 2012 10:43:10 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
 On Tue, 31 Jan 2012 08:01:53 +, David Edmondson d...@dme.org wrote:
  When archiving the last message in a thread (a), rather than just
  moving the pointer to the next thread in the parent search buffer,
  actually display the next thread.
  ---
 
 -1. Magic! Rather some customization option which lets user choose
 consistent behaviour (i.e. 'a' either jumps to search buffer or
 goes to next thread always (default?)).
 

FWIW this behavior is consistent with how archiving worked before
earlier today.  For those who uses archiving, the new behavior is a
surprise.  So I would argue that this patch makes it less magic.  And
consistent with the current A behavior.

Regards,
  Dmitry

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


Re: [PATCH 0/5 v4] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread David Edmondson
I mangled the in-reply-to header, which should be
1327486729-18052-1-git-send-email-...@dme.org
(i.e. id:1327486729-18052-1-git-send-email-...@dme.org).


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


Re: [PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread Tomi Ollila
On Tue, 31 Jan 2012 12:51:44 +0400, Dmitry Kurochkin 
dmitry.kuroch...@gmail.com wrote:
 On Tue, 31 Jan 2012 10:43:10 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
  On Tue, 31 Jan 2012 08:01:53 +, David Edmondson d...@dme.org wrote:
   When archiving the last message in a thread (a), rather than just
   moving the pointer to the next thread in the parent search buffer,
   actually display the next thread.
   ---
  
  -1. Magic! Rather some customization option which lets user choose
  consistent behaviour (i.e. 'a' either jumps to search buffer or
  goes to next thread always (default?)).
  
 
 FWIW this behavior is consistent with how archiving worked before
 earlier today.  For those who uses archiving, the new behavior is a
 surprise.  So I would argue that this patch makes it less magic.  And
 consistent with the current A behavior.

Yes, I had a thinko there. 'a' progresses to next message after archiving
and not back to search buffer...

I like David's alternative suggestion (in IRC) where cursor is left at
the end of buffer in case last message is archived with 'a'.

 Regards,
   Dmitry

Thanks, 

Tomi

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


Re: [PATCH 1/2] emacs: If archiving the last message in a thread, show the next thread.

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 11:25:36 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
 I like David's alternative suggestion (in IRC) where cursor is left at
 the end of buffer in case last message is archived with 'a'.

Unless the cursor is already at the end of the buffer, in which case it
would do the 'next thread' dance (i.e. it behaves like 'space' in that
respect).


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


Re: [PATCH] emacs: Move the blank line from the bottom of the headers to the top of the body.

2012-01-31 Thread David Edmondson
On Mon, 30 Jan 2012 21:25:19 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 On Mon, 30 Jan 2012 16:52:20 +, David Edmondson d...@dme.org wrote:
  The blank line doesn't really change position, but is now considered
  to be part of the body rather than part of the headers. This means
  that it is visible when the body is visible rather than when the
  headers are visible.
 
 This definitely makes sense.  I rarely hide headers anymore, but I never
 liked that the separation between the headers and the body went away
 when the headers are hidden.  +1.

Any objections to changing this?


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


Re: [PATCH 4/7] lib: Add the exclude flag to notmuch_query_search_threads

2012-01-31 Thread Mark Walters
On Mon, 30 Jan 2012 23:50:20 -0500, Austin Clements amdra...@mit.edu wrote:
 Quoth Mark Walters on Jan 29 at  6:39 pm:
  Add the NOTMUCH_MESSAGE_FLAG_EXCLUDED flag to
  notmuch_query_search_threads. Implemented by inspecting the tags
  directly in _notmuch_thread_create/_thread_add_message rather than as
  a Xapian query for speed reasons.
  ---
   lib/notmuch-private.h |   16 ++--
   lib/query.cc  |1 +
   lib/thread.cc |   18 +++---
   3 files changed, 26 insertions(+), 9 deletions(-)
  
  diff --git a/lib/notmuch-private.h b/lib/notmuch-private.h
  index e791bb0..56b87c6 100644
  --- a/lib/notmuch-private.h
  +++ b/lib/notmuch-private.h
  @@ -211,12 +211,8 @@ _notmuch_directory_get_document_id 
  (notmuch_directory_t *directory);
   
   /* thread.cc */
   
  -notmuch_thread_t *
  -_notmuch_thread_create (void *ctx,
  -   notmuch_database_t *notmuch,
  -   unsigned int seed_doc_id,
  -   notmuch_doc_id_set_t *match_set,
  -   notmuch_sort_t sort);
  +/* Definition of _notmuch_thread_create moved later since now uses
  + * string_list_t */
 
 Naw, leave the definition here along with the other things from
 thread.cc and just add a
 
   typedef struct _notmuch_string_list notmuch_string_list_t;
 
 along with the typedef for notmuch_doc_id_set_t near the top.  (You
 might also have to tweak the typedef of notmuch_string_list_t later so
 it's just the struct definition.)

Will do.

   /* message.cc */
   
  @@ -492,6 +488,14 @@ notmuch_filenames_t *
   _notmuch_filenames_create (const void *ctx,
 notmuch_string_list_t *list);
   
  +notmuch_thread_t *
  +_notmuch_thread_create (void *ctx,
  +   notmuch_database_t *notmuch,
  +   unsigned int seed_doc_id,
  +   notmuch_doc_id_set_t *match_set,
  +   notmuch_string_list_t *excluded_terms,
  +   notmuch_sort_t sort);
  +
   #pragma GCC visibility pop
   
   NOTMUCH_END_DECLS
  diff --git a/lib/query.cc b/lib/query.cc
  index 7d165d2..dee7ec0 100644
  --- a/lib/query.cc
  +++ b/lib/query.cc
  @@ -472,6 +472,7 @@ notmuch_threads_get (notmuch_threads_t *threads)
 threads-query-notmuch,
 doc_id,
 threads-match_set,
  +  threads-query-exclude_terms,
 threads-query-sort);
   }
   
  diff --git a/lib/thread.cc b/lib/thread.cc
  index 0435ee6..6d65d52 100644
  --- a/lib/thread.cc
  +++ b/lib/thread.cc
  @@ -214,7 +214,8 @@ _thread_cleanup_author (notmuch_thread_t *thread,
*/
   static void
   _thread_add_message (notmuch_thread_t *thread,
  -notmuch_message_t *message)
  +notmuch_message_t *message,
  +notmuch_string_list_t *exclude_terms)
   {
   notmuch_tags_t *tags;
   const char *tag;
  @@ -262,6 +263,15 @@ _thread_add_message (notmuch_thread_t *thread,
   notmuch_tags_move_to_next (tags))
   {
  tag = notmuch_tags_get (tags);
  +   /* mark excluded messages */
 
 Capital and period.

Will fix.

  +   for (notmuch_string_node_t *term = exclude_terms-head; term;
  +term = term-next) {
  +   /* we ignore initial 'K' */
 
 Same.

Will fix

  +   if (strcmp(tag, (term-string + 1)) == 0) {
  +   notmuch_message_set_flag (message, 
  NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
  +   break;
  +   }
  +   }
  g_hash_table_insert (thread-tags, xstrdup (tag), NULL);
   }
   }
  @@ -321,7 +331,8 @@ _thread_add_matched_message (notmuch_thread_t *thread,
  _thread_set_subject_from_message (thread, message);
   }
   
  -thread-matched_messages++;
  +if (!notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED))
  +   thread-matched_messages++;
 
 I'd still say this warrants a better API.

I agree: I will think about that.

   if (g_hash_table_lookup_extended (thread-message_hash,
  notmuch_message_get_message_id (message), NULL,
  @@ -392,6 +403,7 @@ _notmuch_thread_create (void *ctx,
  notmuch_database_t *notmuch,
  unsigned int seed_doc_id,
  notmuch_doc_id_set_t *match_set,
  +   notmuch_string_list_t *exclude_terms,
  notmuch_sort_t sort)
   {
   notmuch_thread_t *thread;
  @@ -467,7 +479,7 @@ _notmuch_thread_create (void *ctx,
  if (doc_id == seed_doc_id)
  message = seed_message;
   
  -   _thread_add_message (thread, message);
  +   _thread_add_message (thread, message, exclude_terms);
   
  if ( _notmuch_doc_id_set_contains (match_set, doc_id)) {
  _notmuch_doc_id_set_remove (match_set, doc_id);
___
notmuch mailing list
notmuch@notmuchmail.org

Re: [PATCH 5/7] cli: Make notmuch-show respect excludes.

2012-01-31 Thread Mark Walters
On Mon, 30 Jan 2012 23:56:24 -0500, Austin Clements amdra...@mit.edu wrote:
 Quoth Mark Walters on Jan 29 at  6:39 pm:
  This adds the excludes to notmuch-show.c. We do not exclude when only
  a single message (or part) is requested. notmuch-show will output the
  exclude information when either text or json format is requested. As
  this changes the output from notmuch-show it breaks many tests (in a
  trivial and expected fashion).
  ---
   notmuch-show.c |   26 +-
   1 files changed, 21 insertions(+), 5 deletions(-)
  
  diff --git a/notmuch-show.c b/notmuch-show.c
  index dec799c..681827f 100644
  --- a/notmuch-show.c
  +++ b/notmuch-show.c
  @@ -193,10 +193,12 @@ _get_one_line_summary (const void *ctx, 
  notmuch_message_t *message)
   static void
   format_message_text (unused (const void *ctx), notmuch_message_t *message, 
  int indent)
   {
  -printf (id:%s depth:%d match:%d filename:%s\n,
  +/* Could changing this could break users ? */
 
 I don't think anybody seriously tries to parse the text format, so I
 wouldn't worry about breaking anything.

Right: I will remove the comment.

  +printf (id:%s depth:%d match:%d excluded:%d filename:%s\n,
  notmuch_message_get_message_id (message),
  indent,
  -   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH),
  +   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 1 
  : 0,
  +   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 
  1 : 0,
  notmuch_message_get_filename (message));
   }
   
  @@ -212,9 +214,10 @@ format_message_json (const void *ctx, 
  notmuch_message_t *message, unused (int in
   date = notmuch_message_get_date (message);
   relative_date = notmuch_time_relative_date (ctx, date);
   
  -printf (\id\: %s, \match\: %s, \filename\: %s, \timestamp\: 
  %ld, \date_relative\: \%s\, \tags\: [,
  +printf (\id\: %s, \match\: %s, \excluded\: %s, \filename\: 
  %s, \timestamp\: %ld, \date_relative\: \%s\, \tags\: [,
 
 I wonder if it would be better to switch to an array of flag names...
 That obviously would break consumers, but it's worth thinking about in
 the longer term.

Unless you have a strong feeling for this I will leave that for a later
patch.

  json_quote_str (ctx_quote, notmuch_message_get_message_id 
  (message)),
  notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_MATCH) ? 
  true : false,
  +   notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 
  true : false,
  json_quote_str (ctx_quote, notmuch_message_get_filename (message)),
  date, relative_date);
   
  @@ -1059,9 +1062,13 @@ notmuch_show_command (void *ctx, unused (int argc), 
  unused (char *argv[]))
   char *opt;
   const notmuch_show_format_t *format = format_text;
   notmuch_show_params_t params;
  +const char **search_exclude_tags;
  +size_t search_exclude_tags_length;
   int mbox = 0;
   int format_specified = 0;
   int i;
  +notmuch_bool_t do_not_exclude = FALSE;
  +unsigned int j;
   
   params.entire_thread = 0;
   params.raw = 0;
  @@ -1098,6 +1105,8 @@ notmuch_show_command (void *ctx, unused (int argc), 
  unused (char *argv[]))
  params.part = atoi(argv[i] + sizeof (--part=) - 1);
  } else if (STRNCMP_LITERAL (argv[i], --entire-thread) == 0) {
  params.entire_thread = 1;
  +   } else if (STRNCMP_LITERAL (argv[i], --do-not-exclude) == 0) {
  +   do_not_exclude = TRUE;
 
 no-exclude if you change the others.

See comment on first patch: will make sure they are consistent.

  } else if ((STRNCMP_LITERAL (argv[i], --verify) == 0) ||
 (STRNCMP_LITERAL (argv[i], --decrypt) == 0)) {
  if (params.cryptoctx == NULL) {
  @@ -1105,7 +1114,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
  unused (char *argv[]))
  /* TODO: GMimePasswordRequestFunc */
  if (NULL == (params.cryptoctx = g_mime_gpg_context_new(NULL, 
  gpg)))
   #else
  -   GMimeSession* session = g_object_new(g_mime_session_get_type(), 
  NULL);
  +   GMimeSession* session = 
  g_object_new(g_mime_session_get_type(), NULL);
 
 Accidental reindent?

Yes will fix.

  if (NULL == (params.cryptoctx = g_mime_gpg_context_new(session, 
  gpg)))
   #endif
  fprintf (stderr, Failed to construct gpg context.\n);
  @@ -1167,10 +1176,17 @@ notmuch_show_command (void *ctx, unused (int argc), 
  unused (char *argv[]))
   if (params.raw  params.part  0)
  params.part = 0;
   
  +/* if a single message is requested we do not use search_excludes */
 
 Capital and period.

Will fix.

   if (params.part = 0)
  return do_show_single (ctx, query, format, params);
   else
  -   return do_show (ctx, query, format, params);
  +   if (!do_not_exclude) {
  +   search_exclude_tags = notmuch_config_get_search_exclude_tags
  +   

[RFC PATCH] emacs: make show view a/A/x/X key bindings more consistent

2012-01-31 Thread Jani Nikula
Proposal for show view a/A/x/X key bindings, according to
http://titanpad.com/SA39EbNezU and IRC discussion:

'a' = Archive current message, then move to next message, or show next
thread from search if at the last message in thread.

'A' = Archive each message in thread, then show next thread from
search.

'x' = Archive current message, then move to next message, or exit back
to search results if at the last message in thread.

'X' = Archive each message in thread, then exit back to search
results.

IMHO these changes would make the current implementation more
consistent in two ways: 1) 'a'/'A' would advance to next thread like
'a' used to do, 2) 'x' would operate on messages and 'X' on threads
like 'a'/'A' do now.

The implementation here is hacky at best, and I agree with dme that
notmuch-show.el could use some code cleanup and provide
non-interactive primitives. However I won't have the time and energy
for that right now.
---
 emacs/notmuch-show.el |   26 --
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index de9421e..62f3664 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1075,9 +1075,10 @@ thread id.  If a prefix is given, crypto processing is 
toggled.
(define-key map h 'notmuch-show-toggle-headers)
(define-key map - 'notmuch-show-remove-tag)
(define-key map + 'notmuch-show-add-tag)
-   (define-key map x 'notmuch-show-archive-thread-then-exit)
-   (define-key map a 'notmuch-show-archive-message-then-next)
+   (define-key map X 'notmuch-show-archive-thread-then-exit)
+   (define-key map x 'notmuch-show-archive-message-then-next-then-exit)
(define-key map A 'notmuch-show-archive-thread-then-next)
+   (define-key map a 'notmuch-show-archive-message-then-next-then-next)
(define-key map N 'notmuch-show-next-message)
(define-key map P 'notmuch-show-previous-message)
(define-key map n 'notmuch-show-next-open-message)
@@ -1425,10 +1426,12 @@ buffer.
 (if r
(progn
  (notmuch-show-mark-read)
- (notmuch-show-message-adjust))
+ (notmuch-show-message-adjust)
+ t)
   (if pop-at-end
  (notmuch-show-next-thread)
-   (goto-char (point-max))
+   (goto-char (point-max))
+   nil
 
 (defun notmuch-show-previous-open-message ()
   Show the previous open message.
@@ -1645,12 +1648,23 @@ removed).
   (notmuch-show-add-tag inbox)
 (notmuch-show-remove-tag inbox)))
 
-(defun notmuch-show-archive-message-then-next ()
-  Archive the current message, then show the next open message in the current 
thread.
+(defun notmuch-show-archive-message-then-next-then-exit ()
+  Archive the current message, then show the next open message in the current 
thread.
+
+If at the last message in thread, then exit back to search results.
   (interactive)
   (notmuch-show-archive-message)
   (notmuch-show-next-open-message t))
 
+(defun notmuch-show-archive-message-then-next-then-next ()
+  Archive the current message, then show the next open message in the current 
thread.
+
+If at the last message in thread, then show next thread from search.
+  (interactive)
+  (notmuch-show-archive-message)
+  (unless (notmuch-show-next-open-message)
+(notmuch-show-next-thread t)))
+
 (defun notmuch-show-stash-cc ()
   Copy CC field of current message to kill-ring.
   (interactive)
-- 
1.7.5.4

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


Re: [RFC PATCH] emacs: make show view a/A/x/X key bindings more consistent

2012-01-31 Thread Austin Clements
Quoth Jani Nikula on Jan 31 at  5:03 pm:
 Proposal for show view a/A/x/X key bindings, according to
 http://titanpad.com/SA39EbNezU and IRC discussion:
 
 'a' = Archive current message, then move to next message, or show next
 thread from search if at the last message in thread.
 
 'A' = Archive each message in thread, then show next thread from
 search.
 
 'x' = Archive current message, then move to next message, or exit back
 to search results if at the last message in thread.
 
 'X' = Archive each message in thread, then exit back to search
 results.
 
 IMHO these changes would make the current implementation more
 consistent in two ways: 1) 'a'/'A' would advance to next thread like
 'a' used to do, 2) 'x' would operate on messages and 'X' on threads
 like 'a'/'A' do now.

+1 to the proposal.  I don't know the maze of twisty little passages
that implement the show bindings well enough to say if the code is
right.

 The implementation here is hacky at best, and I agree with dme that
 notmuch-show.el could use some code cleanup and provide
 non-interactive primitives. However I won't have the time and energy
 for that right now.
 ---
  emacs/notmuch-show.el |   26 --
  1 files changed, 20 insertions(+), 6 deletions(-)
 
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index de9421e..62f3664 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1075,9 +1075,10 @@ thread id.  If a prefix is given, crypto processing is 
 toggled.
   (define-key map h 'notmuch-show-toggle-headers)
   (define-key map - 'notmuch-show-remove-tag)
   (define-key map + 'notmuch-show-add-tag)
 - (define-key map x 'notmuch-show-archive-thread-then-exit)
 - (define-key map a 'notmuch-show-archive-message-then-next)
 + (define-key map X 'notmuch-show-archive-thread-then-exit)
 + (define-key map x 'notmuch-show-archive-message-then-next-then-exit)
   (define-key map A 'notmuch-show-archive-thread-then-next)
 + (define-key map a 'notmuch-show-archive-message-then-next-then-next)

notmuch-show-archive-message-then-next-then-next-thread?  I like the
very explicit names, but then-next-then-next is rather opaque.

   (define-key map N 'notmuch-show-next-message)
   (define-key map P 'notmuch-show-previous-message)
   (define-key map n 'notmuch-show-next-open-message)
 @@ -1425,10 +1426,12 @@ buffer.
  (if r
   (progn
 (notmuch-show-mark-read)
 -   (notmuch-show-message-adjust))
 +   (notmuch-show-message-adjust)
 +   t)
(if pop-at-end
 (notmuch-show-next-thread)
 - (goto-char (point-max))
 + (goto-char (point-max))
 + nil
  
  (defun notmuch-show-previous-open-message ()
Show the previous open message.
 @@ -1645,12 +1648,23 @@ removed).
(notmuch-show-add-tag inbox)
  (notmuch-show-remove-tag inbox)))
  
 -(defun notmuch-show-archive-message-then-next ()
 -  Archive the current message, then show the next open message in the 
 current thread.
 +(defun notmuch-show-archive-message-then-next-then-exit ()
 +  Archive the current message, then show the next open message in the 
 current thread.
 +
 +If at the last message in thread, then exit back to search results.
(interactive)
(notmuch-show-archive-message)
(notmuch-show-next-open-message t))
  
 +(defun notmuch-show-archive-message-then-next-then-next ()
 +  Archive the current message, then show the next open message in the 
 current thread.
 +
 +If at the last message in thread, then show next thread from search.
 +  (interactive)
 +  (notmuch-show-archive-message)
 +  (unless (notmuch-show-next-open-message)
 +(notmuch-show-next-thread t)))
 +
  (defun notmuch-show-stash-cc ()
Copy CC field of current message to kill-ring.
(interactive)
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH] emacs: add default value to notmuch-search-line-faces

2012-01-31 Thread Austin Clements
Quoth Jani Nikula on Jan 31 at  3:12 pm:
 On Thu, 26 Jan 2012 23:58:51 +0200, Jani Nikula j...@nikula.org wrote:
  On Thu, 26 Jan 2012 14:41:46 -0500, Austin Clements amdra...@mit.edu 
  wrote:
   Quoth Jani Nikula on Jan 26 at  9:21 pm:
+  (flagged :foreground red))
   
   Red is pretty universally used to indicate danger or a serious
   condition, while flagged is simply supposed to draw attention.  I
   would say blue as a neutral and distinct indicator, but it also has
   poor visibility (I used to use blue, but found that when scanning my
   mail, I would habitually skip over flagged messages because they were
   dark, which was the opposite of what I wanted).  Personally I've
   settled on yellow; it's visually distinct enough to be easily
   noticeable and bright enough that I don't skip over it, though it
   obviously wouldn't work on a light background.
  
  Can be yellow, I don't really care that much. But isn't a light
  background the default for emacs in most distros? If that matters,
  *shrug*.
 
 Ugh, yellow is absolutely horrible on a white background... that would
 certainly draw people to figure out how to change the settings. Now
 shall I send v2 with bold for unread and yellow for flagged, or can this
 go in as it is?

Sorry, I really meant to propose blue for flagged.  The thing about
yellow was meant more as an aside.  Blue is reasonably visible on both
light and dark backgrounds.  It should draw people into customizing
it, while still being a reasonable default.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [RFC PATCH] emacs: make show view a/A/x/X key bindings more consistent

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 17:03:55 +0200, Jani Nikula j...@nikula.org wrote:
 'a' = Archive current message, then move to next message, or show next
 thread from search if at the last message in thread.
 
 'A' = Archive each message in thread, then show next thread from
 search.
 
 'x' = Archive current message, then move to next message, or exit back
 to search results if at the last message in thread.
 
 'X' = Archive each message in thread, then exit back to search
 results.

This seems consistent to me and would be an improvement.


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


Re: [PATCH 3/5] emacs: Allow the indentation of content to be toggled.

2012-01-31 Thread Mark Walters

Hi I have reviewed the patch series within the limits of my lisp
knowledge.  Patch 1: is rather beyond my lisp so I won't comment on that
(and I have never tried crypto): Patches 2-5 look fine with one
bikeshed and one query for my own understanding.

The bikeshed is that I agree with Jani in
id:CAB+hUn8KhXHTRCdrLe0cT=8mdtz9ZntPFf13mq0iCo4CX=b...@mail.gmail.com
that I would prefer to reserve '' for saving a file.

The query: in

 +  (props (notmuch-show-get-message-properties))
 +  (indenting notmuch-show-indent-content))
  (with-temp-buffer
(insert all)
 -  (indent-rigidly (point-min) (point-max) (- depth))
 +  (if indenting
 +   (indent-rigidly (point-min) (point-max) (- depth)))

Is the local variable `indenting' needed because
notmuch-show-indent-content is buffer local and this is in the
with-temp-buffer?

Thanks

Mark


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


Re: [PATCH 1/7] cli: add --do-not-exclude option to count and search.

2012-01-31 Thread Austin Clements
Quoth Mark Walters on Jan 31 at 11:40 am:
 
 Thanks for the review. Almost all of it (for all all the patches) I
 agree with and will just fix but I do have a couple of queries.
 
 On Mon, 30 Jan 2012 23:17:32 -0500, Austin Clements amdra...@mit.edu wrote:
  Quoth Mark Walters on Jan 29 at  6:39 pm:
   This option turns off the exclusion so all matching messages are
   returned. We do not need to add this to show as notmuch-show does not
   (yet) exclude.
   ---
notmuch-count.c  |   12 
notmuch-search.c |   12 
2 files changed, 16 insertions(+), 8 deletions(-)
   
   diff --git a/notmuch-count.c b/notmuch-count.c
   index 63459fb..c88975e 100644
   --- a/notmuch-count.c
   +++ b/notmuch-count.c
   @@ -37,6 +37,7 @@ notmuch_count_command (void *ctx, int argc, char 
   *argv[])
int output = OUTPUT_MESSAGES;
const char **search_exclude_tags;
size_t search_exclude_tags_length;
   +notmuch_bool_t do_not_exclude = FALSE;
unsigned int i;

notmuch_opt_desc_t options[] = {
   @@ -44,6 +45,7 @@ notmuch_count_command (void *ctx, int argc, char 
   *argv[])
   (notmuch_keyword_t []){ { threads, OUTPUT_THREADS },
   { messages, OUTPUT_MESSAGES },
   { 0, 0 } } },
   + { NOTMUCH_OPT_BOOLEAN,  do_not_exclude, do-not-exclude, 'd', 0 },
  
  Maybe just no-exclude?  do-not-exclude seems needlessly verbose.
 
 The reason I went for verbose do-not-exclude was to try and avoid the
 double negative ambiguity: does no-exclude mean do-not-exclude or
 do-note-return-excluded-messages. Possibly I am worrying needlessly, and
 obviously I am quite happy to change.

Oh.  Hmm.  --no-exclusions?  --unexcluded?  --all?
--include-excludes?  Maybe --do-not-exclude is best.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 3/5] emacs: Allow the indentation of content to be toggled.

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 16:15:11 +, Mark Walters markwalters1...@gmail.com 
wrote:
 Hi I have reviewed the patch series within the limits of my lisp
 knowledge.  Patch 1: is rather beyond my lisp so I won't comment on that
 (and I have never tried crypto): Patches 2-5 look fine with one
 bikeshed and one query for my own understanding.

Thanks.

 The bikeshed is that I agree with Jani in
 id:CAB+hUn8KhXHTRCdrLe0cT=8mdtz9ZntPFf13mq0iCo4CX=b...@mail.gmail.com
 that I would prefer to reserve '' for saving a file.

'' is 'remove indent', or 'look to the left'.
'' is 'toggle truncation', or 'look to the right'.

(I'm not overly worried about this - would 't' be more acceptable?)

 The query: in
 
  +(props (notmuch-show-get-message-properties))
  +(indenting notmuch-show-indent-content))
   (with-temp-buffer
 (insert all)
  -  (indent-rigidly (point-min) (point-max) (- depth))
  +  (if indenting
  + (indent-rigidly (point-min) (point-max) (- depth)))
 
 Is the local variable `indenting' needed because
 notmuch-show-indent-content is buffer local and this is in the
 with-temp-buffer?

Yes.


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


Re: [PATCH 3/7] lib: Make notmuch_query_search_messages set the exclude flag

2012-01-31 Thread Austin Clements
Quoth Mark Walters on Jan 31 at 11:45 am:
 On Mon, 30 Jan 2012 23:43:52 -0500, Austin Clements amdra...@mit.edu wrote:
  Quoth Mark Walters on Jan 29 at  6:39 pm:
notmuch_message_node_t *iterator;
};

   diff --git a/lib/notmuch.h b/lib/notmuch.h
   index 7929fe7..740d005 100644
   --- a/lib/notmuch.h
   +++ b/lib/notmuch.h
   @@ -449,6 +449,11 @@ 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 */
   +void
   +notmuch_query_set_omit_excluded_messages (notmuch_query_t *query, 
   notmuch_bool_t omit);
   +
  
  I don't think we should add this API.  The library behavior will not
  change for library users that don't use excludes and library users
  that do use excludes should by aware of the excluded flag and do the
  appropriate thing.
  
  I can see why this is handy in some cases, but I don't think it
  provides enough utility to warrant becoming part of the permanent and
  minimal library interface.
 
 This is really a performance improvement: suppose that there are lots of
 threads that only match in excluded messages. Then without this flag we
 will spend lots of time constructing the thread only for it to be
 ignored. (In contrived situations this could be arbitrarily slower.)

I would prefer to keep the public API minimal and only introduce
something like this if people actually experience performance
problems.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH] added support for user-specified files directories to ignore

2012-01-31 Thread Tomi Ollila
A new configuration key 'new.ignore' is used to determine which
files and directories user wants not to be scanned as new mails.

This work merges my previous attempts and Andreas Amann's work
in id:ylp7hi23mw8@tyndall.ie

See notes in id:20120131-new-ignore-1-git-send-email-...@iki.fi
---
Notes

1) Currently there is comment for new.ignore in newly created configuration
file but as the list is initially empty there will be not tag in place.

2) Whenever some already existing directory is added to the exclude list
and the parent directory timestamp has not changed, notmuch new will not
notice the directory has gone (as it still is there), user needs to 'touch'
the parent directory before next 'notmuch new' no make notmuch notice.

2012-01-26: could notmuch track mtime of the configuration file and if
that changes, ignore mail directory timestamps ?


3) in id:1327572718-13411-2-git-send-email-tomi.oll...@iki.fi dropped...

 notmuch-client.h |8 
 notmuch-config.c |   35 +--
 notmuch-new.c|   45 +
 3 files changed, 74 insertions(+), 14 deletions(-)

diff --git a/notmuch-client.h b/notmuch-client.h
index e0eb594..c62ce78 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -250,6 +250,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
 const char *new_tags[],
 size_t length);
 
+const char **
+notmuch_config_get_new_ignore (notmuch_config_t *config,
+  size_t *length);
+void
+notmuch_config_set_new_ignore (notmuch_config_t *config,
+  const char *new_ignore[],
+  size_t length);
+
 notmuch_bool_t
 notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);
 
diff --git a/notmuch-config.c b/notmuch-config.c
index a124e34..f1cc5c2 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -44,7 +44,10 @@ static const char new_config_comment[] =
  The following options are supported here:\n
 \n
 \ttagsA list (separated by ';') of the tags that will be\n
-\tadded to all messages incorporated by \notmuch new\.\n;
+\tadded to all messages incorporated by \notmuch new\.\n
+\n
+\tignore  A list (separated by ';') of files and directories that
+\twill not be searched for messages by \notmuch new\.\n;
 
 static const char user_config_comment[] =
  User configuration\n
@@ -105,6 +108,8 @@ struct _notmuch_config {
 size_t user_other_email_length;
 const char **new_tags;
 size_t new_tags_length;
+const char **new_ignore;
+size_t new_ignore_length;
 notmuch_bool_t maildir_synchronize_flags;
 const char **search_exclude_tags;
 size_t search_exclude_tags_length;
@@ -264,6 +269,8 @@ notmuch_config_open (void *ctx,
 config-user_other_email_length = 0;
 config-new_tags = NULL;
 config-new_tags_length = 0;
+config-new_ignore = NULL;
+config-new_ignore_length = 0;
 config-maildir_synchronize_flags = TRUE;
 config-search_exclude_tags = NULL;
 config-search_exclude_tags_length = 0;
@@ -360,7 +367,11 @@ notmuch_config_open (void *ctx,
 const char *tags[] = { unread, inbox };
notmuch_config_set_new_tags (config, tags, 2);
 }
-
+#if 0 /* No point setting empty list -- it's not written */
+if (notmuch_config_get_new_ignore (config, tmp) == NULL) {
+   notmuch_config_set_new_ignore (config, NULL, 0);
+}
+#endif
 if (notmuch_config_get_search_exclude_tags (config, tmp) == NULL) {
if (is_new) {
const char *tags[] = { deleted, spam };
@@ -609,6 +620,15 @@ notmuch_config_get_new_tags (notmuch_config_t *config,   
size_t *length)
 (config-new_tags_length), length);
 }
 
+const char **
+notmuch_config_get_new_ignore (notmuch_config_t *config,   size_t *length)
+{
+return _config_get_list (config, new, ignore,
+(config-new_ignore),
+(config-new_ignore_length), length);
+}
+
+
 void
 notmuch_config_set_user_other_email (notmuch_config_t *config,
 const char *list[],
@@ -627,6 +647,17 @@ notmuch_config_set_new_tags (notmuch_config_t *config,
 (config-new_tags));
 }
 
+#if 0 /* UNNEEDED SO FAR */
+void
+notmuch_config_set_new_ignore (notmuch_config_t *config,
+  const char *list[],
+  size_t length)
+{
+_config_set_list (config, new, ignore, list, length,
+(config-new_ignore));
+}
+#endif
+
 const char **
 notmuch_config_get_search_exclude_tags (notmuch_config_t *config, size_t 
*length)
 {
diff --git a/notmuch-new.c b/notmuch-new.c
index a569a54..36d5c5d 100644
--- a/notmuch-new.c
+++ b/notmuch-new.c
@@ -39,6 +39,8 @@ typedef struct {
 int verbose;
 const char **new_tags

Re: Bug?: notmuch-search-show-thread shows several threads; only one containing matching messages

2012-01-31 Thread Jameson Graef Rollins
On Tue, 31 Jan 2012 01:18:55 +, Mark Walters markwalters1...@gmail.com 
wrote:
 One of the mails has an in-reply-to header which looks like
 
 In-reply-to: Message from Carsten Dominik carsten.domi...@gmail.com of  
   Tue, 15 Mar 2011 12:18:51 BST.
 17242340-a14f-495a-b144-20c96d52b...@gmail.com

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


Re: [PATCH 1/7] cli: add --do-not-exclude option to count and search.

2012-01-31 Thread Jameson Graef Rollins
On Tue, 31 Jan 2012 11:40:00 +, Mark Walters markwalters1...@gmail.com 
wrote:
 The reason I went for verbose do-not-exclude was to try and avoid the
 double negative ambiguity: does no-exclude mean do-not-exclude or
 do-note-return-excluded-messages. Possibly I am worrying needlessly, and
 obviously I am quite happy to change.

I also think no-exclude or no-excludes would be more appropriate.
It's not a command that people will likely use that frequently, so as
long as it's well documented it will be fine.

jamie.


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


Re: [PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread Jameson Graef Rollins
On Tue, 31 Jan 2012 08:09:08 +, David Edmondson d...@dme.org wrote:
 On Mon, 30 Jan 2012 09:47:34 -0800, Jameson Graef Rollins 
 jroll...@finestructure.net wrote:
  One thing I've noticed, which isn't actually part of this patch, is that
  the long-line truncation doesn't respect the indentation, which makes
  things look strange.
 
 Which lines are getting wrapped in a way that you don't like? The header
 line? The headers? The body?

Header lines, such as Subject, To, Cc, etc.

  But honestly I still don't like our method of displaying threads as a
  giant chain of concatenated messages with indentation.  But that's for
  later work.
 
 It's inherited from sup, and is surely part of the raison de notmuch
 :-)

Inheritance is not a good justification for anything, much less
questionable UI choices (I seem to have inherited baldness from my dad.
Thanks dad).  Problems I have with the current approach:

- thread structure is opaque.  This is especially true with long
  threads, where it can be next to impossible to see which messages are
  replies to what.  This is by far my biggest pet peeve with the current
  format.

- navigation through the thread is difficult.  This is related to above.
  There's no way to simultaneously see the current message and the
  thread structure, which again, makes it very difficult to find
  children and parents.  This could possibly be fixed by having key
  bindings that would navigate through parents, children and siblings of
  the current message, but that might be tricky to implement.

- indentation of the entire message body is a really bad way to indicate
  thread depth.  I don't like how messages start to walk off screen as
  threads get longer, or how copying regions of the body brings the
  indentation with it.  Your indentation toggling will improve this a
  bit, though, but I still think it's a bandaid on the larger issue.

I must say that the approach I've been longing for is a modified version
of what mutt has: a top pain that is just the thread structure (with
nice branching lines), and a bottom pain that displays the current
message.  I think that would be a much cleaner approach.

jamie.


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


Re: [PATCH 0/5 v3] reworked crypto toggle, plus a few other toggles

2012-01-31 Thread David Edmondson
On Tue, 31 Jan 2012 08:31:26 -0800, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 On Tue, 31 Jan 2012 08:09:08 +, David Edmondson d...@dme.org wrote:
  On Mon, 30 Jan 2012 09:47:34 -0800, Jameson Graef Rollins 
  jroll...@finestructure.net wrote:
   One thing I've noticed, which isn't actually part of this patch, is that
   the long-line truncation doesn't respect the indentation, which makes
   things look strange.
  
  Which lines are getting wrapped in a way that you don't like? The header
  line? The headers? The body?
 
 Header lines, such as Subject, To, Cc, etc.

You could try out id:1327565871-19729-3-git-send-email-...@dme.org.

   But honestly I still don't like our method of displaying threads as a
   giant chain of concatenated messages with indentation.  But that's for
   later work.
  
  It's inherited from sup, and is surely part of the raison de notmuch
  :-)
 
 Inheritance is not a good justification for anything, much less
 questionable UI choices (I seem to have inherited baldness from my dad.
 Thanks dad).

I didn't suggest that inheritance was justification. Whether it's a
questionable UI choice is largely a matter of personal preference. When
Carl started the project he chose to follow sup's example in this
respect. (Though sup is more aggressive in scrolling the display to the
left to accommodate deep threads.)

 Problems I have with the current approach:
 
 - thread structure is opaque.  This is especially true with long
   threads, where it can be next to impossible to see which messages are
   replies to what.  This is by far my biggest pet peeve with the current
   format.

A collapsed view of the current `notmuch-show-mode' buffer is not very
different to a mutt index view.

 - navigation through the thread is difficult.  This is related to above.
   There's no way to simultaneously see the current message and the
   thread structure, which again, makes it very difficult to find
   children and parents.  This could possibly be fixed by having key
   bindings that would navigate through parents, children and siblings of
   the current message, but that might be tricky to implement.

It would be relatively simple to add the bindings you describe, based on
the computed thread depth of messages. So far I haven't particularly
missed being able to do it.

 - indentation of the entire message body is a really bad way to indicate
   thread depth. I don't like how messages start to walk off screen as
   threads get longer, or how copying regions of the body brings the
   indentation with it.  Your indentation toggling will improve this a
   bit, though, but I still think it's a bandaid on the larger issue.

The indentation works well until threads are more than about ten levels
deep, I find. It becomes unworkable after about twenty levels (but
conversations that deep tend to stress both the UI and myself in other
ways as well).

I don't copy regions of the `notmuch-show-mode' buffer, so that hasn't
been a problem.

 I must say that the approach I've been longing for is a modified version
 of what mutt has: a top pain that is just the thread structure (with
 nice branching lines), and a bottom pain that displays the current
 message.  I think that would be a much cleaner approach.

Nothing precludes the implementation of what you describe. It's not hard
to see how the two approaches could live side by side.


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


Re: [RFC PATCH v2] emacs: make show view a/A/x/X key bindings more consistent

2012-01-31 Thread Dmitry Kurochkin
On Tue, 31 Jan 2012 19:29:06 +0200, Jani Nikula j...@nikula.org wrote:
 Modify the show view key bindings as follows to make them more
 consistent:
 
 'a' = Archive current message, then move to next message, or show next
 thread from search if at the last message in thread.
 
 'A' = Archive each message in thread, then show next thread from
 search.
 
 'x' = Archive current message, then move to next message, or exit back
 to search results if at the last message in thread.
 
 'X' = Archive each message in thread, then exit back to search
 results.
 
 The changes make the key bindings more consistent in two ways:
 1) 'a'/'A' both advance to the next thread like 'a' used to.
 2) 'x' operates on messages and 'X' on threads like 'a'/'A'.
 
 ---
 
 The original proposal with some discussion is at
 http://titanpad.com/SA39EbNezU.
 
 This v2 is merely a slightly polished version of the original. There
 will be no further contributions on the subject from me.
 ---

Looks good to me.

Regards,
  Dmitry

  emacs/notmuch-show.el |   28 ++--
  1 files changed, 22 insertions(+), 6 deletions(-)
 
 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
 index de9421e..57830b6 100644
 --- a/emacs/notmuch-show.el
 +++ b/emacs/notmuch-show.el
 @@ -1075,9 +1075,10 @@ thread id.  If a prefix is given, crypto processing is 
 toggled.
   (define-key map h 'notmuch-show-toggle-headers)
   (define-key map - 'notmuch-show-remove-tag)
   (define-key map + 'notmuch-show-add-tag)
 - (define-key map x 'notmuch-show-archive-thread-then-exit)
 - (define-key map a 'notmuch-show-archive-message-then-next)
 + (define-key map X 'notmuch-show-archive-thread-then-exit)
 + (define-key map x 'notmuch-show-archive-message-then-next-or-exit)
   (define-key map A 'notmuch-show-archive-thread-then-next)
 + (define-key map a 
 'notmuch-show-archive-message-then-next-or-next-thread)
   (define-key map N 'notmuch-show-next-message)
   (define-key map P 'notmuch-show-previous-message)
   (define-key map n 'notmuch-show-next-open-message)
 @@ -1417,7 +1418,8 @@ thread, navigate to the next thread in the parent 
 search buffer.
  
  If a prefix argument is given and this is the last open message
  in the thread, navigate to the next thread in the parent search
 -buffer.
 +buffer. Return t if there was a next open message in the thread
 +to show, nil otherwise.
(interactive P)
(let (r)
  (while (and (setq r (notmuch-show-goto-message-next))
 @@ -1428,7 +1430,8 @@ buffer.
 (notmuch-show-message-adjust))
(if pop-at-end
 (notmuch-show-next-thread)
 - (goto-char (point-max))
 + (goto-char (point-max
 +r))
  
  (defun notmuch-show-previous-open-message ()
Show the previous open message.
 @@ -1645,12 +1648,25 @@ removed).
(notmuch-show-add-tag inbox)
  (notmuch-show-remove-tag inbox)))
  
 -(defun notmuch-show-archive-message-then-next ()
 -  Archive the current message, then show the next open message in the 
 current thread.
 +(defun notmuch-show-archive-message-then-next-or-exit ()
 +  Archive the current message, then show the next open message in the 
 current thread.
 +
 +If at the last open message in the current thread, then exit back
 +to search results.
(interactive)
(notmuch-show-archive-message)
(notmuch-show-next-open-message t))
  
 +(defun notmuch-show-archive-message-then-next-or-next-thread ()
 +  Archive the current message, then show the next open message in the 
 current thread.
 +
 +If at the last open message in the current thread, then show next
 +thread from search.
 +  (interactive)
 +  (notmuch-show-archive-message)
 +  (unless (notmuch-show-next-open-message)
 +(notmuch-show-next-thread t)))
 +
  (defun notmuch-show-stash-cc ()
Copy CC field of current message to kill-ring.
(interactive)
 -- 
 1.7.5.4
 
 ___
 notmuch mailing list
 notmuch@notmuchmail.org
 http://notmuchmail.org/mailman/listinfo/notmuch
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 3/5] emacs: Allow the indentation of content to be toggled.

2012-01-31 Thread Mark Walters
On Tue, 31 Jan 2012 16:23:32 +, David Edmondson d...@dme.org wrote:
 On Tue, 31 Jan 2012 16:15:11 +, Mark Walters markwalters1...@gmail.com 
 wrote:
  Hi I have reviewed the patch series within the limits of my lisp
  knowledge.  Patch 1: is rather beyond my lisp so I won't comment on that
  (and I have never tried crypto): Patches 2-5 look fine with one
  bikeshed and one query for my own understanding.
 
 Thanks.
 
  The bikeshed is that I agree with Jani in
  id:CAB+hUn8KhXHTRCdrLe0cT=8mdtz9ZntPFf13mq0iCo4CX=b...@mail.gmail.com
  that I would prefer to reserve '' for saving a file.
 
 '' is 'remove indent', or 'look to the left'.
 '' is 'toggle truncation', or 'look to the right'.
 
 (I'm not overly worried about this - would 't' be more acceptable?)

I personally would prefer 't' but it is easy to remap so it really isn't
important.

Best wishes

Mark

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


emacs: quote MML tags in replies

2012-01-31 Thread Dmitry Kurochkin
Hi Aaron.

Thanks for your work!  I took the liberty to do some cleanups for your
patch.  Below is a detailed list of changes.

Hope this helps.

Changes since v2:

* change patch names to be consistent with others:

  - s/emacs:/test:/ for the test patch

  - lower case the first word after colon in the patch title

* polish NEWS wording, move it to 0.12 section

* add comment to `mml-quote-region' call, as suggested by Tomi [1]

* fix and clean up the test:

  - set `notmuch-fcc-dirs' to nil to avoid adding the Fcc header,
otherwise it breaks the test on other systems as pointed by
David [2]

  - use default values for add_message parameters where possible

  - use a sane subject value in add_message

  - use shorter MML tag as produced by (mml-insert-part)

  - indenting and other minor cleanups

Regards,
  Dmitry

[1] id:m2wr89ioos@guru.guru-group.fi
[2] id:87ehugzycb.fsf@zancas.localnet

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


[PATCH v3 1/2] test: add tests for quoting of MML tags in replies

2012-01-31 Thread Dmitry Kurochkin
From: Aaron Ecay aarone...@gmail.com

The test is broken at this time; the next commit will introduce a fix.
---
 test/emacs|   12 
 test/emacs.expected-output/quote-mml-in-reply |7 +++
 2 files changed, 19 insertions(+), 0 deletions(-)
 create mode 100644 test/emacs.expected-output/quote-mml-in-reply

diff --git a/test/emacs b/test/emacs
index 8ca4c8a..a3f4893 100755
--- a/test/emacs
+++ b/test/emacs
@@ -273,6 +273,18 @@ On 01 Jan 2000 12:00:00 -, Notmuch Test Suite 
test_su...@notmuchmail.org w
 EOF
 test_expect_equal_file OUTPUT EXPECTED
 
+test_begin_subtest Quote MML tags in reply
+test_subtest_known_broken
+message_id='test-emacs-mml-quot...@message.id'
+add_message [id]=$message_id \
+   [subject]='$test_subtest_name' \
+   '[body]=#part disposition=inline'
+test_emacs (let ((notmuch-fcc-dirs nil))
+ (notmuch-show \id:$message_id\)
+ (notmuch-show-reply)
+ (test-output))
+test_expect_equal_file OUTPUT $EXPECTED/quote-mml-in-reply
+
 test_begin_subtest Save attachment from within emacs using 
notmuch-show-save-attachments
 # save as archive to test that Emacs does not re-compress .gz
 test_emacs '(let ((standard-input \attachment1.gz\))
diff --git a/test/emacs.expected-output/quote-mml-in-reply 
b/test/emacs.expected-output/quote-mml-in-reply
new file mode 100644
index 000..adec92a
--- /dev/null
+++ b/test/emacs.expected-output/quote-mml-in-reply
@@ -0,0 +1,7 @@
+From: Notmuch Test Suite test_su...@notmuchmail.org
+To: 
+Subject: Re: Quote MML tags in reply
+In-Reply-To: test-emacs-mml-quot...@message.id
+--text follows this line--
+On Fri, 05 Jan 2001 15:43:57 +, Notmuch Test Suite 
test_su...@notmuchmail.org wrote:
+ #!part disposition=inline
-- 
1.7.9

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


[PATCH v3 2/2] emacs: quote MML tags in replies

2012-01-31 Thread Dmitry Kurochkin
From: Aaron Ecay aarone...@gmail.com

Emacs message-mode uses certain text strings to indicate how to attach
files to outgoing mail.  If these are present in the text of an email,
and a user is tricked into replying to the message, the user’s files
could be exposed.
---
 NEWS |   12 
 emacs/notmuch-mua.el |7 ++-
 test/emacs   |1 -
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 2acdce5..ef26b8c 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,17 @@ Reply to sender
   and search modes, 'r' has been bound to reply to sender, replacing
   reply to all, which now has key binding 'R'.
 
+Quote MML tags in replies
+
+  MML tags are text codes that Emacs uses to indicate attachments
+  (among other things) in messages being composed.  The Emacs
+  interface did not quote MML tags in the quoted text of a reply.
+  User could be tricked into replying to a maliciously formatted
+  message and not editing out the MML tags from the quoted text.  This
+  could lead to files from the user's machine being attached to the
+  outgoing message.  The Emacs interface now quotes these tags in
+  reply text, so that they do not effect outgoing messages.
+
 Library changes
 ---
 
@@ -56,6 +67,7 @@ Compatibility with GMime 2.6
   However, a bug in current GMime 2.6 causes notmuch not to report
   signatures where the signer key is unavailable (GNOME bug 668085).
 
+
 Notmuch 0.11 (2012-01-13)
 =
 
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 023645e..4be7c13 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -116,7 +116,12 @@ list.
 (push-mark))
   (set-buffer-modified-p nil)
 
-  (message-goto-body))
+  (message-goto-body)
+  ;; Original message may contain (malicious) MML tags.  We must
+  ;; properly quote them in the reply.  Note that using `point-max'
+  ;; instead of `mark' here is wrong.  The buffer may include user's
+  ;; signature which should not be MML-quoted.
+  (mml-quote-region (point) (mark)))
 
 (defun notmuch-mua-forward-message ()
   (message-forward)
diff --git a/test/emacs b/test/emacs
index a3f4893..b9f7d15 100755
--- a/test/emacs
+++ b/test/emacs
@@ -274,7 +274,6 @@ EOF
 test_expect_equal_file OUTPUT EXPECTED
 
 test_begin_subtest Quote MML tags in reply
-test_subtest_known_broken
 message_id='test-emacs-mml-quot...@message.id'
 add_message [id]=$message_id \
[subject]='$test_subtest_name' \
-- 
1.7.9

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


  1   2   >