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

classic Classic list List threaded Threaded
2 messages Options
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

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

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

_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch
David Bremner-2 David Bremner-2
Reply | Threaded
Open this post in threaded view
|

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

David Bremner <[hidden email]> writes:

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

Since I didn't receive any feedback, I'm going to drop plans to add this
feature for now.

d
_______________________________________________
notmuch mailing list
[hidden email]
https://notmuchmail.org/mailman/listinfo/notmuch