--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 365A76DE1B7F\r
+ for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 16:03:11 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.519\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.519 tagged_above=-999 required=5 tests=[AWL=0.509, \r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 0VnzuO-pRVzu for <notmuch@notmuchmail.org>;\r
+ Sun, 5 Apr 2015 16:03:09 -0700 (PDT)\r
+Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net\r
+ [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id ACFBA6DE1BB6\r
+ for <notmuch@notmuchmail.org>; Sun, 5 Apr 2015 16:03:01 -0700 (PDT)\r
+Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim\r
+ 4.80) (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1YetYZ-0002pl-PW; Sun, 05 Apr 2015 23:02:19 +0000\r
+Received: (nullmailer pid 2245 invoked by uid 1000); Sun, 05 Apr 2015\r
+ 22:59:25 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [WIP2 05/12] cli: add two sprinter utility functions\r
+Date: Mon, 6 Apr 2015 07:59:07 +0900\r
+Message-Id: <1428274754-1698-6-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1428274754-1698-1-git-send-email-david@tethera.net>\r
+References: <1428274754-1698-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\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, 05 Apr 2015 23:03:11 -0000\r
+\r
+These are called directly, rather than via a vtable. They will\r
+help add common metadata to search/show/reply\r
+---\r
+ devel/schemata | 1 +\r
+ sprinter-utils.c | 41 +++++++++++++++++++++++++++++++++++++++++\r
+ sprinter.h | 7 +++++++\r
+ 3 files changed, 49 insertions(+)\r
+ create mode 100644 sprinter-utils.c\r
+\r
+diff --git a/devel/schemata b/devel/schemata\r
+index 41dc4a6..98a1b2b 100644\r
+--- a/devel/schemata\r
++++ b/devel/schemata\r
+@@ -147,6 +147,7 @@ search_files = [string*]\r
+ search_tags = [string*]\r
+ \r
+ thread_summary = {\r
++ database: database_metadata\r
+ thread: threadid,\r
+ timestamp: unix_time,\r
+ date_relative: string, # user-friendly timestamp\r
+diff --git a/sprinter-utils.c b/sprinter-utils.c\r
+new file mode 100644\r
+index 0000000..2ba588e\r
+--- /dev/null\r
++++ b/sprinter-utils.c\r
+@@ -0,0 +1,41 @@\r
++#include "notmuch-client.h"\r
++#include "sprinter.h"\r
++\r
++notmuch_status_t\r
++sprinter_start_output (sprinter_t *sp,\r
++ const notmuch_query_t *query,\r
++ const char *query_type)\r
++{\r
++ long int rev;\r
++ const char *uuid;\r
++ notmuch_database_t *notmuch;\r
++\r
++ sp->begin_list (sp);\r
++\r
++ if (sp->type != NOTMUCH_SPRINTER_TEXT && notmuch_format_version >= 3) {\r
++ notmuch = notmuch_query_get_database (query);\r
++\r
++ rev = notmuch_database_get_revision (notmuch, &uuid);\r
++\r
++ sp->begin_map (sp);\r
++ sp->map_key (sp, "query_type");\r
++ sp->string (sp, query_type);\r
++\r
++ sp->map_key (sp, "uuid");\r
++ sp->string (sp, uuid);\r
++\r
++ sp->map_key (sp, "lastmod");\r
++ sp->integer (sp, rev);\r
++\r
++ sp->end (sp);\r
++\r
++ }\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++}\r
++\r
++notmuch_status_t\r
++sprinter_finish_output (sprinter_t *sp)\r
++{\r
++ sp->end (sp); /* map */\r
++ return NOTMUCH_STATUS_SUCCESS;\r
++}\r
+diff --git a/sprinter.h b/sprinter.h\r
+index 7e58f69..4873f69 100644\r
+--- a/sprinter.h\r
++++ b/sprinter.h\r
+@@ -91,4 +91,11 @@ sprinter_json_create (const void *ctx, FILE *stream);\r
+ struct sprinter *\r
+ sprinter_sexp_create (const void *ctx, FILE *stream);\r
+ \r
++notmuch_status_t\r
++sprinter_start_output (struct sprinter *sp,\r
++ const notmuch_query_t *query,\r
++ const char *query_type);\r
++\r
++notmuch_status_t\r
++sprinter_finish_output (struct sprinter *sp);\r
+ #endif // NOTMUCH_SPRINTER_H\r
+-- \r
+2.1.4\r
+\r