[PATCH v3 1/8] cli: add --duplicate=N option to notmuch search
authorJani Nikula <jani@nikula.org>
Sat, 17 Aug 2013 12:11:26 +0000 (15:11 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:56:22 +0000 (09:56 -0800)
73/f6010f300bb191630607b156ae94a3c52c4832 [new file with mode: 0644]

diff --git a/73/f6010f300bb191630607b156ae94a3c52c4832 b/73/f6010f300bb191630607b156ae94a3c52c4832
new file mode 100644 (file)
index 0000000..29e9f5a
--- /dev/null
@@ -0,0 +1,144 @@
+Return-Path: <jani@nikula.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id AEB49429E5D\r
+       for <notmuch@notmuchmail.org>; Sat, 17 Aug 2013 05:11:41 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References"\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id FelIe38QyDgs for <notmuch@notmuchmail.org>;\r
+       Sat, 17 Aug 2013 05:11:36 -0700 (PDT)\r
+Received: from mail-bk0-f45.google.com (mail-bk0-f45.google.com\r
+       [209.85.214.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id F0E1C431E82\r
+       for <notmuch@notmuchmail.org>; Sat, 17 Aug 2013 05:11:35 -0700 (PDT)\r
+Received: by mail-bk0-f45.google.com with SMTP id mx11so913478bkb.18\r
+       for <notmuch@notmuchmail.org>; Sat, 17 Aug 2013 05:11:34 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+       d=google.com; s=20120113;\r
+       h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+       :references:in-reply-to:references;\r
+       bh=MmYw4TKA8Xbd3O7DA8EMUslE6/k1CJwzGMT8Xl+cCVk=;\r
+       b=jgkTvEAc90fq8yGQ40OGN2nY0Y4H0aeTWplMqE+/MAiOcPG3J0WF1E6NkFgN5yJcl5\r
+       blnNm04IcnejzWJTqf1ESbokq0XiOU1eEqfzo5YK02K9ThurwaS+ozIlSEOOpm4sAjOm\r
+       2i7DXUYtWpuMEk3JIUB1NC4MpcwF0y3Uydvg41o3Tt7pAlRlRR/v75t22GCiKAQCmp/n\r
+       nziAncJEDh36iLQMXfiog+1LR3xYhhLakojy5EZRBn0xv3CWDmVXUBPzhhveQbpl8btz\r
+       KaYNXSN1Z+uS7b5LQg18OsJfLNfwfgQ//iQR0GIW2qrpgAGraivGbQscvvcvd4f2DZfF\r
+       7Z1g==\r
+X-Gm-Message-State:\r
+ ALoCoQnpaZcOBN9tzENBgQ5nebTUG2SE6cuxwmG1MucHRNopeXvamBfdBSksh/3+TY/YT5nQaowu\r
+X-Received: by 10.205.10.132 with SMTP id pa4mr3931980bkb.15.1376741493407;\r
+       Sat, 17 Aug 2013 05:11:33 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+       [88.195.111.91])\r
+       by mx.google.com with ESMTPSA id h5sm249685bkg.8.1969.12.31.16.00.00\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Sat, 17 Aug 2013 05:11:32 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 1/8] cli: add --duplicate=N option to notmuch search\r
+Date: Sat, 17 Aug 2013 15:11:26 +0300\r
+Message-Id:\r
+ <bbe225e1cc50211258f85a8533a83093337bde3f.1376741447.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <cover.1376741447.git.jani@nikula.org>\r
+References: <cover.1376741447.git.jani@nikula.org>\r
+In-Reply-To: <cover.1376741447.git.jani@nikula.org>\r
+References: <cover.1376741447.git.jani@nikula.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 17 Aug 2013 12:11:41 -0000\r
+\r
+Effective with --output=files, output the Nth filename associated with\r
+each message matching the query (N is 1-based). If N is greater than\r
+the number of files associated with the message, don't print anything.\r
+\r
+---\r
+\r
+v3: fix commit message, no other changes\r
+---\r
+ notmuch-search.c |   18 ++++++++++++------\r
+ 1 file changed, 12 insertions(+), 6 deletions(-)\r
+\r
+diff --git a/notmuch-search.c b/notmuch-search.c\r
+index a96f07d..d9d39ec 100644\r
+--- a/notmuch-search.c\r
++++ b/notmuch-search.c\r
+@@ -177,7 +177,8 @@ do_search_messages (sprinter_t *format,\r
+                   notmuch_query_t *query,\r
+                   output_t output,\r
+                   int offset,\r
+-                  int limit)\r
++                  int limit,\r
++                  int dupe)\r
+ {\r
+     notmuch_message_t *message;\r
+     notmuch_messages_t *messages;\r
+@@ -206,14 +207,17 @@ do_search_messages (sprinter_t *format,\r
+       message = notmuch_messages_get (messages);\r
\r
+       if (output == OUTPUT_FILES) {\r
++          int j;\r
+           filenames = notmuch_message_get_filenames (message);\r
\r
+-          for (;\r
++          for (j = 1;\r
+                notmuch_filenames_valid (filenames);\r
+-               notmuch_filenames_move_to_next (filenames))\r
++               notmuch_filenames_move_to_next (filenames), j++)\r
+           {\r
+-              format->string (format, notmuch_filenames_get (filenames));\r
+-              format->separator (format);\r
++              if (dupe < 0 || dupe == j) {\r
++                  format->string (format, notmuch_filenames_get (filenames));\r
++                  format->separator (format);\r
++              }\r
+           }\r
+           \r
+           notmuch_filenames_destroy( filenames );\r
+@@ -296,6 +300,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+     int offset = 0;\r
+     int limit = -1; /* unlimited */\r
+     notmuch_exclude_t exclude = NOTMUCH_EXCLUDE_TRUE;\r
++    int dupe = -1;\r
+     unsigned int i;\r
\r
+     enum {\r
+@@ -332,6 +337,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+                                   { 0, 0 } } },\r
+       { NOTMUCH_OPT_INT, &offset, "offset", 'O', 0 },\r
+       { NOTMUCH_OPT_INT, &limit, "limit", 'L', 0  },\r
++      { NOTMUCH_OPT_INT, &dupe, "duplicate", 'D', 0  },\r
+       { 0, 0, 0, 0, 0 }\r
+     };\r
\r
+@@ -414,7 +420,7 @@ notmuch_search_command (notmuch_config_t *config, int argc, char *argv[])\r
+       break;\r
+     case OUTPUT_MESSAGES:\r
+     case OUTPUT_FILES:\r
+-      ret = do_search_messages (format, query, output, offset, limit);\r
++      ret = do_search_messages (format, query, output, offset, limit, dupe);\r
+       break;\r
+     case OUTPUT_TAGS:\r
+       ret = do_search_tags (notmuch, format, query);\r
+-- \r
+1.7.10.4\r
+\r