From: Michal Sojka <sojkam1@fel.cvut.cz>
To: notmuch@notmuchmail.org
Subject: [PATCH 2/2] Print nothing when search result is empty
Date: Mon, 1 Nov 2010 17:15:40 +0100 [thread overview]
Message-ID: <1288628140-15410-2-git-send-email-sojkam1@fel.cvut.cz> (raw)
In-Reply-To: <1288628140-15410-1-git-send-email-sojkam1@fel.cvut.cz>
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
next prev parent reply other threads:[~2010-11-01 16:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-01 16:15 [PATCH 1/2] test: Search for non-existent message should return nothing Michal Sojka
2010-11-01 16:15 ` Michal Sojka [this message]
2010-11-04 19:39 ` Carl Worth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1288628140-15410-2-git-send-email-sojkam1@fel.cvut.cz \
--to=sojkam1@fel.cvut.cz \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).