--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\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 1AD57431FDE\r
+ for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:35:07 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ 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 sHsNimsaWPZQ for <notmuch@notmuchmail.org>;\r
+ Sun, 11 May 2014 01:35:02 -0700 (PDT)\r
+Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com\r
+ [209.85.212.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A000E431FC4\r
+ for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:56 -0700 (PDT)\r
+Received: by mail-wi0-f179.google.com with SMTP id bs8so3127287wib.0\r
+ for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:54 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=IpMfDVDE2qHBwlzwRRn1AMd+cpFwdKfkM+Gl0aVpQ00=;\r
+ b=e6gusMWkHSxbyWhRwiGh7JBf5lGhvG/F2QwcEq1IFypc+WxLH8NLZpUQ7qQraw+z/b\r
+ /MnqGWYqva1elTGSm7AzZLCLdeZMZZBQz25lgRcJxTh8HoOURt2mXO3BFqSjnuS0tm/x\r
+ xIPe7EArOe3kgTWgH0jrCB3mH+b/P1hR9dhSZElFlZ5qG9GQNrOV9Nej2iB54Cb6gyK2\r
+ lVS2rIDht67IyDjN9hEFVKDATdmSFi0f1EH2GQmGkVYcbDzCtYR/OJaox2kJJ5g27wrq\r
+ oZkwI760To0lR+X1OWIy6221bA7TwLb6xPWEFur1H0v46KxvWKurX5rOkVSVwNCHQR/k\r
+ XrjA==\r
+X-Received: by 10.194.175.70 with SMTP id by6mr16128915wjc.3.1399797294441;\r
+ Sun, 11 May 2014 01:34:54 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by mx.google.com with ESMTPSA id fi2sm9107958wib.2.2014.05.11.01.34.53\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 11 May 2014 01:34:53 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 4/7] emacs: hello: add a threads-and-messages function\r
+Date: Sun, 11 May 2014 09:34:39 +0100\r
+Message-Id: <1399797282-20389-5-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1399797282-20389-1-git-send-email-markwalters1009@gmail.com>\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, 11 May 2014 08:35:07 -0000\r
+\r
+This is an example of a possible display function. It displays the\r
+count for a search as messages/threads. This will be slow on a large\r
+search but could be useful for a small search.\r
+\r
+It also extends and renames the existing (unused)\r
+notmuch-saved-search-count function to count threads if wanted. The\r
+rename is done because the function is not saved-search specific.\r
+---\r
+ emacs/notmuch-hello.el | 30 +++++++++++++++++++++++++-----\r
+ 1 file changed, 25 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index e11006b..6b2dedc 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -90,8 +90,13 @@ (define-widget 'notmuch-saved-search-plist 'list\r
+ (const :tag "Default" nil)\r
+ (const :tag "Oldest-first" oldest-first)\r
+ (const :tag "Newest-first" newest-first)))\r
+- (group :format "%v" :inline t (const :format "Display-function: " :display-function) (function :format "%v")))))\r
+-\r
++ (group :format "%v" :inline t\r
++ (const :format "" :display-function)\r
++ (choice :tag " Display function"\r
++ (const :tag "Default (messages)" nil)\r
++ (function-item :tag "messages/threads"\r
++ notmuch-hello-display-count-threads-and-messages)\r
++ function)))))\r
+ \r
+ (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox")\r
+ (:name "unread" :query "tag:unread"))\r
+@@ -435,9 +440,6 @@ (defun notmuch-hello-widget-search (widget &rest ignore)\r
+ (widget-get widget\r
+ :notmuch-search-oldest-first)))\r
+ \r
+-(defun notmuch-saved-search-count (search)\r
+- (car (process-lines notmuch-command "count" search)))\r
+-\r
+ (defun notmuch-hello-tags-per-line (widest)\r
+ "Determine how many tags to show per line and how wide they\r
+ should be. Returns a cons cell `(tags-per-line width)'."\r
+@@ -487,6 +489,24 @@ (defun notmuch-hello-filtered-query (query filter)\r
+ (concat "(" query ") and (" filter ")"))\r
+ (t query)))\r
+ \r
++(defun notmuch-hello-count (query &optional threads)\r
++ (let ((arg (if threads "--output=threads" "--output=messages")))\r
++ (string-to-number\r
++ (car (process-lines notmuch-command "count" arg query)))))\r
++\r
++(defun notmuch-hello-display-count-threads-and-messages (&rest args)\r
++ "Display the saved search count as messages/threads.\r
++\r
++This will be slow for large queries."\r
++ (let* ((current (plist-get args :current))\r
++ (query (plist-get current :query))\r
++ (messages (notmuch-hello-count query nil))\r
++ (threads (notmuch-hello-count query t))\r
++ (display (concat (notmuch-hello-nice-number messages)\r
++ "/"\r
++ (notmuch-hello-nice-number threads))))\r
++ (plist-put current :count display)))\r
++\r
+ (defun notmuch-hello-batch-message-count (elem-plist options)\r
+ "Update the message count for a saved search.\r
+ \r
+-- \r
+1.7.10.4\r
+\r