--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 92CF16DE00BD\r
+ for <notmuch@notmuchmail.org>; Tue, 2 Aug 2016 17:30:46 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.005\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5\r
+ tests=[AWL=-0.006, HEADER_FROM_DIFFERENT_DOMAINS=0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id wB3Uu-mMOK0J for <notmuch@notmuchmail.org>;\r
+ Tue, 2 Aug 2016 17:30:37 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 3C9186DE00B8\r
+ for <notmuch@notmuchmail.org>; Tue, 2 Aug 2016 17:30:36 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2)\r
+ (envelope-from <bremner@tesseract.cs.unb.ca>) id 1bUk5F-0005kk-2L\r
+ for notmuch@notmuchmail.org; Tue, 02 Aug 2016 20:30:53 -0400\r
+Received: (nullmailer pid 12776 invoked by uid 1000);\r
+ Wed, 03 Aug 2016 00:30:32 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: v2 of message properties patches\r
+Date: Wed, 3 Aug 2016 09:30:20 +0900\r
+Message-Id: <1470184228-12517-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.1\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 03 Aug 2016 00:30:46 -0000\r
+\r
+This includes a bunch of whitespace cleanup (enough that the interdiff\r
+is a bit boring/noisy) and\r
+id:1468665174-11929-1-git-send-email-david@tethera.net, as well as\r
+being rebased on master.\r
+\r
+Here is said boring interdiff\r
+\r
+diff --git a/lib/message-property.cc b/lib/message-property.cc\r
+index 4fa6cac..0b13cac 100644\r
+--- a/lib/message-property.cc\r
++++ b/lib/message-property.cc\r
+@@ -86,16 +86,23 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co\r
+ }\r
+ \r
+ notmuch_status_t\r
+-notmuch_message_remove_all_properties (notmuch_message_t *message)\r
++notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key)\r
+ {\r
+ notmuch_status_t status;\r
++ const char * term_prefix;\r
++\r
+ status = _notmuch_database_ensure_writable (_notmuch_message_database (message));\r
+ if (status)\r
+ return status;\r
+ \r
+ _notmuch_message_invalidate_metadata (message, "property");\r
++ if (key)\r
++ term_prefix = talloc_asprintf (message, "%s%s=", _find_prefix ("property"), key);\r
++ else\r
++ term_prefix = _find_prefix ("property");\r
++\r
+ /* XXX better error reporting ? */\r
+- _notmuch_message_remove_terms (message, _find_prefix ("property"));\r
++ _notmuch_message_remove_terms (message, term_prefix);\r
+ \r
+ return NOTMUCH_STATUS_SUCCESS;\r
+ }\r
+diff --git a/lib/notmuch.h b/lib/notmuch.h\r
+index f6bad67..e03a05d 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -1711,6 +1711,9 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co\r
+ /**\r
+ * Remove all (key,value) pairs from the given message.\r
+ *\r
++ * @param[in,out] message message to operate on.\r
++ * @param[in] key key to delete properties for. If NULL, delete\r
++ * properties for all keys\r
+ * @returns\r
+ * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in\r
+ * read-only mode so message cannot be modified.\r
+@@ -1718,7 +1721,7 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co\r
+ *\r
+ */\r
+ notmuch_status_t\r
+-notmuch_message_remove_all_properties (notmuch_message_t *message);\r
++notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key);\r
+ \r
+ /**\r
+ * Opaque message property iterator\r
+diff --git a/notmuch-dump.c b/notmuch-dump.c\r
+index ec82660..e7965ce 100644\r
+--- a/notmuch-dump.c\r
++++ b/notmuch-dump.c\r
+@@ -80,11 +80,11 @@ print_dump_header (gzFile output, int output_format, int include)\r
+ sep = ",";\r
+ }\r
+ if (include & DUMP_INCLUDE_PROPERTIES) {\r
+- gzprintf (output, "%sproperties",sep);\r
++ gzprintf (output, "%sproperties", sep);\r
+ sep = ",";\r
+ }\r
+ if (include & DUMP_INCLUDE_TAGS) {\r
+- gzprintf (output, "%sproperties",sep);\r
++ gzprintf (output, "%sproperties", sep);\r
+ }\r
+ gzputs (output, "\n");\r
+ }\r
+@@ -106,38 +106,38 @@ dump_properties_message (void *ctx,\r
+ return 0;\r
+ }\r
+ \r
+- for (list = notmuch_message_get_properties (message, "", FALSE);\r
+- notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) {\r
+- const char *key, *val;\r
+-\r
+- if (first) {\r
+- if (hex_encode (ctx, message_id, buffer_p, size_p) != HEX_SUCCESS) {\r
+- fprintf (stderr, "Error: failed to hex-encode message-id %s\n", message_id);\r
+- return 1;\r
+- }\r
+- gzprintf (output, "#= %s", *buffer_p);\r
+- first = FALSE;\r
+- }\r
+-\r
+- key = notmuch_message_properties_key (list);\r
+- val = notmuch_message_properties_value (list);\r
+-\r
+- if (hex_encode (ctx, key, buffer_p, size_p) != HEX_SUCCESS) {\r
+- fprintf (stderr, "Error: failed to hex-encode key %s\n", key);\r
+- return 1;\r
+- }\r
+- gzprintf (output, " %s", *buffer_p);\r
+-\r
+- if (hex_encode (ctx, val, buffer_p, size_p) != HEX_SUCCESS) {\r
+- fprintf (stderr, "Error: failed to hex-encode value %s\n", val);\r
+- return 1;\r
+- }\r
+- gzprintf (output, "=%s", *buffer_p);\r
+-}\r
+- notmuch_message_properties_destroy (list);\r
++ for (list = notmuch_message_get_properties (message, "", FALSE);\r
++ notmuch_message_properties_valid (list); notmuch_message_properties_move_to_next (list)) {\r
++ const char *key, *val;\r
++\r
++ if (first) {\r
++ if (hex_encode (ctx, message_id, buffer_p, size_p) != HEX_SUCCESS) {\r
++ fprintf (stderr, "Error: failed to hex-encode message-id %s\n", message_id);\r
++ return 1;\r
++ }\r
++ gzprintf (output, "#= %s", *buffer_p);\r
++ first = FALSE;\r
++ }\r
++\r
++ key = notmuch_message_properties_key (list);\r
++ val = notmuch_message_properties_value (list);\r
++\r
++ if (hex_encode (ctx, key, buffer_p, size_p) != HEX_SUCCESS) {\r
++ fprintf (stderr, "Error: failed to hex-encode key %s\n", key);\r
++ return 1;\r
++ }\r
++ gzprintf (output, " %s", *buffer_p);\r
++\r
++ if (hex_encode (ctx, val, buffer_p, size_p) != HEX_SUCCESS) {\r
++ fprintf (stderr, "Error: failed to hex-encode value %s\n", val);\r
++ return 1;\r
++ }\r
++ gzprintf (output, "=%s", *buffer_p);\r
++ }\r
++ notmuch_message_properties_destroy (list);\r
+ \r
+- if (!first)\r
+- gzprintf (output, "\n", *buffer_p);\r
++ if (! first)\r
++ gzprintf (output, "\n", *buffer_p);\r
+ \r
+ return 0;\r
+ }\r
+diff --git a/notmuch-restore.c b/notmuch-restore.c\r
+index d2ada61..4b3690f 100644\r
+--- a/notmuch-restore.c\r
++++ b/notmuch-restore.c\r
+@@ -69,7 +69,7 @@ process_properties_line (notmuch_database_t *notmuch, const char* line)\r
+ const char *delim = " \t\n";\r
+ int ret = EXIT_FAILURE;\r
+ \r
+- void *local = talloc_new(NULL);\r
++ void *local = talloc_new (NULL);\r
+ \r
+ id_p = strtok_len_c (line, delim, &id_len);\r
+ id = talloc_strndup (local, id_p, id_len);\r
+@@ -97,7 +97,7 @@ process_properties_line (notmuch_database_t *notmuch, const char* line)\r
+ }\r
+ \r
+ key = talloc_strndup (local, tok, off);\r
+- value = talloc_strndup (local, tok+off+1, tok_len - off - 1);\r
++ value = talloc_strndup (local, tok + off + 1, tok_len - off - 1);\r
+ \r
+ if (hex_decode_inplace (key) != HEX_SUCCESS) {\r
+ fprintf (stderr, "hex decoding failure on key %s\n", key);\r
+@@ -111,13 +111,13 @@ process_properties_line (notmuch_database_t *notmuch, const char* line)\r
+ \r
+ if (print_status_database ("notmuch restore", notmuch,\r
+ notmuch_message_add_property (message, key, value)))\r
+- goto DONE;\r
++ goto DONE;\r
+ \r
+ }\r
+ \r
+ ret = EXIT_SUCCESS;\r
+ \r
+- DONE:\r
++ DONE:\r
+ talloc_free (local);\r
+ return ret;\r
+ }\r
+@@ -341,7 +341,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])\r
+ goto DONE;\r
+ }\r
+ if ((include & DUMP_INCLUDE_PROPERTIES) && line_len >= 2 && line[0] == '#' && line[1] == '=') {\r
+- ret = process_properties_line(notmuch, line+2);\r
++ ret = process_properties_line (notmuch, line + 2);\r
+ if (ret)\r
+ goto DONE;\r
+ }\r
+@@ -380,7 +380,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])\r
+ line_ctx = talloc_new (config);\r
+ \r
+ if ((include & DUMP_INCLUDE_PROPERTIES) && line_len >= 2 && line[0] == '#' && line[1] == '=') {\r
+- ret = process_properties_line(notmuch, line+2);\r
++ ret = process_properties_line (notmuch, line + 2);\r
+ if (ret)\r
+ goto DONE;\r
+ }\r
+@@ -423,7 +423,7 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])\r
+ break;\r
+ \r
+ } while (! (ret = gz_getline (line_ctx, &line, &line_len, input)));\r
+- \r
++\r
+ \r
+ /* EOF is normal loop termination condition, UTIL_SUCCESS is\r
+ * impossible here */\r
+@@ -435,14 +435,14 @@ notmuch_restore_command (notmuch_config_t *config, int argc, char *argv[])\r
+ ret = EXIT_FAILURE;\r
+ }\r
+ \r
+- /* currently this should not be after DONE: since we don't \r
++ /* currently this should not be after DONE: since we don't\r
+ * know if the xregcomp was reached\r
+ */\r
+ \r
+ if (input_format == DUMP_FORMAT_SUP)\r
+ regfree (®ex);\r
+ \r
+- DONE:\r
++ DONE:\r
+ if (line_ctx != NULL)\r
+ talloc_free (line_ctx);\r
+ \r
+\r
+\r