--- /dev/null
+Return-Path: <bateast@bat.fr.eu.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id BC3AD431FAF\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Mar 2015 06:32:41 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.439\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.439 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438, HTML_MESSAGE=0.001]\r
+ autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id jlZ28vrTL2jq for <notmuch@notmuchmail.org>;\r
+ Wed, 4 Mar 2015 06:32:35 -0800 (PST)\r
+Received: from mx1b.lautre.net (mx1b.lautre.net [80.67.160.72])\r
+ (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 48B23431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Mar 2015 06:32:34 -0800 (PST)\r
+Received: from vm_arch_64.bat.fr.eu.org (97.100.203.77.rev.sfr.net\r
+ [77.203.100.97])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ (Authenticated sender: vm_arch_64@bat.fr.eu.org)\r
+ by mx1b.lautre.net (Postfix) with ESMTPSA id 6B6B27E0D2\r
+ for <notmuch@notmuchmail.org>; Wed, 4 Mar 2015 15:31:20 +0100 (CET)\r
+Received: by vm_arch_64.bat.fr.eu.org (sSMTP sendmail emulation);\r
+ Wed, 04 Mar 2015 15:31:18 +0100\r
+From: Baptiste <bateast@bat.fr.eu.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] Re: Add /renew/ tag to moved/renamed/reflagged messages\r
+In-Reply-To: <87ioegq5ca.fsf@vm_arch_64.bat.fr.eu.org>\r
+Organization: bat.fr.eu.org\r
+References: <87ioegq5ca.fsf@vm_arch_64.bat.fr.eu.org>\r
+User-Agent: Notmuch/0.19+67~g326e188 (http://notmuchmail.org) Emacs/25.0.50.2\r
+ (x86_64-unknown-linux-gnu)\r
+Date: Wed, 04 Mar 2015 15:31:17 +0100\r
+Message-ID: <87fv9kq1fu.fsf@vm_arch_64.bat.fr.eu.org>\r
+MIME-Version: 1.0\r
+Content-Type: multipart/alternative; boundary="=-=-="\r
+X-Mailman-Approved-At: Wed, 04 Mar 2015 12:10:35 -0800\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 04 Mar 2015 14:32:42 -0000\r
+\r
+--=-=-=\r
+Content-Type: text/plain; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+Hi,=20\r
+\r
+> What about another automatic tag to re-add to an existing mail when =3Dno=\r
+tmuch new=3D detect a moved, renamed or reflagged message=C2=A0...\r
+\r
+\r
+the following code sample seems to actually do the job=C2=A0=E2=80=A6\r
+\r
+Best regards,\r
+\r
+--=20\r
+~~^v^~~ Baptiste\r
+\r
+-----\r
+\r
+#+BEGIN_EXAMPLE\r
+5aa6f240a34d28ff3a8f768e399ec3c483961cb2 HEAD renew\r
+Author: Baptiste Fouques <bateast@bat.fr.eu.org>\r
+Date: Wed Mar 4 15:16:20 2015 +0100\r
+\r
+ Add /renew/ tags to moved or reflagged messages\r
+=20=20=20=20\r
+ (message that are added or removed and have database dupplicated id)\r
+\r
+5 files changed, 74 insertions(+), 1 deletion(-)\r
+ doc/man1/notmuch-config.rst | 6 ++++++\r
+ notmuch-client.h | 8 ++++++++\r
+ notmuch-config.c | 25 +++++++++++++++++++++++++\r
+ notmuch-new.c | 21 ++++++++++++++++++++-\r
+ notmuch-setup.c | 15 +++++++++++++++\r
+\r
+ Modified doc/man1/notmuch-config.rst\r
+diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst\r
+index 2676a86..6e58d1e 100644\r
+--- a/doc/man1/notmuch-config.rst\r
++++ b/doc/man1/notmuch-config.rst\r
+@@ -74,6 +74,12 @@ The available configuration items are described below.\r
+=20\r
+ Default: ``unread;inbox``.\r
+=20\r
++ **renew.tags**\r
++ A list of tags that will be added to all moved or re-flagged messa=\r
+ges\r
++ by **notmuch new**.\r
++\r
++ Default: empty list.\r
++\r
+ ,**new.ignore**\r
+ A list of file and directory names, without path, that will not\r
+ be searched for messages by **notmuch new**. All the files and\r
+ Modified notmuch-client.h\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 5e0d475..3bf7f7b 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -309,6 +309,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
+ size_t length);\r
+=20\r
+ const char **\r
++notmuch_config_get_re_new_tags (notmuch_config_t *config,\r
++ size_t *length);\r
++void\r
++notmuch_config_set_re_new_tags (notmuch_config_t *config,\r
++ const char *new_tags[],\r
++ size_t length);\r
++\r
++const char **\r
+ notmuch_config_get_new_ignore (notmuch_config_t *config,\r
+ size_t *length);\r
+=20\r
+ Modified notmuch-config.c\r
+diff --git a/notmuch-config.c b/notmuch-config.c\r
+index a564bca..f7f787e 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -113,6 +113,8 @@ struct _notmuch_config {\r
+ size_t user_other_email_length;\r
+ const char **new_tags;\r
+ size_t new_tags_length;\r
++ const char **re_new_tags;\r
++ size_t re_new_tags_length;\r
+ const char **new_ignore;\r
+ size_t new_ignore_length;\r
+ notmuch_bool_t maildir_synchronize_flags;\r
+@@ -272,6 +274,8 @@ notmuch_config_open (void *ctx,\r
+ config->user_other_email_length =3D 0;\r
+ config->new_tags =3D NULL;\r
+ config->new_tags_length =3D 0;\r
++ config->re_new_tags =3D NULL;\r
++ config->re_new_tags_length =3D 0;\r
+ config->new_ignore =3D NULL;\r
+ config->new_ignore_length =3D 0;\r
+ config->maildir_synchronize_flags =3D TRUE;\r
+@@ -384,6 +388,10 @@ notmuch_config_open (void *ctx,\r
+ notmuch_config_set_new_tags (config, tags, 2);\r
+ }\r
+=20\r
++ if (notmuch_config_get_re_new_tags (config, &tmp) =3D=3D NULL) {\r
++ notmuch_config_set_re_new_tags (config, NULL, 0);\r
++ }\r
++\r
+ if (notmuch_config_get_new_ignore (config, &tmp) =3D=3D NULL) {\r
+ notmuch_config_set_new_ignore (config, NULL, 0);\r
+ }\r
+@@ -639,6 +647,14 @@ notmuch_config_get_new_tags (notmuch_config_t *config,=\r
+ size_t *length)\r
+ }\r
+=20\r
+ const char **\r
++notmuch_config_get_re_new_tags (notmuch_config_t *config, size_t *length)\r
++{\r
++ return _config_get_list (config, "renew", "tags",\r
++ &(config->re_new_tags),\r
++ &(config->re_new_tags_length), length);\r
++}\r
++\r
++const char **\r
+ notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length)\r
+ {\r
+ return _config_get_list (config, "new", "ignore",\r
+@@ -665,6 +681,15 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
+ }\r
+=20\r
+ void\r
++notmuch_config_set_re_new_tags (notmuch_config_t *config,\r
++ const char *list[],\r
++ size_t length)\r
++{\r
++ _config_set_list (config, "renew", "tags", list, length,\r
++ &(config->re_new_tags));\r
++}\r
++\r
++void\r
+ notmuch_config_set_new_ignore (notmuch_config_t *config,\r
+ const char *list[],\r
+ size_t length)\r
+ Modified notmuch-new.c\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index ddf42c1..1dc7b07 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -47,6 +47,8 @@ typedef struct {\r
+ notmuch_bool_t debug;\r
+ const char **new_tags;\r
+ size_t new_tags_length;\r
++ const char **re_new_tags;\r
++ size_t re_new_tags_length;\r
+ const char **new_ignore;\r
+ size_t new_ignore_length;\r
+=20\r
+@@ -274,6 +276,8 @@ add_file (notmuch_database_t *notmuch, const char *file=\r
+name,\r
+ break;\r
+ /* Non-fatal issues (go on to next file). */\r
+ case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
++ for (tag =3D state->re_new_tags; *tag !=3D NULL; tag++)\r
++ notmuch_message_add_tag (message, *tag);\r
+ if (state->synchronize_flags)\r
+ notmuch_message_maildir_flags_to_tags (message);\r
+ break;\r
+@@ -799,6 +803,7 @@ remove_filename (notmuch_database_t *notmuch,\r
+ add_files_state_t *add_files_state)\r
+ {\r
+ notmuch_status_t status;\r
++ const char **tag;\r
+ notmuch_message_t *message;\r
+ status =3D notmuch_database_begin_atomic (notmuch);\r
+ if (status)\r
+@@ -810,7 +815,9 @@ remove_filename (notmuch_database_t *notmuch,\r
+ status =3D notmuch_database_remove_message (notmuch, path);\r
+ if (status =3D=3D NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {\r
+ add_files_state->renamed_messages++;\r
+- if (add_files_state->synchronize_flags =3D=3D TRUE)\r
++ for (tag =3D add_files_state->re_new_tags; *tag !=3D NULL; tag++)\r
++ notmuch_message_add_tag (message, *tag);\r
++ if (add_files_state->synchronize_flags =3D=3D TRUE)\r
+ notmuch_message_maildir_flags_to_tags (message);\r
+ status =3D NOTMUCH_STATUS_SUCCESS;\r
+ } else if (status =3D=3D NOTMUCH_STATUS_SUCCESS) {\r
+@@ -948,6 +955,7 @@ notmuch_new_command (notmuch_config_t *config, int argc=\r
+, char *argv[])\r
+ add_files_state.verbosity =3D VERBOSITY_VERBOSE;\r
+=20\r
+ add_files_state.new_tags =3D notmuch_config_get_new_tags (config, &add=\r
+_files_state.new_tags_length);\r
++ add_files_state.re_new_tags =3D notmuch_config_get_re_new_tags (config=\r
+, &add_files_state.re_new_tags_length);\r
+ add_files_state.new_ignore =3D notmuch_config_get_new_ignore (config, =\r
+&add_files_state.new_ignore_length);\r
+ add_files_state.synchronize_flags =3D notmuch_config_get_maildir_synch=\r
+ronize_flags (config);\r
+ db_path =3D notmuch_config_get_database_path (config);\r
+@@ -962,6 +970,17 @@ notmuch_new_command (notmuch_config_t *config, int arg=\r
+c, char *argv[])\r
+ return EXIT_FAILURE;\r
+ }\r
+ }\r
++ for (i =3D 0; i < add_files_state.re_new_tags_length; i++) {\r
++ const char *error_msg;\r
++\r
++ error_msg =3D illegal_tag (add_files_state.re_new_tags[i], FALSE);\r
++ if (error_msg) {\r
++ fprintf (stderr, "Error: tag '%s' in re_new.tags: %s\n",\r
++ add_files_state.re_new_tags[i], error_msg);\r
++ return EXIT_FAILURE;\r
++ }\r
++ }\r
++\r
+=20\r
+ if (!no_hooks) {\r
+ ret =3D notmuch_run_hook (db_path, "pre-new");\r
+ Modified notmuch-setup.c\r
+diff --git a/notmuch-setup.c b/notmuch-setup.c\r
+index 36a6171..c00516b 100644\r
+--- a/notmuch-setup.c\r
++++ b/notmuch-setup.c\r
+@@ -131,6 +131,8 @@ notmuch_setup_command (notmuch_config_t *config,\r
+ unsigned int i;\r
+ const char **new_tags;\r
+ size_t new_tags_len;\r
++ const char **re_new_tags;\r
++ size_t re_new_tags_len;\r
+ const char **search_exclude_tags;\r
+ size_t search_exclude_tags_len;\r
+=20\r
+@@ -192,6 +194,7 @@ notmuch_setup_command (notmuch_config_t *config,\r
+ }\r
+=20\r
+ new_tags =3D notmuch_config_get_new_tags (config, &new_tags_len);\r
++ re_new_tags =3D notmuch_config_get_re_new_tags (config, &re_new_tags_l=\r
+en);\r
+=20\r
+ printf ("Tags to apply to all new messages (separated by spaces) [");\r
+ print_tag_list (new_tags, new_tags_len);\r
+@@ -206,6 +209,18 @@ notmuch_setup_command (notmuch_config_t *config,\r
+ g_ptr_array_free (tags, TRUE);\r
+ }\r
+=20\r
++ printf ("Tags to apply to all moved or reflagged messages (separated b=\r
+y spaces) [");\r
++ print_tag_list (re_new_tags, re_new_tags_len);\r
++ prompt ("]: ");\r
++\r
++ if (strlen (response)) {\r
++ GPtrArray *tags =3D parse_tag_list (config, response);\r
++\r
++ notmuch_config_set_re_new_tags (config, (const char **) tags->pdata,\r
++ tags->len);\r
++\r
++ g_ptr_array_free (tags, TRUE);\r
++ }\r
+=20\r
+ search_exclude_tags =3D notmuch_config_get_search_exclude_tags (config=\r
+, &search_exclude_tags_len);\r
+#+END_EXAMPLE\r
+\r
+--=-=-=\r
+Content-Type: multipart/related; boundary="==-=-="\r
+\r
+--==-=-=\r
+Content-Type: text/html; charset=utf-8\r
+Content-Transfer-Encoding: quoted-printable\r
+\r
+<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf-8"><d=\r
+iv class=3D"mail" style=3D"font-family: 'Calibri', 'DejaVu Sans';"><p>\r
+Hi,<br />\r
+</p>\r
+\r
+<p>\r
+> What about another automatic tag to re-add to an existing mail when <c=\r
+ode>notmuch new</code> detect a moved, renamed or reflagged message=C2=A0&#=\r
+x2026;<br />\r
+</p>\r
+\r
+\r
+<p>\r
+the following code sample seems to actually do the job=C2=A0=E2=80=A6<br />\r
+</p>\r
+\r
+<p>\r
+Best regards,<br />\r
+</p>\r
+\r
+<p>\r
+–<br />\r
+<code>~^v^~</code> Baptiste<br />\r
+</p>\r
+\r
+<hr />\r
+\r
+<pre style=3D"color: #E6E1DC; background-color: #232323; padding: 0.5em;" c=\r
+lass=3D"example">\r
+5aa6f240a34d28ff3a8f768e399ec3c483961cb2 HEAD renew\r
+Author: Baptiste Fouques <bateast@bat.fr.eu.org>\r
+Date: Wed Mar 4 15:16:20 2015 +0100\r
+\r
+ Add /renew/ tags to moved or reflagged messages\r
+=20=20=20=20\r
+ (message that are added or removed and have database dupplicated id)\r
+\r
+5 files changed, 74 insertions(+), 1 deletion(-)\r
+ doc/man1/notmuch-config.rst | 6 ++++++\r
+ notmuch-client.h | 8 ++++++++\r
+ notmuch-config.c | 25 +++++++++++++++++++++++++\r
+ notmuch-new.c | 21 ++++++++++++++++++++-\r
+ notmuch-setup.c | 15 +++++++++++++++\r
+\r
+ Modified doc/man1/notmuch-config.rst\r
+diff --git a/doc/man1/notmuch-config.rst b/doc/man1/notmuch-config.rst\r
+index 2676a86..6e58d1e 100644\r
+--- a/doc/man1/notmuch-config.rst\r
++++ b/doc/man1/notmuch-config.rst\r
+@@ -74,6 +74,12 @@ The available configuration items are described below.\r
+=20\r
+ Default: ``unread;inbox``.\r
+=20\r
++ **renew.tags**\r
++ A list of tags that will be added to all moved or re-flagged messa=\r
+ges\r
++ by **notmuch new**.\r
++\r
++ Default: empty list.\r
++\r
+ **new.ignore**\r
+ A list of file and directory names, without path, that will not\r
+ be searched for messages by **notmuch new**. All the files and\r
+ Modified notmuch-client.h\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 5e0d475..3bf7f7b 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -309,6 +309,14 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
+ size_t length);\r
+=20\r
+ const char **\r
++notmuch_config_get_re_new_tags (notmuch_config_t *config,\r
++ size_t *length);\r
++void\r
++notmuch_config_set_re_new_tags (notmuch_config_t *config,\r
++ const char *new_tags[],\r
++ size_t length);\r
++\r
++const char **\r
+ notmuch_config_get_new_ignore (notmuch_config_t *config,\r
+ size_t *length);\r
+=20\r
+ Modified notmuch-config.c\r
+diff --git a/notmuch-config.c b/notmuch-config.c\r
+index a564bca..f7f787e 100644\r
+--- a/notmuch-config.c\r
++++ b/notmuch-config.c\r
+@@ -113,6 +113,8 @@ struct _notmuch_config {\r
+ size_t user_other_email_length;\r
+ const char **new_tags;\r
+ size_t new_tags_length;\r
++ const char **re_new_tags;\r
++ size_t re_new_tags_length;\r
+ const char **new_ignore;\r
+ size_t new_ignore_length;\r
+ notmuch_bool_t maildir_synchronize_flags;\r
+@@ -272,6 +274,8 @@ notmuch_config_open (void *ctx,\r
+ config->user_other_email_length =3D 0;\r
+ config->new_tags =3D NULL;\r
+ config->new_tags_length =3D 0;\r
++ config->re_new_tags =3D NULL;\r
++ config->re_new_tags_length =3D 0;\r
+ config->new_ignore =3D NULL;\r
+ config->new_ignore_length =3D 0;\r
+ config->maildir_synchronize_flags =3D TRUE;\r
+@@ -384,6 +388,10 @@ notmuch_config_open (void *ctx,\r
+ notmuch_config_set_new_tags (config, tags, 2);\r
+ }\r
+=20\r
++ if (notmuch_config_get_re_new_tags (config, &tmp) =3D=3D NULL) {\r
++ notmuch_config_set_re_new_tags (config, NULL, 0);\r
++ }\r
++\r
+ if (notmuch_config_get_new_ignore (config, &tmp) =3D=3D NULL) {\r
+ notmuch_config_set_new_ignore (config, NULL, 0);\r
+ }\r
+@@ -639,6 +647,14 @@ notmuch_config_get_new_tags (notmuch_config_t *config,=\r
+ size_t *length)\r
+ }\r
+=20\r
+ const char **\r
++notmuch_config_get_re_new_tags (notmuch_config_t *config, size_t *length)\r
++{\r
++ return _config_get_list (config, "renew", "tags",\r
++ &(config->re_new_tags),\r
++ &(config->re_new_tags_length), length);\r
++}\r
++\r
++const char **\r
+ notmuch_config_get_new_ignore (notmuch_config_t *config, size_t *length)\r
+ {\r
+ return _config_get_list (config, "new", "ignore",\r
+@@ -665,6 +681,15 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
+ }\r
+=20\r
+ void\r
++notmuch_config_set_re_new_tags (notmuch_config_t *config,\r
++ const char *list[],\r
++ size_t length)\r
++{\r
++ _config_set_list (config, "renew", "tags", list, length,\r
++ &(config->re_new_tags));\r
++}\r
++\r
++void\r
+ notmuch_config_set_new_ignore (notmuch_config_t *config,\r
+ const char *list[],\r
+ size_t length)\r
+ Modified notmuch-new.c\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index ddf42c1..1dc7b07 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -47,6 +47,8 @@ typedef struct {\r
+ notmuch_bool_t debug;\r
+ const char **new_tags;\r
+ size_t new_tags_length;\r
++ const char **re_new_tags;\r
++ size_t re_new_tags_length;\r
+ const char **new_ignore;\r
+ size_t new_ignore_length;\r
+=20\r
+@@ -274,6 +276,8 @@ add_file (notmuch_database_t *notmuch, const char *file=\r
+name,\r
+ break;\r
+ /* Non-fatal issues (go on to next file). */\r
+ case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:\r
++ for (tag =3D state->re_new_tags; *tag !=3D NULL; tag++)\r
++ notmuch_message_add_tag (message, *tag);\r
+ if (state->synchronize_flags)\r
+ notmuch_message_maildir_flags_to_tags (message);\r
+ break;\r
+@@ -799,6 +803,7 @@ remove_filename (notmuch_database_t *notmuch,\r
+ add_files_state_t *add_files_state)\r
+ {\r
+ notmuch_status_t status;\r
++ const char **tag;\r
+ notmuch_message_t *message;\r
+ status =3D notmuch_database_begin_atomic (notmuch);\r
+ if (status)\r
+@@ -810,7 +815,9 @@ remove_filename (notmuch_database_t *notmuch,\r
+ status =3D notmuch_database_remove_message (notmuch, path);\r
+ if (status =3D=3D NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) {\r
+ add_files_state->renamed_messages++;\r
+- if (add_files_state->synchronize_flags =3D=3D TRUE)\r
++ for (tag =3D add_files_state->re_new_tags; *tag !=3D NULL; tag++)\r
++ notmuch_message_add_tag (message, *tag);\r
++ if (add_files_state->synchronize_flags =3D=3D TRUE)\r
+ notmuch_message_maildir_flags_to_tags (message);\r
+ status =3D NOTMUCH_STATUS_SUCCESS;\r
+ } else if (status =3D=3D NOTMUCH_STATUS_SUCCESS) {\r
+@@ -948,6 +955,7 @@ notmuch_new_command (notmuch_config_t *config, int argc=\r
+, char *argv[])\r
+ add_files_state.verbosity =3D VERBOSITY_VERBOSE;\r
+=20\r
+ add_files_state.new_tags =3D notmuch_config_get_new_tags (config, &=\r
+;add_files_state.new_tags_length);\r
++ add_files_state.re_new_tags =3D notmuch_config_get_re_new_tags (config=\r
+, &add_files_state.re_new_tags_length);\r
+ add_files_state.new_ignore =3D notmuch_config_get_new_ignore (config, =\r
+&add_files_state.new_ignore_length);\r
+ add_files_state.synchronize_flags =3D notmuch_config_get_maildir_synch=\r
+ronize_flags (config);\r
+ db_path =3D notmuch_config_get_database_path (config);\r
+@@ -962,6 +970,17 @@ notmuch_new_command (notmuch_config_t *config, int arg=\r
+c, char *argv[])\r
+ return EXIT_FAILURE;\r
+ }\r
+ }\r
++ for (i =3D 0; i < add_files_state.re_new_tags_length; i++) {\r
++ const char *error_msg;\r
++\r
++ error_msg =3D illegal_tag (add_files_state.re_new_tags[i], FALSE);\r
++ if (error_msg) {\r
++ fprintf (stderr, "Error: tag '%s' in re_new.tags: %s\n",\r
++ add_files_state.re_new_tags[i], error_msg);\r
++ return EXIT_FAILURE;\r
++ }\r
++ }\r
++\r
+=20\r
+ if (!no_hooks) {\r
+ ret =3D notmuch_run_hook (db_path, "pre-new");\r
+ Modified notmuch-setup.c\r
+diff --git a/notmuch-setup.c b/notmuch-setup.c\r
+index 36a6171..c00516b 100644\r
+--- a/notmuch-setup.c\r
++++ b/notmuch-setup.c\r
+@@ -131,6 +131,8 @@ notmuch_setup_command (notmuch_config_t *config,\r
+ unsigned int i;\r
+ const char **new_tags;\r
+ size_t new_tags_len;\r
++ const char **re_new_tags;\r
++ size_t re_new_tags_len;\r
+ const char **search_exclude_tags;\r
+ size_t search_exclude_tags_len;\r
+=20\r
+@@ -192,6 +194,7 @@ notmuch_setup_command (notmuch_config_t *config,\r
+ }\r
+=20\r
+ new_tags =3D notmuch_config_get_new_tags (config, &new_tags_len);\r
++ re_new_tags =3D notmuch_config_get_re_new_tags (config, &re_new_ta=\r
+gs_len);\r
+=20\r
+ printf ("Tags to apply to all new messages (separated by spaces) [");\r
+ print_tag_list (new_tags, new_tags_len);\r
+@@ -206,6 +209,18 @@ notmuch_setup_command (notmuch_config_t *config,\r
+ g_ptr_array_free (tags, TRUE);\r
+ }\r
+=20\r
++ printf ("Tags to apply to all moved or reflagged messages (separated b=\r
+y spaces) [");\r
++ print_tag_list (re_new_tags, re_new_tags_len);\r
++ prompt ("]: ");\r
++\r
++ if (strlen (response)) {\r
++ GPtrArray *tags =3D parse_tag_list (config, response);\r
++\r
++ notmuch_config_set_re_new_tags (config, (const char **) tags->pdata,\r
++ tags->len);\r
++\r
++ g_ptr_array_free (tags, TRUE);\r
++ }\r
+=20\r
+ search_exclude_tags =3D notmuch_config_get_search_exclude_tags (config=\r
+, &search_exclude_tags_len);\r
+</pre>\r
+</div>\r
+\r
+--==-=-=--\r
+\r
+--=-=-=--\r