[PATCH v2 00/14] reply refactor, fixes
[notmuch-archives.git] / 63 / 315661f9dfc325c685e2d599fafe978b298b84
1 Return-Path: <bremner@tethera.net>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id A84DF6DE0281\r
6  for <notmuch@notmuchmail.org>; Sat, 16 Jul 2016 03:33:16 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.011\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.011 tagged_above=-999 required=5 tests=[AWL=0.000,\r
12   SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id 7cXfcqVPSQI8 for <notmuch@notmuchmail.org>;\r
16  Sat, 16 Jul 2016 03:33:08 -0700 (PDT)\r
17 Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197])\r
18  by arlo.cworth.org (Postfix) with ESMTPS id 454566DE0243\r
19  for <notmuch@notmuchmail.org>; Sat, 16 Jul 2016 03:33:07 -0700 (PDT)\r
20 Received: from remotemail by fethera.tethera.net with local (Exim 4.84)\r
21  (envelope-from <bremner@tethera.net>)\r
22  id 1bOMuV-0004O4-HA; Sat, 16 Jul 2016 06:33:27 -0400\r
23 Received: (nullmailer pid 11985 invoked by uid 1000);\r
24  Sat, 16 Jul 2016 10:33:02 -0000\r
25 From: David Bremner <david@tethera.net>\r
26 To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,\r
27  Notmuch Mail <notmuch@notmuchmail.org>\r
28 Subject: [PATCH] RFC: all deleting all properties with a given key\r
29 Date: Sat, 16 Jul 2016 07:32:54 -0300\r
30 Message-Id: <1468665174-11929-1-git-send-email-david@tethera.net>\r
31 X-Mailer: git-send-email 2.8.1\r
32 In-Reply-To: <1467952610-27015-1-git-send-email-dkg@fifthhorseman.net>\r
33 References: <1467952610-27015-1-git-send-email-dkg@fifthhorseman.net>\r
34 X-BeenThere: notmuch@notmuchmail.org\r
35 X-Mailman-Version: 2.1.20\r
36 Precedence: list\r
37 List-Id: "Use and development of the notmuch mail system."\r
38  <notmuch.notmuchmail.org>\r
39 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
40  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
42 List-Post: <mailto:notmuch@notmuchmail.org>\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
44 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
45  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
46 X-List-Received-Date: Sat, 16 Jul 2016 10:33:16 -0000\r
47 \r
48 ---\r
49 \r
50 I think I somewhat prefer this way of providing the same\r
51 functionality, because the control flow is simpler. If it seems\r
52 useful, we could forward remove_property with a NULL value to\r
53 remove_all_properties\r
54 \r
55  lib/message-property.cc | 11 +++++++++--\r
56  lib/notmuch.h           |  5 ++++-\r
57  2 files changed, 13 insertions(+), 3 deletions(-)\r
58 \r
59 diff --git a/lib/message-property.cc b/lib/message-property.cc\r
60 index edc6f2f..c6cff33 100644\r
61 --- a/lib/message-property.cc\r
62 +++ b/lib/message-property.cc\r
63 @@ -98,16 +98,23 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co\r
64  }\r
65  \r
66  notmuch_status_t\r
67 -notmuch_message_remove_all_properties (notmuch_message_t *message)\r
68 +notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key)\r
69  {\r
70      notmuch_status_t status;\r
71 +    const char * term_prefix;\r
72 +\r
73      status = _notmuch_database_ensure_writable (_notmuch_message_database (message));\r
74      if (status)\r
75         return status;\r
76  \r
77      _notmuch_message_invalidate_metadata (message, "property");\r
78 +    if (key)\r
79 +       term_prefix = talloc_asprintf (message, "%s%s=", _find_prefix ("property"), key);\r
80 +    else\r
81 +       term_prefix = _find_prefix ("property");\r
82 +\r
83      /* XXX better error reporting ? */\r
84 -    _notmuch_message_remove_terms (message, _find_prefix ("property"));\r
85 +    _notmuch_message_remove_terms (message, term_prefix);\r
86  \r
87      return NOTMUCH_STATUS_SUCCESS;\r
88  }\r
89 diff --git a/lib/notmuch.h b/lib/notmuch.h\r
90 index 41aee3c..cf5de3e 100644\r
91 --- a/lib/notmuch.h\r
92 +++ b/lib/notmuch.h\r
93 @@ -1712,6 +1712,9 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co\r
94  /**\r
95   * Remove all (key,value) pairs from the given message.\r
96   *\r
97 + * @param[in,out] message  message to operate on.\r
98 + * @param[in]     key      key to delete properties for. If NULL, delete\r
99 + *                        properties for all keys\r
100   * @returns\r
101   * - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in\r
102   *   read-only mode so message cannot be modified.\r
103 @@ -1719,7 +1722,7 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co\r
104   *\r
105   */\r
106  notmuch_status_t\r
107 -notmuch_message_remove_all_properties (notmuch_message_t *message);\r
108 +notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key);\r
109  \r
110  /**@}*/\r
111  \r
112 -- \r
113 2.8.1\r
114 \r