--- /dev/null
+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 49B4C42116E\r
+ for <notmuch@notmuchmail.org>; Sat, 17 Aug 2013 05:12:06 -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 Lnpr710Vnusl for <notmuch@notmuchmail.org>;\r
+ Sat, 17 Aug 2013 05:12:01 -0700 (PDT)\r
+Received: from mail-bk0-f49.google.com (mail-bk0-f49.google.com\r
+ [209.85.214.49]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id B297A421164\r
+ for <notmuch@notmuchmail.org>; Sat, 17 Aug 2013 05:11:44 -0700 (PDT)\r
+Received: by mail-bk0-f49.google.com with SMTP id r7so910343bkg.22\r
+ for <notmuch@notmuchmail.org>; Sat, 17 Aug 2013 05:11:43 -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=NG/O/Rbm6Yp8iPwA78WqtYtjhP1aDjP101L2NBI3HMg=;\r
+ b=Slu5qFu9Yb0gHbPMERFEATr+ex6RHHIjc/fNOoxEw4DfN6a5TPQYImS92BpmtWB3IA\r
+ HUFdGquksv7NPs4U9vdFayth0QCaDNe/kQN38AOj3QaTONzSBVdwWG88hCga27ER21bs\r
+ ENOdnsrmjzsKWep9cPW4rXjkb/W66ZO54uGVTpwuBMpR45UeToiWFZRa+6M6hS+NDDmv\r
+ cdHPj4c/Vptr50MWGGUorT7opmvEuENq4yVLam3VncopKnNzX0o3dWw1aaHzem0YpJpT\r
+ i6+MOBREwRzl8vXZsYVsagJN5QvXyY/YqRLIEupKwA9+5X8+st9ktP/JrnYXc3lmYlGD\r
+ TbMw==\r
+X-Gm-Message-State:\r
+ ALoCoQkVn+TxksUWrcy8joWdWxa7LdBtPRLuRW178nyZQelD9ZigHF9R+ychhjRplMBzIrcBKPUu\r
+X-Received: by 10.204.225.12 with SMTP id iq12mr1652252bkb.4.1376741503399;\r
+ Sat, 17 Aug 2013 05:11:43 -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 ku9sm251156bkb.1.1969.12.31.16.00.00\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 17 Aug 2013 05:11:42 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 4/8] cli: add --output=files option to notmuch count\r
+Date: Sat, 17 Aug 2013 15:11:29 +0300\r
+Message-Id:\r
+ <a074af5f0b74c84494c73d1e0202b2e84b962573.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:12:06 -0000\r
+\r
+Add support for querying the total number of files associated with the\r
+messages matching the search. This is mostly useful with an\r
+id:<message-id> query for a single message.\r
+---\r
+ notmuch-count.c | 37 +++++++++++++++++++++++++++++++++++++\r
+ 1 file changed, 37 insertions(+)\r
+\r
+diff --git a/notmuch-count.c b/notmuch-count.c\r
+index 8772cff..01e4e30 100644\r
+--- a/notmuch-count.c\r
++++ b/notmuch-count.c\r
+@@ -24,6 +24,7 @@\r
+ enum {\r
+ OUTPUT_THREADS,\r
+ OUTPUT_MESSAGES,\r
++ OUTPUT_FILES,\r
+ };\r
+ \r
+ /* The following is to allow future options to be added more easily */\r
+@@ -32,6 +33,38 @@ enum {\r
+ EXCLUDE_FALSE,\r
+ };\r
+ \r
++static unsigned int\r
++count_files (notmuch_query_t *query)\r
++{\r
++ notmuch_messages_t *messages;\r
++ notmuch_message_t *message;\r
++ notmuch_filenames_t *filenames;\r
++ unsigned int count = 0;\r
++\r
++ messages = notmuch_query_search_messages (query);\r
++ if (messages == NULL)\r
++ return 0;\r
++\r
++ for (;\r
++ notmuch_messages_valid (messages);\r
++ notmuch_messages_move_to_next (messages)) {\r
++ message = notmuch_messages_get (messages);\r
++ filenames = notmuch_message_get_filenames (message);\r
++\r
++ for (;\r
++ notmuch_filenames_valid (filenames);\r
++ notmuch_filenames_move_to_next (filenames))\r
++ count++;\r
++\r
++ notmuch_filenames_destroy (filenames);\r
++ notmuch_message_destroy (message);\r
++ }\r
++\r
++ notmuch_messages_destroy (messages);\r
++\r
++ return count;\r
++}\r
++\r
+ static int\r
+ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+ const char **exclude_tags, size_t exclude_tags_length, int output)\r
+@@ -55,6 +88,9 @@ print_count (notmuch_database_t *notmuch, const char *query_str,\r
+ case OUTPUT_THREADS:\r
+ printf ("%u\n", notmuch_query_count_threads (query));\r
+ break;\r
++ case OUTPUT_FILES:\r
++ printf ("%u\n", count_files (query));\r
++ break;\r
+ }\r
+ \r
+ notmuch_query_destroy (query);\r
+@@ -102,6 +138,7 @@ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[])\r
+ { NOTMUCH_OPT_KEYWORD, &output, "output", 'o',\r
+ (notmuch_keyword_t []){ { "threads", OUTPUT_THREADS },\r
+ { "messages", OUTPUT_MESSAGES },\r
++ { "files", OUTPUT_FILES },\r
+ { 0, 0 } } },\r
+ { NOTMUCH_OPT_KEYWORD, &exclude, "exclude", 'x',\r
+ (notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },\r
+-- \r
+1.7.10.4\r
+\r