]> git.notmuchmail.org Git - notmuch/commitdiff
lib: Handle "*" as a query string to match all messages.
authorCarl Worth <cworth@cworth.org>
Fri, 9 Apr 2010 23:40:31 +0000 (16:40 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 10 Apr 2010 00:43:58 +0000 (17:43 -0700)
This seems like a generally useful thing to support, (but the previous
support through an empty string was not convenient for some users,
(such as the command-line client).

lib/notmuch.h
lib/query.cc

index 88da07898eb20958154d80e5cfb72e054b6a2981..426828542bcf50fc6dfa4f2908ec2c0ac7ba6b57 100644 (file)
@@ -325,7 +325,8 @@ notmuch_database_get_all_tags (notmuch_database_t *db);
  *
  * http://xapian.org/docs/queryparser.html
  *
  *
  * http://xapian.org/docs/queryparser.html
  *
- * As a special case, passing a length-zero string, (that is ""), will
+ * As a special case, passing either a length-zero string, (that is ""),
+ * or a string consisting of a single asterisk (that is "*"), will
  * result in a query that returns all messages in the database.
  *
  * See notmuch_query_set_sort for controlling the order of results.
  * result in a query that returns all messages in the database.
  *
  * See notmuch_query_set_sort for controlling the order of results.
index 9266d35f8fc517dbda11d3be9f68a0b47f7105da..10f8dc8a1a7aa0ade1ced3ff129e6cf1143d574f 100644 (file)
@@ -125,7 +125,9 @@ notmuch_query_search_messages (notmuch_query_t *query)
                              Xapian::QueryParser::FLAG_WILDCARD |
                              Xapian::QueryParser::FLAG_PURE_NOT);
 
                              Xapian::QueryParser::FLAG_WILDCARD |
                              Xapian::QueryParser::FLAG_PURE_NOT);
 
-       if (strcmp (query_string, "") == 0) {
+       if (strcmp (query_string, "") == 0 ||
+           strcmp (query_string, "*") == 0)
+       {
            final_query = mail_query;
        } else {
            string_query = notmuch->query_parser->
            final_query = mail_query;
        } else {
            string_query = notmuch->query_parser->
@@ -333,7 +335,9 @@ notmuch_query_count_messages (notmuch_query_t *query)
                              Xapian::QueryParser::FLAG_WILDCARD |
                              Xapian::QueryParser::FLAG_PURE_NOT);
 
                              Xapian::QueryParser::FLAG_WILDCARD |
                              Xapian::QueryParser::FLAG_PURE_NOT);
 
-       if (strcmp (query_string, "") == 0) {
+       if (strcmp (query_string, "") == 0 ||
+           strcmp (query_string, "*") == 0)
+       {
            final_query = mail_query;
        } else {
            string_query = notmuch->query_parser->
            final_query = mail_query;
        } else {
            string_query = notmuch->query_parser->