[PATCH 1/2] NEWS: markup changes to make mdwn->html look slightly better

2012-02-04 Thread Mark Walters

On Wed,  1 Feb 2012 17:22:49 +0200, Tomi Ollila  wrote:
> Some formatting in NEWS file has been changed so that it could
> be given to markdown processing almost verbatim.
> More effort has been put into formatting of version 0.11 (and 0.12)
> of notmuch NEWS than previous versions but everything is in better
> shape that those used to be.

Hi

Could you add something saying what markup rules developers should
follow when writing NEWS items? It would also make this patch easier to
comment upon. As far as I can see there are 2 relatively small things:
start an item with a * and put commands in backticks. (Actually it might
also be worth saying how to get * and ` if you actually want them too.)

I like the output at the address you gave.

Thanks

Mark



Bug: emacs 23.2 doesn't like ido-completing-read

2012-02-04 Thread Tomi Ollila
On Sat, 04 Feb 2012 12:31:57 +, Mark Walters  
wrote:
> 
> I hadn't realised before but this also goes wrong if you use the prefix
> argument to mail (eg ctrl-u m). The current code seems to mess up the
> mini-buffer and even closing the buffer does not get out of it.
> 
> Changing ido-completing-read read to completing-read seems to fix the
> problem entirely. Since this will affect most debian stable users (*) I
> think we should fix it. The trivial patch below works for me but other 
> solutions
> may be better as they could maintain the benefits of ido-completing-read
> (eg that it shows the possibilities).
>
> Best wishes
> 
> Mark
> 
> (*) Perhaps only those who have more than one email address.
> 
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index 023645e..41f82c2 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -191,7 +191,7 @@ the From: header is already filled in by notmuch."
>  ;; Now prompt the user, either for an email address only or for a full 
> identity.
>  (if one-name-only
>   (let ((address
> -(ido-completing-read (concat "Sender address for " name ": ") 
> addresses
> +(completing-read (concat "Sender address for " name ": ") 
> addresses
>   nil nil nil 'notmuch-mua-sender-history 
> (car addresses
> (concat name " <" address ">"))
>(ido-completing-read "Send mail From: " notmuch-identities

Should that other ido-completing-read be kept there -- it is the only
one left after this patch...

Tomi


> -- 
> 1.7.2.3



[PATCH v2 4/4] test: test the new --from option to notmuch-reply

2012-02-04 Thread Mark Walters
---
 test/reply |   69 
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/test/reply b/test/reply
index 00f4bea..0bb22bb 100755
--- a/test/reply
+++ b/test/reply
@@ -138,4 +138,73 @@ References: <${gen_msg_id}>

 On Tue, 05 Jan 2010 15:43:56 -, Notmuch Test Suite  wrote:
 > 200-byte header"
+
+test_begin_subtest "reply --from=none"
+add_message '[from]="Sender "' \
+[to]=test_suite at notmuchmail.org \
+[subject]=notmuch-reply-test \
+   '[date]="Tue, 05 Jan 2010 15:43:56 -"' \
+   '[body]="reply --from=none test"'
+
+output=$(notmuch reply --from=none id:${gen_msg_id})
+test_expect_equal "$output" "From: 
+Subject: Re: notmuch-reply-test
+To: Sender 
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -, Sender  wrote:
+> reply --from=none test"
+
+test_begin_subtest "reply --from:fallback-none"
+add_message '[from]="Sender "' \
+   '[to]="Someone Else "' \
+[subject]=notmuch-reply-test \
+   '[date]="Tue, 05 Jan 2010 15:43:56 -"' \
+   '[body]="reply --from=fallback-none test"'
+
+output=$(notmuch reply --from=fallback-none id:${gen_msg_id})
+test_expect_equal "$output" "From: 
+Subject: Re: notmuch-reply-test
+To: Sender , Someone Else 
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -, Sender  wrote:
+> reply --from=fallback-none test"
+
+test_begin_subtest "reply default from:"
+add_message '[from]="Sender "' \
+   '[to]="Someone Else "' \
+[subject]=notmuch-reply-test \
+   '[date]="Tue, 05 Jan 2010 15:43:56 -"' \
+   '[body]="reply default from: test"'
+
+output=$(notmuch reply id:${gen_msg_id})
+test_expect_equal "$output" "From: Notmuch Test Suite 
+Subject: Re: notmuch-reply-test
+To: Sender , Someone Else 
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -, Sender  wrote:
+> reply default from: test"
+
+test_begin_subtest "Reply --from=primary"
+add_message '[from]="Sender "' \
+[to]=test_suite_other at notmuchmail.org \
+[subject]=notmuch-reply-test \
+   '[date]="Tue, 05 Jan 2010 15:43:56 -"' \
+   '[body]="reply --from=primary"'
+
+output=$(notmuch reply --from=primary id:${gen_msg_id})
+test_expect_equal "$output" "From: Notmuch Test Suite 
+Subject: Re: notmuch-reply-test
+To: Sender 
+In-Reply-To: <${gen_msg_id}>
+References: <${gen_msg_id}>
+
+On Tue, 05 Jan 2010 15:43:56 -, Sender  wrote:
+> reply --from=primary"
+
 test_done
-- 
1.7.2.3



[PATCH v2 3/4] emacs: Improve prompting for user address when replying.

2012-02-04 Thread Mark Walters
This patch uses the new --from option to notmuch reply to allow it to
prompt the user for the From: address in cases when the cli does not
know the "correct" from address. If the cli does not it either uses
the users default address or, if notmuch-always-prompt-for-sender
is set, prompts the user.
---
 emacs/notmuch-mua.el |   47 ---
 1 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 41f82c2..36e62f9 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -51,6 +51,24 @@ list."

 ;;

+(defcustom notmuch-identities nil
+  "Identities that can be used as the From: address when composing a new 
message.
+
+If this variable is left unset, then a list will be constructed from the
+name and addresses configured in the notmuch configuration file."
+  :type '(repeat string)
+  :group 'notmuch-send)
+
+(defcustom notmuch-always-prompt-for-sender nil
+  "Always prompt for the From: address when composing or forwarding a message.
+
+This is not taken into account when replying to a message, because in that case
+the From: header is already filled in by notmuch."
+  :type 'boolean
+  :group 'notmuch-send)
+
+(defvar notmuch-mua-sender-history nil)
+
 (defun notmuch-mua-user-agent-full ()
   "Generate a `User-Agent:' string suitable for notmuch."
   (concat (notmuch-mua-user-agent-notmuch)
@@ -75,7 +93,7 @@ list."
 (defun notmuch-mua-reply (query-string  sender reply-all)
   (let (headers
body
-   (args '("reply")))
+   (args '("reply" "--from=fallback-received")))
 (if notmuch-show-process-crypto
(setq args (append args '("--decrypt"
 (if reply-all
@@ -99,6 +117,15 @@ list."
 ;; If sender is non-nil, set the From: header to its value.
 (when sender
   (mail-header-set 'from sender headers))
+;; If we do not have a From: header yet it means that
+;; notmuch-reply.c was not able to make a useful guess so we fill
+;; it in ourselves.
+(when (string= "" (mail-header 'from headers))
+  (if notmuch-always-prompt-for-sender
+ (setq sender (notmuch-mua-prompt-for-sender))
+   (setq sender (concat
+ (notmuch-user-name) " <" (notmuch-user-primary-email) 
">")))
+  (mail-header-set 'from sender headers))
 (let
;; Overlay the composition window on that being used to read
;; the original message.
@@ -153,24 +180,6 @@ OTHER-ARGS are passed through to `message-mail'."

   (message-goto-to))

-(defcustom notmuch-identities nil
-  "Identities that can be used as the From: address when composing a new 
message.
-
-If this variable is left unset, then a list will be constructed from the
-name and addresses configured in the notmuch configuration file."
-  :type '(repeat string)
-  :group 'notmuch-send)
-
-(defcustom notmuch-always-prompt-for-sender nil
-  "Always prompt for the From: address when composing or forwarding a message.
-
-This is not taken into account when replying to a message, because in that case
-the From: header is already filled in by notmuch."
-  :type 'boolean
-  :group 'notmuch-send)
-
-(defvar notmuch-mua-sender-history nil)
-
 (defun notmuch-mua-prompt-for-sender ()
   (interactive)
   (let (name addresses one-name-only)
-- 
1.7.2.3



[PATCH v2 2/4] cli: update man page for notmuch-reply --from:

2012-02-04 Thread Mark Walters
---
 man/man1/notmuch-reply.1 |   27 +++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1
index 5160ece..101ed47 100644
--- a/man/man1/notmuch-reply.1
+++ b/man/man1/notmuch-reply.1
@@ -62,6 +62,33 @@ addresses), try To:, Cc:, and Bcc: headers in this order, 
and copy
 values from the first that contains something other than only the
 user's addresses.
 .RE
+.TP 4
+.BR \-\-from= ( default | fallback-all | fallback-received | fallback-none | 
none | primary )
+.RS
+.TP 4
+Controls the choice of the From: header returned.
+.TP 4
+.BR default | fallback-all
+Chooses the From: address by looking at the reply-to/from/to/cc
+headers of the message being replied to, if no user address is found
+look in the delivery headers, if still no user address is found return
+the user's primary address.
+.TP 4
+.BR fallback-received
+As above but if no user address is found after looking in the delivery
+headers returns an empty From: header.
+.TP 4
+.BR fallback-none
+Only look at the reply-to/from/to/cc of the original message. If no
+user address is found return an empty From: header.
+.TP 4
+.BR none
+Always return an empty From: header.
+.TP 4
+.BR primary
+Always return the users primary address as the From: header.
+.RE
+.RE
 .RE

 See \fBnotmuch-search-terms\fR(7)
-- 
1.7.2.3



[PATCH v2 1/4] cli: add --from option to reply to restrict guessing of the From: header.

2012-02-04 Thread Mark Walters
Add an option --from= to notmuch-reply.c to restrict guessing of the
From: header. The existing logic looks as the main headers, then at
the delivery headers, and finally defaults to the config file address.

This patch allows the user to restrict which of these guesses are
made.  Currently the supported values are:
   default|fallback-allcurrent behaviour
   fallback-received   fallback to delivery headers but not config file
   fallback-none   only look at from/reply-to/to/cc/ headers
   noneFrom: header is always left empty

If the code does not find an allowed address it outputs an empty From:
line and the caller can decide how to respond.
---
 notmuch-reply.c |   45 -
 1 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index f55b1d2..8c73cb7 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -24,6 +24,15 @@
 #include "gmime-filter-reply.h"
 #include "gmime-filter-headers.h"

+/* The order here matters as we use '<' when deciding how to behave. */
+enum {
+FROM_FALLBACK_ALL,
+FROM_FALLBACK_RECEIVED,
+FROM_FALLBACK_NONE,
+FROM_NONE,
+FROM_PRIMARY
+};
+
 static void
 reply_headers_message_part (GMimeMessage *message);

@@ -510,7 +519,8 @@ notmuch_reply_format_default(void *ctx,
 notmuch_config_t *config,
 notmuch_query_t *query,
 notmuch_show_params_t *params,
-notmuch_bool_t reply_all)
+notmuch_bool_t reply_all,
+int from_select)
 {
 GMimeMessage *reply;
 notmuch_messages_t *messages;
@@ -542,15 +552,22 @@ notmuch_reply_format_default(void *ctx,
from_addr = add_recipients_from_message (reply, config, message,
 reply_all);

-   if (from_addr == NULL)
+   if (from_addr == NULL && from_select <= FROM_FALLBACK_RECEIVED)
from_addr = guess_from_received_header (config, message);

-   if (from_addr == NULL)
+   if ((from_addr == NULL && from_select <= FROM_FALLBACK_ALL) ||
+   from_select == FROM_PRIMARY)
from_addr = notmuch_config_get_user_primary_email (config);

-   from_addr = talloc_asprintf (ctx, "%s <%s>",
-notmuch_config_get_user_name (config),
-from_addr);
+   /* If we have an address and we want an address print
+* it. Otherwise set an empty From: header. */
+   if (from_addr != NULL && from_select != FROM_NONE) {
+   from_addr = talloc_asprintf (ctx, "%s <%s>",
+notmuch_config_get_user_name (config),
+from_addr);
+   } else {
+   from_addr = talloc_strdup (ctx, "");
+   }
g_mime_object_set_header (GMIME_OBJECT (reply),
  "From", from_addr);

@@ -590,7 +607,8 @@ notmuch_reply_format_headers_only(void *ctx,
  notmuch_config_t *config,
  notmuch_query_t *query,
  unused (notmuch_show_params_t *params),
- notmuch_bool_t reply_all)
+ notmuch_bool_t reply_all,
+ unused (int from_select))
 {
 GMimeMessage *reply;
 notmuch_messages_t *messages;
@@ -657,10 +675,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 notmuch_query_t *query;
 char *query_string;
 int opt_index, ret = 0;
-int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all);
+int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all, int from_select);
 notmuch_show_params_t params = { .part = -1 };
 int format = FORMAT_DEFAULT;
 int reply_all = TRUE;
+int from_select = FROM_FALLBACK_ALL;
 notmuch_bool_t decrypt = FALSE;

 notmuch_opt_desc_t options[] = {
@@ -672,6 +691,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
  (notmuch_keyword_t []){ { "all", TRUE },
  { "sender", FALSE },
  { 0, 0 } } },
+   { NOTMUCH_OPT_KEYWORD, _select, "from", 'F',
+ (notmuch_keyword_t []){ { "default", FROM_FALLBACK_ALL },
+ { "fallback-all", FROM_FALLBACK_ALL },
+ { "fallback-received", FROM_FALLBACK_RECEIVED 
},
+ { "fallback-none", FROM_FALLBACK_NONE },
+ { "none", FROM_NONE },
+ { "primary", FROM_PRIMARY },
+ 

[Patch v2 0/4] Control selection of From: header when replying

2012-02-04 Thread Mark Walters

This is version 2 of the patch set first posted in
id:"1328375350-10352-1-git-send-email-markwalters1009 at gmail.com"

This fixes the bug Jani pointed out as well as the more minor
criticisms. It also has some tests and the man pages are updated.

Best wishes

Mark



Bug: emacs 23.2 doesn't like ido-completing-read

2012-02-04 Thread Mark Walters
On Sat, 04 Feb 2012 22:14:25 +0200, Tomi Ollila  wrote:
> On Sat, 04 Feb 2012 12:31:57 +, Mark Walters  gmail.com> wrote:
> > 
> > I hadn't realised before but this also goes wrong if you use the prefix
> > argument to mail (eg ctrl-u m). The current code seems to mess up the
> > mini-buffer and even closing the buffer does not get out of it.
> > 
> > Changing ido-completing-read read to completing-read seems to fix the
> > problem entirely. Since this will affect most debian stable users (*) I
> > think we should fix it. The trivial patch below works for me but other 
> > solutions
> > may be better as they could maintain the benefits of ido-completing-read
> > (eg that it shows the possibilities).
> >
> > Best wishes
> > 
> > Mark
> > 
> > (*) Perhaps only those who have more than one email address.
> > 
> > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> > index 023645e..41f82c2 100644
> > --- a/emacs/notmuch-mua.el
> > +++ b/emacs/notmuch-mua.el
> > @@ -191,7 +191,7 @@ the From: header is already filled in by notmuch."
> >  ;; Now prompt the user, either for an email address only or for a full 
> > identity.
> >  (if one-name-only
> > (let ((address
> > -  (ido-completing-read (concat "Sender address for " name ": ") 
> > addresses
> > +  (completing-read (concat "Sender address for " name ": ") 
> > addresses
> > nil nil nil 'notmuch-mua-sender-history 
> > (car addresses
> >   (concat name " <" address ">"))
> >(ido-completing-read "Send mail From: " notmuch-identities
> 
> Should that other ido-completing-read be kept there -- it is the only
> one left after this patch...

Whoops: I hadn't even noticed that one. Is there any way of fixing it
so ido-completing-read works (see the link in my first message
id:"871uqijdy4.fsf at qmul.ac.uk")? Not because I want the extra
functionality but perhaps someone else likes it as it is.

Many thanks

Mark



[PATCH 2/2] emacs: Improve prompting for user address when replying.

2012-02-04 Thread Jani Nikula
On Sat,  4 Feb 2012 17:09:10 +, Mark Walters  
wrote:
> This patch uses the new --from option to notmuch reply to allow it to
> prompt the user for the From: address in cases when the cli does not
> know the "correct" from address. If the cli does not it either uses
> the users default address or, if notmuch-always-prompt-for-sender
> is set, prompts the user.
> ---
>  emacs/notmuch-mua.el |   47 ---
>  1 files changed, 28 insertions(+), 19 deletions(-)
> 
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index 41f82c2..36e62f9 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -51,6 +51,24 @@ list."
>  
>  ;;
>  
> +(defcustom notmuch-identities nil
> +  "Identities that can be used as the From: address when composing a new 
> message.
> +
> +If this variable is left unset, then a list will be constructed from the
> +name and addresses configured in the notmuch configuration file."
> +  :type '(repeat string)
> +  :group 'notmuch-send)
> +
> +(defcustom notmuch-always-prompt-for-sender nil
> +  "Always prompt for the From: address when composing or forwarding a 
> message.
> +
> +This is not taken into account when replying to a message, because in that 
> case
> +the From: header is already filled in by notmuch."
> +  :type 'boolean
> +  :group 'notmuch-send)
> +
> +(defvar notmuch-mua-sender-history nil)
> +
>  (defun notmuch-mua-user-agent-full ()
>"Generate a `User-Agent:' string suitable for notmuch."
>(concat (notmuch-mua-user-agent-notmuch)
> @@ -75,7 +93,7 @@ list."
>  (defun notmuch-mua-reply (query-string  sender reply-all)
>(let (headers
>   body
> - (args '("reply")))
> + (args '("reply" "--from=fallback-received")))

There are better reviewers for the rest of the emacs bits, but wouldn't
it be better to just use the "notmuch reply" default when the user wants
the current behaviour?

BR,
Jani.


>  (if notmuch-show-process-crypto
>   (setq args (append args '("--decrypt"
>  (if reply-all
> @@ -99,6 +117,15 @@ list."
>  ;; If sender is non-nil, set the From: header to its value.
>  (when sender
>(mail-header-set 'from sender headers))
> +;; If we do not have a From: header yet it means that
> +;; notmuch-reply.c was not able to make a useful guess so we fill
> +;; it in ourselves.
> +(when (string= "" (mail-header 'from headers))
> +  (if notmuch-always-prompt-for-sender
> +   (setq sender (notmuch-mua-prompt-for-sender))
> + (setq sender (concat
> +   (notmuch-user-name) " <" (notmuch-user-primary-email) 
> ">")))
> +  (mail-header-set 'from sender headers))
>  (let
>   ;; Overlay the composition window on that being used to read
>   ;; the original message.
> @@ -153,24 +180,6 @@ OTHER-ARGS are passed through to `message-mail'."
>  
>(message-goto-to))
>  
> -(defcustom notmuch-identities nil
> -  "Identities that can be used as the From: address when composing a new 
> message.
> -
> -If this variable is left unset, then a list will be constructed from the
> -name and addresses configured in the notmuch configuration file."
> -  :type '(repeat string)
> -  :group 'notmuch-send)
> -
> -(defcustom notmuch-always-prompt-for-sender nil
> -  "Always prompt for the From: address when composing or forwarding a 
> message.
> -
> -This is not taken into account when replying to a message, because in that 
> case
> -the From: header is already filled in by notmuch."
> -  :type 'boolean
> -  :group 'notmuch-send)
> -
> -(defvar notmuch-mua-sender-history nil)
> -
>  (defun notmuch-mua-prompt-for-sender ()
>(interactive)
>(let (name addresses one-name-only)
> -- 
> 1.7.2.3
> 
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] cli: add --from option to reply to restrict guessing of the From: header.

2012-02-04 Thread Jani Nikula
On Sat,  4 Feb 2012 17:09:09 +, Mark Walters  
wrote:
> Add an option --from= to notmuch-reply.c to restrict guessing of the
> From: header. The existing logic looks as the main headers, then at
> the delivery headers, and finally defaults to the config file address.
> 
> This patch allows the user to restrict which of these guesses are
> made.  Currently the supported values are:
>default|fallback-allcurrent behaviour
>fallback-received   fallback to delivery headers but not config 
> file
>fallback-none only look at from/reply-to/to/cc/ headers
>none  From: header is always left empty

As discussed on IRC, --from=primary is a natural extension to always use
the primary address from config, but that can be a later patch.

> 
> If the code does not find an allowed address it outputs an empty From:
> line and the caller can decide how to respond.
> ---
>  notmuch-reply.c |   39 ++-
>  1 files changed, 30 insertions(+), 9 deletions(-)
> 
> diff --git a/notmuch-reply.c b/notmuch-reply.c
> index f55b1d2..f660749 100644
> --- a/notmuch-reply.c
> +++ b/notmuch-reply.c
> @@ -24,6 +24,13 @@
>  #include "gmime-filter-reply.h"
>  #include "gmime-filter-headers.h"
>  

I think it would be good to have a comment here reminding later
developers that the order matters in this enum.

> +enum {
> +FROM_FALLBACK_ALL,
> +FROM_FALLBACK_RECEIVED,
> +FROM_FALLBACK_NONE,
> +FROM_NONE
> +};
> +
>  static void
>  reply_headers_message_part (GMimeMessage *message);
>  
> @@ -510,7 +517,8 @@ notmuch_reply_format_default(void *ctx,
>notmuch_config_t *config,
>notmuch_query_t *query,
>notmuch_show_params_t *params,
> -  notmuch_bool_t reply_all)
> +  notmuch_bool_t reply_all,
> +  int from_guess)

Hrmh, I'd like this to sound more deterministic than
"guessing". from_select? from_use? from?

>  {
>  GMimeMessage *reply;
>  notmuch_messages_t *messages;
> @@ -542,15 +550,19 @@ notmuch_reply_format_default(void *ctx,
>   from_addr = add_recipients_from_message (reply, config, message,
>reply_all);
>  
> - if (from_addr == NULL)
> + if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_RECEIVED))

Please drop the extra braces here and below.

>   from_addr = guess_from_received_header (config, message);
>  
> - if (from_addr == NULL)
> + if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_ALL ))
>   from_addr = notmuch_config_get_user_primary_email (config);
>  
> - from_addr = talloc_asprintf (ctx, "%s <%s>",
> -  notmuch_config_get_user_name (config),
> -  from_addr);
> + if ((from_addr != NULL) || (from_guess = FROM_NONE)) {

Should that be (from_addr != NULL && from_guess != FROM_NONE)?
Definitely the assignment is an error!

> + from_addr = talloc_asprintf (ctx, "%s <%s>",
> +  notmuch_config_get_user_name (config),
> +  from_addr);
> + } else {
> + from_addr = talloc_strdup (ctx, "");
> + }
>   g_mime_object_set_header (GMIME_OBJECT (reply),
> "From", from_addr);
>  
> @@ -590,7 +602,8 @@ notmuch_reply_format_headers_only(void *ctx,
> notmuch_config_t *config,
> notmuch_query_t *query,
> unused (notmuch_show_params_t *params),
> -   notmuch_bool_t reply_all)
> +   notmuch_bool_t reply_all,
> +   unused (int from_guess))
>  {
>  GMimeMessage *reply;
>  notmuch_messages_t *messages;
> @@ -657,10 +670,11 @@ notmuch_reply_command (void *ctx, int argc, char 
> *argv[])
>  notmuch_query_t *query;
>  char *query_string;
>  int opt_index, ret = 0;
> -int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
> notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
> reply_all);
> +int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
> notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
> reply_all, int from_guess);
>  notmuch_show_params_t params = { .part = -1 };
>  int format = FORMAT_DEFAULT;
>  int reply_all = TRUE;
> +int from_guess = FROM_FALLBACK_ALL;
>  notmuch_bool_t decrypt = FALSE;
>  
>  notmuch_opt_desc_t options[] = {
> @@ -672,6 +686,13 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
> (notmuch_keyword_t []){ { "all", TRUE },
> { "sender", FALSE },
> { 0, 0 } } },
> + { NOTMUCH_OPT_KEYWORD, 

[PATCH 2/2] emacs: Improve prompting for user address when replying.

2012-02-04 Thread Mark Walters

On Sat, 04 Feb 2012 20:03:13 +0200, Jani Nikula  wrote:
> On Sat,  4 Feb 2012 17:09:10 +, Mark Walters  gmail.com> wrote:
> > This patch uses the new --from option to notmuch reply to allow it to
> > prompt the user for the From: address in cases when the cli does not
> > know the "correct" from address. If the cli does not it either uses
> > the users default address or, if notmuch-always-prompt-for-sender
> > is set, prompts the user.
> > ---
> >  emacs/notmuch-mua.el |   47 ---
> >  1 files changed, 28 insertions(+), 19 deletions(-)
> > 
> > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> > index 41f82c2..36e62f9 100644
> > --- a/emacs/notmuch-mua.el
> > +++ b/emacs/notmuch-mua.el
> > @@ -51,6 +51,24 @@ list."
> >  
> >  ;;
> >  
> > +(defcustom notmuch-identities nil
> > +  "Identities that can be used as the From: address when composing a new 
> > message.
> > +
> > +If this variable is left unset, then a list will be constructed from the
> > +name and addresses configured in the notmuch configuration file."
> > +  :type '(repeat string)
> > +  :group 'notmuch-send)
> > +
> > +(defcustom notmuch-always-prompt-for-sender nil
> > +  "Always prompt for the From: address when composing or forwarding a 
> > message.
> > +
> > +This is not taken into account when replying to a message, because in that 
> > case
> > +the From: header is already filled in by notmuch."
> > +  :type 'boolean
> > +  :group 'notmuch-send)
> > +
> > +(defvar notmuch-mua-sender-history nil)
> > +
> >  (defun notmuch-mua-user-agent-full ()
> >"Generate a `User-Agent:' string suitable for notmuch."
> >(concat (notmuch-mua-user-agent-notmuch)
> > @@ -75,7 +93,7 @@ list."
> >  (defun notmuch-mua-reply (query-string  sender reply-all)
> >(let (headers
> > body
> > -   (args '("reply")))
> > +   (args '("reply" "--from=fallback-received")))
> 
> There are better reviewers for the rest of the emacs bits, but wouldn't
> it be better to just use the "notmuch reply" default when the user wants
> the current behaviour?

Does any user actually want to be prompted for a From address when
mailing/forwarding normally but not when replying and there is no reason
to choose one address over another?

What I would actually like is to consolidate the From address choosing
so that it occurs in one place in the emacs code, so the three
(mail/forward/reply) naturally behave the same.

Thanks for the rapid review (and the significant bug catch!)

Best wishes

Mark


> BR,
> Jani.
> 
> 
> >  (if notmuch-show-process-crypto
> > (setq args (append args '("--decrypt"
> >  (if reply-all
> > @@ -99,6 +117,15 @@ list."
> >  ;; If sender is non-nil, set the From: header to its value.
> >  (when sender
> >(mail-header-set 'from sender headers))
> > +;; If we do not have a From: header yet it means that
> > +;; notmuch-reply.c was not able to make a useful guess so we fill
> > +;; it in ourselves.
> > +(when (string= "" (mail-header 'from headers))
> > +  (if notmuch-always-prompt-for-sender
> > + (setq sender (notmuch-mua-prompt-for-sender))
> > +   (setq sender (concat
> > + (notmuch-user-name) " <" (notmuch-user-primary-email) 
> > ">")))
> > +  (mail-header-set 'from sender headers))
> >  (let
> > ;; Overlay the composition window on that being used to read
> > ;; the original message.
> > @@ -153,24 +180,6 @@ OTHER-ARGS are passed through to `message-mail'."
> >  
> >(message-goto-to))
> >  
> > -(defcustom notmuch-identities nil
> > -  "Identities that can be used as the From: address when composing a new 
> > message.
> > -
> > -If this variable is left unset, then a list will be constructed from the
> > -name and addresses configured in the notmuch configuration file."
> > -  :type '(repeat string)
> > -  :group 'notmuch-send)
> > -
> > -(defcustom notmuch-always-prompt-for-sender nil
> > -  "Always prompt for the From: address when composing or forwarding a 
> > message.
> > -
> > -This is not taken into account when replying to a message, because in that 
> > case
> > -the From: header is already filled in by notmuch."
> > -  :type 'boolean
> > -  :group 'notmuch-send)
> > -
> > -(defvar notmuch-mua-sender-history nil)
> > -
> >  (defun notmuch-mua-prompt-for-sender ()
> >(interactive)
> >(let (name addresses one-name-only)
> > -- 
> > 1.7.2.3
> > 
> > ___
> > notmuch mailing list
> > notmuch at notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] cli: add --from option to reply to restrict guessing of the From: header.

2012-02-04 Thread Mark Walters

On Sat, 04 Feb 2012 19:59:58 +0200, Jani Nikula  wrote:
> On Sat,  4 Feb 2012 17:09:09 +, Mark Walters  gmail.com> wrote:
> > Add an option --from= to notmuch-reply.c to restrict guessing of the
> > From: header. The existing logic looks as the main headers, then at
> > the delivery headers, and finally defaults to the config file address.
> > 
> > This patch allows the user to restrict which of these guesses are
> > made.  Currently the supported values are:
> >default|fallback-allcurrent behaviour
> >fallback-received   fallback to delivery headers but not config 
> > file
> >fallback-none   only look at from/reply-to/to/cc/ headers
> >noneFrom: header is always left empty
> 
> As discussed on IRC, --from=primary is a natural extension to always use
> the primary address from config, but that can be a later patch.

Ok, I will probably add that.

> > 
> > If the code does not find an allowed address it outputs an empty From:
> > line and the caller can decide how to respond.
> > ---
> >  notmuch-reply.c |   39 ++-
> >  1 files changed, 30 insertions(+), 9 deletions(-)
> > 
> > diff --git a/notmuch-reply.c b/notmuch-reply.c
> > index f55b1d2..f660749 100644
> > --- a/notmuch-reply.c
> > +++ b/notmuch-reply.c
> > @@ -24,6 +24,13 @@
> >  #include "gmime-filter-reply.h"
> >  #include "gmime-filter-headers.h"
> >  
> 
> I think it would be good to have a comment here reminding later
> developers that the order matters in this enum.

Have fixed

> > +enum {
> > +FROM_FALLBACK_ALL,
> > +FROM_FALLBACK_RECEIVED,
> > +FROM_FALLBACK_NONE,
> > +FROM_NONE
> > +};
> > +
> >  static void
> >  reply_headers_message_part (GMimeMessage *message);
> >  
> > @@ -510,7 +517,8 @@ notmuch_reply_format_default(void *ctx,
> >  notmuch_config_t *config,
> >  notmuch_query_t *query,
> >  notmuch_show_params_t *params,
> > -notmuch_bool_t reply_all)
> > +notmuch_bool_t reply_all,
> > +int from_guess)
> 
> Hrmh, I'd like this to sound more deterministic than
> "guessing". from_select? from_use? from?

I have gone for from_select.

> >  {
> >  GMimeMessage *reply;
> >  notmuch_messages_t *messages;
> > @@ -542,15 +550,19 @@ notmuch_reply_format_default(void *ctx,
> > from_addr = add_recipients_from_message (reply, config, message,
> >  reply_all);
> >  
> > -   if (from_addr == NULL)
> > +   if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_RECEIVED))
> 
> Please drop the extra braces here and below.

Have fixed. (Indeed in a sense this was a bug see below!)
> 
> > from_addr = guess_from_received_header (config, message);
> >  
> > -   if (from_addr == NULL)
> > +   if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_ALL ))
> > from_addr = notmuch_config_get_user_primary_email (config);
> >  
> > -   from_addr = talloc_asprintf (ctx, "%s <%s>",
> > -notmuch_config_get_user_name (config),
> > -from_addr);
> > +   if ((from_addr != NULL) || (from_guess = FROM_NONE)) {
> 
> Should that be (from_addr != NULL && from_guess != FROM_NONE)?
> Definitely the assignment is an error!

You are quite right. And if I didn't have the superfluous brackets the
compiler would probably have given a warning. I have fixed it.

> 
> > +   from_addr = talloc_asprintf (ctx, "%s <%s>",
> > +notmuch_config_get_user_name (config),
> > +from_addr);
> > +   } else {
> > +   from_addr = talloc_strdup (ctx, "");
> > +   }
> > g_mime_object_set_header (GMIME_OBJECT (reply),
> >   "From", from_addr);
> >  
> > @@ -590,7 +602,8 @@ notmuch_reply_format_headers_only(void *ctx,
> >   notmuch_config_t *config,
> >   notmuch_query_t *query,
> >   unused (notmuch_show_params_t *params),
> > - notmuch_bool_t reply_all)
> > + notmuch_bool_t reply_all,
> > + unused (int from_guess))
> >  {
> >  GMimeMessage *reply;
> >  notmuch_messages_t *messages;
> > @@ -657,10 +670,11 @@ notmuch_reply_command (void *ctx, int argc, char 
> > *argv[])
> >  notmuch_query_t *query;
> >  char *query_string;
> >  int opt_index, ret = 0;
> > -int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
> > notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
> > reply_all);
> > +int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
> > notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
> > reply_all, int from_guess);
> >  

[PATCH 2/2] emacs: Improve prompting for user address when replying.

2012-02-04 Thread Mark Walters
This patch uses the new --from option to notmuch reply to allow it to
prompt the user for the From: address in cases when the cli does not
know the "correct" from address. If the cli does not it either uses
the users default address or, if notmuch-always-prompt-for-sender
is set, prompts the user.
---
 emacs/notmuch-mua.el |   47 ---
 1 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 41f82c2..36e62f9 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -51,6 +51,24 @@ list."

 ;;

+(defcustom notmuch-identities nil
+  "Identities that can be used as the From: address when composing a new 
message.
+
+If this variable is left unset, then a list will be constructed from the
+name and addresses configured in the notmuch configuration file."
+  :type '(repeat string)
+  :group 'notmuch-send)
+
+(defcustom notmuch-always-prompt-for-sender nil
+  "Always prompt for the From: address when composing or forwarding a message.
+
+This is not taken into account when replying to a message, because in that case
+the From: header is already filled in by notmuch."
+  :type 'boolean
+  :group 'notmuch-send)
+
+(defvar notmuch-mua-sender-history nil)
+
 (defun notmuch-mua-user-agent-full ()
   "Generate a `User-Agent:' string suitable for notmuch."
   (concat (notmuch-mua-user-agent-notmuch)
@@ -75,7 +93,7 @@ list."
 (defun notmuch-mua-reply (query-string  sender reply-all)
   (let (headers
body
-   (args '("reply")))
+   (args '("reply" "--from=fallback-received")))
 (if notmuch-show-process-crypto
(setq args (append args '("--decrypt"
 (if reply-all
@@ -99,6 +117,15 @@ list."
 ;; If sender is non-nil, set the From: header to its value.
 (when sender
   (mail-header-set 'from sender headers))
+;; If we do not have a From: header yet it means that
+;; notmuch-reply.c was not able to make a useful guess so we fill
+;; it in ourselves.
+(when (string= "" (mail-header 'from headers))
+  (if notmuch-always-prompt-for-sender
+ (setq sender (notmuch-mua-prompt-for-sender))
+   (setq sender (concat
+ (notmuch-user-name) " <" (notmuch-user-primary-email) 
">")))
+  (mail-header-set 'from sender headers))
 (let
;; Overlay the composition window on that being used to read
;; the original message.
@@ -153,24 +180,6 @@ OTHER-ARGS are passed through to `message-mail'."

   (message-goto-to))

-(defcustom notmuch-identities nil
-  "Identities that can be used as the From: address when composing a new 
message.
-
-If this variable is left unset, then a list will be constructed from the
-name and addresses configured in the notmuch configuration file."
-  :type '(repeat string)
-  :group 'notmuch-send)
-
-(defcustom notmuch-always-prompt-for-sender nil
-  "Always prompt for the From: address when composing or forwarding a message.
-
-This is not taken into account when replying to a message, because in that case
-the From: header is already filled in by notmuch."
-  :type 'boolean
-  :group 'notmuch-send)
-
-(defvar notmuch-mua-sender-history nil)
-
 (defun notmuch-mua-prompt-for-sender ()
   (interactive)
   (let (name addresses one-name-only)
-- 
1.7.2.3



[PATCH 1/2] cli: add --from option to reply to restrict guessing of the From: header.

2012-02-04 Thread Mark Walters
Add an option --from= to notmuch-reply.c to restrict guessing of the
From: header. The existing logic looks as the main headers, then at
the delivery headers, and finally defaults to the config file address.

This patch allows the user to restrict which of these guesses are
made.  Currently the supported values are:
   default|fallback-allcurrent behaviour
   fallback-received   fallback to delivery headers but not config file
   fallback-none   only look at from/reply-to/to/cc/ headers
   noneFrom: header is always left empty

If the code does not find an allowed address it outputs an empty From:
line and the caller can decide how to respond.
---
 notmuch-reply.c |   39 ++-
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index f55b1d2..f660749 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -24,6 +24,13 @@
 #include "gmime-filter-reply.h"
 #include "gmime-filter-headers.h"

+enum {
+FROM_FALLBACK_ALL,
+FROM_FALLBACK_RECEIVED,
+FROM_FALLBACK_NONE,
+FROM_NONE
+};
+
 static void
 reply_headers_message_part (GMimeMessage *message);

@@ -510,7 +517,8 @@ notmuch_reply_format_default(void *ctx,
 notmuch_config_t *config,
 notmuch_query_t *query,
 notmuch_show_params_t *params,
-notmuch_bool_t reply_all)
+notmuch_bool_t reply_all,
+int from_guess)
 {
 GMimeMessage *reply;
 notmuch_messages_t *messages;
@@ -542,15 +550,19 @@ notmuch_reply_format_default(void *ctx,
from_addr = add_recipients_from_message (reply, config, message,
 reply_all);

-   if (from_addr == NULL)
+   if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_RECEIVED))
from_addr = guess_from_received_header (config, message);

-   if (from_addr == NULL)
+   if ((from_addr == NULL) && (from_guess <= FROM_FALLBACK_ALL ))
from_addr = notmuch_config_get_user_primary_email (config);

-   from_addr = talloc_asprintf (ctx, "%s <%s>",
-notmuch_config_get_user_name (config),
-from_addr);
+   if ((from_addr != NULL) || (from_guess = FROM_NONE)) {
+   from_addr = talloc_asprintf (ctx, "%s <%s>",
+notmuch_config_get_user_name (config),
+from_addr);
+   } else {
+   from_addr = talloc_strdup (ctx, "");
+   }
g_mime_object_set_header (GMIME_OBJECT (reply),
  "From", from_addr);

@@ -590,7 +602,8 @@ notmuch_reply_format_headers_only(void *ctx,
  notmuch_config_t *config,
  notmuch_query_t *query,
  unused (notmuch_show_params_t *params),
- notmuch_bool_t reply_all)
+ notmuch_bool_t reply_all,
+ unused (int from_guess))
 {
 GMimeMessage *reply;
 notmuch_messages_t *messages;
@@ -657,10 +670,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 notmuch_query_t *query;
 char *query_string;
 int opt_index, ret = 0;
-int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all);
+int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all, int from_guess);
 notmuch_show_params_t params = { .part = -1 };
 int format = FORMAT_DEFAULT;
 int reply_all = TRUE;
+int from_guess = FROM_FALLBACK_ALL;
 notmuch_bool_t decrypt = FALSE;

 notmuch_opt_desc_t options[] = {
@@ -672,6 +686,13 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
  (notmuch_keyword_t []){ { "all", TRUE },
  { "sender", FALSE },
  { 0, 0 } } },
+   { NOTMUCH_OPT_KEYWORD, _guess, "from", 'F',
+ (notmuch_keyword_t []){ { "default", FROM_FALLBACK_ALL },
+ { "fallback-all", FROM_FALLBACK_ALL },
+ { "fallback-received", FROM_FALLBACK_RECEIVED 
},
+ { "fallback-none", FROM_FALLBACK_NONE },
+ { "none", FROM_NONE },
+ { 0, 0 } } },
{ NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 },
{ 0, 0, 0, 0, 0 }
 };
@@ -732,7 +753,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
return 1;
 }

-if (reply_format_func (ctx, config, query, , reply_all) != 0)
+if 

[PATCH 0/2] Control guessing of the from-address when replying

2012-02-04 Thread Mark Walters

Hello

This patch sets is intended to allow the user more control over the
From: address when replying to emails. 

In notmuch-reply.c the current logic for the From: address looks as
the main headers, then at the delivery headers, and finally defaults
to the config file address. This means that the frontends (e.g. emacs)
cannot tell whether the users primary address is in the From: header
because the message being replied to was sent to that address, or
notmuch just fellback to using it as it had no better guess. 

The first patch allows the user to control which fallbacks are
used. The second implements this in emacs so that it does not fallback
to the primary address; thus, in this case, emacs can ask for the
address (if notmuch-always-prompt-for-sender is set). The set is not
heavily tested but appears to work.

There is some bikeshedding available as to what options we should be
able to pass to the --from= in notmuch-reply.c.

It obviously also needs some tests and some man pages updates.

Finally, we may want a defcustom option for emacs to control which it
uses (e.g., the user always wants to reply from ther primary address).


Best wishes

Mark




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

2012-02-04 Thread Austin Clements
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.
---
 notmuch-show.c |   85 +---
 test/crypto|2 +-
 test/thread-naming |   16 +-
 3 files changed, 30 insertions(+), 73 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index 6a890b2..816e0f8 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";

+   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,19 @@ 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);
g_object_unref(stream_stdout);
-   }
-   else if (g_mime_content_type_is_type (content_type, "multipart", "*") ||
-g_mime_content_type_is_type (content_type, "message", 
"rfc822"))
-   {
-   /* Do nothing for multipart since its content will be printed
-* when recursing. */
-   }
-   else
-   {
+   } else {
printf 

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

2012-02-04 Thread Austin Clements
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 = ""
 };

 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"))
-{
-   GMimeStream *stream_stdout = g_mime_stream_file_new (stdout);
-   g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream_stdout), FALSE);
-   show_text_part_content (part, stream_stdout);
-   g_object_unref(stream_stdout);
-}
-else if (g_mime_content_type_is_type (content_type, "multipart", "*") ||
-g_mime_content_type_is_type (content_type, "message", "rfc822"))
-{
-   /* Do nothing for multipart since its content will be printed
-* when recursing. */
-}
-else
-{
-   printf ("Non-text part: %s\n",
-   

[PATCH v2 0/2] Rewrite text show format

2012-02-04 Thread Austin Clements
v2

* Remove unnecessary braces (id:87lioooj7m.fsf at gmail.com)

* Trivial rebase against master



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

2012-02-04 Thread Austin Clements
Quoth Dmitry Kurochkin on Jan 31 at  3:26 am:
> 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.

I wouldn't want to support this without supporting it for all of the
string members of notmuch_show_format_t, which turns out to be a
fairly big change.  At the end of the show rewrite, all of these other
string members will go away, so I'll add support for just these being
NULL at that point.

> Looks good otherwise.
> 
> Regards,
>   Dmitry


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

2012-02-04 Thread David Bremner
On Tue, 31 Jan 2012 19:29:06 +0200, Jani Nikula  wrote:
> Modify the show view key bindings as follows to make them more
> consistent:

Last chance for objections...

d


For gmail how do you setup notmuch mail ?...

2012-02-04 Thread Jani Nikula
On Sat, 04 Feb 2012 09:15:16 +, David Edmondson  wrote:
> On Sat, 4 Feb 2012 03:39:23 -0500, don warner saklad  gmail.com> wrote:
> > a) For gmail how do you setup notmuch mail ?...
> > 
> > b) Any workarounds?
> > 
> > c) Any kludges?

I'll describe my own setup for using notmuch with gmail. I don't pretend
it will work for everyone, but you might find some bits of it useful.

I don't even try to sync notmuch tags and gmail labels (because I rarely
use the labels or the web interface anyway), but I do get sync for
"unread" and "flagged" (gmail and Android "starred"). You'll need
maildir.synchronize_flags = true in your ~/.notmuch-config for this.

> Many people around here do that using offlineimap, which will
> synchronise an IMAP server (Gmail in this instance) with various local
> directories in Maildir format.

I use offlineimap. I run it from the notmuch pre-new hook. This means I
have to run "notmuch new" to receive new mail.

$ cat ~/.maildir/.notmuch/hooks/pre-new
#!/bin/sh
exec /usr/bin/offlineimap

I only sync "All Mail" from gmail. Perhaps there would be some
optimizations that could be done, but I haven't bothered yet.

$ cat ~/.offlineimaprc
[general]
accounts = Gmail
ui = Noninteractive.Basic

[Account Gmail]
localrepository = Local
remoterepository = Remote

[Repository Local]
type = Maildir
localfolders = ~/.maildir

[Repository Remote]
type = IMAP
ssl = yes
remotehost = imap.gmail.com
remoteuser = USER at gmail.com
expunge = no
realdelete = no

folderfilter = lambda foldername: foldername in ['[Gmail]/All Mail']
nametrans = lambda foldername: re.sub('^\[Gmail\]/All Mail', 'gmail', 
foldername)

> Sending mail via Gmail can be done in various ways. You can set up your
> local MTA (Postfix, Exim, ...) to deliver mail via Gmail, or have Emacs
> do the same directly using the smtpmail.el package.

Personally I use msmtp (msmtp and msmtp-mta packages in Debian based
distros). The msmtp-mta sets up a sendmail-like binary that works out of
the box in Emacs. Beware that it doesn't have a local queue, it works
synchronously.

$ cat ~/.msmtprc
defaults
logfile ~/.msmtp.log
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account default
host smtp.gmail.com
from USER at gmail.com
tls on
tls_starttls off
auth on
user USER at gmail.com

Finally, I use goobook to use the gmail contacts as addressbook in
Emacs. See http://mid.gmane.org/87zkfuh3i0.fsf at nikula.org for that.


HTH,
Jani.


Bug: emacs 23.2 doesn't like ido-completing-read

2012-02-04 Thread Mark Walters
On Mon, 30 Jan 2012 10:21:38 +, Mark Walters  
wrote:
> On Mon, 30 Jan 2012 09:39:32 +, David Edmondson  wrote:
> > On Sun, 29 Jan 2012 23:17:55 +, Mark Walters  > gmail.com> wrote:
> > > I have been experimenting with notmuch-always-prompt-for-sender on my
> > > debian stable setup (emacs 23.2.1) and it doesn't like
> > > ido-completing-read. It goes to the minibuffer and then it seems to be
> > > impossible to exit the minibuffer.
> > > 
> > > I can find an emacs bug report #3274 and some discussion
> > > http://comments.gmane.org/gmane.emacs.bugs/27856 which indicates that it
> > > is a problem with ido initialisation. Unfortunately I can't get from 
> > > there to a
> > > solution (except upgrade emacs).
> > 
> > I'm not sure that notmuch-mua.el should be using `ido-completing-read',
> > and certainly not without `require'ing it.
> > 
> > Is there a particular thing required that `completing-read' doesn't do?
> 
> Thanks for the suggestion: I can confirm that with ido-completing-read
> replaced by completing-read it works nicely. The "ido" version shows the
> possibilities for you which is nice, but this works fine.

I hadn't realised before but this also goes wrong if you use the prefix
argument to mail (eg ctrl-u m). The current code seems to mess up the
mini-buffer and even closing the buffer does not get out of it.

Changing ido-completing-read read to completing-read seems to fix the
problem entirely. Since this will affect most debian stable users (*) I
think we should fix it. The trivial patch below works for me but other solutions
may be better as they could maintain the benefits of ido-completing-read
(eg that it shows the possibilities).

Best wishes

Mark

(*) Perhaps only those who have more than one email address.

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 023645e..41f82c2 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -191,7 +191,7 @@ the From: header is already filled in by notmuch."
 ;; Now prompt the user, either for an email address only or for a full 
identity.
 (if one-name-only
(let ((address
-  (ido-completing-read (concat "Sender address for " name ": ") 
addresses
+  (completing-read (concat "Sender address for " name ": ") 
addresses
nil nil nil 'notmuch-mua-sender-history 
(car addresses
  (concat name " <" address ">"))
   (ido-completing-read "Send mail From: " notmuch-identities
-- 
1.7.2.3



[PATCH v2 2/2] emacs: fix `notmuch-wash-region-to-button' to work at beginning of buffer

2012-02-04 Thread Dmitry Kurochkin
`Notmuch-wash-region-to-button' is the function that creates hidden
regions with buttons for signatures, citations and original messages.
Before the change, it did not work correctly if the to-be-hidden
region started at the beginning of a message: the visibility toggle
button was hidden as well.  The patch fixes this.  There are two parts
in the fix:

* Use `insert-before-markers' instead of `insert' for creating the
  button, so that it does not get added to the hidden overlay.

* Stop using PREFIX argument for adding a newline before the button.
  The newline should not be added before a button at the beginning of
  buffer.

The corresponding test is fixed now.
---
 emacs/notmuch-wash.el |   24 ++--
 test/emacs-show   |1 -
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 67143e5..56981d0 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -136,12 +136,13 @@ collapse the remaining lines into a button.")
 (lines-count (count-lines (overlay-start overlay) (overlay-end 
overlay
 (format label-format lines-count)))

-(defun notmuch-wash-region-to-button (msg beg end type prefix)
+(defun notmuch-wash-region-to-button (msg beg end type  prefix)
   "Auxiliary function to do the actual making of overlays and buttons

 BEG and END are buffer locations. TYPE should a string, either
-\"citation\" or \"signature\". PREFIX is some arbitrary text to
-insert before the button, probably for indentation."
+\"citation\" or \"signature\". Optional PREFIX is some arbitrary
+text to insert before the button, probably for indentation.  Note
+that PREFIX should not include a newline."

   ;; This uses some slightly tricky conversions between strings and
   ;; symbols because of the way the button code works. Note that
@@ -160,12 +161,15 @@ insert before the button, probably for indentation."
 (overlay-put overlay 'type type)
 (goto-char (1+ end))
 (save-excursion
-  (goto-char (1- beg))
-  (insert prefix)
-  (insert-button (notmuch-wash-button-label overlay)
+  (goto-char beg)
+  (if prefix
+ (insert-before-markers prefix))
+  (let ((button-beg (point)))
+   (insert-before-markers (notmuch-wash-button-label overlay) "\n")
+   (make-button button-beg (1- (point))
 'invisibility-spec invis-spec
 'overlay overlay
-:type button-type
+:type button-type)

 (defun notmuch-wash-excerpt-citations (msg depth)
   "Excerpt citations and up to one signature."
@@ -177,7 +181,7 @@ insert before the button, probably for indentation."
 (msg-end (point-max))
 (msg-lines (count-lines msg-start msg-end)))
(notmuch-wash-region-to-button
-msg msg-start msg-end "original" "\n")))
+msg msg-start msg-end "original")))
   (while (and (< (point) (point-max))
  (re-search-forward notmuch-wash-citation-regexp nil t))
 (let* ((cite-start (match-beginning 0))
@@ -194,7 +198,7 @@ insert before the button, probably for indentation."
  (forward-line (- notmuch-wash-citation-lines-suffix))
  (notmuch-wash-region-to-button
   msg hidden-start (point-marker)
-  "citation" "\n")
+  "citation")
   (if (and (not (eobp))
   (re-search-forward notmuch-wash-signature-regexp nil t))
   (let* ((sig-start (match-beginning 0))
@@ -208,7 +212,7 @@ insert before the button, probably for indentation."
  (overlay-put (make-overlay sig-start-marker sig-end-marker) 'face 
'message-cited-text)
  (notmuch-wash-region-to-button
   msg sig-start-marker sig-end-marker
-  "signature" "\n"))
+  "signature"))

 ;;

diff --git a/test/emacs-show b/test/emacs-show
index 9800575..5700d2e 100755
--- a/test/emacs-show
+++ b/test/emacs-show
@@ -4,7 +4,6 @@ test_description="Testing emacs notmuch-show view"
 . test-lib.sh

 test_begin_subtest "Hiding Original Message region at beginning of a message"
-test_subtest_known_broken
 message_id='OriginalMessageHiding.1 at notmuchmail.org'
 add_message \
 [id]="$message_id" \
-- 
1.7.9



[PATCH v2 1/2] test: add test for hiding Original Message region at beginning of a message

2012-02-04 Thread Dmitry Kurochkin
The test is currently broken and will be fixed by a subsequent patch.

The patch adds a new file for tests of Emacs notmuch-show view.

Based on patch by David Edmondson [1].

[1] id:"1327562380-12894-4-git-send-email-dme at dme.org"
---
 test/emacs-show   |   28 
 test/notmuch-test |1 +
 2 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100755 test/emacs-show

diff --git a/test/emacs-show b/test/emacs-show
new file mode 100755
index 000..9800575
--- /dev/null
+++ b/test/emacs-show
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+
+test_description="Testing emacs notmuch-show view"
+. test-lib.sh
+
+test_begin_subtest "Hiding Original Message region at beginning of a message"
+test_subtest_known_broken
+message_id='OriginalMessageHiding.1 at notmuchmail.org'
+add_message \
+[id]="$message_id" \
+'[subject]="Hiding Original Message region at beginning of a message"' \
+'[body]="-Original Message-
+Text here."'
+
+cat 

[PATCH v2 0/2] emacs: fix `notmuch-wash-region-to-button' to work at beginning of buffer

2012-02-04 Thread Dmitry Kurochkin
Changes since v1:

* rebase on the current master, just one trivial conflict so no need
  for another round of review

Regards,
  Dmitry



[PATCH 1/2] cli: convert "notmuch show" to use the new argument parser

2012-02-04 Thread Jani Nikula
On Sat, 04 Feb 2012 00:00:00 +, Mark Walters  
wrote:
> 
> On Sat,  4 Feb 2012 00:41:08 +0200, Jani Nikula  wrote:
> > Use the new notmuch argument parser to handle arguments in "notmuch
> > show". There are two corner case functional changes:
> > 
> > 1) Also set params.raw = 1 when defaulting to raw format when part is
> >requested but format is not specified.
> > 
> > 2) Do not set params.decrypt if crypto context creation fails.
> 
> This looks great. As far as I can see it is fine (I haven't run or even
> compiled it yet). I only have two query/nits below.
> 
> Best wishes
> 
> Mark
> 
> > Signed-off-by: Jani Nikula 
> > ---
> >  notmuch-show.c |  153 
> > +---
> >  1 files changed, 79 insertions(+), 74 deletions(-)
> > 
> > diff --git a/notmuch-show.c b/notmuch-show.c
> > index dec799c..f93e121 100644
> > --- a/notmuch-show.c
> > +++ b/notmuch-show.c
> > @@ -1049,6 +1049,14 @@ do_show (void *ctx,
> >  return 0;
> >  }
> >  
> > +enum {
> > +NOTMUCH_FORMAT_NOT_SPECIFIED,
> > +NOTMUCH_FORMAT_JSON,
> > +NOTMUCH_FORMAT_TEXT,
> > +NOTMUCH_FORMAT_MBOX,
> > +NOTMUCH_FORMAT_RAW
> > +};
> > +
> >  int
> >  notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
> >  {
> > @@ -1056,92 +1064,98 @@ notmuch_show_command (void *ctx, unused (int argc), 
> > unused (char *argv[]))
> >  notmuch_database_t *notmuch;
> >  notmuch_query_t *query;
> >  char *query_string;
> > -char *opt;
> > +int opt_index;
> >  const notmuch_show_format_t *format = _text;
> 
> I think you don't need the default value here. If you think it is
> clearer with the default then that is fine. I think I slightly prefer
> without since in some cases the default is raw but entirely up to you.

I actually dropped this at first, but the compiler has no way of knowing
that all the cases are covered in the switch, and thinks format may be
uninitialized. I was wondering whether to have a default case in the
switch (which would be just to make the compiler happy), but settled on
this instead.

> 
> > -notmuch_show_params_t params;
> > -int mbox = 0;
> > -int format_specified = 0;
> > -int i;
> > +notmuch_show_params_t params = { .part = -1 };
> 
> Does this initialize all the other params bits to zero/NULL?  

Yes. It's called a "designated initializer for aggregate type" if you
want to look it up.

Thanks for the review.


BR,
Jani.

> 
> 
> 
> 
> > +int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
> > +notmuch_bool_t decrypt = FALSE;
> > +notmuch_bool_t verify = FALSE;
> > +notmuch_bool_t entire_thread = FALSE;
> > +
> > +notmuch_opt_desc_t options[] = {
> > +   { NOTMUCH_OPT_KEYWORD, _sel, "format", 'f',
> > + (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
> > + { "text", NOTMUCH_FORMAT_TEXT },
> > + { "mbox", NOTMUCH_FORMAT_MBOX },
> > + { "raw", NOTMUCH_FORMAT_RAW },
> > + { 0, 0 } } },
> > +   { NOTMUCH_OPT_INT, , "part", 'p', 0 },
> > +   { NOTMUCH_OPT_BOOLEAN, _thread, "entire-thread", 't', 0 },
> > +   { NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 },
> > +   { NOTMUCH_OPT_BOOLEAN, , "verify", 'v', 0 },
> > +   { 0, 0, 0, 0, 0 }
> > +};
> > +
> > +opt_index = parse_arguments (argc, argv, options, 1);
> > +if (opt_index < 0) {
> > +   /* diagnostics already printed */
> > +   return 1;
> > +}
> >  
> > -params.entire_thread = 0;
> > -params.raw = 0;
> > -params.part = -1;
> > -params.cryptoctx = NULL;
> > -params.decrypt = 0;
> > +params.entire_thread = entire_thread;
> >  
> > -argc--; argv++; /* skip subcommand argument */
> > +if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
> > +   /* if part was requested and format was not specified, use format=raw */
> > +   if (params.part >= 0)
> > +   format_sel = NOTMUCH_FORMAT_RAW;
> > +   else
> > +   format_sel = NOTMUCH_FORMAT_TEXT;
> > +}
> >  
> > -for (i = 0; i < argc && argv[i][0] == '-'; i++) {
> > -   if (strcmp (argv[i], "--") == 0) {
> > -   i++;
> > -   break;
> > +switch (format_sel) {
> > +case NOTMUCH_FORMAT_JSON:
> > +   format = _json;
> > +   params.entire_thread = 1;
> > +   break;
> > +case NOTMUCH_FORMAT_TEXT:
> > +   format = _text;
> > +   break;
> > +case NOTMUCH_FORMAT_MBOX:
> > +   if (params.part > 0) {
> > +   fprintf (stderr, "Error: specifying parts is incompatible with mbox 
> > output format.\n");
> > +   return 1;
> > }
> > -   if (STRNCMP_LITERAL (argv[i], "--format=") == 0) {
> > -   opt = argv[i] + sizeof ("--format=") - 1;
> > -   if (strcmp (opt, "text") == 0) {
> > -   format = _text;
> > -   } else if (strcmp (opt, "json") == 0) {
> > -   format = _json;
> > -   params.entire_thread = 1;
> > -   } else if (strcmp (opt, "mbox") == 0) {
> > 

[PATCH 1/2] test: add check for filename argument for test_expect_equal_file

2012-02-04 Thread Tomi Ollila
On Fri, 03 Feb 2012 18:04:05 +0400, Dmitry Kurochkin  wrote:
> On Thu, 02 Feb 2012 10:00:59 -0800, Jameson Graef Rollins  finestructure.net> wrote:
> > Hey, Dmitry.  I'm so sorry I sent my last email on your original patch
> > before I saw this new series.  I do now like your original proposal
> > better, since it shows the diff based the names the caller provides,
> > which I now agree is probably the clearest and most robust solution.
> > The second patch in this series could still go through, though, no
> > matter what version of the change to test_expect_equal_file we go with.
> > 
> 
> Actually, we can do both: check file name for consistent diff order
> (from expected to actual) and use file names that the caller provides.
> 
> What do you think?

+1

> Regards,
>   Dmitry

Tomi


[PATCH 0/2] Bug and potential fix: forwarded messages

2012-02-04 Thread Dmitry Kurochkin
On Fri, 3 Feb 2012 23:01:23 -0700, Adam Wolfe Gordon  
wrote:
> Oh, and I just noticed that Dmitry has already fixed this, probably in
> a better way [1] (though I maintain that there still may be a problem
> with the approach in general).  I clearly haven't been following the
> list closely enough this week.
> 

Yep, creating buttons for regions at the beginning of message is fixed.
But I like the idea of not hiding the message if there is no text.
Though, I think we should create the button, just not hide the text
initially.

This change would conflict with my fix, so we should probably wait until
it is applied before working on this.

Regards,
  Dmitry

> [1] id:"1327926286-16680-1-git-send-email-dmitry.kurochkin at gmail.com"
> 
> On Fri, Feb 3, 2012 at 17:32, Adam Wolfe Gordon  wrote:
> > Hi everyone,
> >
> > I encountered today a bug that I remember being mentioned on IRC where
> > some messages are shown in emacs as completely empty, even though their
> > content is present and simple. For me, the bug shows up with messages that
> > have been forwarded by an Outlook user who didn't add any content to the top
> > of the message. The first line of the message is "-Original 
> > Message-",
> > and the rest is the forwarded text. Notmuch tries to collapse the forwarded
> > content into a button, but fails mysteriously.
> >
> > The first patch in this series adds a test (marked as broken) that 
> > demonstrates
> > the bug. I think this should be pushed regardless of whether my solution is
> > the right one. My solution is to check whether we're collapsing the entire
> > message before doing so, and avoid turning it into a button if that's the 
> > case.
> > I think this is a desirable behavior, since if someone has forwarded a 
> > message
> > without adding anything the user probably wants to read that message. But,
> > I'll admit that I didn't figure out the real cause of the problem, and I
> > would be happy to hear other suggestions.
> >
> > It also occurs to me that this might indicate a bigger problem with how
> > notmuch-wash.el handles messages starting with "-Original Message-".
> > Notmuch seems to assume that this indicates the rest of the message is 
> > quoted
> > stuff that's been top-posted on. In my office this isn't necessarily the 
> > case,
> > since Outlook produces that line at the top of every reply, and it's up to
> > the user whether to top-post or not (and not everyone does).
> >
> > I'll have to experiment a bit more to verify whether a problem (i.e. whether
> > Notmuch hides inappropriate things when someone replies inline with 
> > Outlook).
> > Someone please correct me if I'm missing something in how the code operates.
> >
> > Adam Wolfe Gordon (2):
> > ?test: Add broken test for showing forwarded messages
> > ?emacs: Fix broken showing of forwarded messages.
> >
> > ?emacs/notmuch-wash.el | ? ?5 +++--
> > ?test/emacs ? ? ? ? ? ?| ? 32 
> > ?2 files changed, 35 insertions(+), 2 deletions(-)
> >
> > --
> > 1.7.5.4
> >
> ___
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 0/2] Bug and potential fix: forwarded messages

2012-02-04 Thread Adam Wolfe Gordon
On Fri, Feb 3, 2012 at 23:10, Dmitry Kurochkin
 wrote:
> Yep, creating buttons for regions at the beginning of message is fixed.
> But I like the idea of not hiding the message if there is no text.
> Though, I think we should create the button, just not hide the text
> initially.
>
> This change would conflict with my fix, so we should probably wait until
> it is applied before working on this.

Yes, this sounds like a good idea.  I'll wait until your fix is in
before giving it more thought.


For gmail how do you setup notmuch mail ?...

2012-02-04 Thread David Edmondson
On Sat, 4 Feb 2012 03:39:23 -0500, don warner saklad  
wrote:
> a) For gmail how do you setup notmuch mail ?...
> 
> b) Any workarounds?
> 
> c) Any kludges?

notmuch wants to be able to access your mail as individual files in the
filesystem. That means you need a way to get the mail from Gmail onto
your local system.

Many people around here do that using offlineimap, which will
synchronise an IMAP server (Gmail in this instance) with various local
directories in Maildir format.

You can also use fetchmail or getmail or ... to achieve similar end
results, but I think that offlineimap is more common and therefore
you're more likely to get help.

You could, of course, have Gmail forward your mail to some place that
you can run an SMTP server and notmuch.

Sending mail via Gmail can be done in various ways. You can set up your
local MTA (Postfix, Exim, ...) to deliver mail via Gmail, or have Emacs
do the same directly using the smtpmail.el package.
-- 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/20120204/824281e6/attachment.pgp>


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

2012-02-04 Thread David Bremner
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.

pushed.

d


[PATCH] emacs: More address cleaning.

2012-02-04 Thread David Bremner
On Mon, 30 Jan 2012 14:59:54 +, David Edmondson  wrote:
> Remove outer single-quotes from the mailbox part. Allow for multiple
> sets of nested single and double quotes.

pushed, 

d


[PATCH 0/2 v2] minor cleanup and improvements

2012-02-04 Thread David Bremner
On Mon, 30 Jan 2012 10:15:59 +, David Edmondson  wrote:
> Address the comments from Mark and Austin:
>  - Don't assume that `subject' is a string,
>  - Show [No Subject] in search output

pushed, 

d


[PATCH 3/3] lib: Use talloc to simplify cleanup in notmuch_database_open

2012-02-04 Thread David Bremner
On Sun, 29 Jan 2012 00:50:10 -0500, Austin Clements  wrote:
> Previously, we manually "free"d various pointers in
> notmuch_database_open.  Use a local talloc context instead to simplify
> cleanup and eliminate various NULL pointer initializations and
> conditionals.

pushed all 3.

d


[PATCH] tag: remove unused attribute from notmuch_tag_command() arguments

2012-02-04 Thread David Bremner
On Sat, 28 Jan 2012 12:02:33 +0400, Dmitry Kurochkin  wrote:
> Argc and argv arguments are used in notmuch_tag_command() function.
> So unused attribute is not appropriate for them.

pushed, 

d


[PATCH] test: remove ".sh" extension from the recently added Emacs tests

2012-02-04 Thread David Bremner
On Sat, 28 Jan 2012 08:47:39 +0400, Dmitry Kurochkin  wrote:
> All test files, except for the recently added Emacs tests, do not have
> ".sh" extension.  So remove it from the new test files for consistency.

pushed

d


[PATCH] configure: update explicit check for glib : >= 2.22

2012-02-04 Thread David Bremner
On Fri,  3 Feb 2012 13:12:25 +0100, Pieter Praet  wrote:
> As of commit b3caef1f, we're using g_array_unref() in 'lib/query.cc',
> which was only introduced in glib 2.22, so update the dependency.

pushed

d


[PATCH v2 0/2] emacs: fix `notmuch-wash-region-to-button' to work at beginning of buffer

2012-02-04 Thread David Bremner
On Sat,  4 Feb 2012 11:36:35 +0400, Dmitry Kurochkin  wrote:
> Changes since v1:
> 
> * rebase on the current master, just one trivial conflict so no need
>   for another round of review
> 

pushed,

d


For gmail how do you setup notmuch mail ?...

2012-02-04 Thread don warner saklad
a) For gmail how do you setup notmuch mail ?...

b) Any workarounds?

c) Any kludges?


[PATCH 2/2] cli: reach previously unreachable cleanup code in "notmuch show"

2012-02-04 Thread Jani Nikula
The last lines of notmuch_show_command() function were
unreachable. Fix it by using a variable for return value.

Signed-off-by: Jani Nikula 
---
 notmuch-show.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index f93e121..b18e279 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1064,7 +1064,7 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
 notmuch_database_t *notmuch;
 notmuch_query_t *query;
 char *query_string;
-int opt_index;
+int opt_index, ret;
 const notmuch_show_format_t *format = _text;
 notmuch_show_params_t params = { .part = -1 };
 int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
@@ -1173,9 +1173,9 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
 }

 if (params.part >= 0)
-   return do_show_single (ctx, query, format, );
+   ret = do_show_single (ctx, query, format, );
 else
-   return do_show (ctx, query, format, );
+   ret = do_show (ctx, query, format, );

 notmuch_query_destroy (query);
 notmuch_database_close (notmuch);
@@ -1183,5 +1183,5 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
 if (params.cryptoctx)
g_object_unref(params.cryptoctx);

-return 0;
+return ret;
 }
-- 
1.7.5.4



[PATCH 1/2] cli: convert "notmuch show" to use the new argument parser

2012-02-04 Thread Jani Nikula
Use the new notmuch argument parser to handle arguments in "notmuch
show". There are two corner case functional changes:

1) Also set params.raw = 1 when defaulting to raw format when part is
   requested but format is not specified.

2) Do not set params.decrypt if crypto context creation fails.

Signed-off-by: Jani Nikula 
---
 notmuch-show.c |  153 +---
 1 files changed, 79 insertions(+), 74 deletions(-)

diff --git a/notmuch-show.c b/notmuch-show.c
index dec799c..f93e121 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -1049,6 +1049,14 @@ do_show (void *ctx,
 return 0;
 }

+enum {
+NOTMUCH_FORMAT_NOT_SPECIFIED,
+NOTMUCH_FORMAT_JSON,
+NOTMUCH_FORMAT_TEXT,
+NOTMUCH_FORMAT_MBOX,
+NOTMUCH_FORMAT_RAW
+};
+
 int
 notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
 {
@@ -1056,92 +1064,98 @@ notmuch_show_command (void *ctx, unused (int argc), 
unused (char *argv[]))
 notmuch_database_t *notmuch;
 notmuch_query_t *query;
 char *query_string;
-char *opt;
+int opt_index;
 const notmuch_show_format_t *format = _text;
-notmuch_show_params_t params;
-int mbox = 0;
-int format_specified = 0;
-int i;
+notmuch_show_params_t params = { .part = -1 };
+int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
+notmuch_bool_t decrypt = FALSE;
+notmuch_bool_t verify = FALSE;
+notmuch_bool_t entire_thread = FALSE;
+
+notmuch_opt_desc_t options[] = {
+   { NOTMUCH_OPT_KEYWORD, _sel, "format", 'f',
+ (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
+ { "text", NOTMUCH_FORMAT_TEXT },
+ { "mbox", NOTMUCH_FORMAT_MBOX },
+ { "raw", NOTMUCH_FORMAT_RAW },
+ { 0, 0 } } },
+   { NOTMUCH_OPT_INT, , "part", 'p', 0 },
+   { NOTMUCH_OPT_BOOLEAN, _thread, "entire-thread", 't', 0 },
+   { NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 },
+   { NOTMUCH_OPT_BOOLEAN, , "verify", 'v', 0 },
+   { 0, 0, 0, 0, 0 }
+};
+
+opt_index = parse_arguments (argc, argv, options, 1);
+if (opt_index < 0) {
+   /* diagnostics already printed */
+   return 1;
+}

-params.entire_thread = 0;
-params.raw = 0;
-params.part = -1;
-params.cryptoctx = NULL;
-params.decrypt = 0;
+params.entire_thread = entire_thread;

-argc--; argv++; /* skip subcommand argument */
+if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
+   /* if part was requested and format was not specified, use format=raw */
+   if (params.part >= 0)
+   format_sel = NOTMUCH_FORMAT_RAW;
+   else
+   format_sel = NOTMUCH_FORMAT_TEXT;
+}

-for (i = 0; i < argc && argv[i][0] == '-'; i++) {
-   if (strcmp (argv[i], "--") == 0) {
-   i++;
-   break;
+switch (format_sel) {
+case NOTMUCH_FORMAT_JSON:
+   format = _json;
+   params.entire_thread = 1;
+   break;
+case NOTMUCH_FORMAT_TEXT:
+   format = _text;
+   break;
+case NOTMUCH_FORMAT_MBOX:
+   if (params.part > 0) {
+   fprintf (stderr, "Error: specifying parts is incompatible with mbox 
output format.\n");
+   return 1;
}
-   if (STRNCMP_LITERAL (argv[i], "--format=") == 0) {
-   opt = argv[i] + sizeof ("--format=") - 1;
-   if (strcmp (opt, "text") == 0) {
-   format = _text;
-   } else if (strcmp (opt, "json") == 0) {
-   format = _json;
-   params.entire_thread = 1;
-   } else if (strcmp (opt, "mbox") == 0) {
-   format = _mbox;
-   mbox = 1;
-   } else if (strcmp (opt, "raw") == 0) {
-   format = _raw;
-   params.raw = 1;
-   } else {
-   fprintf (stderr, "Invalid value for --format: %s\n", opt);
-   return 1;
-   }
-   format_specified = 1;
-   } else if (STRNCMP_LITERAL (argv[i], "--part=") == 0) {
-   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], "--verify") == 0) ||
-  (STRNCMP_LITERAL (argv[i], "--decrypt") == 0)) {
-   if (params.cryptoctx == NULL) {
+   format = _mbox;
+   break;
+case NOTMUCH_FORMAT_RAW:
+   format = _raw;
+   /* If --format=raw specified without specifying part, we can only
+* output single message, so set part=0 */
+   if (params.part < 0)
+   params.part = 0;
+   params.raw = 1;
+   break;
+}
+
+if (decrypt || verify) {
 #ifdef GMIME_ATLEAST_26
-   /* TODO: GMimePasswordRequestFunc */
-   if (NULL == (params.cryptoctx = g_mime_gpg_context_new(NULL, 
"gpg")))
+   /* TODO: 

notmuch release 0.11.1 now available

2012-02-04 Thread David Bremner

Where to obtain notmuch 0.11.1
===
  http://notmuchmail.org/releases/notmuch-0.11.1.tar.gz

Which can be verified with:

  http://notmuchmail.org/releases/notmuch-0.11.1.tar.gz.sha1
  05694ae8762076bf91d63b199e72a12e5ce012b0  notmuch-0.11.1.tar.gz

  http://notmuchmail.org/releases/notmuch-0.11.1.tar.gz.sha1.asc
  (signed by David Bremner)

What's new in notmuch 0.11.1
=

Bug-fix release.


Fix error handling in python bindings.

  The python bindings in 0.11 failed to detect NULL pointers being
  returned from libnotmuch functions and thus failed to raise
  exceptions to indicate the error condition. Any subsequent calls
  into libnotmuch caused segmentation faults.

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.

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


[PATCH 1/2] cli: convert "notmuch show" to use the new argument parser

2012-02-04 Thread Mark Walters

On Sat,  4 Feb 2012 00:41:08 +0200, Jani Nikula  wrote:
> Use the new notmuch argument parser to handle arguments in "notmuch
> show". There are two corner case functional changes:
> 
> 1) Also set params.raw = 1 when defaulting to raw format when part is
>requested but format is not specified.
> 
> 2) Do not set params.decrypt if crypto context creation fails.

This looks great. As far as I can see it is fine (I haven't run or even
compiled it yet). I only have two query/nits below.

Best wishes

Mark

> Signed-off-by: Jani Nikula 
> ---
>  notmuch-show.c |  153 
> +---
>  1 files changed, 79 insertions(+), 74 deletions(-)
> 
> diff --git a/notmuch-show.c b/notmuch-show.c
> index dec799c..f93e121 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -1049,6 +1049,14 @@ do_show (void *ctx,
>  return 0;
>  }
>  
> +enum {
> +NOTMUCH_FORMAT_NOT_SPECIFIED,
> +NOTMUCH_FORMAT_JSON,
> +NOTMUCH_FORMAT_TEXT,
> +NOTMUCH_FORMAT_MBOX,
> +NOTMUCH_FORMAT_RAW
> +};
> +
>  int
>  notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
>  {
> @@ -1056,92 +1064,98 @@ notmuch_show_command (void *ctx, unused (int argc), 
> unused (char *argv[]))
>  notmuch_database_t *notmuch;
>  notmuch_query_t *query;
>  char *query_string;
> -char *opt;
> +int opt_index;
>  const notmuch_show_format_t *format = _text;

I think you don't need the default value here. If you think it is
clearer with the default then that is fine. I think I slightly prefer
without since in some cases the default is raw but entirely up to you.

> -notmuch_show_params_t params;
> -int mbox = 0;
> -int format_specified = 0;
> -int i;
> +notmuch_show_params_t params = { .part = -1 };

Does this initialize all the other params bits to zero/NULL?  




> +int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
> +notmuch_bool_t decrypt = FALSE;
> +notmuch_bool_t verify = FALSE;
> +notmuch_bool_t entire_thread = FALSE;
> +
> +notmuch_opt_desc_t options[] = {
> + { NOTMUCH_OPT_KEYWORD, _sel, "format", 'f',
> +   (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON },
> +   { "text", NOTMUCH_FORMAT_TEXT },
> +   { "mbox", NOTMUCH_FORMAT_MBOX },
> +   { "raw", NOTMUCH_FORMAT_RAW },
> +   { 0, 0 } } },
> + { NOTMUCH_OPT_INT, , "part", 'p', 0 },
> + { NOTMUCH_OPT_BOOLEAN, _thread, "entire-thread", 't', 0 },
> + { NOTMUCH_OPT_BOOLEAN, , "decrypt", 'd', 0 },
> + { NOTMUCH_OPT_BOOLEAN, , "verify", 'v', 0 },
> + { 0, 0, 0, 0, 0 }
> +};
> +
> +opt_index = parse_arguments (argc, argv, options, 1);
> +if (opt_index < 0) {
> + /* diagnostics already printed */
> + return 1;
> +}
>  
> -params.entire_thread = 0;
> -params.raw = 0;
> -params.part = -1;
> -params.cryptoctx = NULL;
> -params.decrypt = 0;
> +params.entire_thread = entire_thread;
>  
> -argc--; argv++; /* skip subcommand argument */
> +if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
> + /* if part was requested and format was not specified, use format=raw */
> + if (params.part >= 0)
> + format_sel = NOTMUCH_FORMAT_RAW;
> + else
> + format_sel = NOTMUCH_FORMAT_TEXT;
> +}
>  
> -for (i = 0; i < argc && argv[i][0] == '-'; i++) {
> - if (strcmp (argv[i], "--") == 0) {
> - i++;
> - break;
> +switch (format_sel) {
> +case NOTMUCH_FORMAT_JSON:
> + format = _json;
> + params.entire_thread = 1;
> + break;
> +case NOTMUCH_FORMAT_TEXT:
> + format = _text;
> + break;
> +case NOTMUCH_FORMAT_MBOX:
> + if (params.part > 0) {
> + fprintf (stderr, "Error: specifying parts is incompatible with mbox 
> output format.\n");
> + return 1;
>   }
> - if (STRNCMP_LITERAL (argv[i], "--format=") == 0) {
> - opt = argv[i] + sizeof ("--format=") - 1;
> - if (strcmp (opt, "text") == 0) {
> - format = _text;
> - } else if (strcmp (opt, "json") == 0) {
> - format = _json;
> - params.entire_thread = 1;
> - } else if (strcmp (opt, "mbox") == 0) {
> - format = _mbox;
> - mbox = 1;
> - } else if (strcmp (opt, "raw") == 0) {
> - format = _raw;
> - params.raw = 1;
> - } else {
> - fprintf (stderr, "Invalid value for --format: %s\n", opt);
> - return 1;
> - }
> - format_specified = 1;
> - } else if (STRNCMP_LITERAL (argv[i], "--part=") == 0) {
> - 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], "--verify") == 0) ||
> -

For gmail how do you setup notmuch mail ?...

2012-02-04 Thread don warner saklad
a) For gmail how do you setup notmuch mail ?...

b) Any workarounds?

c) Any kludges?
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/2] cli: convert notmuch show to use the new argument parser

2012-02-04 Thread Jani Nikula
On Sat, 04 Feb 2012 00:00:00 +, Mark Walters markwalters1...@gmail.com 
wrote:
 
 On Sat,  4 Feb 2012 00:41:08 +0200, Jani Nikula j...@nikula.org wrote:
  Use the new notmuch argument parser to handle arguments in notmuch
  show. There are two corner case functional changes:
  
  1) Also set params.raw = 1 when defaulting to raw format when part is
 requested but format is not specified.
  
  2) Do not set params.decrypt if crypto context creation fails.
 
 This looks great. As far as I can see it is fine (I haven't run or even
 compiled it yet). I only have two query/nits below.
 
 Best wishes
 
 Mark
 
  Signed-off-by: Jani Nikula j...@nikula.org
  ---
   notmuch-show.c |  153 
  +---
   1 files changed, 79 insertions(+), 74 deletions(-)
  
  diff --git a/notmuch-show.c b/notmuch-show.c
  index dec799c..f93e121 100644
  --- a/notmuch-show.c
  +++ b/notmuch-show.c
  @@ -1049,6 +1049,14 @@ do_show (void *ctx,
   return 0;
   }
   
  +enum {
  +NOTMUCH_FORMAT_NOT_SPECIFIED,
  +NOTMUCH_FORMAT_JSON,
  +NOTMUCH_FORMAT_TEXT,
  +NOTMUCH_FORMAT_MBOX,
  +NOTMUCH_FORMAT_RAW
  +};
  +
   int
   notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
   {
  @@ -1056,92 +1064,98 @@ notmuch_show_command (void *ctx, unused (int argc), 
  unused (char *argv[]))
   notmuch_database_t *notmuch;
   notmuch_query_t *query;
   char *query_string;
  -char *opt;
  +int opt_index;
   const notmuch_show_format_t *format = format_text;
 
 I think you don't need the default value here. If you think it is
 clearer with the default then that is fine. I think I slightly prefer
 without since in some cases the default is raw but entirely up to you.

I actually dropped this at first, but the compiler has no way of knowing
that all the cases are covered in the switch, and thinks format may be
uninitialized. I was wondering whether to have a default case in the
switch (which would be just to make the compiler happy), but settled on
this instead.

 
  -notmuch_show_params_t params;
  -int mbox = 0;
  -int format_specified = 0;
  -int i;
  +notmuch_show_params_t params = { .part = -1 };
 
 Does this initialize all the other params bits to zero/NULL?  

Yes. It's called a designated initializer for aggregate type if you
want to look it up.

Thanks for the review.


BR,
Jani.

 
 
 
 
  +int format_sel = NOTMUCH_FORMAT_NOT_SPECIFIED;
  +notmuch_bool_t decrypt = FALSE;
  +notmuch_bool_t verify = FALSE;
  +notmuch_bool_t entire_thread = FALSE;
  +
  +notmuch_opt_desc_t options[] = {
  +   { NOTMUCH_OPT_KEYWORD, format_sel, format, 'f',
  + (notmuch_keyword_t []){ { json, NOTMUCH_FORMAT_JSON },
  + { text, NOTMUCH_FORMAT_TEXT },
  + { mbox, NOTMUCH_FORMAT_MBOX },
  + { raw, NOTMUCH_FORMAT_RAW },
  + { 0, 0 } } },
  +   { NOTMUCH_OPT_INT, params.part, part, 'p', 0 },
  +   { NOTMUCH_OPT_BOOLEAN, entire_thread, entire-thread, 't', 0 },
  +   { NOTMUCH_OPT_BOOLEAN, decrypt, decrypt, 'd', 0 },
  +   { NOTMUCH_OPT_BOOLEAN, verify, verify, 'v', 0 },
  +   { 0, 0, 0, 0, 0 }
  +};
  +
  +opt_index = parse_arguments (argc, argv, options, 1);
  +if (opt_index  0) {
  +   /* diagnostics already printed */
  +   return 1;
  +}
   
  -params.entire_thread = 0;
  -params.raw = 0;
  -params.part = -1;
  -params.cryptoctx = NULL;
  -params.decrypt = 0;
  +params.entire_thread = entire_thread;
   
  -argc--; argv++; /* skip subcommand argument */
  +if (format_sel == NOTMUCH_FORMAT_NOT_SPECIFIED) {
  +   /* if part was requested and format was not specified, use format=raw */
  +   if (params.part = 0)
  +   format_sel = NOTMUCH_FORMAT_RAW;
  +   else
  +   format_sel = NOTMUCH_FORMAT_TEXT;
  +}
   
  -for (i = 0; i  argc  argv[i][0] == '-'; i++) {
  -   if (strcmp (argv[i], --) == 0) {
  -   i++;
  -   break;
  +switch (format_sel) {
  +case NOTMUCH_FORMAT_JSON:
  +   format = format_json;
  +   params.entire_thread = 1;
  +   break;
  +case NOTMUCH_FORMAT_TEXT:
  +   format = format_text;
  +   break;
  +case NOTMUCH_FORMAT_MBOX:
  +   if (params.part  0) {
  +   fprintf (stderr, Error: specifying parts is incompatible with mbox 
  output format.\n);
  +   return 1;
  }
  -   if (STRNCMP_LITERAL (argv[i], --format=) == 0) {
  -   opt = argv[i] + sizeof (--format=) - 1;
  -   if (strcmp (opt, text) == 0) {
  -   format = format_text;
  -   } else if (strcmp (opt, json) == 0) {
  -   format = format_json;
  -   params.entire_thread = 1;
  -   } else if (strcmp (opt, mbox) == 0) {
  -   format = format_mbox;
  -   mbox = 1;
  -   } else if (strcmp (opt, raw) == 0) {
  -   format = format_raw;
  -   params.raw = 

Re: For gmail how do you setup notmuch mail ?...

2012-02-04 Thread David Edmondson
On Sat, 4 Feb 2012 03:39:23 -0500, don warner saklad don.sak...@gmail.com 
wrote:
 a) For gmail how do you setup notmuch mail ?...
 
 b) Any workarounds?
 
 c) Any kludges?

notmuch wants to be able to access your mail as individual files in the
filesystem. That means you need a way to get the mail from Gmail onto
your local system.

Many people around here do that using offlineimap, which will
synchronise an IMAP server (Gmail in this instance) with various local
directories in Maildir format.

You can also use fetchmail or getmail or ... to achieve similar end
results, but I think that offlineimap is more common and therefore
you're more likely to get help.

You could, of course, have Gmail forward your mail to some place that
you can run an SMTP server and notmuch.

Sending mail via Gmail can be done in various ways. You can set up your
local MTA (Postfix, Exim, ...) to deliver mail via Gmail, or have Emacs
do the same directly using the smtpmail.el package.


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


Re: Bug: emacs 23.2 doesn't like ido-completing-read

2012-02-04 Thread Mark Walters
On Mon, 30 Jan 2012 10:21:38 +, Mark Walters markwalters1...@gmail.com 
wrote:
 On Mon, 30 Jan 2012 09:39:32 +, David Edmondson d...@dme.org wrote:
  On Sun, 29 Jan 2012 23:17:55 +, Mark Walters 
  markwalters1...@gmail.com wrote:
   I have been experimenting with notmuch-always-prompt-for-sender on my
   debian stable setup (emacs 23.2.1) and it doesn't like
   ido-completing-read. It goes to the minibuffer and then it seems to be
   impossible to exit the minibuffer.
   
   I can find an emacs bug report #3274 and some discussion
   http://comments.gmane.org/gmane.emacs.bugs/27856 which indicates that it
   is a problem with ido initialisation. Unfortunately I can't get from 
   there to a
   solution (except upgrade emacs).
  
  I'm not sure that notmuch-mua.el should be using `ido-completing-read',
  and certainly not without `require'ing it.
  
  Is there a particular thing required that `completing-read' doesn't do?
 
 Thanks for the suggestion: I can confirm that with ido-completing-read
 replaced by completing-read it works nicely. The ido version shows the
 possibilities for you which is nice, but this works fine.

I hadn't realised before but this also goes wrong if you use the prefix
argument to mail (eg ctrl-u m). The current code seems to mess up the
mini-buffer and even closing the buffer does not get out of it.

Changing ido-completing-read read to completing-read seems to fix the
problem entirely. Since this will affect most debian stable users (*) I
think we should fix it. The trivial patch below works for me but other solutions
may be better as they could maintain the benefits of ido-completing-read
(eg that it shows the possibilities).

Best wishes

Mark

(*) Perhaps only those who have more than one email address.

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 023645e..41f82c2 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -191,7 +191,7 @@ the From: header is already filled in by notmuch.
 ;; Now prompt the user, either for an email address only or for a full 
identity.
 (if one-name-only
(let ((address
-  (ido-completing-read (concat Sender address for  name : ) 
addresses
+  (completing-read (concat Sender address for  name : ) 
addresses
nil nil nil 'notmuch-mua-sender-history 
(car addresses
  (concat name   address ))
   (ido-completing-read Send mail From:  notmuch-identities
-- 
1.7.2.3

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


Re: For gmail how do you setup notmuch mail ?...

2012-02-04 Thread Jani Nikula
On Sat, 04 Feb 2012 09:15:16 +, David Edmondson d...@dme.org wrote:
 On Sat, 4 Feb 2012 03:39:23 -0500, don warner saklad don.sak...@gmail.com 
 wrote:
  a) For gmail how do you setup notmuch mail ?...
  
  b) Any workarounds?
  
  c) Any kludges?

I'll describe my own setup for using notmuch with gmail. I don't pretend
it will work for everyone, but you might find some bits of it useful.

I don't even try to sync notmuch tags and gmail labels (because I rarely
use the labels or the web interface anyway), but I do get sync for
unread and flagged (gmail and Android starred). You'll need
maildir.synchronize_flags = true in your ~/.notmuch-config for this.

 Many people around here do that using offlineimap, which will
 synchronise an IMAP server (Gmail in this instance) with various local
 directories in Maildir format.

I use offlineimap. I run it from the notmuch pre-new hook. This means I
have to run notmuch new to receive new mail.

$ cat ~/.maildir/.notmuch/hooks/pre-new
#!/bin/sh
exec /usr/bin/offlineimap

I only sync All Mail from gmail. Perhaps there would be some
optimizations that could be done, but I haven't bothered yet.

$ cat ~/.offlineimaprc
[general]
accounts = Gmail
ui = Noninteractive.Basic

[Account Gmail]
localrepository = Local
remoterepository = Remote

[Repository Local]
type = Maildir
localfolders = ~/.maildir

[Repository Remote]
type = IMAP
ssl = yes
remotehost = imap.gmail.com
remoteuser = u...@gmail.com
expunge = no
realdelete = no

folderfilter = lambda foldername: foldername in ['[Gmail]/All Mail']
nametrans = lambda foldername: re.sub('^\[Gmail\]/All Mail', 'gmail', 
foldername)

 Sending mail via Gmail can be done in various ways. You can set up your
 local MTA (Postfix, Exim, ...) to deliver mail via Gmail, or have Emacs
 do the same directly using the smtpmail.el package.

Personally I use msmtp (msmtp and msmtp-mta packages in Debian based
distros). The msmtp-mta sets up a sendmail-like binary that works out of
the box in Emacs. Beware that it doesn't have a local queue, it works
synchronously.

$ cat ~/.msmtprc
defaults
logfile ~/.msmtp.log
tls_trust_file /etc/ssl/certs/ca-certificates.crt

account default
host smtp.gmail.com
from u...@gmail.com
tls on
tls_starttls off
auth on
user u...@gmail.com

Finally, I use goobook to use the gmail contacts as addressbook in
Emacs. See http://mid.gmane.org/87zkfuh3i0@nikula.org for that.


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


Re: [PATCH v2 0/2] emacs: fix `notmuch-wash-region-to-button' to work at beginning of buffer

2012-02-04 Thread David Bremner
On Sat,  4 Feb 2012 11:36:35 +0400, Dmitry Kurochkin 
dmitry.kuroch...@gmail.com wrote:
 Changes since v1:
 
 * rebase on the current master, just one trivial conflict so no need
   for another round of review
 

pushed,

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


Re: [PATCH] test: remove .sh extension from the recently added Emacs tests

2012-02-04 Thread David Bremner
On Sat, 28 Jan 2012 08:47:39 +0400, Dmitry Kurochkin 
dmitry.kuroch...@gmail.com wrote:
 All test files, except for the recently added Emacs tests, do not have
 .sh extension.  So remove it from the new test files for consistency.

pushed

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


Re: [PATCH] tag: remove unused attribute from notmuch_tag_command() arguments

2012-02-04 Thread David Bremner
On Sat, 28 Jan 2012 12:02:33 +0400, Dmitry Kurochkin 
dmitry.kuroch...@gmail.com wrote:
 Argc and argv arguments are used in notmuch_tag_command() function.
 So unused attribute is not appropriate for them.

pushed, 

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


Re: [PATCH 3/3] lib: Use talloc to simplify cleanup in notmuch_database_open

2012-02-04 Thread David Bremner
On Sun, 29 Jan 2012 00:50:10 -0500, Austin Clements amdra...@mit.edu wrote:
 Previously, we manually freed various pointers in
 notmuch_database_open.  Use a local talloc context instead to simplify
 cleanup and eliminate various NULL pointer initializations and
 conditionals.

pushed all 3.

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


Re: [PATCH 0/2 v2] minor cleanup and improvements

2012-02-04 Thread David Bremner
On Mon, 30 Jan 2012 10:15:59 +, David Edmondson d...@dme.org wrote:
 Address the comments from Mark and Austin:
  - Don't assume that `subject' is a string,
  - Show [No Subject] in search output

pushed, 

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


Re: [PATCH] emacs: More address cleaning.

2012-02-04 Thread David Bremner
On Mon, 30 Jan 2012 14:59:54 +, David Edmondson d...@dme.org wrote:
 Remove outer single-quotes from the mailbox part. Allow for multiple
 sets of nested single and double quotes.

pushed, 

d
___
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-02-04 Thread David Bremner
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.

pushed.

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


Re: [PATCH 0/2] Bug and potential fix: forwarded messages

2012-02-04 Thread Adam Wolfe Gordon
On Fri, Feb 3, 2012 at 23:10, Dmitry Kurochkin
dmitry.kuroch...@gmail.com wrote:
 Yep, creating buttons for regions at the beginning of message is fixed.
 But I like the idea of not hiding the message if there is no text.
 Though, I think we should create the button, just not hide the text
 initially.

 This change would conflict with my fix, so we should probably wait until
 it is applied before working on this.

Yes, this sounds like a good idea.  I'll wait until your fix is in
before giving it more thought.
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 1/2] cli: add --from option to reply to restrict guessing of the From: header.

2012-02-04 Thread Mark Walters
Add an option --from= to notmuch-reply.c to restrict guessing of the
From: header. The existing logic looks as the main headers, then at
the delivery headers, and finally defaults to the config file address.

This patch allows the user to restrict which of these guesses are
made.  Currently the supported values are:
   default|fallback-allcurrent behaviour
   fallback-received   fallback to delivery headers but not config file
   fallback-none   only look at from/reply-to/to/cc/ headers
   noneFrom: header is always left empty

If the code does not find an allowed address it outputs an empty From:
line and the caller can decide how to respond.
---
 notmuch-reply.c |   39 ++-
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index f55b1d2..f660749 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -24,6 +24,13 @@
 #include gmime-filter-reply.h
 #include gmime-filter-headers.h
 
+enum {
+FROM_FALLBACK_ALL,
+FROM_FALLBACK_RECEIVED,
+FROM_FALLBACK_NONE,
+FROM_NONE
+};
+
 static void
 reply_headers_message_part (GMimeMessage *message);
 
@@ -510,7 +517,8 @@ notmuch_reply_format_default(void *ctx,
 notmuch_config_t *config,
 notmuch_query_t *query,
 notmuch_show_params_t *params,
-notmuch_bool_t reply_all)
+notmuch_bool_t reply_all,
+int from_guess)
 {
 GMimeMessage *reply;
 notmuch_messages_t *messages;
@@ -542,15 +550,19 @@ notmuch_reply_format_default(void *ctx,
from_addr = add_recipients_from_message (reply, config, message,
 reply_all);
 
-   if (from_addr == NULL)
+   if ((from_addr == NULL)  (from_guess = FROM_FALLBACK_RECEIVED))
from_addr = guess_from_received_header (config, message);
 
-   if (from_addr == NULL)
+   if ((from_addr == NULL)  (from_guess = FROM_FALLBACK_ALL ))
from_addr = notmuch_config_get_user_primary_email (config);
 
-   from_addr = talloc_asprintf (ctx, %s %s,
-notmuch_config_get_user_name (config),
-from_addr);
+   if ((from_addr != NULL) || (from_guess = FROM_NONE)) {
+   from_addr = talloc_asprintf (ctx, %s %s,
+notmuch_config_get_user_name (config),
+from_addr);
+   } else {
+   from_addr = talloc_strdup (ctx, );
+   }
g_mime_object_set_header (GMIME_OBJECT (reply),
  From, from_addr);
 
@@ -590,7 +602,8 @@ notmuch_reply_format_headers_only(void *ctx,
  notmuch_config_t *config,
  notmuch_query_t *query,
  unused (notmuch_show_params_t *params),
- notmuch_bool_t reply_all)
+ notmuch_bool_t reply_all,
+ unused (int from_guess))
 {
 GMimeMessage *reply;
 notmuch_messages_t *messages;
@@ -657,10 +670,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 notmuch_query_t *query;
 char *query_string;
 int opt_index, ret = 0;
-int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all);
+int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all, int from_guess);
 notmuch_show_params_t params = { .part = -1 };
 int format = FORMAT_DEFAULT;
 int reply_all = TRUE;
+int from_guess = FROM_FALLBACK_ALL;
 notmuch_bool_t decrypt = FALSE;
 
 notmuch_opt_desc_t options[] = {
@@ -672,6 +686,13 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
  (notmuch_keyword_t []){ { all, TRUE },
  { sender, FALSE },
  { 0, 0 } } },
+   { NOTMUCH_OPT_KEYWORD, from_guess, from, 'F',
+ (notmuch_keyword_t []){ { default, FROM_FALLBACK_ALL },
+ { fallback-all, FROM_FALLBACK_ALL },
+ { fallback-received, FROM_FALLBACK_RECEIVED 
},
+ { fallback-none, FROM_FALLBACK_NONE },
+ { none, FROM_NONE },
+ { 0, 0 } } },
{ NOTMUCH_OPT_BOOLEAN, decrypt, decrypt, 'd', 0 },
{ 0, 0, 0, 0, 0 }
 };
@@ -732,7 +753,7 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
return 1;
 }
 
-if (reply_format_func (ctx, config, query, params, reply_all) != 0)
+if (reply_format_func (ctx, 

Re: [PATCH 2/2] emacs: Improve prompting for user address when replying.

2012-02-04 Thread Jani Nikula
On Sat,  4 Feb 2012 17:09:10 +, Mark Walters markwalters1...@gmail.com 
wrote:
 This patch uses the new --from option to notmuch reply to allow it to
 prompt the user for the From: address in cases when the cli does not
 know the correct from address. If the cli does not it either uses
 the users default address or, if notmuch-always-prompt-for-sender
 is set, prompts the user.
 ---
  emacs/notmuch-mua.el |   47 ---
  1 files changed, 28 insertions(+), 19 deletions(-)
 
 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
 index 41f82c2..36e62f9 100644
 --- a/emacs/notmuch-mua.el
 +++ b/emacs/notmuch-mua.el
 @@ -51,6 +51,24 @@ list.
  
  ;;
  
 +(defcustom notmuch-identities nil
 +  Identities that can be used as the From: address when composing a new 
 message.
 +
 +If this variable is left unset, then a list will be constructed from the
 +name and addresses configured in the notmuch configuration file.
 +  :type '(repeat string)
 +  :group 'notmuch-send)
 +
 +(defcustom notmuch-always-prompt-for-sender nil
 +  Always prompt for the From: address when composing or forwarding a 
 message.
 +
 +This is not taken into account when replying to a message, because in that 
 case
 +the From: header is already filled in by notmuch.
 +  :type 'boolean
 +  :group 'notmuch-send)
 +
 +(defvar notmuch-mua-sender-history nil)
 +
  (defun notmuch-mua-user-agent-full ()
Generate a `User-Agent:' string suitable for notmuch.
(concat (notmuch-mua-user-agent-notmuch)
 @@ -75,7 +93,7 @@ list.
  (defun notmuch-mua-reply (query-string optional sender reply-all)
(let (headers
   body
 - (args '(reply)))
 + (args '(reply --from=fallback-received)))

There are better reviewers for the rest of the emacs bits, but wouldn't
it be better to just use the notmuch reply default when the user wants
the current behaviour?

BR,
Jani.


  (if notmuch-show-process-crypto
   (setq args (append args '(--decrypt
  (if reply-all
 @@ -99,6 +117,15 @@ list.
  ;; If sender is non-nil, set the From: header to its value.
  (when sender
(mail-header-set 'from sender headers))
 +;; If we do not have a From: header yet it means that
 +;; notmuch-reply.c was not able to make a useful guess so we fill
 +;; it in ourselves.
 +(when (string=  (mail-header 'from headers))
 +  (if notmuch-always-prompt-for-sender
 +   (setq sender (notmuch-mua-prompt-for-sender))
 + (setq sender (concat
 +   (notmuch-user-name)   (notmuch-user-primary-email) 
 )))
 +  (mail-header-set 'from sender headers))
  (let
   ;; Overlay the composition window on that being used to read
   ;; the original message.
 @@ -153,24 +180,6 @@ OTHER-ARGS are passed through to `message-mail'.
  
(message-goto-to))
  
 -(defcustom notmuch-identities nil
 -  Identities that can be used as the From: address when composing a new 
 message.
 -
 -If this variable is left unset, then a list will be constructed from the
 -name and addresses configured in the notmuch configuration file.
 -  :type '(repeat string)
 -  :group 'notmuch-send)
 -
 -(defcustom notmuch-always-prompt-for-sender nil
 -  Always prompt for the From: address when composing or forwarding a 
 message.
 -
 -This is not taken into account when replying to a message, because in that 
 case
 -the From: header is already filled in by notmuch.
 -  :type 'boolean
 -  :group 'notmuch-send)
 -
 -(defvar notmuch-mua-sender-history nil)
 -
  (defun notmuch-mua-prompt-for-sender ()
(interactive)
(let (name addresses one-name-only)
 -- 
 1.7.2.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 v6 3/3] post-merge fixes

2012-02-04 Thread David Bremner
On Fri,  3 Feb 2012 11:24:09 +0100, Pieter Praet pie...@praet.org wrote:
 ---
  emacs/notmuch-mua.el |2 +-
  test/emacs   |2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

split into two commits and pushed,

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


Re: [PATCH 1/2] cli: add --from option to reply to restrict guessing of the From: header.

2012-02-04 Thread Mark Walters

On Sat, 04 Feb 2012 19:59:58 +0200, Jani Nikula j...@nikula.org wrote:
 On Sat,  4 Feb 2012 17:09:09 +, Mark Walters markwalters1...@gmail.com 
 wrote:
  Add an option --from= to notmuch-reply.c to restrict guessing of the
  From: header. The existing logic looks as the main headers, then at
  the delivery headers, and finally defaults to the config file address.
  
  This patch allows the user to restrict which of these guesses are
  made.  Currently the supported values are:
 default|fallback-allcurrent behaviour
 fallback-received   fallback to delivery headers but not config 
  file
 fallback-none   only look at from/reply-to/to/cc/ headers
 noneFrom: header is always left empty
 
 As discussed on IRC, --from=primary is a natural extension to always use
 the primary address from config, but that can be a later patch.

Ok, I will probably add that.

  
  If the code does not find an allowed address it outputs an empty From:
  line and the caller can decide how to respond.
  ---
   notmuch-reply.c |   39 ++-
   1 files changed, 30 insertions(+), 9 deletions(-)
  
  diff --git a/notmuch-reply.c b/notmuch-reply.c
  index f55b1d2..f660749 100644
  --- a/notmuch-reply.c
  +++ b/notmuch-reply.c
  @@ -24,6 +24,13 @@
   #include gmime-filter-reply.h
   #include gmime-filter-headers.h
   
 
 I think it would be good to have a comment here reminding later
 developers that the order matters in this enum.

Have fixed

  +enum {
  +FROM_FALLBACK_ALL,
  +FROM_FALLBACK_RECEIVED,
  +FROM_FALLBACK_NONE,
  +FROM_NONE
  +};
  +
   static void
   reply_headers_message_part (GMimeMessage *message);
   
  @@ -510,7 +517,8 @@ notmuch_reply_format_default(void *ctx,
   notmuch_config_t *config,
   notmuch_query_t *query,
   notmuch_show_params_t *params,
  -notmuch_bool_t reply_all)
  +notmuch_bool_t reply_all,
  +int from_guess)
 
 Hrmh, I'd like this to sound more deterministic than
 guessing. from_select? from_use? from?

I have gone for from_select.

   {
   GMimeMessage *reply;
   notmuch_messages_t *messages;
  @@ -542,15 +550,19 @@ notmuch_reply_format_default(void *ctx,
  from_addr = add_recipients_from_message (reply, config, message,
   reply_all);
   
  -   if (from_addr == NULL)
  +   if ((from_addr == NULL)  (from_guess = FROM_FALLBACK_RECEIVED))
 
 Please drop the extra braces here and below.

Have fixed. (Indeed in a sense this was a bug see below!)
 
  from_addr = guess_from_received_header (config, message);
   
  -   if (from_addr == NULL)
  +   if ((from_addr == NULL)  (from_guess = FROM_FALLBACK_ALL ))
  from_addr = notmuch_config_get_user_primary_email (config);
   
  -   from_addr = talloc_asprintf (ctx, %s %s,
  -notmuch_config_get_user_name (config),
  -from_addr);
  +   if ((from_addr != NULL) || (from_guess = FROM_NONE)) {
 
 Should that be (from_addr != NULL  from_guess != FROM_NONE)?
 Definitely the assignment is an error!

You are quite right. And if I didn't have the superfluous brackets the
compiler would probably have given a warning. I have fixed it.

 
  +   from_addr = talloc_asprintf (ctx, %s %s,
  +notmuch_config_get_user_name (config),
  +from_addr);
  +   } else {
  +   from_addr = talloc_strdup (ctx, );
  +   }
  g_mime_object_set_header (GMIME_OBJECT (reply),
From, from_addr);
   
  @@ -590,7 +602,8 @@ notmuch_reply_format_headers_only(void *ctx,
notmuch_config_t *config,
notmuch_query_t *query,
unused (notmuch_show_params_t *params),
  - notmuch_bool_t reply_all)
  + notmuch_bool_t reply_all,
  + unused (int from_guess))
   {
   GMimeMessage *reply;
   notmuch_messages_t *messages;
  @@ -657,10 +670,11 @@ notmuch_reply_command (void *ctx, int argc, char 
  *argv[])
   notmuch_query_t *query;
   char *query_string;
   int opt_index, ret = 0;
  -int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
  notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
  reply_all);
  +int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
  notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
  reply_all, int from_guess);
   notmuch_show_params_t params = { .part = -1 };
   int format = FORMAT_DEFAULT;
   int reply_all = TRUE;
  +int from_guess = FROM_FALLBACK_ALL;
   notmuch_bool_t decrypt = FALSE;
   
   

Re: [PATCH 2/2] emacs: Improve prompting for user address when replying.

2012-02-04 Thread Mark Walters

On Sat, 04 Feb 2012 20:03:13 +0200, Jani Nikula j...@nikula.org wrote:
 On Sat,  4 Feb 2012 17:09:10 +, Mark Walters markwalters1...@gmail.com 
 wrote:
  This patch uses the new --from option to notmuch reply to allow it to
  prompt the user for the From: address in cases when the cli does not
  know the correct from address. If the cli does not it either uses
  the users default address or, if notmuch-always-prompt-for-sender
  is set, prompts the user.
  ---
   emacs/notmuch-mua.el |   47 ---
   1 files changed, 28 insertions(+), 19 deletions(-)
  
  diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
  index 41f82c2..36e62f9 100644
  --- a/emacs/notmuch-mua.el
  +++ b/emacs/notmuch-mua.el
  @@ -51,6 +51,24 @@ list.
   
   ;;
   
  +(defcustom notmuch-identities nil
  +  Identities that can be used as the From: address when composing a new 
  message.
  +
  +If this variable is left unset, then a list will be constructed from the
  +name and addresses configured in the notmuch configuration file.
  +  :type '(repeat string)
  +  :group 'notmuch-send)
  +
  +(defcustom notmuch-always-prompt-for-sender nil
  +  Always prompt for the From: address when composing or forwarding a 
  message.
  +
  +This is not taken into account when replying to a message, because in that 
  case
  +the From: header is already filled in by notmuch.
  +  :type 'boolean
  +  :group 'notmuch-send)
  +
  +(defvar notmuch-mua-sender-history nil)
  +
   (defun notmuch-mua-user-agent-full ()
 Generate a `User-Agent:' string suitable for notmuch.
 (concat (notmuch-mua-user-agent-notmuch)
  @@ -75,7 +93,7 @@ list.
   (defun notmuch-mua-reply (query-string optional sender reply-all)
 (let (headers
  body
  -   (args '(reply)))
  +   (args '(reply --from=fallback-received)))
 
 There are better reviewers for the rest of the emacs bits, but wouldn't
 it be better to just use the notmuch reply default when the user wants
 the current behaviour?

Does any user actually want to be prompted for a From address when
mailing/forwarding normally but not when replying and there is no reason
to choose one address over another?

What I would actually like is to consolidate the From address choosing
so that it occurs in one place in the emacs code, so the three
(mail/forward/reply) naturally behave the same.

Thanks for the rapid review (and the significant bug catch!)

Best wishes

Mark


 BR,
 Jani.
 
 
   (if notmuch-show-process-crypto
  (setq args (append args '(--decrypt
   (if reply-all
  @@ -99,6 +117,15 @@ list.
   ;; If sender is non-nil, set the From: header to its value.
   (when sender
 (mail-header-set 'from sender headers))
  +;; If we do not have a From: header yet it means that
  +;; notmuch-reply.c was not able to make a useful guess so we fill
  +;; it in ourselves.
  +(when (string=  (mail-header 'from headers))
  +  (if notmuch-always-prompt-for-sender
  + (setq sender (notmuch-mua-prompt-for-sender))
  +   (setq sender (concat
  + (notmuch-user-name)   (notmuch-user-primary-email) 
  )))
  +  (mail-header-set 'from sender headers))
   (let
  ;; Overlay the composition window on that being used to read
  ;; the original message.
  @@ -153,24 +180,6 @@ OTHER-ARGS are passed through to `message-mail'.
   
 (message-goto-to))
   
  -(defcustom notmuch-identities nil
  -  Identities that can be used as the From: address when composing a new 
  message.
  -
  -If this variable is left unset, then a list will be constructed from the
  -name and addresses configured in the notmuch configuration file.
  -  :type '(repeat string)
  -  :group 'notmuch-send)
  -
  -(defcustom notmuch-always-prompt-for-sender nil
  -  Always prompt for the From: address when composing or forwarding a 
  message.
  -
  -This is not taken into account when replying to a message, because in that 
  case
  -the From: header is already filled in by notmuch.
  -  :type 'boolean
  -  :group 'notmuch-send)
  -
  -(defvar notmuch-mua-sender-history nil)
  -
   (defun notmuch-mua-prompt-for-sender ()
 (interactive)
 (let (name addresses one-name-only)
  -- 
  1.7.2.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: [RFC PATCH v2] emacs: make show view a/A/x/X key bindings more consistent

2012-02-04 Thread David Bremner
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:

Last chance for objections...

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


Re: Bug: emacs 23.2 doesn't like ido-completing-read

2012-02-04 Thread Tomi Ollila
On Sat, 04 Feb 2012 12:31:57 +, Mark Walters markwalters1...@gmail.com 
wrote:
 
 I hadn't realised before but this also goes wrong if you use the prefix
 argument to mail (eg ctrl-u m). The current code seems to mess up the
 mini-buffer and even closing the buffer does not get out of it.
 
 Changing ido-completing-read read to completing-read seems to fix the
 problem entirely. Since this will affect most debian stable users (*) I
 think we should fix it. The trivial patch below works for me but other 
 solutions
 may be better as they could maintain the benefits of ido-completing-read
 (eg that it shows the possibilities).

 Best wishes
 
 Mark
 
 (*) Perhaps only those who have more than one email address.
 
 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
 index 023645e..41f82c2 100644
 --- a/emacs/notmuch-mua.el
 +++ b/emacs/notmuch-mua.el
 @@ -191,7 +191,7 @@ the From: header is already filled in by notmuch.
  ;; Now prompt the user, either for an email address only or for a full 
 identity.
  (if one-name-only
   (let ((address
 -(ido-completing-read (concat Sender address for  name : ) 
 addresses
 +(completing-read (concat Sender address for  name : ) 
 addresses
   nil nil nil 'notmuch-mua-sender-history 
 (car addresses
 (concat name   address ))
(ido-completing-read Send mail From:  notmuch-identities

Should that other ido-completing-read be kept there -- it is the only
one left after this patch...

Tomi


 -- 
 1.7.2.3

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


Re: Bug: emacs 23.2 doesn't like ido-completing-read

2012-02-04 Thread Mark Walters
On Sat, 04 Feb 2012 22:14:25 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
 On Sat, 04 Feb 2012 12:31:57 +, Mark Walters markwalters1...@gmail.com 
 wrote:
  
  I hadn't realised before but this also goes wrong if you use the prefix
  argument to mail (eg ctrl-u m). The current code seems to mess up the
  mini-buffer and even closing the buffer does not get out of it.
  
  Changing ido-completing-read read to completing-read seems to fix the
  problem entirely. Since this will affect most debian stable users (*) I
  think we should fix it. The trivial patch below works for me but other 
  solutions
  may be better as they could maintain the benefits of ido-completing-read
  (eg that it shows the possibilities).
 
  Best wishes
  
  Mark
  
  (*) Perhaps only those who have more than one email address.
  
  diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
  index 023645e..41f82c2 100644
  --- a/emacs/notmuch-mua.el
  +++ b/emacs/notmuch-mua.el
  @@ -191,7 +191,7 @@ the From: header is already filled in by notmuch.
   ;; Now prompt the user, either for an email address only or for a full 
  identity.
   (if one-name-only
  (let ((address
  -  (ido-completing-read (concat Sender address for  name : ) 
  addresses
  +  (completing-read (concat Sender address for  name : ) 
  addresses
  nil nil nil 'notmuch-mua-sender-history 
  (car addresses
(concat name   address ))
 (ido-completing-read Send mail From:  notmuch-identities
 
 Should that other ido-completing-read be kept there -- it is the only
 one left after this patch...

Whoops: I hadn't even noticed that one. Is there any way of fixing it
so ido-completing-read works (see the link in my first message
id:871uqijdy4@qmul.ac.uk)? Not because I want the extra
functionality but perhaps someone else likes it as it is.

Many thanks

Mark

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


[Patch v2 0/4] Control selection of From: header when replying

2012-02-04 Thread Mark Walters

This is version 2 of the patch set first posted in
id:1328375350-10352-1-git-send-email-markwalters1...@gmail.com

This fixes the bug Jani pointed out as well as the more minor
criticisms. It also has some tests and the man pages are updated.

Best wishes

Mark

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


[PATCH v2 1/4] cli: add --from option to reply to restrict guessing of the From: header.

2012-02-04 Thread Mark Walters
Add an option --from= to notmuch-reply.c to restrict guessing of the
From: header. The existing logic looks as the main headers, then at
the delivery headers, and finally defaults to the config file address.

This patch allows the user to restrict which of these guesses are
made.  Currently the supported values are:
   default|fallback-allcurrent behaviour
   fallback-received   fallback to delivery headers but not config file
   fallback-none   only look at from/reply-to/to/cc/ headers
   noneFrom: header is always left empty

If the code does not find an allowed address it outputs an empty From:
line and the caller can decide how to respond.
---
 notmuch-reply.c |   45 -
 1 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index f55b1d2..8c73cb7 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -24,6 +24,15 @@
 #include gmime-filter-reply.h
 #include gmime-filter-headers.h
 
+/* The order here matters as we use '' when deciding how to behave. */
+enum {
+FROM_FALLBACK_ALL,
+FROM_FALLBACK_RECEIVED,
+FROM_FALLBACK_NONE,
+FROM_NONE,
+FROM_PRIMARY
+};
+
 static void
 reply_headers_message_part (GMimeMessage *message);
 
@@ -510,7 +519,8 @@ notmuch_reply_format_default(void *ctx,
 notmuch_config_t *config,
 notmuch_query_t *query,
 notmuch_show_params_t *params,
-notmuch_bool_t reply_all)
+notmuch_bool_t reply_all,
+int from_select)
 {
 GMimeMessage *reply;
 notmuch_messages_t *messages;
@@ -542,15 +552,22 @@ notmuch_reply_format_default(void *ctx,
from_addr = add_recipients_from_message (reply, config, message,
 reply_all);
 
-   if (from_addr == NULL)
+   if (from_addr == NULL  from_select = FROM_FALLBACK_RECEIVED)
from_addr = guess_from_received_header (config, message);
 
-   if (from_addr == NULL)
+   if ((from_addr == NULL  from_select = FROM_FALLBACK_ALL) ||
+   from_select == FROM_PRIMARY)
from_addr = notmuch_config_get_user_primary_email (config);
 
-   from_addr = talloc_asprintf (ctx, %s %s,
-notmuch_config_get_user_name (config),
-from_addr);
+   /* If we have an address and we want an address print
+* it. Otherwise set an empty From: header. */
+   if (from_addr != NULL  from_select != FROM_NONE) {
+   from_addr = talloc_asprintf (ctx, %s %s,
+notmuch_config_get_user_name (config),
+from_addr);
+   } else {
+   from_addr = talloc_strdup (ctx, );
+   }
g_mime_object_set_header (GMIME_OBJECT (reply),
  From, from_addr);
 
@@ -590,7 +607,8 @@ notmuch_reply_format_headers_only(void *ctx,
  notmuch_config_t *config,
  notmuch_query_t *query,
  unused (notmuch_show_params_t *params),
- notmuch_bool_t reply_all)
+ notmuch_bool_t reply_all,
+ unused (int from_select))
 {
 GMimeMessage *reply;
 notmuch_messages_t *messages;
@@ -657,10 +675,11 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 notmuch_query_t *query;
 char *query_string;
 int opt_index, ret = 0;
-int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all);
+int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
reply_all, int from_select);
 notmuch_show_params_t params = { .part = -1 };
 int format = FORMAT_DEFAULT;
 int reply_all = TRUE;
+int from_select = FROM_FALLBACK_ALL;
 notmuch_bool_t decrypt = FALSE;
 
 notmuch_opt_desc_t options[] = {
@@ -672,6 +691,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
  (notmuch_keyword_t []){ { all, TRUE },
  { sender, FALSE },
  { 0, 0 } } },
+   { NOTMUCH_OPT_KEYWORD, from_select, from, 'F',
+ (notmuch_keyword_t []){ { default, FROM_FALLBACK_ALL },
+ { fallback-all, FROM_FALLBACK_ALL },
+ { fallback-received, FROM_FALLBACK_RECEIVED 
},
+ { fallback-none, FROM_FALLBACK_NONE },
+ { none, FROM_NONE },
+ { primary, FROM_PRIMARY },
+ { 

[PATCH v2 2/4] cli: update man page for notmuch-reply --from:

2012-02-04 Thread Mark Walters
---
 man/man1/notmuch-reply.1 |   27 +++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/man/man1/notmuch-reply.1 b/man/man1/notmuch-reply.1
index 5160ece..101ed47 100644
--- a/man/man1/notmuch-reply.1
+++ b/man/man1/notmuch-reply.1
@@ -62,6 +62,33 @@ addresses), try To:, Cc:, and Bcc: headers in this order, 
and copy
 values from the first that contains something other than only the
 user's addresses.
 .RE
+.TP 4
+.BR \-\-from= ( default | fallback-all | fallback-received | fallback-none | 
none | primary )
+.RS
+.TP 4
+Controls the choice of the From: header returned.
+.TP 4
+.BR default | fallback-all
+Chooses the From: address by looking at the reply-to/from/to/cc
+headers of the message being replied to, if no user address is found
+look in the delivery headers, if still no user address is found return
+the user's primary address.
+.TP 4
+.BR fallback-received
+As above but if no user address is found after looking in the delivery
+headers returns an empty From: header.
+.TP 4
+.BR fallback-none
+Only look at the reply-to/from/to/cc of the original message. If no
+user address is found return an empty From: header.
+.TP 4
+.BR none
+Always return an empty From: header.
+.TP 4
+.BR primary
+Always return the users primary address as the From: header.
+.RE
+.RE
 .RE
 
 See \fBnotmuch-search-terms\fR(7)
-- 
1.7.2.3

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


[PATCH v2 3/4] emacs: Improve prompting for user address when replying.

2012-02-04 Thread Mark Walters
This patch uses the new --from option to notmuch reply to allow it to
prompt the user for the From: address in cases when the cli does not
know the correct from address. If the cli does not it either uses
the users default address or, if notmuch-always-prompt-for-sender
is set, prompts the user.
---
 emacs/notmuch-mua.el |   47 ---
 1 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 41f82c2..36e62f9 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -51,6 +51,24 @@ list.
 
 ;;
 
+(defcustom notmuch-identities nil
+  Identities that can be used as the From: address when composing a new 
message.
+
+If this variable is left unset, then a list will be constructed from the
+name and addresses configured in the notmuch configuration file.
+  :type '(repeat string)
+  :group 'notmuch-send)
+
+(defcustom notmuch-always-prompt-for-sender nil
+  Always prompt for the From: address when composing or forwarding a message.
+
+This is not taken into account when replying to a message, because in that case
+the From: header is already filled in by notmuch.
+  :type 'boolean
+  :group 'notmuch-send)
+
+(defvar notmuch-mua-sender-history nil)
+
 (defun notmuch-mua-user-agent-full ()
   Generate a `User-Agent:' string suitable for notmuch.
   (concat (notmuch-mua-user-agent-notmuch)
@@ -75,7 +93,7 @@ list.
 (defun notmuch-mua-reply (query-string optional sender reply-all)
   (let (headers
body
-   (args '(reply)))
+   (args '(reply --from=fallback-received)))
 (if notmuch-show-process-crypto
(setq args (append args '(--decrypt
 (if reply-all
@@ -99,6 +117,15 @@ list.
 ;; If sender is non-nil, set the From: header to its value.
 (when sender
   (mail-header-set 'from sender headers))
+;; If we do not have a From: header yet it means that
+;; notmuch-reply.c was not able to make a useful guess so we fill
+;; it in ourselves.
+(when (string=  (mail-header 'from headers))
+  (if notmuch-always-prompt-for-sender
+ (setq sender (notmuch-mua-prompt-for-sender))
+   (setq sender (concat
+ (notmuch-user-name)   (notmuch-user-primary-email) 
)))
+  (mail-header-set 'from sender headers))
 (let
;; Overlay the composition window on that being used to read
;; the original message.
@@ -153,24 +180,6 @@ OTHER-ARGS are passed through to `message-mail'.
 
   (message-goto-to))
 
-(defcustom notmuch-identities nil
-  Identities that can be used as the From: address when composing a new 
message.
-
-If this variable is left unset, then a list will be constructed from the
-name and addresses configured in the notmuch configuration file.
-  :type '(repeat string)
-  :group 'notmuch-send)
-
-(defcustom notmuch-always-prompt-for-sender nil
-  Always prompt for the From: address when composing or forwarding a message.
-
-This is not taken into account when replying to a message, because in that case
-the From: header is already filled in by notmuch.
-  :type 'boolean
-  :group 'notmuch-send)
-
-(defvar notmuch-mua-sender-history nil)
-
 (defun notmuch-mua-prompt-for-sender ()
   (interactive)
   (let (name addresses one-name-only)
-- 
1.7.2.3

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


[PATCH v2 4/4] test: test the new --from option to notmuch-reply

2012-02-04 Thread Mark Walters
---
 test/reply |   69 
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/test/reply b/test/reply
index 00f4bea..0bb22bb 100755
--- a/test/reply
+++ b/test/reply
@@ -138,4 +138,73 @@ References: ${gen_msg_id}
 
 On Tue, 05 Jan 2010 15:43:56 -, Notmuch Test Suite 
test_su...@notmuchmail.org wrote:
  200-byte header
+
+test_begin_subtest reply --from=none
+add_message '[from]=Sender sen...@example.com' \
+[to]=test_su...@notmuchmail.org \
+[subject]=notmuch-reply-test \
+   '[date]=Tue, 05 Jan 2010 15:43:56 -' \
+   '[body]=reply --from=none test'
+
+output=$(notmuch reply --from=none id:${gen_msg_id})
+test_expect_equal $output From: 
+Subject: Re: notmuch-reply-test
+To: Sender sen...@example.com
+In-Reply-To: ${gen_msg_id}
+References: ${gen_msg_id}
+
+On Tue, 05 Jan 2010 15:43:56 -, Sender sen...@example.com wrote:
+ reply --from=none test
+
+test_begin_subtest reply --from:fallback-none
+add_message '[from]=Sender sen...@example.com' \
+   '[to]=Someone Else some...@example.com' \
+[subject]=notmuch-reply-test \
+   '[date]=Tue, 05 Jan 2010 15:43:56 -' \
+   '[body]=reply --from=fallback-none test'
+
+output=$(notmuch reply --from=fallback-none id:${gen_msg_id})
+test_expect_equal $output From: 
+Subject: Re: notmuch-reply-test
+To: Sender sen...@example.com, Someone Else some...@example.com
+In-Reply-To: ${gen_msg_id}
+References: ${gen_msg_id}
+
+On Tue, 05 Jan 2010 15:43:56 -, Sender sen...@example.com wrote:
+ reply --from=fallback-none test
+
+test_begin_subtest reply default from:
+add_message '[from]=Sender sen...@example.com' \
+   '[to]=Someone Else some...@example.com' \
+[subject]=notmuch-reply-test \
+   '[date]=Tue, 05 Jan 2010 15:43:56 -' \
+   '[body]=reply default from: test'
+
+output=$(notmuch reply id:${gen_msg_id})
+test_expect_equal $output From: Notmuch Test Suite 
test_su...@notmuchmail.org
+Subject: Re: notmuch-reply-test
+To: Sender sen...@example.com, Someone Else some...@example.com
+In-Reply-To: ${gen_msg_id}
+References: ${gen_msg_id}
+
+On Tue, 05 Jan 2010 15:43:56 -, Sender sen...@example.com wrote:
+ reply default from: test
+
+test_begin_subtest Reply --from=primary
+add_message '[from]=Sender sen...@example.com' \
+[to]=test_suite_ot...@notmuchmail.org \
+[subject]=notmuch-reply-test \
+   '[date]=Tue, 05 Jan 2010 15:43:56 -' \
+   '[body]=reply --from=primary'
+
+output=$(notmuch reply --from=primary id:${gen_msg_id})
+test_expect_equal $output From: Notmuch Test Suite 
test_su...@notmuchmail.org
+Subject: Re: notmuch-reply-test
+To: Sender sen...@example.com
+In-Reply-To: ${gen_msg_id}
+References: ${gen_msg_id}
+
+On Tue, 05 Jan 2010 15:43:56 -, Sender sen...@example.com wrote:
+ reply --from=primary
+
 test_done
-- 
1.7.2.3

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


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

2012-02-04 Thread Austin Clements
Quoth Dmitry Kurochkin on Jan 31 at  3:26 am:
 On Thu, 26 Jan 2012 01:55:25 -0500, Austin Clements amdra...@mit.edu 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.

I wouldn't want to support this without supporting it for all of the
string members of notmuch_show_format_t, which turns out to be a
fairly big change.  At the end of the show rewrite, all of these other
string members will go away, so I'll add support for just these being
NULL at that point.

 Looks good otherwise.
 
 Regards,
   Dmitry
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH v2 1/4] cli: add --from option to reply to restrict guessing of the From: header.

2012-02-04 Thread Jani Nikula
On Sat,  4 Feb 2012 20:45:14 +, Mark Walters markwalters1...@gmail.com 
wrote:
 Add an option --from= to notmuch-reply.c to restrict guessing of the
 From: header. The existing logic looks as the main headers, then at
 the delivery headers, and finally defaults to the config file address.
 
 This patch allows the user to restrict which of these guesses are
 made.  Currently the supported values are:
default|fallback-allcurrent behaviour
fallback-received   fallback to delivery headers but not config 
 file
fallback-none only look at from/reply-to/to/cc/ headers
none  From: header is always left empty

The patch looks good. The primary option added in v2 is missing from
the commit message, but no need to send a new version because of that.

I didn't check the other patches in the series.

BR,
Jani.


 
 If the code does not find an allowed address it outputs an empty From:
 line and the caller can decide how to respond.
 ---
  notmuch-reply.c |   45 -
  1 files changed, 36 insertions(+), 9 deletions(-)
 
 diff --git a/notmuch-reply.c b/notmuch-reply.c
 index f55b1d2..8c73cb7 100644
 --- a/notmuch-reply.c
 +++ b/notmuch-reply.c
 @@ -24,6 +24,15 @@
  #include gmime-filter-reply.h
  #include gmime-filter-headers.h
  
 +/* The order here matters as we use '' when deciding how to behave. */
 +enum {
 +FROM_FALLBACK_ALL,
 +FROM_FALLBACK_RECEIVED,
 +FROM_FALLBACK_NONE,
 +FROM_NONE,
 +FROM_PRIMARY
 +};
 +
  static void
  reply_headers_message_part (GMimeMessage *message);
  
 @@ -510,7 +519,8 @@ notmuch_reply_format_default(void *ctx,
notmuch_config_t *config,
notmuch_query_t *query,
notmuch_show_params_t *params,
 -  notmuch_bool_t reply_all)
 +  notmuch_bool_t reply_all,
 +  int from_select)
  {
  GMimeMessage *reply;
  notmuch_messages_t *messages;
 @@ -542,15 +552,22 @@ notmuch_reply_format_default(void *ctx,
   from_addr = add_recipients_from_message (reply, config, message,
reply_all);
  
 - if (from_addr == NULL)
 + if (from_addr == NULL  from_select = FROM_FALLBACK_RECEIVED)
   from_addr = guess_from_received_header (config, message);
  
 - if (from_addr == NULL)
 + if ((from_addr == NULL  from_select = FROM_FALLBACK_ALL) ||
 + from_select == FROM_PRIMARY)
   from_addr = notmuch_config_get_user_primary_email (config);
  
 - from_addr = talloc_asprintf (ctx, %s %s,
 -  notmuch_config_get_user_name (config),
 -  from_addr);
 + /* If we have an address and we want an address print
 +  * it. Otherwise set an empty From: header. */
 + if (from_addr != NULL  from_select != FROM_NONE) {
 + from_addr = talloc_asprintf (ctx, %s %s,
 +  notmuch_config_get_user_name (config),
 +  from_addr);
 + } else {
 + from_addr = talloc_strdup (ctx, );
 + }
   g_mime_object_set_header (GMIME_OBJECT (reply),
 From, from_addr);
  
 @@ -590,7 +607,8 @@ notmuch_reply_format_headers_only(void *ctx,
 notmuch_config_t *config,
 notmuch_query_t *query,
 unused (notmuch_show_params_t *params),
 -   notmuch_bool_t reply_all)
 +   notmuch_bool_t reply_all,
 +   unused (int from_select))
  {
  GMimeMessage *reply;
  notmuch_messages_t *messages;
 @@ -657,10 +675,11 @@ notmuch_reply_command (void *ctx, int argc, char 
 *argv[])
  notmuch_query_t *query;
  char *query_string;
  int opt_index, ret = 0;
 -int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
 notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
 reply_all);
 +int (*reply_format_func)(void *ctx, notmuch_config_t *config, 
 notmuch_query_t *query, notmuch_show_params_t *params, notmuch_bool_t 
 reply_all, int from_select);
  notmuch_show_params_t params = { .part = -1 };
  int format = FORMAT_DEFAULT;
  int reply_all = TRUE;
 +int from_select = FROM_FALLBACK_ALL;
  notmuch_bool_t decrypt = FALSE;
  
  notmuch_opt_desc_t options[] = {
 @@ -672,6 +691,14 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
 (notmuch_keyword_t []){ { all, TRUE },
 { sender, FALSE },
 { 0, 0 } } },
 + { NOTMUCH_OPT_KEYWORD, from_select, from, 'F',
 +   (notmuch_keyword_t []){ { default, FROM_FALLBACK_ALL },
 +   { fallback-all, 

Re: [PATCH 1/2] NEWS: markup changes to make mdwn-html look slightly better

2012-02-04 Thread Mark Walters

On Wed,  1 Feb 2012 17:22:49 +0200, Tomi Ollila tomi.oll...@iki.fi wrote:
 Some formatting in NEWS file has been changed so that it could
 be given to markdown processing almost verbatim.
 More effort has been put into formatting of version 0.11 (and 0.12)
 of notmuch NEWS than previous versions but everything is in better
 shape that those used to be.

Hi

Could you add something saying what markup rules developers should
follow when writing NEWS items? It would also make this patch easier to
comment upon. As far as I can see there are 2 relatively small things:
start an item with a * and put commands in backticks. (Actually it might
also be worth saying how to get * and ` if you actually want them too.)

I like the output at the address you gave.

Thanks

Mark

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


Re: [PATCH v3 09/10] random-dump.c: new test-binary to generate dump files

2012-02-04 Thread Mark Walters
On Sat, 14 Jan 2012 21:40:23 -0400, David Bremner da...@tethera.net wrote:
 From: David Bremner brem...@debian.org
 
 This binary creates a torture test dump file for the new dump
 format.
 ---
  test/Makefile.local |4 ++
  test/basic  |2 +-
  test/random-dump.c  |  144 
 +++
  3 files changed, 149 insertions(+), 1 deletions(-)
  create mode 100644 test/random-dump.c
 
 diff --git a/test/Makefile.local b/test/Makefile.local
 index ba697f4..b59f837 100644
 --- a/test/Makefile.local
 +++ b/test/Makefile.local
 @@ -16,6 +16,9 @@ $(dir)/arg-test: $(dir)/arg-test.o command-line-arguments.o 
 util/libutil.a
  $(dir)/hex-xcode: $(dir)/hex-xcode.o command-line-arguments.o util/libutil.a
   $(call quiet,CC) -I. $^ -o $@ -ltalloc
  
 +$(dir)/random-dump:  $(dir)/random-dump.o command-line-arguments.o 
 util/libutil.a
 + $(call quiet,CC) -I. $^ -o $@ -ltalloc -lm
 +
  $(dir)/smtp-dummy: $(smtp_dummy_modules)
   $(call quiet,CC) $^ -o $@
  
 @@ -25,6 +28,7 @@ $(dir)/symbol-test: $(dir)/symbol-test.o
  .PHONY: test check
  
  test-binaries: $(dir)/arg-test $(dir)/hex-xcode \
 + $(dir)/random-dump \
$(dir)/smtp-dummy $(dir)/symbol-test
  
  test:all test-binaries
 diff --git a/test/basic b/test/basic
 index af57026..e3a6cef 100755
 --- a/test/basic
 +++ b/test/basic
 @@ -54,7 +54,7 @@ test_begin_subtest 'Ensure that all available tests will be 
 run by notmuch-test'
  eval $(sed -n -e '/^TESTS=$/,/^$/p' $TEST_DIRECTORY/notmuch-test)
  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)
  available=$(find $TEST_DIRECTORY -maxdepth 1 -type f -executable -printf 
 '%f\n' | \
 -sed -r -e 
 /^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode)$/d
  | \
 +sed -r -e 
 /^(aggregate-results.sh|notmuch-test|smtp-dummy|test-verbose|symbol-test|arg-test|hex-xcode|random-dump)$/d
  | \
  sort)
  test_expect_equal $tests_in_suite $available
  
 diff --git a/test/random-dump.c b/test/random-dump.c
 new file mode 100644
 index 000..1949425
 --- /dev/null
 +++ b/test/random-dump.c
 @@ -0,0 +1,144 @@
 +/*
 +   Generate a random dump file in 'notmuch' format.
 +   Generated message-id's and tags are intentionally nasty.
 +
 +   We restrict ourselves to 7 bit message-ids, because generating
 +   random valid UTF-8 seems like work. And invalid UTF-8 can't be
 +   round-tripped via Xapian.
 +
 + */
 +
 +#include stdlib.h
 +#include assert.h
 +#include talloc.h
 +#include string.h
 +#include math.h
 +#include hex-escape.h
 +#include command-line-arguments.h
 +
 +static void
 +hex_out (void *ctx, char *buf)
 +{
 +static char *encoded_buf = NULL;
 +static size_t encoded_buf_size = 0;
 +
 +if (hex_encode (ctx, buf, encoded_buf, encoded_buf_size) != 
 HEX_SUCCESS) {
 + fprintf (stderr, Hex encoding failed);
 + exit (1);
 +}
 +
 +fputs (encoded_buf, stdout);
 +}
 +
 +static void
 +random_chars (char *buf, int from, int stop, int max_char,
 +   const char *blacklist)
 +{
 +int i;
 +
 +for (i = from; i  stop; i++) {
 + do {
 + buf[i] = ' ' + (random () % (max_char - ' '));
 + } while (blacklist  strchr (blacklist, buf[i]));
 +}
 +}
 +
 +static void
 +random_tag (void *ctx, size_t len)
 +{
 +static char *buf = NULL;
 +static size_t buf_len = 0;
 +
 +int use = (random () % (len - 1)) + 1;
 +
 +if (len  buf_len) {
 + buf = talloc_realloc (ctx, buf, char, len);
 + buf_len = len;
 +}
 +
 +random_chars (buf, 0, use, 255, NULL);
 +
 +buf[use] = '\0';
 +
 +hex_out (ctx, buf);
 +}
 +
 +static void
 +random_message_id (void *ctx, size_t len)
 +{
 +static char *buf = NULL;
 +static size_t buf_len = 0;
 +
 +int lhs_len = (random () % (len / 2 - 1)) + 1;
 +
 +int rhs_len = (random () % len / 2) + 1;
 +
 +const char *blacklist = \n\r@[]();
 +
 +if (len  buf_len) {
 + buf = talloc_realloc (ctx, buf, char, len);
 + buf_len = len;
 +}
 +
 +random_chars (buf, 0, lhs_len, 127, blacklist);
 +
 +buf[lhs_len] = '@';
 +
 +random_chars (buf, lhs_len + 1, lhs_len + rhs_len + 1, 127, blacklist);
 +
 +hex_out (ctx, buf);
 +}
 +
 +int
 +main (int argc, char **argv)
 +{
 +
 +void *ctx = talloc_new (NULL);
 +int num_lines = 500;
 +int max_tags = 10;
 +int message_id_len = 100;
 +int tag_len = 50;
 +int seed = 734569;
 +
 +int pad_tag = 0, pad_mid = 0;
 +
 +notmuch_opt_desc_t options[] = {
 + { NOTMUCH_OPT_INT, num_lines, num-lines, 'n', 0 },
 + { NOTMUCH_OPT_INT, max_tags, max-tags, 'm', 0 },
 + { NOTMUCH_OPT_INT, message_id_len, message-id-len, 'M', 0 },
 + { NOTMUCH_OPT_INT, tag_len, tag-len, 't', 0 },
 + { NOTMUCH_OPT_INT, seed, tag-len, 't', 0 },
 + { 0, 0, 0, 0, 0 }
 +};
 +
 +int opt_index = parse_arguments (argc, argv, options, 1);
 +
 +if (opt_index  0)
 + exit (1);
 +
 +pad_mid = ((int) 

Re: [Patch v2 0/4] Control selection of From: header when replying

2012-02-04 Thread Dmitry Kurochkin
Hi Mark.

I am not sure I like this solution.  My concerns are:

* New option looks too complex, too specific.

* There are more aspects of notmuch reply behavior which users would
  like to change (e.g. which part to quote).  If we add an option for
  each, we complicate both nomtuch show UI and code.

The problem is that notmuch show output format is too limiting.  Instead
of providing myriad of options for tweaking notmuch show text format
behavior, we should add JSON format for notmuch reply similar to nomtuch
show.  That would allow notmuch reply to produce structured output with
required additional information, which should be enough for users to
construct whatever reply they want.

In this particular case, notmuch reply JSON format could have
from-source attribute that would indicate how it was guessed.

Now the best part.  Not so long ago, Adam (in Cc) provided a patch for
improving nomtuch reply for HTML-only emails.  At first he added an
option for notmuch reply, like you did for from-guessing.  I suggested
him to implement it based on the JSON format instead and he did.  AFAIK
the latest version of his patches is [1].  I did not look at the code
though.  It seems that it is waiting for more review.

So, instead of adding more nomtuch show options, I think a better
solution is to work with Adam to get the notmuch reply JSON format to
master and then fix the from-guessing issue by adding an attribute to
notmuch reply JSON format.

Regards,
  Dmitry

[1] id:1326995217-27423-1-git-send-email-awg+notm...@xvx.ca
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


Re: [PATCH 1/2] test: auto load elisp tests file in test_emacs if available

2012-02-04 Thread Dmitry Kurochkin
Hi David.

I think this is a pretty simple change.  And there is one +1 for it.  So
I am going to remove the needs-review tag, please add it back if you
disagree.

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


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

2012-02-04 Thread Dmitry Kurochkin
Changes:

v4:

* rebased on master, no conflicts so no need for another review

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.gk17...@mit.edu
[2] id:20120129225710.gg17...@mit.edu
[3] id:20120129230229.gi17...@mit.edu
[4] id:20120129231120.gj17...@mit.edu
[5] id:20120130044806.gm17...@mit.edu
[6] id:20120130050402.gp17...@mit.edu

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


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

2012-02-04 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 cd04ffd..19206db 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -516,6 +516,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)))
@@ -883,12 +889,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

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


[PATCH v5 04/12] emacs: make + and - tagging operations in notmuch-show more flexible

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

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 7469e2e..48a2a60 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -38,9 +38,10 @@
 
 (declare-function notmuch-call-notmuch-process notmuch (rest args))
 (declare-function notmuch-fontify-headers notmuch nil)
-(declare-function notmuch-select-tag-with-completion notmuch (prompt rest 
search-terms))
+(declare-function notmuch-read-tag-changes notmuch (optional initial-input 
rest search-terms))
 (declare-function notmuch-search-next-thread notmuch nil)
 (declare-function notmuch-search-show-thread notmuch nil)
+(declare-function notmuch-update-tags notmuch (current-tags tag-changes))
 
 (defcustom notmuch-message-headers '(Subject To Cc Date)
   Headers that should be shown in a message, in this order.
@@ -1282,7 +1283,7 @@ Some useful entries are:
 
 (defun notmuch-show-mark-read ()
   Mark the current message as read.
-  (notmuch-show-remove-tag unread))
+  (notmuch-show-tag-message -unread))
 
 ;; Functions for getting attributes of several messages in the current
 ;; thread.
@@ -1495,51 +1496,32 @@ than only the current message.
(message (format Command '%s' exited abnormally with code %d
 shell-command exit-code
 
-(defun notmuch-show-add-tags-worker (current-tags add-tags)
-  Add to `current-tags' with any tags from `add-tags' not
-currently present and return the result.
-  (let ((result-tags (copy-sequence current-tags)))
-(mapc (lambda (add-tag)
-   (unless (member add-tag current-tags)
- (setq result-tags (push add-tag result-tags
-   add-tags)
-(sort result-tags 'string)))
-
-(defun notmuch-show-del-tags-worker (current-tags del-tags)
-  Remove any tags in `del-tags' from `current-tags' and return
-the result.
-  (let ((result-tags (copy-sequence current-tags)))
-(mapc (lambda (del-tag)
-   (setq result-tags (delete del-tag result-tags)))
- del-tags)
-result-tags))
-
-(defun notmuch-show-add-tag (rest toadd)
-  Add a tag to the current message.
-  (interactive
-   (list (notmuch-select-tag-with-completion Tag to add: )))
+(defun notmuch-show-tag-message (rest tag-changes)
+  Change tags for the current message.
 
+TAG-CHANGES is a list of tag operations for `notmuch-tag'.
   (let* ((current-tags (notmuch-show-get-tags))
-(new-tags (notmuch-show-add-tags-worker current-tags toadd)))
-
+(new-tags (notmuch-update-tags current-tags tag-changes)))
 (unless (equal current-tags new-tags)
-  (apply 'notmuch-tag (notmuch-show-get-message-id)
-(mapcar (lambda (s) (concat + s)) toadd))
+  (apply 'notmuch-tag (notmuch-show-get-message-id) tag-changes)
   (notmuch-show-set-tags new-tags
 
-(defun notmuch-show-remove-tag (rest toremove)
-  Remove a tag from the current message.
-  (interactive
-   (list (notmuch-select-tag-with-completion
- Tag to remove:  (notmuch-show-get-message-id
+(defun notmuch-show-tag (optional initial-input)
+  Change tags for the current message, read input from the minibuffer.
+  (interactive)
+  (let ((tag-changes (notmuch-read-tag-changes
+ initial-input (notmuch-show-get-message-id
+(apply 'notmuch-show-tag-message tag-changes)))
 
-  (let* ((current-tags (notmuch-show-get-tags))
-(new-tags (notmuch-show-del-tags-worker current-tags toremove)))
+(defun notmuch-show-add-tag ()
+  Same as `notmuch-show-tag' but sets initial input to '+'.
+  (interactive)
+  (notmuch-show-tag +))
 
-(unless (equal current-tags new-tags)
-  (apply 'notmuch-tag (notmuch-show-get-message-id)
-(mapcar (lambda (s) (concat - s)) toremove))
-  (notmuch-show-set-tags new-tags
+(defun notmuch-show-remove-tag ()
+  Same as `notmuch-show-tag' but sets initial input to '-'.
+  (interactive)
+  (notmuch-show-tag -))
 
 (defun notmuch-show-toggle-headers ()
   Toggle the visibility of the current message headers.
@@ -1587,10 +1569,8 @@ argument, hide all of the messages.
 If the remove switch is given, tags will be removed instead of
 added.
   (goto-char (point-min))
-  (let ((tag-function (if remove
- 'notmuch-show-remove-tag
-   'notmuch-show-add-tag)))
-(loop do (funcall tag-function tag)
+  (let ((op (if remove - +)))
+(loop do (notmuch-show-tag-message (concat op tag))
  until 

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

2012-02-04 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 5980fea..1b472dd 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 (optional 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 (optional 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 rest 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 optional prefixes rest 
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 tab
-   ;; 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 (optional initial-input rest 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 tab
+;; 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 current thread

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

2012-02-04 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 256a738..b74cfa9 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:ddd65cda0911171950o4eea4389v86de9525e4605...@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@example '[subject]=Message with .. in Message-Id'
 test_emacs '(notmuch-search id:\123..456@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@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@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

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


[PATCH v5 06/12] emacs: rename `notmuch-search-operate-all' to `notmuch-search-tag-all'

2012-02-04 Thread Dmitry Kurochkin
`Notmuch-search-tag-all' is more clear and consistent with other
tagging function names.
---
 emacs/notmuch.el |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 1b472dd..1f351a5 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -270,7 +270,7 @@ For a mouse binding, return nil.
 (define-key map t 'notmuch-search-filter-by-tag)
 (define-key map f 'notmuch-search-filter)
 (define-key map [mouse-1] 'notmuch-search-show-thread)
-(define-key map * 'notmuch-search-operate-all)
+(define-key map * 'notmuch-search-tag-all)
 (define-key map a 'notmuch-search-archive-thread)
 (define-key map - 'notmuch-search-remove-tag)
 (define-key map + 'notmuch-search-add-tag)
@@ -419,7 +419,7 @@ any tags).
 Pressing \\[notmuch-search-show-thread] on any line displays that thread. The 
'\\[notmuch-search-add-tag]' and '\\[notmuch-search-remove-tag]'
 keys can be used to add or remove tags from a thread. The 
'\\[notmuch-search-archive-thread]' key
 is a convenience for archiving a thread (removing the \inbox\
-tag). The '\\[notmuch-search-operate-all]' key can be used to add or remove a 
tag from all
+tag). The '\\[notmuch-search-tag-all]' key can be used to add or remove a tag 
from all
 threads in the current buffer.
 
 Other useful commands are '\\[notmuch-search-filter]' for filtering the 
current search
@@ -876,7 +876,7 @@ non-authors is found, assume that all of the authors match.
  (goto-char found-target)))
   (delete-process proc
 
-(defun notmuch-search-operate-all (rest actions)
+(defun notmuch-search-tag-all (rest actions)
   Add/remove tags from all matching messages.
 
 This command adds or removes tags from all messages matching the
-- 
1.7.9

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


[PATCH v5 08/12] emacs: separate history for operations which accept single and multiple tags

2012-02-04 Thread Dmitry Kurochkin
Some tag-related operations accept a single tag without prefix
(`notmuch-select-tag-with-completion'), others accept multiple tags
prefixed with '+' or '-' (`notmuch-read-tag-changes').  Before the
change, both functions used a single default minibuffer history.  This
is inconvenient because you have to skip options with incompatible
format when going through the history.  The patch adds separate
history lists for the two functions.  Note that functions that accept
the same input format (e.g. +, -, *) share the history list as
before.
---
 emacs/notmuch.el |   13 +++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 1f351a5..862d9e8 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -76,6 +76,14 @@ For example:
 (defvar notmuch-query-history nil
   Variable to store minibuffer history for notmuch queries)
 
+(defvar notmuch-select-tag-history nil
+  Variable to store minibuffer history for
+`notmuch-select-tag-with-completion' function.)
+
+(defvar notmuch-read-tag-changes-history nil
+  Variable to store minibuffer history for
+`notmuch-read-tag-changes' function.)
+
 (defun notmuch-tag-completions (optional search-terms)
   (split-string
(with-output-to-string
@@ -86,7 +94,7 @@ For example:
 
 (defun notmuch-select-tag-with-completion (prompt rest search-terms)
   (let ((tag-list (notmuch-tag-completions search-terms)))
-(completing-read prompt tag-list)))
+(completing-read prompt tag-list nil nil nil 'notmuch-select-tag-history)))
 
 (defun notmuch-read-tag-changes (optional initial-input rest search-terms)
   (let* ((all-tag-list (notmuch-tag-completions))
@@ -106,7 +114,8 @@ For example:
(define-key map   'self-insert-command)
map)))
 (delete  (completing-read-multiple Tags (+add -drop): 
-   tag-list nil nil initial-input
+   tag-list nil nil initial-input
+   'notmuch-read-tag-changes-history
 
 (defun notmuch-update-tags (tags tag-changes)
   Return a copy of TAGS with additions and removals from TAG-CHANGES.
-- 
1.7.9

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


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

2012-02-04 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 862d9e8..b06d8a1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -550,7 +550,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

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


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

2012-02-04 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 b06d8a1..0ffdf9c 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -548,15 +548,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

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


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

2012-02-04 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 0ffdf9c..8250961 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -537,25 +537,26 @@ and will also appear in a buffer named \*Notmuch 
errors*\.
(error (buffer-substring beg end))
))
 
-(defun notmuch-tag (query rest tags)
-  Add/remove tags in TAGS to messages matching QUERY.
+(defun notmuch-tag (query rest 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
@@ -615,26 +616,26 @@ the messages that were tagged
(forward-line 1))
   output)))
 
-(defun notmuch-search-tag-thread (rest tags)
+(defun notmuch-search-tag-thread (rest 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 rest tags)
+(defun notmuch-search-tag-region (beg end rest 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 (optional initial-input)
@@ -885,7 +886,7 @@ non-authors is found, assume that all of the authors match.
  (goto-char found-target)))
   (delete-process proc
 
-(defun notmuch-search-tag-all (rest actions)
+(defun notmuch-search-tag-all (rest tag-changes)
   Add/remove tags from all matching messages.
 
 This command adds or removes tags from all messages matching the
@@ -897,7 +898,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

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


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

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

diff --git a/NEWS b/NEWS
index 5c5b645..f449fba 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

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