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 3D5DE40D171 for ; Mon, 1 Nov 2010 09:16:38 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham 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 ZA76bNce4On9 for ; Mon, 1 Nov 2010 09:16:26 -0700 (PDT) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id 04D3C40D155 for ; Mon, 1 Nov 2010 09:16:26 -0700 (PDT) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id 93AEF19F32EE; Mon, 1 Nov 2010 17:16:24 +0100 (CET) X-Virus-Scanned: IMAP AMAVIS Received: from max.feld.cvut.cz ([192.168.200.1]) by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, port 10044) with ESMTP id VwsSWUm1bZPB; Mon, 1 Nov 2010 17:16:23 +0100 (CET) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by max.feld.cvut.cz (Postfix) with ESMTP id F244D19F32F2; Mon, 1 Nov 2010 17:16:22 +0100 (CET) Received: from steelpick.2x.cz (pc-dolezilkova.felk.cvut.cz [147.32.86.26]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id E791815C082; Mon, 1 Nov 2010 17:16:22 +0100 (CET) Received: from wsh by steelpick.2x.cz with local (Exim 4.72) (envelope-from ) id 1PCx3V-000416-U6; Mon, 01 Nov 2010 17:16:22 +0100 From: Michal Sojka To: notmuch@notmuchmail.org Subject: [PATCH 2/2] Print nothing when search result is empty Date: Mon, 1 Nov 2010 17:15:40 +0100 Message-Id: <1288628140-15410-2-git-send-email-sojkam1@fel.cvut.cz> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1288628140-15410-1-git-send-email-sojkam1@fel.cvut.cz> References: <1288628140-15410-1-git-send-email-sojkam1@fel.cvut.cz> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 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: Mon, 01 Nov 2010 16:16:38 -0000 This change affects both text and json formats. Now, text format behaves as before commit 6dcb7592, but json format is changed. Earlier, the empty search returned '[]', now it returns ''. The emacs interface seems not to be affected by this change. --- notmuch-search.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 5907c2e..bb989da 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -189,7 +189,9 @@ do_search_threads (const void *ctx, { int first_tag = 1; - if (! first_thread) + if (first_thread) + fputs (format->results_start, stdout); + else fputs (format->item_sep, stdout); thread = notmuch_threads_get (threads); @@ -235,6 +237,9 @@ do_search_threads (const void *ctx, notmuch_thread_destroy (thread); } + if (! first_thread) + fputs (format->results_end, stdout); + return 0; } @@ -258,7 +263,9 @@ do_search_messages (const void *ctx, { message = notmuch_messages_get (messages); - if (! first_message) + if (first_message) + fputs (format->results_start, stdout); + else fputs (format->item_sep, stdout); if (output == OUTPUT_FILES) { @@ -276,6 +283,9 @@ do_search_messages (const void *ctx, notmuch_messages_destroy (messages); + if (! first_message) + fputs (format->results_end, stdout); + return 0; } @@ -415,8 +425,6 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) notmuch_query_set_sort (query, sort); - fputs (format->results_start, stdout); - switch (output) { default: case OUTPUT_SUMMARY: @@ -432,8 +440,6 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) break; } - fputs (format->results_end, stdout); - notmuch_query_destroy (query); notmuch_database_close (notmuch); -- 1.7.2.3