unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Make reply/show/tag all require at least one search term
@ 2009-11-18 21:45 Keith Packard
  2009-11-19  0:34 ` Carl Worth
  0 siblings, 1 reply; 2+ messages in thread
From: Keith Packard @ 2009-11-18 21:45 UTC (permalink / raw)
  To: notmuch

In particular, notmuch tag -inbox "" tended to take a long time to
run, happened if you hit 'a' on a blank line in the search view and
probably didn't have the desired effect.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 notmuch-reply.c |   13 +++++++++----
 notmuch-show.c  |   13 +++++++++----
 notmuch-tag.c   |    8 ++++----
 3 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/notmuch-reply.c b/notmuch-reply.c
index 4a4a782..31e2c87 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -196,16 +196,21 @@ notmuch_reply_command (void *ctx, int argc, char *argv[])
     if (config == NULL)
 	return 1;
 
-    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));
-    if (notmuch == NULL)
-	return 1;
-
     query_string = query_string_from_args (ctx, argc, argv);
     if (query_string == NULL) {
 	fprintf (stderr, "Out of memory\n");
 	return 1;
     }
 
+    if (*query_string == '\0') {
+	fprintf (stderr, "Error: notmuch reply requires at least one search term.\n");
+	return 1;
+    }
+
+    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));
+    if (notmuch == NULL)
+	return 1;
+
     query = notmuch_query_create (notmuch, query_string);
     if (query == NULL) {
 	fprintf (stderr, "Out of memory\n");
diff --git a/notmuch-show.c b/notmuch-show.c
index 59a58c2..c0c3ca3 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -196,16 +196,21 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[]))
     if (config == NULL)
 	return 1;
 
-    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));
-    if (notmuch == NULL)
-	return 1;
-
     query_string = query_string_from_args (ctx, argc, argv);
     if (query_string == NULL) {
 	fprintf (stderr, "Out of memory\n");
 	return 1;
     }
 
+    if (*query_string == '\0') {
+	fprintf (stderr, "Error: notmuch show requires at least one search term.\n");
+	return 1;
+    }
+
+    notmuch = notmuch_database_open (notmuch_config_get_database_path (config));
+    if (notmuch == NULL)
+	return 1;
+
     query = notmuch_query_create (notmuch, query_string);
     if (query == NULL) {
 	fprintf (stderr, "Out of memory\n");
diff --git a/notmuch-tag.c b/notmuch-tag.c
index 7d92ec4..12ab86c 100644
--- a/notmuch-tag.c
+++ b/notmuch-tag.c
@@ -83,8 +83,10 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
 	return 1;
     }
 
-    if (i == argc) {
-	fprintf (stderr, "Error: 'notmuch tag' requires at least one search term.\n");
+    query_string = query_string_from_args (ctx, argc - i, &argv[i]);
+
+    if (*query_string == '\0') {
+	fprintf (stderr, "Error: notmuch tag requires at least one search term.\n");
 	return 1;
     }
 
@@ -96,8 +98,6 @@ notmuch_tag_command (void *ctx, unused (int argc), unused (char *argv[]))
     if (notmuch == NULL)
 	return 1;
 
-    query_string = query_string_from_args (ctx, argc - i, &argv[i]);
-
     query = notmuch_query_create (notmuch, query_string);
     if (query == NULL) {
 	fprintf (stderr, "Out of memory.\n");
-- 
1.6.5.2

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

* Re: [PATCH] Make reply/show/tag all require at least one search term
  2009-11-18 21:45 [PATCH] Make reply/show/tag all require at least one search term Keith Packard
@ 2009-11-19  0:34 ` Carl Worth
  0 siblings, 0 replies; 2+ messages in thread
From: Carl Worth @ 2009-11-19  0:34 UTC (permalink / raw)
  To: Keith Packard, notmuch

On Wed, 18 Nov 2009 13:45:58 -0800, Keith Packard <keithp@keithp.com> wrote:
> In particular, notmuch tag -inbox "" tended to take a long time to
> run, happened if you hit 'a' on a blank line in the search view and
> probably didn't have the desired effect.

Another nice fix. Thanks again. This is pushed.

-Carl

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

end of thread, other threads:[~2009-11-19  0:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-18 21:45 [PATCH] Make reply/show/tag all require at least one search term Keith Packard
2009-11-19  0:34 ` Carl Worth

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