From: David Bremner <david@tethera.net>
To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,
Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH] RFC: all deleting all properties with a given key
Date: Sat, 16 Jul 2016 07:32:54 -0300 [thread overview]
Message-ID: <1468665174-11929-1-git-send-email-david@tethera.net> (raw)
In-Reply-To: <1467952610-27015-1-git-send-email-dkg@fifthhorseman.net>
---
I think I somewhat prefer this way of providing the same
functionality, because the control flow is simpler. If it seems
useful, we could forward remove_property with a NULL value to
remove_all_properties
lib/message-property.cc | 11 +++++++++--
lib/notmuch.h | 5 ++++-
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/lib/message-property.cc b/lib/message-property.cc
index edc6f2f..c6cff33 100644
--- a/lib/message-property.cc
+++ b/lib/message-property.cc
@@ -98,16 +98,23 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co
}
notmuch_status_t
-notmuch_message_remove_all_properties (notmuch_message_t *message)
+notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key)
{
notmuch_status_t status;
+ const char * term_prefix;
+
status = _notmuch_database_ensure_writable (_notmuch_message_database (message));
if (status)
return status;
_notmuch_message_invalidate_metadata (message, "property");
+ if (key)
+ term_prefix = talloc_asprintf (message, "%s%s=", _find_prefix ("property"), key);
+ else
+ term_prefix = _find_prefix ("property");
+
/* XXX better error reporting ? */
- _notmuch_message_remove_terms (message, _find_prefix ("property"));
+ _notmuch_message_remove_terms (message, term_prefix);
return NOTMUCH_STATUS_SUCCESS;
}
diff --git a/lib/notmuch.h b/lib/notmuch.h
index 41aee3c..cf5de3e 100644
--- a/lib/notmuch.h
+++ b/lib/notmuch.h
@@ -1712,6 +1712,9 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co
/**
* Remove all (key,value) pairs from the given message.
*
+ * @param[in,out] message message to operate on.
+ * @param[in] key key to delete properties for. If NULL, delete
+ * properties for all keys
* @returns
* - NOTMUCH_STATUS_READ_ONLY_DATABASE: Database was opened in
* read-only mode so message cannot be modified.
@@ -1719,7 +1722,7 @@ notmuch_message_remove_property (notmuch_message_t *message, const char *key, co
*
*/
notmuch_status_t
-notmuch_message_remove_all_properties (notmuch_message_t *message);
+notmuch_message_remove_all_properties (notmuch_message_t *message, const char *key);
/**@}*/
--
2.8.1
next prev parent reply other threads:[~2016-07-16 10:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-13 1:05 message properties patches, v1.0 David Bremner
2016-06-13 1:05 ` [PATCH 1/8] lib: read "property" terms from messages David Bremner
2016-06-13 1:05 ` [PATCH 2/8] lib: private string map (associative array) API David Bremner
2016-06-13 8:10 ` Tomi Ollila
2016-06-13 13:02 ` David Bremner
2016-06-13 15:18 ` Bijan Chokoufe Nejad
2016-06-13 1:05 ` [PATCH 3/8] lib: basic message-property API David Bremner
2016-07-08 4:36 ` [PATCH] n_m_remove_property(msg, key, NULL) should removes all properties with key Daniel Kahn Gillmor
2016-07-16 10:32 ` David Bremner [this message]
2016-07-17 23:33 ` [PATCH] RFC: all deleting all properties with a given key Daniel Kahn Gillmor
2016-06-13 1:05 ` [PATCH 4/8] lib: extend private string map API with iterators David Bremner
2016-06-13 1:05 ` [PATCH 5/8] lib: iterator API for message properties David Bremner
2016-06-13 1:05 ` [PATCH 6/8] CLI: refactor dumping of tags David Bremner
2016-06-13 1:05 ` [PATCH 7/8] CLI: add properties to dump output David Bremner
2016-06-13 1:05 ` [PATCH 8/8] cli: optionally restore message properties from dump file David Bremner
2016-07-08 9:15 ` [PATCH] add has: query prefix to search for specific properties Daniel Kahn Gillmor
2016-07-17 0:39 ` David Bremner
2016-07-17 10:38 ` David Bremner
2016-07-17 23:44 ` Daniel Kahn Gillmor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468665174-11929-1-git-send-email-david@tethera.net \
--to=david@tethera.net \
--cc=dkg@fifthhorseman.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).