From 68cc3c141c2bcea1506463382d1beee0c104ed5f Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Mon, 17 Dec 2012 00:05:11 +0200 Subject: [PATCH] [PATCH v4 3/5] cli: add --format=text0 to notmuch search --- 8a/28234fe9ec75962836e5ab42132a837112dd35 | 120 ++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 8a/28234fe9ec75962836e5ab42132a837112dd35 diff --git a/8a/28234fe9ec75962836e5ab42132a837112dd35 b/8a/28234fe9ec75962836e5ab42132a837112dd35 new file mode 100644 index 000000000..909ce18b4 --- /dev/null +++ b/8a/28234fe9ec75962836e5ab42132a837112dd35 @@ -0,0 +1,120 @@ +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 4F809431FC0 + for ; Sun, 16 Dec 2012 14:05:29 -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 FowfaireEszM for ; + Sun, 16 Dec 2012 14:05:27 -0800 (PST) +Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com + [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 37AB1429E34 + for ; Sun, 16 Dec 2012 14:05:27 -0800 (PST) +Received: by mail-lb0-f181.google.com with SMTP id ge1so4072140lbb.26 + for ; Sun, 16 Dec 2012 14:05:25 -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=h+5ItNnYKblODbKUDb/r/dljMhbz3lBRx6ePs+998jY=; + b=aaeoIjp6e9qwq6Y7NqSel9xIRLILnofEEq5/qrpuyigDc8x2FnoVZ4v2wrWWNxjDEh + L5pFruAfKHctt3CyWFZb4y5AddksoHXgiulgX1i5Q74LPvcUPf2x4OeZ0fpLD70rHF1A + PZtnHD/1qtJiJ+P5aDu4rTwk0DLzqhZJ37ofh0HRpmwbaXW+jCKqTcyOsC3NMhzhY5gE + ZyldDBsT6o3VwpNG6Y0AST+Mpw/ekJ4G2k4IStujSo87nRXTsoUxGKjVTXC8Elz4TP2Y + rmjQT2h9G8bCy6lYI069UkKTu4Owb+SDUOl/55MCX4WlYgMbHHLXc9NS3eZ+w6dzfsKA + 6Iyw== +Received: by 10.152.124.111 with SMTP id mh15mr8860466lab.20.1355695525542; + Sun, 16 Dec 2012 14:05:25 -0800 (PST) +Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi. + [80.223.81.27]) + by mx.google.com with ESMTPS id sj3sm4118153lab.2.2012.12.16.14.05.23 + (version=SSLv3 cipher=OTHER); Sun, 16 Dec 2012 14:05:24 -0800 (PST) +From: Jani Nikula +To: notmuch@notmuchmail.org +Subject: [PATCH v4 3/5] cli: add --format=text0 to notmuch search +Date: Mon, 17 Dec 2012 00:05:11 +0200 +Message-Id: + +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: +References: +In-Reply-To: +References: +X-Gm-Message-State: + ALoCoQno4Qdn5eWkkQXuQKOn5sztPnwXuxK93yNhpX/D5m68IacpIyr+BWlF8XY4ZbQpRC56y9ly +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 22:05:29 -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 7704915..0b0a879 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_INT, ¬much_format_version, "format-version", 0, 0 }, + { NOTMUCH_OPT_KEYWORD, &output, "output", 'o', +@@ -346,6 +351,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 + -- 2.26.2