unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* v3 of message properties patches
@ 2016-08-06 13:52 David Bremner
  2016-08-06 13:52 ` [PATCH 1/9] lib: read "property" terms from messages David Bremner
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: David Bremner @ 2016-08-06 13:52 UTC (permalink / raw)
  To: notmuch

This obsoletes

     id:1470184228-12517-1-git-send-email-david@tethera.net

In particular it fixes the compile errors (boo), and adds dkg's
has: queries, with minimal doc and tests.

interdiff follows:

diff --git a/doc/man7/notmuch-search-terms.rst b/doc/man7/notmuch-search-terms.rst
index 075f88c..86d02ee 100644
--- a/doc/man7/notmuch-search-terms.rst
+++ b/doc/man7/notmuch-search-terms.rst
@@ -58,6 +58,8 @@ indicate user-supplied values):
 
 -  query:<name>
 
+-  has:<key>=<value>
+
 The **from:** prefix is used to match the name or address of the sender
 of an email message.
 
@@ -139,6 +141,11 @@ queries added with **notmuch-config(1)**. Named queries are only
 available if notmuch is built with **Xapian Field Processors** (see
 below).
 
+The **has:** prefix searches for messages with a particular
+<key>=<value> property pair. Properties are used internally by notmuch
+(and extensions) to add metadata to messages. A given key can be
+present on a given message with several different values.
+
 Operators
 ---------
 
@@ -217,7 +224,7 @@ exact matches like "tag:inbox"  or **probabilistic**, supporting a more flexible
 
 
 Boolean
-   **tag:**, **id:**, **thread:**, **folder:**, **path:**
+   **tag:**, **id:**, **thread:**, **folder:**, **path:**, **has**
 Probabilistic
    **from:**, **to:**, **subject:**, **attachment:**, **mimetype:**
 
diff --git a/lib/database.cc b/lib/database.cc
index 3a741f0..3bdbd07 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -97,6 +97,9 @@ typedef struct {
  *		        STRING is the name of a file within that
  *		        directory for this mail message.
  *
+ *      has:       Has a property with key=value
+ *                 FIXME: if no = is present, should match on any value
+ *
  *    A mail document also has four values:
  *
  *	TIMESTAMP:	The time_t value corresponding to the message's
@@ -260,6 +263,7 @@ static prefix_t BOOLEAN_PREFIX_EXTERNAL[] = {
     { "is",			"K" },
     { "id",			"Q" },
     { "path",			"P" },
+    { "has",			"XPROPERTY" },
     /*
      * Without the ":", since this is a multi-letter prefix, Xapian
      * will add a colon itself if the first letter of the path is
diff --git a/notmuch-restore.c b/notmuch-restore.c
index 3cd8a40..d6429ef 100644
--- a/notmuch-restore.c
+++ b/notmuch-restore.c
@@ -83,7 +83,7 @@ process_properties_line (notmuch_database_t *notmuch, const char* line)
 	goto DONE;
 
     if (print_status_database ("notmuch restore", notmuch,
-			       notmuch_message_remove_all_properties (message)))
+			       notmuch_message_remove_all_properties (message, NULL)))
 	goto DONE;
 
     tok = id_p + id_len;
diff --git a/test/T610-message-property.sh b/test/T610-message-property.sh
index 8952eb7..ee7910b 100755
--- a/test/T610-message-property.sh
+++ b/test/T610-message-property.sh
@@ -91,7 +91,7 @@ test_expect_equal_file EXPECTED OUTPUT
 
 test_begin_subtest "notmuch_message_remove_all_properties"
 cat c_head - c_tail <<'EOF' | test_C ${MAIL_DIR}
-EXPECT0(notmuch_message_remove_all_properties (message));
+EXPECT0(notmuch_message_remove_all_properties (message, NULL));
 print_properties (message, "", FALSE);
 EOF
 cat <<'EOF' >EXPECTED
@@ -237,4 +237,15 @@ notmuch restore < BEFORE2
 notmuch dump | grep '^#=' > OUTPUT
 test_expect_equal_file PROPERTIES OUTPUT
 
+test_begin_subtest "test 'has:' queries: empty"
+notmuch search has:testkey1=charles > OUTPUT
+test_expect_equal_file /dev/null OUTPUT
+
+test_begin_subtest "test 'has:' queries: single message"
+notmuch search --output=messages has:testkey1=alice > OUTPUT
+cat <<EOF >EXPECTED
+id:4EFC743A.3060609@april.org
+EOF
+test_expect_equal_file EXPECTED OUTPUT
+
 test_done

^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-09-21 21:21 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-06 13:52 v3 of message properties patches David Bremner
2016-08-06 13:52 ` [PATCH 1/9] lib: read "property" terms from messages David Bremner
2016-08-06 13:52 ` [PATCH 2/9] lib: private string map (associative array) API David Bremner
2016-08-06 13:52 ` [PATCH 3/9] lib: basic message-property API David Bremner
2016-08-06 13:52 ` [PATCH 4/9] lib: extend private string map API with iterators David Bremner
2016-08-06 13:52 ` [PATCH 5/9] lib: iterator API for message properties David Bremner
2016-08-06 13:52 ` [PATCH 6/9] CLI: refactor dumping of tags David Bremner
2016-08-06 13:52 ` [PATCH 7/9] CLI: add properties to dump output David Bremner
2016-08-06 13:52 ` [PATCH 8/9] cli: optionally restore message properties from dump file David Bremner
2016-08-06 13:52 ` [PATCH 9/9] add has: query prefix to search for specific properties David Bremner
2016-08-06 14:18   ` David Bremner
2016-08-13  9:38     ` Jani Nikula
2016-08-13 11:31       ` David Bremner
2016-08-18  8:14       ` [PATCH] lib: reword comment about XFOLDER: prefix David Bremner
2016-08-18  8:18         ` David Bremner
2016-08-19 12:18           ` David Bremner
2016-08-13 19:00   ` [PATCH 9/9] add has: query prefix to search for specific properties Jameson Graef Rollins
2016-08-13 23:14     ` David Bremner
2016-09-20 21:56 ` v3 of message properties patches Daniel Kahn Gillmor
2016-09-21 12:01   ` David Bremner
2016-09-21 13:04     ` Tomi Ollila
2016-09-21 21:21       ` David Bremner

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).