Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id A3F0C431FBF for ; Wed, 18 Nov 2009 13:46:04 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Na4UJR2xWfHB for ; Wed, 18 Nov 2009 13:46:03 -0800 (PST) Received: from keithp.com (home.keithp.com [63.227.221.253]) by olra.theworths.org (Postfix) with ESMTP id 90B99431FBC for ; Wed, 18 Nov 2009 13:46:03 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 0665EB9404C for ; Wed, 18 Nov 2009 13:46:03 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at keithp.com Received: from keithp.com ([127.0.0.1]) by localhost (keithp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id PNyzIBrT-lJf; Wed, 18 Nov 2009 13:46:00 -0800 (PST) Received: by keithp.com (Postfix, from userid 1033) id 1609BB9402F; Wed, 18 Nov 2009 13:46:00 -0800 (PST) Received: from koto.keithp.com (localhost [127.0.0.1]) by keithp.com (Postfix) with ESMTP id 13B6EB88003; Wed, 18 Nov 2009 13:46:00 -0800 (PST) Received: by koto.keithp.com (Postfix, from userid 1488) id B11841581A5; Wed, 18 Nov 2009 13:45:59 -0800 (PST) From: Keith Packard To: notmuch@notmuchmail.org Date: Wed, 18 Nov 2009 13:45:58 -0800 Message-Id: <1258580758-24474-1-git-send-email-keithp@keithp.com> X-Mailer: git-send-email 1.6.5.2 Subject: [notmuch] [PATCH] Make reply/show/tag all require at least one search term X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Nov 2009 21:46:04 -0000 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 --- 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