[RFC PATCH] cli/search: interpret no search terms as synonym for '*'

David Bremner david at tethera.net
Wed Jun 29 13:34:06 PDT 2016


This is a bit less typing (and escaping), especially for the
--output=tags case.
---

I started merrily on other commands, but I'm not so sure. For example
"git annex metadata" has the feature of interpreting missing file name
as all files and I find it super irritating in general because I keep
adding tags to all files. Hence RFC.

 notmuch-search.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/notmuch-search.c b/notmuch-search.c
index 8c65d5a..a7e397c 100644
--- a/notmuch-search.c
+++ b/notmuch-search.c
@@ -625,7 +625,8 @@ do_search_tags (const search_context_t *ctx)
      * specified? */
 
     /* Special-case query of "*" for better performance. */
-    if (strcmp (notmuch_query_get_query_string (query), "*") == 0) {
+    if (strcmp (notmuch_query_get_query_string (query), "*") == 0 ||
+	strlen (notmuch_query_get_query_string (query)) == 0) {
 	tags = notmuch_database_get_all_tags (notmuch);
     } else {
 	notmuch_status_t status;
@@ -711,10 +712,6 @@ _notmuch_search_prepare (search_context_t *ctx, notmuch_config_t *config, int ar
 	fprintf (stderr, "Out of memory.\n");
 	return EXIT_FAILURE;
     }
-    if (*query_str == '\0') {
-	fprintf (stderr, "Error: notmuch search requires at least one search term.\n");
-	return EXIT_FAILURE;
-    }
 
     ctx->query = notmuch_query_create (ctx->notmuch, query_str);
     if (ctx->query == NULL) {
-- 
2.8.1



More information about the notmuch mailing list