--- /dev/null
+Return-Path: <dme@hotblack-desiato.hh.sledj.net>\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 6B999431FDA\r
+ for <notmuch@notmuchmail.org>; Fri, 2 May 2014 01:23:22 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.379\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.379 tagged_above=-999 required=5\r
+ tests=[NO_DNS_FOR_FROM=0.379] 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 p5KUvIVvvnox for <notmuch@notmuchmail.org>;\r
+ Fri, 2 May 2014 01:23:17 -0700 (PDT)\r
+Received: from disaster-area.hh.sledj.net (disaster-area.hh.sledj.net\r
+ [81.149.164.25])\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 894B1431FAF\r
+ for <notmuch@notmuchmail.org>; Fri, 2 May 2014 01:23:17 -0700 (PDT)\r
+Received: from hotblack-desiato.hh.sledj.net (hotblack-desiato.hh.sledj.net\r
+ [172.16.100.105])\r
+ by disaster-area.hh.sledj.net (Postfix) with ESMTPSA id F07A9501560;\r
+ Fri, 2 May 2014 09:16:11 +0100 (BST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+ id BF3E7103457; Fri, 2 May 2014 09:16:10 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/5] notmuch-new: Allow the tags of new messages to be\r
+ manipulated.\r
+Date: Fri, 2 May 2014 09:15:52 +0100\r
+Message-Id: <1399018555-1994-3-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.9.2\r
+In-Reply-To: <1399018555-1994-1-git-send-email-dme@dme.org>\r
+References: <1399018555-1994-1-git-send-email-dme@dme.org>\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: Fri, 02 May 2014 08:23:22 -0000\r
+\r
+Add support for specifying a set of tags to be added/removed from\r
+messages added to the database by 'notmuch new'. These tags are\r
+addition to those specified in .notmuch-config. They can be used to\r
+override the pre-configured tags (e.g. -inbox).\r
+---\r
+ notmuch-new.c | 5 +++++\r
+ tag-util.c | 20 +++++++++++++++-----\r
+ tag-util.h | 15 +++++++++++++++\r
+ 3 files changed, 35 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index b53401a..855e1e2 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -951,6 +951,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+ add_files_state.tag_ops = tag_op_list_create (config);\r
+ db_path = notmuch_config_get_database_path (config);\r
+ \r
++ /* Add the configured tags to the list applied. */\r
+ for (i = 0; i < new_tags_length; i++) {\r
+ const char *error_msg;\r
+ \r
+@@ -963,6 +964,10 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+ return EXIT_FAILURE;\r
+ }\r
+ \r
++ /* Add any command line tags to the list applied. */\r
++ if (process_tag_command_line (argc - opt_index, &argv[opt_index], add_files_state.tag_ops) < 0)\r
++ return EXIT_FAILURE;\r
++\r
+ if (!no_hooks) {\r
+ ret = notmuch_run_hook (db_path, "pre-new");\r
+ if (ret)\r
+diff --git a/tag-util.c b/tag-util.c\r
+index 343c161..5ad78aa 100644\r
+--- a/tag-util.c\r
++++ b/tag-util.c\r
+@@ -151,11 +151,9 @@ parse_tag_line (void *ctx, char *line,\r
+ return ret;\r
+ }\r
+ \r
+-tag_parse_status_t\r
+-parse_tag_command_line (void *ctx, int argc, char **argv,\r
+- char **query_str, tag_op_list_t *tag_ops)\r
++int\r
++process_tag_command_line (int argc, char **argv, tag_op_list_t *tag_ops)\r
+ {\r
+-\r
+ int i;\r
+ \r
+ for (i = 0; i < argc; i++) {\r
+@@ -173,12 +171,24 @@ parse_tag_command_line (void *ctx, int argc, char **argv,\r
+ msg = illegal_tag (argv[i] + 1, is_remove);\r
+ if (msg) {\r
+ fprintf (stderr, "Error: %s\n", msg);\r
+- return TAG_PARSE_INVALID;\r
++ return -1;\r
+ }\r
+ \r
+ tag_op_list_append (tag_ops, argv[i] + 1, is_remove);\r
+ }\r
+ \r
++ return i;\r
++}\r
++\r
++tag_parse_status_t\r
++parse_tag_command_line (void *ctx, int argc, char **argv,\r
++ char **query_str, tag_op_list_t *tag_ops)\r
++{\r
++ int i = process_tag_command_line (argc, argv, tag_ops);\r
++\r
++ if (i < 0)\r
++ return TAG_PARSE_INVALID;\r
++\r
+ *query_str = query_string_from_args (ctx, argc - i, &argv[i]);\r
+ \r
+ if (*query_str == NULL) {\r
+diff --git a/tag-util.h b/tag-util.h\r
+index 8a4074c..9f2c18c 100644\r
+--- a/tag-util.h\r
++++ b/tag-util.h\r
+@@ -74,6 +74,21 @@ parse_tag_line (void *ctx, char *line,\r
+ \r
+ \r
+ \r
++/* Process a command line of the following format:\r
++ *\r
++ * +<tag>|-<tag> [...] [--]\r
++ *\r
++ * Return the number of tags operations, or -1 for failure to parse.\r
++ *\r
++ * Output Parameters:\r
++ * ops contains a list of tag operations\r
++ *\r
++ * The ops argument is not cleared.\r
++ */\r
++\r
++int\r
++process_tag_command_line (int argc, char **argv, tag_op_list_t *ops);\r
++\r
+ /* Parse a command line of the following format:\r
+ *\r
+ * +<tag>|-<tag> [...] [--] <search-terms>\r
+-- \r
+1.9.2\r
+\r