[PATCH] RFC: all deleting all properties with a given key
authorDavid Bremner <david@tethera.net>
Sat, 16 Jul 2016 10:32:54 +0000 (07:32 +2100)
committerW. Trevor King <wking@tremily.us>
Sat, 20 Aug 2016 23:22:13 +0000 (16:22 -0700)
63/315661f9dfc325c685e2d599fafe978b298b84 [new file with mode: 0644]

diff --git a/63/315661f9dfc325c685e2d599fafe978b298b84 b/63/315661f9dfc325c685e2d599fafe978b298b84
new file mode 100644 (file)
index 0000000..2131fd7
--- /dev/null
@@ -0,0 +1,114 @@
+Return-Path: <bremner@tethera.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 arlo.cworth.org (Postfix) with ESMTP id A84DF6DE0281\r
+ for <notmuch@notmuchmail.org>; Sat, 16 Jul 2016 03:33:16 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.011\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.011 tagged_above=-999 required=5 tests=[AWL=0.000,\r
+  SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] 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 7cXfcqVPSQI8 for <notmuch@notmuchmail.org>;\r
+ Sat, 16 Jul 2016 03:33:08 -0700 (PDT)\r
+Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 454566DE0243\r
+ for <notmuch@notmuchmail.org>; Sat, 16 Jul 2016 03:33:07 -0700 (PDT)\r
+Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
+ (envelope-from <bremner@tethera.net>)\r
+ id 1bOMuV-0004O4-HA; Sat, 16 Jul 2016 06:33:27 -0400\r
+Received: (nullmailer pid 11985 invoked by uid 1000);\r
+ Sat, 16 Jul 2016 10:33:02 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,\r
+ Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH] RFC: all deleting all properties with a given key\r
+Date: Sat, 16 Jul 2016 07:32:54 -0300\r
+Message-Id: <1468665174-11929-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1467952610-27015-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1467952610-27015-1-git-send-email-dkg@fifthhorseman.net>\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: Sat, 16 Jul 2016 10:33:16 -0000\r
+\r
+---\r
+\r
+I think I somewhat prefer this way of providing the same\r
+functionality, because the control flow is simpler. If it seems\r
+useful, we could forward remove_property with a NULL value to\r
+remove_all_properties\r
+\r
+ lib/message-property.cc | 11 +++++++++--\r
+ lib/notmuch.h           |  5 ++++-\r
+ 2 files changed, 13 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/lib/message-property.cc b/lib/message-property.cc\r
+index edc6f2f..c6cff33 100644\r
+--- a/lib/message-property.cc\r
++++ b/lib/message-property.cc\r
+@@ -98,16 +98,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 41aee3c..cf5de3e 100644\r
+--- a/lib/notmuch.h\r
++++ b/lib/notmuch.h\r
+@@ -1712,6 +1712,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
+@@ -1719,7 +1722,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
\r
+-- \r
+2.8.1\r
+\r