--- /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 4D8B5431E64\r
+ for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:33:09 -0800 (PST)\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 HUN9YlOFzSmI for <notmuch@notmuchmail.org>;\r
+ Sun, 19 Jan 2014 12:33:03 -0800 (PST)\r
+Received: from mail-ea0-f173.google.com (mail-ea0-f173.google.com\r
+ [209.85.215.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 0A500431FC0\r
+ for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:49 -0800 (PST)\r
+Received: by mail-ea0-f173.google.com with SMTP id o10so2704189eaj.32\r
+ for <notmuch@notmuchmail.org>; Sun, 19 Jan 2014 12:32:48 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references:in-reply-to:references;\r
+ bh=GN27nkrca6L387o5tQ5mtCNaTql1AeLIZ3fwHje/bEA=;\r
+ b=D8Gnnxc6mkIGyR+qSRtA2tnD0juBN4RtPYBLKvmU92ItSnY01bg4GpaPcMzfMZ9EU4\r
+ 2Lu2ERHdpg865Zij1kvBPvc50mYQfED8HPh/44MINJDO4SBv8o6bkmilA6NOvJlF/859\r
+ kLwSFRLSEQmL/iiwwH3hcYzZmVsNI3hdRaHLjkTq5Uh4zn8cfDZ9nqWdl7nvqbh9Z6TZ\r
+ mq8BHNpQigOzT76x2/Ssd68GSnLDIaTwGSS2R+epletOITX5inCIlWW/yxQEEFTntZYm\r
+ PotFkC7RNHmPKIbJFMO3p+WbFW5LNZQsTw/5bOdme8vox4cueTDfQIKyQlUjIjp8JgnU\r
+ GjEQ==\r
+X-Gm-Message-State:\r
+ ALoCoQkkNgl+kvYhTmM9tiXIUtvQpPjkzHr6gfImtoXMUIWJdfDssUBEA8lPX4PYa8Ayl4DBdARq\r
+X-Received: by 10.15.94.201 with SMTP id bb49mr14162929eeb.45.1390163568893;\r
+ Sun, 19 Jan 2014 12:32:48 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91]) by mx.google.com with ESMTPSA id\r
+ j46sm46540798eew.18.2014.01.19.12.32.47 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 19 Jan 2014 12:32:48 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 5/7] cli: abstract notmuch new result printing\r
+Date: Sun, 19 Jan 2014 22:32:26 +0200\r
+Message-Id:\r
+ <3c2ac7334d0f57b35c7cb53b6231f7a9b325d1b0.1390163335.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.5.2\r
+In-Reply-To: <cover.1390163335.git.jani@nikula.org>\r
+References: <cover.1390163335.git.jani@nikula.org>\r
+In-Reply-To: <cover.1390163335.git.jani@nikula.org>\r
+References: <cover.1390163335.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: Sun, 19 Jan 2014 20:33:09 -0000\r
+\r
+The notmuch_new_command() function has grown huge, chop it up a\r
+bit. This should also be helpful when adding a --quiet option to\r
+notmuch new. No functional changes.\r
+---\r
+ notmuch-new.c | 80 +++++++++++++++++++++++++++++------------------------------\r
+ 1 file changed, 39 insertions(+), 41 deletions(-)\r
+\r
+diff --git a/notmuch-new.c b/notmuch-new.c\r
+index f6d9c3a..c443181 100644\r
+--- a/notmuch-new.c\r
++++ b/notmuch-new.c\r
+@@ -864,13 +864,49 @@ _remove_directory (void *ctx,\r
+ return status;\r
+ }\r
+ \r
++static void\r
++print_results (const add_files_state_t *state)\r
++{\r
++ double elapsed;\r
++ struct timeval tv_now;\r
++\r
++ gettimeofday (&tv_now, NULL);\r
++ elapsed = notmuch_time_elapsed (state->tv_start, tv_now);\r
++\r
++ if (state->processed_files) {\r
++ printf ("Processed %d %s in ", state->processed_files,\r
++ state->processed_files == 1 ? "file" : "total files");\r
++ notmuch_time_print_formatted_seconds (elapsed);\r
++ if (elapsed > 1)\r
++ printf (" (%d files/sec.).\033[K\n",\r
++ (int) (state->processed_files / elapsed));\r
++ else\r
++ printf (".\033[K\n");\r
++ }\r
++\r
++ if (state->added_messages)\r
++ printf ("Added %d new %s to the database.", state->added_messages,\r
++ state->added_messages == 1 ? "message" : "messages");\r
++ else\r
++ printf ("No new mail.");\r
++\r
++ if (state->removed_messages)\r
++ printf (" Removed %d %s.", state->removed_messages,\r
++ state->removed_messages == 1 ? "message" : "messages");\r
++\r
++ if (state->renamed_messages)\r
++ printf (" Detected %d file %s.", state->renamed_messages,\r
++ state->renamed_messages == 1 ? "rename" : "renames");\r
++\r
++ printf ("\n");\r
++}\r
++\r
+ int\r
+ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+ {\r
+ notmuch_database_t *notmuch;\r
+ add_files_state_t add_files_state;\r
+- double elapsed;\r
+- struct timeval tv_now, tv_start;\r
++ struct timeval tv_start;\r
+ int ret = 0;\r
+ struct stat st;\r
+ const char *db_path;\r
+@@ -1017,45 +1053,7 @@ notmuch_new_command (notmuch_config_t *config, int argc, char *argv[])\r
+ if (timer_is_active)\r
+ stop_progress_printing_timer ();\r
+ \r
+- gettimeofday (&tv_now, NULL);\r
+- elapsed = notmuch_time_elapsed (add_files_state.tv_start,\r
+- tv_now);\r
+-\r
+- if (add_files_state.processed_files) {\r
+- printf ("Processed %d %s in ", add_files_state.processed_files,\r
+- add_files_state.processed_files == 1 ?\r
+- "file" : "total files");\r
+- notmuch_time_print_formatted_seconds (elapsed);\r
+- if (elapsed > 1) {\r
+- printf (" (%d files/sec.).\033[K\n",\r
+- (int) (add_files_state.processed_files / elapsed));\r
+- } else {\r
+- printf (".\033[K\n");\r
+- }\r
+- }\r
+-\r
+- if (add_files_state.added_messages) {\r
+- printf ("Added %d new %s to the database.",\r
+- add_files_state.added_messages,\r
+- add_files_state.added_messages == 1 ?\r
+- "message" : "messages");\r
+- } else {\r
+- printf ("No new mail.");\r
+- }\r
+-\r
+- if (add_files_state.removed_messages) {\r
+- printf (" Removed %d %s.",\r
+- add_files_state.removed_messages,\r
+- add_files_state.removed_messages == 1 ? "message" : "messages");\r
+- }\r
+-\r
+- if (add_files_state.renamed_messages) {\r
+- printf (" Detected %d file %s.",\r
+- add_files_state.renamed_messages,\r
+- add_files_state.renamed_messages == 1 ? "rename" : "renames");\r
+- }\r
+-\r
+- printf ("\n");\r
++ print_results (&add_files_state);\r
+ \r
+ if (ret)\r
+ fprintf (stderr, "Note: A fatal error was encountered: %s\n",\r
+-- \r
+1.8.5.2\r
+\r