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 0A4BD431FD5 for ; Sun, 9 Dec 2012 06:56:14 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled 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 Akjrbgv44anR for ; Sun, 9 Dec 2012 06:56:13 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com [209.85.215.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 4C2D4431FBF for ; Sun, 9 Dec 2012 06:56:09 -0800 (PST) Received: by mail-la0-f53.google.com with SMTP id w12so1484151lag.26 for ; Sun, 09 Dec 2012 06:56:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references:x-gm-message-state; bh=Y9qPt4eCs0YUlyxgvBEc0UeKVlnfQk8A0m/W2fp5NI0=; b=TKGAtEQcVKRfc2EWhG9jtBRgczkUKdyulb+6yFLXxGfWF5RNsBujPRhiLlvR8i/yt9 F0fTD5af00reuJOu26dZnZvx6fiiAwPjN/0RBC3hS/2rsQVI6SwXQj++2hZGrPWTi3WA gmFQo2zr+tVRpPEtXbAEKXp/CBndHIo/hx73zh9L5DRebsX/+aO2IKNMIqz63X4ukDDC +NpnHnXF0uODYyoF6sHD/ckZj+FUIFLehdEoJxK+/MCArxjj1ZSEoe51eekaDCW/NdFj vcM1Cdthr9y0oD8N/5Tdjc9mw+a8dNK8JA3hCrS++Z0Bg4QVqMzFzg6wEtidLQgI38DR FDsQ== Received: by 10.152.114.65 with SMTP id je1mr11127525lab.33.1355064968790; Sun, 09 Dec 2012 06:56:08 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-fe51df00-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id v6sm6706707lbf.11.2012.12.09.06.56.07 (version=SSLv3 cipher=OTHER); Sun, 09 Dec 2012 06:56:08 -0800 (PST) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v2 2/4] cli: add --format=text0 to notmuch search Date: Sun, 9 Dec 2012 16:55:57 +0200 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQl9JjToSScaV3ChGT8hFAaZ0MxEVSKdWA67Tx5hOJNOY2zfVohJ7G++gzdo4pDblHpVQfqS 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: Sun, 09 Dec 2012 14:56:14 -0000 Add new format text0, which is otherwise the same as text, but use the null character as separator instead of the newline character. This is similar to find(1) -print0 option, and works together with the xargs(1) -0 option. --- notmuch-search.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/notmuch-search.c b/notmuch-search.c index 6218622..627962b 100644 --- a/notmuch-search.c +++ b/notmuch-search.c @@ -305,8 +305,12 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) int exclude = EXCLUDE_TRUE; unsigned int i; - enum { NOTMUCH_FORMAT_JSON, NOTMUCH_FORMAT_TEXT, NOTMUCH_FORMAT_SEXP } - format_sel = NOTMUCH_FORMAT_TEXT; + enum { + NOTMUCH_FORMAT_JSON, + NOTMUCH_FORMAT_TEXT, + NOTMUCH_FORMAT_TEXT0, + NOTMUCH_FORMAT_SEXP + } format_sel = NOTMUCH_FORMAT_TEXT; notmuch_opt_desc_t options[] = { { NOTMUCH_OPT_KEYWORD, &sort, "sort", 's', @@ -317,6 +321,7 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) (notmuch_keyword_t []){ { "json", NOTMUCH_FORMAT_JSON }, { "sexp", NOTMUCH_FORMAT_SEXP }, { "text", NOTMUCH_FORMAT_TEXT }, + { "text0", NOTMUCH_FORMAT_TEXT0 }, { 0, 0 } } }, { NOTMUCH_OPT_KEYWORD, &output, "output", 'o', (notmuch_keyword_t []){ { "summary", OUTPUT_SUMMARY }, @@ -345,6 +350,13 @@ notmuch_search_command (void *ctx, int argc, char *argv[]) case NOTMUCH_FORMAT_TEXT: format = sprinter_text_create (ctx, stdout); break; + case NOTMUCH_FORMAT_TEXT0: + if (output == OUTPUT_SUMMARY) { + fprintf (stderr, "Error: --format=text0 is not compatible with --output=summary.\n"); + return 1; + } + format = sprinter_text0_create (ctx, stdout); + break; case NOTMUCH_FORMAT_JSON: format = sprinter_json_create (ctx, stdout); break; -- 1.7.10.4