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 959A7431FB6 for ; Sun, 16 Dec 2012 13:02:56 -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 Vw+EwPvJjJMI for ; Sun, 16 Dec 2012 13:02:56 -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 EAE68431FAE for ; Sun, 16 Dec 2012 13:02:55 -0800 (PST) Received: by mail-la0-f53.google.com with SMTP id w12so4045336lag.26 for ; Sun, 16 Dec 2012 13:02:54 -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=gzCcGJnX2ZB16g+vELeAZjA4rqNTofO6JHT+ZRKAI9b4GINIywM4RV9YcA82u20PQG bMp/fNTRaU7BN9uE0emsbCCX2EnmrbtQ/A6hmI/VxA7RSU9s8d/yi8QK/E34IdWPrYES izKGxGB+9TMg21ySC2rvAS+c7eHarLVw92eAi1wydK9gNhgBr2zVF+kdXaID+jels6wA xcJl/yy/tBTr1UadBkDolzK7QAagdRWKiL2UKIkaeTI875G228qQ1UsNRMxOPVAMlLum DsjdwCATNfGr+2qr1gZB91b7T6stvtBRvPftceeBtlLeCpQANv7p8Axy7FP+TytBU//+ FdJw== Received: by 10.152.134.243 with SMTP id pn19mr8762203lab.11.1355691774434; Sun, 16 Dec 2012 13:02:54 -0800 (PST) Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi. [80.223.81.27]) by mx.google.com with ESMTPS id u5sm4115128lbm.8.2012.12.16.13.02.52 (version=SSLv3 cipher=OTHER); Sun, 16 Dec 2012 13:02:53 -0800 (PST) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v3 3/5] cli: add --format=text0 to notmuch search Date: Sun, 16 Dec 2012 23:02:39 +0200 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: In-Reply-To: References: X-Gm-Message-State: ALoCoQkdp4PJo1JoEv8ukJeFurgmG6mYT6JBzB/AZVzI5COl7XwVa+ZWHClq0/IufrFK0/CuUenZ 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, 16 Dec 2012 21:02:56 -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