unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [RFC PATCH 1/3] cli: cosmetic style cleanup
@ 2013-03-02 19:55 Jani Nikula
  2013-03-02 19:55 ` [RFC PATCH 2/3] cli: add reply.honor_followup_to configuration option Jani Nikula
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jani Nikula @ 2013-03-02 19:55 UTC (permalink / raw)
  To: notmuch

---
 notmuch-config.c |   13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/notmuch-config.c b/notmuch-config.c
index b5c2066..45b4c0e 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -398,39 +398,28 @@ notmuch_config_open (void *ctx,
      * the configuration file, we add some comments to help the user
      * understand what can be done. */
     if (is_new)
-    {
 	g_key_file_set_comment (config->key_file, NULL, NULL,
 				toplevel_config_comment, NULL);
-    }
 
     if (! file_had_database_group)
-    {
 	g_key_file_set_comment (config->key_file, "database", NULL,
 				database_config_comment, NULL);
-    }
 
     if (! file_had_new_group)
-    {
 	g_key_file_set_comment (config->key_file, "new", NULL,
 				new_config_comment, NULL);
-    }
 
     if (! file_had_user_group)
-    {
 	g_key_file_set_comment (config->key_file, "user", NULL,
 				user_config_comment, NULL);
-    }
 
     if (! file_had_maildir_group)
-    {
 	g_key_file_set_comment (config->key_file, "maildir", NULL,
 				maildir_config_comment, NULL);
-    }
 
-    if (! file_had_search_group) {
+    if (! file_had_search_group)
 	g_key_file_set_comment (config->key_file, "search", NULL,
 				search_config_comment, NULL);
-    }
 
     if (is_new_ret)
 	*is_new_ret = is_new;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC PATCH 2/3] cli: add reply.honor_followup_to configuration option
  2013-03-02 19:55 [RFC PATCH 1/3] cli: cosmetic style cleanup Jani Nikula
@ 2013-03-02 19:55 ` Jani Nikula
  2013-03-02 19:55 ` [RFC PATCH 3/3] cli: support Mail-Followup-To: in notmuch reply Jani Nikula
  2013-03-29 14:13 ` [RFC PATCH 1/3] cli: cosmetic style cleanup David Bremner
  2 siblings, 0 replies; 7+ messages in thread
From: Jani Nikula @ 2013-03-02 19:55 UTC (permalink / raw)
  To: notmuch

The reply.honor_followup_to configuration option determines whether
notmuch reply takes into account the Mail-Followup-To: header in
incoming messages.
---
 notmuch-client.h |    7 +++++++
 notmuch-config.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

diff --git a/notmuch-client.h b/notmuch-client.h
index 5f28836..54df811 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -304,6 +304,13 @@ notmuch_config_set_new_ignore (notmuch_config_t *config,
 			       size_t length);
 
 notmuch_bool_t
+notmuch_config_get_reply_honor_followup_to (notmuch_config_t *config);
+
+void
+notmuch_config_set_reply_honor_followup_to (notmuch_config_t *config,
+					    notmuch_bool_t honor_followup_to);
+
+notmuch_bool_t
 notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config);
 
 void
diff --git a/notmuch-config.c b/notmuch-config.c
index 45b4c0e..69c4bee 100644
--- a/notmuch-config.c
+++ b/notmuch-config.c
@@ -53,6 +53,17 @@ static const char new_config_comment[] =
     "\t	names will be ignored, independent of its depth/location\n"
     "\t	in the mail store.\n";
 
+static const char reply_config_comment[] =
+    " Configuration for \"notmuch reply\"\n"
+    "\n"
+    " The following option is supported here:\n"
+    "\n"
+    "\thonor_followup_to	Valid values are true and false.\n"
+    "\n"
+    "\tIf true, \"notmuch reply\" will honor the \"Mail-Followup-To:\""
+    "\theader in incoming messages. (This will not generate the headers"
+    "\tto outgoing messages.)\n";
+
 static const char user_config_comment[] =
     " User configuration\n"
     "\n"
@@ -114,6 +125,7 @@ struct _notmuch_config {
     size_t new_tags_length;
     const char **new_ignore;
     size_t new_ignore_length;
+    notmuch_bool_t reply_honor_followup_to;
     notmuch_bool_t maildir_synchronize_flags;
     const char **search_exclude_tags;
     size_t search_exclude_tags_length;
@@ -240,6 +252,7 @@ notmuch_config_open (void *ctx,
     char *notmuch_config_env = NULL;
     int file_had_database_group;
     int file_had_new_group;
+    int file_had_reply_group;
     int file_had_user_group;
     int file_had_maildir_group;
     int file_had_search_group;
@@ -275,6 +288,7 @@ notmuch_config_open (void *ctx,
     config->new_tags_length = 0;
     config->new_ignore = NULL;
     config->new_ignore_length = 0;
+    config->reply_honor_followup_to = FALSE;
     config->maildir_synchronize_flags = TRUE;
     config->search_exclude_tags = NULL;
     config->search_exclude_tags_length = 0;
@@ -319,6 +333,7 @@ notmuch_config_open (void *ctx,
     file_had_database_group = g_key_file_has_group (config->key_file,
 						    "database");
     file_had_new_group = g_key_file_has_group (config->key_file, "new");
+    file_had_reply_group = g_key_file_has_group (config->key_file, "reply");
     file_had_user_group = g_key_file_has_group (config->key_file, "user");
     file_had_maildir_group = g_key_file_has_group (config->key_file, "maildir");
     file_had_search_group = g_key_file_has_group (config->key_file, "search");
@@ -386,6 +401,15 @@ notmuch_config_open (void *ctx,
     }
 
     error = NULL;
+    config->reply_honor_followup_to =
+	g_key_file_get_boolean (config->key_file,
+				"reply", "honor_followup_to", &error);
+    if (error) {
+	notmuch_config_set_reply_honor_followup_to (config, FALSE);
+	g_error_free (error);
+    }
+
+    error = NULL;
     config->maildir_synchronize_flags =
 	g_key_file_get_boolean (config->key_file,
 				"maildir", "synchronize_flags", &error);
@@ -409,6 +433,10 @@ notmuch_config_open (void *ctx,
 	g_key_file_set_comment (config->key_file, "new", NULL,
 				new_config_comment, NULL);
 
+    if (! file_had_reply_group)
+	g_key_file_set_comment (config->key_file, "reply", NULL,
+				reply_config_comment, NULL);
+
     if (! file_had_user_group)
 	g_key_file_set_comment (config->key_file, "user", NULL,
 				user_config_comment, NULL);
@@ -868,6 +896,21 @@ notmuch_config_command (void *ctx, int argc, char *argv[])
 }
 
 notmuch_bool_t
+notmuch_config_get_reply_honor_followup_to (notmuch_config_t *config)
+{
+    return config->reply_honor_followup_to;
+}
+
+void
+notmuch_config_set_reply_honor_followup_to (notmuch_config_t *config,
+					    notmuch_bool_t honor_followup_to)
+{
+    g_key_file_set_boolean (config->key_file,
+			    "reply", "honor_followup_to", honor_followup_to);
+    config->reply_honor_followup_to = honor_followup_to;
+}
+
+notmuch_bool_t
 notmuch_config_get_maildir_synchronize_flags (notmuch_config_t *config)
 {
     return config->maildir_synchronize_flags;
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC PATCH 3/3] cli: support Mail-Followup-To: in notmuch reply
  2013-03-02 19:55 [RFC PATCH 1/3] cli: cosmetic style cleanup Jani Nikula
  2013-03-02 19:55 ` [RFC PATCH 2/3] cli: add reply.honor_followup_to configuration option Jani Nikula
@ 2013-03-02 19:55 ` Jani Nikula
  2013-03-03  1:07   ` Peter Wang
  2013-03-29 14:13 ` [RFC PATCH 1/3] cli: cosmetic style cleanup David Bremner
  2 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2013-03-02 19:55 UTC (permalink / raw)
  To: notmuch

Use Mail-Followup-To header to determine recipients according to
http://cr.yp.to/proto/replyto.html if configured and present in the
message being replied to.
---
 notmuch-reply.c |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 22c58ff..604691a 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -324,6 +324,7 @@ add_recipients_from_message (GMimeMessage *reply,
 	{ "bcc",        NULL, GMIME_RECIPIENT_TYPE_BCC }
     };
     const char *from_addr = NULL;
+    const char *recipients;
     unsigned int i;
     unsigned int n = 0;
 
@@ -343,9 +344,29 @@ add_recipients_from_message (GMimeMessage *reply,
 	reply_to_map[0].fallback = NULL;
     }
 
-    for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
-	const char *recipients;
+    /* Use Mail-Followup-To header to determine recipients according
+     * to http://cr.yp.to/proto/replyto.html if configured and present
+     * in the message being replied to.
+     */
+    if (reply_all && notmuch_config_get_reply_honor_followup_to (config)) {
+	recipients = notmuch_message_get_header (message, "mail-followup-to");
+	if (recipients && *recipients) {
+	    n = scan_address_string (recipients, config, reply,
+				     GMIME_RECIPIENT_TYPE_TO, &from_addr);
+	    if (n) {
+		/* Same rationale as in the loop below. */
+		reply = NULL;
+
+		/* From address and some recipients are enough, bail out. */
+		if (from_addr)
+		    return from_addr;
+
+		/* Else need to find from address in other headers. */
+	    }
+	}
+    }
 
+    for (i = 0; i < ARRAY_SIZE (reply_to_map); i++) {
 	recipients = notmuch_message_get_header (message,
 						 reply_to_map[i].header);
 	if ((recipients == NULL || recipients[0] == '\0') && reply_to_map[i].fallback)
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 3/3] cli: support Mail-Followup-To: in notmuch reply
  2013-03-02 19:55 ` [RFC PATCH 3/3] cli: support Mail-Followup-To: in notmuch reply Jani Nikula
@ 2013-03-03  1:07   ` Peter Wang
  2013-03-03  9:56     ` Jani Nikula
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Wang @ 2013-03-03  1:07 UTC (permalink / raw)
  To: Jani Nikula; +Cc: notmuch

On Sat,  2 Mar 2013 21:55:21 +0200, Jani Nikula <jani@nikula.org> wrote:
> Use Mail-Followup-To header to determine recipients according to
> http://cr.yp.to/proto/replyto.html if configured and present in the
> message being replied to.

I would like to see an option to --reply-to=list that, as far as
possible, does the right thing.  If we had that, do we need
reply.honor_followup_to?

Peter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 3/3] cli: support Mail-Followup-To: in notmuch reply
  2013-03-03  1:07   ` Peter Wang
@ 2013-03-03  9:56     ` Jani Nikula
  2013-03-06 11:08       ` Peter Wang
  0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2013-03-03  9:56 UTC (permalink / raw)
  To: Peter Wang; +Cc: notmuch

On Sun, 03 Mar 2013, Peter Wang <novalazy@gmail.com> wrote:
> On Sat,  2 Mar 2013 21:55:21 +0200, Jani Nikula <jani@nikula.org> wrote:
>> Use Mail-Followup-To header to determine recipients according to
>> http://cr.yp.to/proto/replyto.html if configured and present in the
>> message being replied to.
>
> I would like to see an option to --reply-to=list that, as far as
> possible, does the right thing.  If we had that, do we need
> reply.honor_followup_to?

If you look at http://cr.yp.to/proto/replyto.html, it talks about *two*
response functions, which correspond to our --reply-to=sender and
--reply-to=all. The idea is to amend reply-all to honor Mail-Followup-To
header if it is present in the mail being replied to. I don't think the
interface should be more complicated than that.

I have added the reply.honor_followup_to configuration because, although
widely used, it's not a standard, and therefore some people might not
like to respect that. Although I'd argue if the sender of the message
has added that header, it's the sender's wish it should be respected.

If people think our reply-all should always and unconditionally respect
Mail-Followup-To if it's present, I'd be happy to throw out the config
option. It's ugly.

BR,
Jani.


PS. Please note that this is only the part that supports the
Mail-Followup-To header when replying to incoming mail that has it;
adding it to outgoing mail is beyond the scope here.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 3/3] cli: support Mail-Followup-To: in notmuch reply
  2013-03-03  9:56     ` Jani Nikula
@ 2013-03-06 11:08       ` Peter Wang
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Wang @ 2013-03-06 11:08 UTC (permalink / raw)
  To: Jani Nikula; +Cc: notmuch

On Sun, 03 Mar 2013 11:56:00 +0200, Jani Nikula <jani@nikula.org> wrote:
> I have added the reply.honor_followup_to configuration because, although
> widely used, it's not a standard, and therefore some people might not
> like to respect that. Although I'd argue if the sender of the message
> has added that header, it's the sender's wish it should be respected.
> 
> If people think our reply-all should always and unconditionally respect
> Mail-Followup-To if it's present, I'd be happy to throw out the config
> option. It's ugly.

How about making it it optional on the command-line rather than through
configuration?  Then you don't lose the functionality where you can
initiate a reply to all visible From/To/Cc addresses (ready for pruning),
regardless of the value of some header you probably don't even see, even
if typically you *do* want to respect that header.

(Bringing us back to the three reply functions.)

Peter

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 1/3] cli: cosmetic style cleanup
  2013-03-02 19:55 [RFC PATCH 1/3] cli: cosmetic style cleanup Jani Nikula
  2013-03-02 19:55 ` [RFC PATCH 2/3] cli: add reply.honor_followup_to configuration option Jani Nikula
  2013-03-02 19:55 ` [RFC PATCH 3/3] cli: support Mail-Followup-To: in notmuch reply Jani Nikula
@ 2013-03-29 14:13 ` David Bremner
  2 siblings, 0 replies; 7+ messages in thread
From: David Bremner @ 2013-03-29 14:13 UTC (permalink / raw)
  To: Jani Nikula, notmuch




This doesn't apply anymore. Also, the commit message could be a bit more
specific.

d

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-03-29 14:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-02 19:55 [RFC PATCH 1/3] cli: cosmetic style cleanup Jani Nikula
2013-03-02 19:55 ` [RFC PATCH 2/3] cli: add reply.honor_followup_to configuration option Jani Nikula
2013-03-02 19:55 ` [RFC PATCH 3/3] cli: support Mail-Followup-To: in notmuch reply Jani Nikula
2013-03-03  1:07   ` Peter Wang
2013-03-03  9:56     ` Jani Nikula
2013-03-06 11:08       ` Peter Wang
2013-03-29 14:13 ` [RFC PATCH 1/3] cli: cosmetic style cleanup David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).