[PATCH v5 1/5] cli: slightly refactor "notmuch reply" address scanning functions

2012-01-16 Thread Dmitry Kurochkin
Hello.

Since this patches got in, I have yet to send a single email to the
address(es) I intend to :( I am really used to the bindings and this
change is a pain.  From IRC discussion, it seems like I am not alone
here.

There was a proposal to change reply bindings to 'ra' and 'rs'.  When
'r' is pressed an appropriate help message can be given in the
minibuffer.  I like this proposal.  What do others think?

If others like it, how about reverting to the old bindings until the new
ones are implemented?

Regards,
  Dmitry


[PATCH v5 1/5] cli: slightly refactor "notmuch reply" address scanning functions

2012-01-16 Thread David Edmondson
On Mon, 16 Jan 2012 22:06:15 +0400, Dmitry Kurochkin  wrote:
> Hello.
> 
> Since this patches got in, I have yet to send a single email to the
> address(es) I intend to :( I am really used to the bindings and this
> change is a pain.  From IRC discussion, it seems like I am not alone
> here.
> 
> There was a proposal to change reply bindings to 'ra' and 'rs'.  When
> 'r' is pressed an appropriate help message can be given in the
> minibuffer.  I like this proposal.  What do others think?
> 
> If others like it, how about reverting to the old bindings until the new
> ones are implemented?

I'm inclined to push on for a while and see if it sticks. Previous
experience with this kind of change suggests that it takes a week or so.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: 



[PATCH v5 1/5] cli: slightly refactor "notmuch reply" address scanning functions

2012-01-16 Thread David Bremner
On Mon, 16 Jan 2012 22:06:15 +0400, Dmitry Kurochkin  wrote:
> 
> If others like it, how about reverting to the old bindings until the new
> ones are implemented?
> 

Flip-flopping the bindings will just cause more confusion, in my opinion.

It is easy (and documented in the wiki) to customize the bindings
in your .emacs. 

So as a temporary measure, the latter seems simplest.

d


[PATCH v5 1/5] cli: slightly refactor "notmuch reply" address scanning functions

2012-01-16 Thread Jameson Graef Rollins
On Mon, 16 Jan 2012 22:06:15 +0400, Dmitry Kurochkin  wrote:
> Since this patches got in, I have yet to send a single email to the
> address(es) I intend to :( I am really used to the bindings and this
> change is a pain.  From IRC discussion, it seems like I am not alone
> here.

Yeah, this has bit me too much recently.

> There was a proposal to change reply bindings to 'ra' and 'rs'.  When
> 'r' is pressed an appropriate help message can be given in the
> minibuffer.  I like this proposal.  What do others think?

My first reaction to this proposal was "yuck".  Then I realized it might
just provide that extra split second to think about where you actually
want the reply to go, which might be a good thing.

Otherwise I could live with any option.  I can get used to the new
bindings.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



Re: [PATCH v5 1/5] cli: slightly refactor notmuch reply address scanning functions

2012-01-16 Thread David Bremner
On Mon, 16 Jan 2012 22:06:15 +0400, Dmitry Kurochkin 
dmitry.kuroch...@gmail.com wrote:
 
 If others like it, how about reverting to the old bindings until the new
 ones are implemented?
 

Flip-flopping the bindings will just cause more confusion, in my opinion.

It is easy (and documented in the wiki) to customize the bindings
in your .emacs. 

So as a temporary measure, the latter seems simplest.

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


[PATCH v5 1/5] cli: slightly refactor "notmuch reply" address scanning functions

2012-01-14 Thread Jani Nikula

For those not on IRC:

On Sat, 14 Jan 2012 11:31:16 -0400, David Bremner  wrote:
> This series definitely needs a NEWS item. 

id:"1326559168-29178-1-git-send-email-jani at nikula.org"

> Perhaps some kind soul could add a wiki entry explaining to people how
> to swap the bindings, just in case there people who don't like the
> "one-true-reply-bindings" (cough).

http://notmuchmail.org/emacstips/#index7h2


BR,
Jani.


[PATCH v5 1/5] cli: slightly refactor "notmuch reply" address scanning functions

2012-01-14 Thread Jani Nikula
Slightly refactor "notmuch reply" recipient and user from address scanning
functions in preparation for reply-to-sender feature.

Add support for not adding recipients at all (just scan for user from
address), and returning the number of recipients added.

No externally visible functional changes.

Signed-off-by: Jani Nikula 
---
 notmuch-reply.c |   76 +--
 1 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 000f6da..a8d6a94 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -168,22 +168,29 @@ address_is_users (const char *address, notmuch_config_t 
*config)
 return 0;
 }

-/* For each address in 'list' that is not configured as one of the
- * user's addresses in 'config', add that address to 'message' as an
- * address of 'type'.
+/* Scan addresses in 'list'.
  *
- * The first address encountered that *is* the user's address will be
- * returned, (otherwise NULL is returned).
+ * If 'message' is non-NULL, then for each address in 'list' that is
+ * not configured as one of the user's addresses in 'config', add that
+ * address to 'message' as an address of 'type'.
+ *
+ * If 'user_from' is non-NULL and *user_from is NULL, *user_from will
+ * be set to the first address encountered in 'list' that is the
+ * user's address.
+ *
+ * Return the number of addresses added to 'message'. (If 'message' is
+ * NULL, the function returns 0 by definition.)
  */
-static const char *
-add_recipients_for_address_list (GMimeMessage *message,
-notmuch_config_t *config,
-GMimeRecipientType type,
-InternetAddressList *list)
+static unsigned int
+scan_address_list (InternetAddressList *list,
+  notmuch_config_t *config,
+  GMimeMessage *message,
+  GMimeRecipientType type,
+  const char **user_from)
 {
 InternetAddress *address;
 int i;
-const char *ret = NULL;
+unsigned int n = 0;

 for (i = 0; i < internet_address_list_length (list); i++) {
address = internet_address_list_get_address (list, i);
@@ -196,8 +203,7 @@ add_recipients_for_address_list (GMimeMessage *message,
if (group_list == NULL)
continue;

-   add_recipients_for_address_list (message, config,
-type, group_list);
+   n += scan_address_list (group_list, config, message, type, NULL);
} else {
InternetAddressMailbox *mailbox;
const char *name;
@@ -209,40 +215,41 @@ add_recipients_for_address_list (GMimeMessage *message,
addr = internet_address_mailbox_get_addr (mailbox);

if (address_is_users (addr, config)) {
-   if (ret == NULL)
-   ret = addr;
-   } else {
+   if (user_from && *user_from == NULL)
+   *user_from = addr;
+   } else if (message) {
g_mime_message_add_recipient (message, type, name, addr);
+   n++;
}
}
 }

-return ret;
+return n;
 }

-/* For each address in 'recipients' that is not configured as one of
- * the user's addresses in 'config', add that address to 'message' as
- * an address of 'type'.
+/* Scan addresses in 'recipients'.
  *
- * The first address encountered that *is* the user's address will be
- * returned, (otherwise NULL is returned).
+ * See the documentation of scan_address_list() above. This function
+ * does exactly the same, but converts 'recipients' to an
+ * InternetAddressList first.
  */
-static const char *
-add_recipients_for_string (GMimeMessage *message,
-  notmuch_config_t *config,
-  GMimeRecipientType type,
-  const char *recipients)
+static unsigned int
+scan_address_string (const char *recipients,
+notmuch_config_t *config,
+GMimeMessage *message,
+GMimeRecipientType type,
+const char **user_from)
 {
 InternetAddressList *list;

 if (recipients == NULL)
-   return NULL;
+   return 0;

 list = internet_address_list_parse_string (recipients);
 if (list == NULL)
-   return NULL;
+   return 0;

-return add_recipients_for_address_list (message, config, type, list);
+return scan_address_list (list, config, message, type, user_from);
 }

 /* Does the address in the Reply-To header of 'message' already appear
@@ -324,7 +331,7 @@ add_recipients_from_message (GMimeMessage *reply,
 }

 for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
-   const char *addr, *recipients;
+   const char *recipients;

recipients = notmuch_message_get_header (message,
 reply_to_map[i].header);
@@ -332,11 +339,8 @@ 

[PATCH v5 1/5] cli: slightly refactor "notmuch reply" address scanning functions

2012-01-14 Thread David Bremner
On Sat, 14 Jan 2012 16:46:15 +0200, Jani Nikula  wrote:
> Slightly refactor "notmuch reply" recipient and user from address scanning
> functions in preparation for reply-to-sender feature.
> 

Pushed, bindings change and all.

This series definitely needs a NEWS item. 

Perhaps some kind soul could add a wiki entry explaining to people how
to swap the bindings, just in case there people who don't like the
"one-true-reply-bindings" (cough).

d





[PATCH v5 1/5] cli: slightly refactor notmuch reply address scanning functions

2012-01-14 Thread Jani Nikula
Slightly refactor notmuch reply recipient and user from address scanning
functions in preparation for reply-to-sender feature.

Add support for not adding recipients at all (just scan for user from
address), and returning the number of recipients added.

No externally visible functional changes.

Signed-off-by: Jani Nikula j...@nikula.org
---
 notmuch-reply.c |   76 +--
 1 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 000f6da..a8d6a94 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -168,22 +168,29 @@ address_is_users (const char *address, notmuch_config_t 
*config)
 return 0;
 }
 
-/* For each address in 'list' that is not configured as one of the
- * user's addresses in 'config', add that address to 'message' as an
- * address of 'type'.
+/* Scan addresses in 'list'.
  *
- * The first address encountered that *is* the user's address will be
- * returned, (otherwise NULL is returned).
+ * If 'message' is non-NULL, then for each address in 'list' that is
+ * not configured as one of the user's addresses in 'config', add that
+ * address to 'message' as an address of 'type'.
+ *
+ * If 'user_from' is non-NULL and *user_from is NULL, *user_from will
+ * be set to the first address encountered in 'list' that is the
+ * user's address.
+ *
+ * Return the number of addresses added to 'message'. (If 'message' is
+ * NULL, the function returns 0 by definition.)
  */
-static const char *
-add_recipients_for_address_list (GMimeMessage *message,
-notmuch_config_t *config,
-GMimeRecipientType type,
-InternetAddressList *list)
+static unsigned int
+scan_address_list (InternetAddressList *list,
+  notmuch_config_t *config,
+  GMimeMessage *message,
+  GMimeRecipientType type,
+  const char **user_from)
 {
 InternetAddress *address;
 int i;
-const char *ret = NULL;
+unsigned int n = 0;
 
 for (i = 0; i  internet_address_list_length (list); i++) {
address = internet_address_list_get_address (list, i);
@@ -196,8 +203,7 @@ add_recipients_for_address_list (GMimeMessage *message,
if (group_list == NULL)
continue;
 
-   add_recipients_for_address_list (message, config,
-type, group_list);
+   n += scan_address_list (group_list, config, message, type, NULL);
} else {
InternetAddressMailbox *mailbox;
const char *name;
@@ -209,40 +215,41 @@ add_recipients_for_address_list (GMimeMessage *message,
addr = internet_address_mailbox_get_addr (mailbox);
 
if (address_is_users (addr, config)) {
-   if (ret == NULL)
-   ret = addr;
-   } else {
+   if (user_from  *user_from == NULL)
+   *user_from = addr;
+   } else if (message) {
g_mime_message_add_recipient (message, type, name, addr);
+   n++;
}
}
 }
 
-return ret;
+return n;
 }
 
-/* For each address in 'recipients' that is not configured as one of
- * the user's addresses in 'config', add that address to 'message' as
- * an address of 'type'.
+/* Scan addresses in 'recipients'.
  *
- * The first address encountered that *is* the user's address will be
- * returned, (otherwise NULL is returned).
+ * See the documentation of scan_address_list() above. This function
+ * does exactly the same, but converts 'recipients' to an
+ * InternetAddressList first.
  */
-static const char *
-add_recipients_for_string (GMimeMessage *message,
-  notmuch_config_t *config,
-  GMimeRecipientType type,
-  const char *recipients)
+static unsigned int
+scan_address_string (const char *recipients,
+notmuch_config_t *config,
+GMimeMessage *message,
+GMimeRecipientType type,
+const char **user_from)
 {
 InternetAddressList *list;
 
 if (recipients == NULL)
-   return NULL;
+   return 0;
 
 list = internet_address_list_parse_string (recipients);
 if (list == NULL)
-   return NULL;
+   return 0;
 
-return add_recipients_for_address_list (message, config, type, list);
+return scan_address_list (list, config, message, type, user_from);
 }
 
 /* Does the address in the Reply-To header of 'message' already appear
@@ -324,7 +331,7 @@ add_recipients_from_message (GMimeMessage *reply,
 }
 
 for (i = 0; i  ARRAY_SIZE (reply_to_map); i++) {
-   const char *addr, *recipients;
+   const char *recipients;
 
recipients = notmuch_message_get_header (message,
 reply_to_map[i].header);
@@ 

Re: [PATCH v5 1/5] cli: slightly refactor notmuch reply address scanning functions

2012-01-14 Thread David Bremner
On Sat, 14 Jan 2012 16:46:15 +0200, Jani Nikula j...@nikula.org wrote:
 Slightly refactor notmuch reply recipient and user from address scanning
 functions in preparation for reply-to-sender feature.
 

Pushed, bindings change and all.

This series definitely needs a NEWS item. 

Perhaps some kind soul could add a wiki entry explaining to people how
to swap the bindings, just in case there people who don't like the
one-true-reply-bindings (cough).

d



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


Re: [PATCH v5 1/5] cli: slightly refactor notmuch reply address scanning functions

2012-01-14 Thread Jani Nikula

For those not on IRC:

On Sat, 14 Jan 2012 11:31:16 -0400, David Bremner da...@tethera.net wrote:
 This series definitely needs a NEWS item. 

id:1326559168-29178-1-git-send-email-j...@nikula.org

 Perhaps some kind soul could add a wiki entry explaining to people how
 to swap the bindings, just in case there people who don't like the
 one-true-reply-bindings (cough).

http://notmuchmail.org/emacstips/#index7h2


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