[PATCH 3/4] cli: add support for replying just to the sender in "notmuch reply"
Add new option --no-reply-all to "notmuch reply" to reply just to the sender instead of sender and all recipients. Signed-off-by: Jani Nikula --- notmuch-reply.c | 52 1 files changed, 32 insertions(+), 20 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index 000f6da..57458ec 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -170,7 +170,7 @@ address_is_users (const char *address, notmuch_config_t *config) /* 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'. + * address of 'type', if 'add' is true. * * The first address encountered that *is* the user's address will be * returned, (otherwise NULL is returned). @@ -179,7 +179,8 @@ static const char * add_recipients_for_address_list (GMimeMessage *message, notmuch_config_t *config, GMimeRecipientType type, -InternetAddressList *list) +InternetAddressList *list, +notmuch_bool_t add) { InternetAddress *address; int i; @@ -197,7 +198,7 @@ add_recipients_for_address_list (GMimeMessage *message, continue; add_recipients_for_address_list (message, config, -type, group_list); +type, group_list, add); } else { InternetAddressMailbox *mailbox; const char *name; @@ -211,7 +212,7 @@ add_recipients_for_address_list (GMimeMessage *message, if (address_is_users (addr, config)) { if (ret == NULL) ret = addr; - } else { + } else if (add) { g_mime_message_add_recipient (message, type, name, addr); } } @@ -222,7 +223,7 @@ add_recipients_for_address_list (GMimeMessage *message, /* 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'. + * an address of 'type', if 'add' is true. * * The first address encountered that *is* the user's address will be * returned, (otherwise NULL is returned). @@ -231,7 +232,8 @@ static const char * add_recipients_for_string (GMimeMessage *message, notmuch_config_t *config, GMimeRecipientType type, - const char *recipients) + const char *recipients, + notmuch_bool_t add) { InternetAddressList *list; @@ -242,7 +244,7 @@ add_recipients_for_string (GMimeMessage *message, if (list == NULL) return NULL; -return add_recipients_for_address_list (message, config, type, list); +return add_recipients_for_address_list (message, config, type, list, add); } /* Does the address in the Reply-To header of 'message' already appear @@ -284,7 +286,9 @@ reply_to_header_is_redundant (notmuch_message_t *message) return 0; } -/* Augments the recipients of reply from the headers of message. +/* Augments the recipients of reply from the headers of message. If 'reply_all' + * is true, use sender and all recipients, otherwise use just the sender + * ("reply-to" or "from" headers). * * If any of the user's addresses were found in these headers, the first * of these returned, otherwise NULL is returned. @@ -292,17 +296,19 @@ reply_to_header_is_redundant (notmuch_message_t *message) static const char * add_recipients_from_message (GMimeMessage *reply, notmuch_config_t *config, -notmuch_message_t *message) +notmuch_message_t *message, +notmuch_bool_t reply_all) { struct { const char *header; const char *fallback; GMimeRecipientType recipient_type; + notmuch_bool_t always; /* use entry when not reply_all */ } reply_to_map[] = { - { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO }, - { "to", NULL, GMIME_RECIPIENT_TYPE_TO }, - { "cc", NULL, GMIME_RECIPIENT_TYPE_CC }, - { "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC } + { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO, TRUE }, + { "to", NULL, GMIME_RECIPIENT_TYPE_TO, FALSE }, + { "cc", NULL, GMIME_RECIPIENT_TYPE_CC, FALSE }, + { "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC, FALSE } }; const char *from_addr = NULL; unsigned int i; @@ -334,7 +340,8 @@ add_recipients_from_message (GMimeMessage *reply, addr = add_recipients_for_string (reply, config, reply_to_map[i].recipient_type, - recipients); +
[PATCH 3/4] cli: add support for replying just to the sender in "notmuch reply"
Add new option --no-reply-all to "notmuch reply" to reply just to the sender instead of sender and all recipients. Signed-off-by: Jani Nikula --- notmuch-reply.c | 52 1 files changed, 32 insertions(+), 20 deletions(-) diff --git a/notmuch-reply.c b/notmuch-reply.c index 000f6da..57458ec 100644 --- a/notmuch-reply.c +++ b/notmuch-reply.c @@ -170,7 +170,7 @@ address_is_users (const char *address, notmuch_config_t *config) /* 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'. + * address of 'type', if 'add' is true. * * The first address encountered that *is* the user's address will be * returned, (otherwise NULL is returned). @@ -179,7 +179,8 @@ static const char * add_recipients_for_address_list (GMimeMessage *message, notmuch_config_t *config, GMimeRecipientType type, -InternetAddressList *list) +InternetAddressList *list, +notmuch_bool_t add) { InternetAddress *address; int i; @@ -197,7 +198,7 @@ add_recipients_for_address_list (GMimeMessage *message, continue; add_recipients_for_address_list (message, config, -type, group_list); +type, group_list, add); } else { InternetAddressMailbox *mailbox; const char *name; @@ -211,7 +212,7 @@ add_recipients_for_address_list (GMimeMessage *message, if (address_is_users (addr, config)) { if (ret == NULL) ret = addr; - } else { + } else if (add) { g_mime_message_add_recipient (message, type, name, addr); } } @@ -222,7 +223,7 @@ add_recipients_for_address_list (GMimeMessage *message, /* 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'. + * an address of 'type', if 'add' is true. * * The first address encountered that *is* the user's address will be * returned, (otherwise NULL is returned). @@ -231,7 +232,8 @@ static const char * add_recipients_for_string (GMimeMessage *message, notmuch_config_t *config, GMimeRecipientType type, - const char *recipients) + const char *recipients, + notmuch_bool_t add) { InternetAddressList *list; @@ -242,7 +244,7 @@ add_recipients_for_string (GMimeMessage *message, if (list == NULL) return NULL; -return add_recipients_for_address_list (message, config, type, list); +return add_recipients_for_address_list (message, config, type, list, add); } /* Does the address in the Reply-To header of 'message' already appear @@ -284,7 +286,9 @@ reply_to_header_is_redundant (notmuch_message_t *message) return 0; } -/* Augments the recipients of reply from the headers of message. +/* Augments the recipients of reply from the headers of message. If 'reply_all' + * is true, use sender and all recipients, otherwise use just the sender + * ("reply-to" or "from" headers). * * If any of the user's addresses were found in these headers, the first * of these returned, otherwise NULL is returned. @@ -292,17 +296,19 @@ reply_to_header_is_redundant (notmuch_message_t *message) static const char * add_recipients_from_message (GMimeMessage *reply, notmuch_config_t *config, -notmuch_message_t *message) +notmuch_message_t *message, +notmuch_bool_t reply_all) { struct { const char *header; const char *fallback; GMimeRecipientType recipient_type; + notmuch_bool_t always; /* use entry when not reply_all */ } reply_to_map[] = { - { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO }, - { "to", NULL, GMIME_RECIPIENT_TYPE_TO }, - { "cc", NULL, GMIME_RECIPIENT_TYPE_CC }, - { "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC } + { "reply-to", "from", GMIME_RECIPIENT_TYPE_TO, TRUE }, + { "to", NULL, GMIME_RECIPIENT_TYPE_TO, FALSE }, + { "cc", NULL, GMIME_RECIPIENT_TYPE_CC, FALSE }, + { "bcc",NULL, GMIME_RECIPIENT_TYPE_BCC, FALSE } }; const char *from_addr = NULL; unsigned int i; @@ -334,7 +340,8 @@ add_recipients_from_message (GMimeMessage *reply, addr = add_recipients_for_string (reply, config, reply_to_map[i].recipient_type, - recipients); +