--- /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 4E2BF431FBF\r
+ for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:57 -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 g6vWVQpyH0TF for <notmuch@notmuchmail.org>;\r
+ Sun, 11 May 2014 01:34:51 -0700 (PDT)\r
+Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com\r
+ [74.125.82.47]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client\r
+ certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
+ 99F51431FC0 for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:51 -0700\r
+ (PDT)\r
+Received: by mail-wg0-f47.google.com with SMTP id x12so5511982wgg.6\r
+ for <notmuch@notmuchmail.org>; Sun, 11 May 2014 01:34:49 -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=N1+1WnnbCmlsWbuJns99+T3NGsJZvexJr6Fu1BEjHW8=;\r
+ b=OZ2On+P3Pnq7wDfmR6yQB1+wGpy+va4AJYo4YP+Q/cC37AVfJKtOUJ2/n+GNUxKwTJ\r
+ 11hxLfHRjZ5AkAe9vRjMgtPChZON6Y6hRkHkq62vDTUUDkOdkNH/qlWOXhRCM045BOOO\r
+ fuyk2IgsZQIk4MXXgQFxA/CSgTgNgJjOwZn4nj3i9gOtkV/pQ1Ds7DAEkrzKxzHT4z9s\r
+ 9tf0uE3crxAOJ9tHChOZLhKN9vjg1sdKA44PDnGRu/yEXMfjqIMneRENq0c/Kgt8khYW\r
+ dKI8y3l6jhIVtztWN1c3IT266ddAv83ySmacgKS2zN/pFqLNJukQWzABSqBb08Ce5rhf\r
+ WThA==\r
+X-Received: by 10.194.206.2 with SMTP id lk2mr15971349wjc.33.1399797289354;\r
+ Sun, 11 May 2014 01:34:49 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by mx.google.com with ESMTPSA id gz1sm9091621wib.14.2014.05.11.01.34.48\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 11 May 2014 01:34:48 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/7] emacs: hello: separate out the saved-search display\r
+ function\r
+Date: Sun, 11 May 2014 09:34:36 +0100\r
+Message-Id: <1399797282-20389-2-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:34:57 -0000\r
+\r
+Separate the code that prints a saved-search and count into its own\r
+function.\r
+---\r
+ emacs/notmuch-hello.el | 30 +++++++++++++++++++-----------\r
+ 1 file changed, 19 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 3de5238..0a7004c 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -475,6 +475,22 @@ (defun notmuch-hello-filtered-query (query filter)\r
+ (concat "(" query ") and (" filter ")"))\r
+ (t query)))\r
+ \r
++(defun notmuch-hello-batch-message-count (elem-plist options)\r
++ "Update the message count for a saved search.\r
++\r
++This takes the next line in the current buffer (the output from a\r
++call to notmuch count --batch) as the message count and sets\r
++the :count property in ELEM-PLIST to it."\r
++ (let* ((count (prog1 (read (current-buffer))\r
++ (forward-line 1)))\r
++ (search-query (plist-get elem-plist :query))\r
++ (filtered-query (notmuch-hello-filtered-query\r
++ search-query (plist-get options :filter))))\r
++ (when (and filtered-query (or (plist-get options :show-empty-searches)\r
++ (> count 0)))\r
++ (setq elem-plist (plist-put elem-plist :query filtered-query))\r
++ (plist-put elem-plist :count (notmuch-hello-nice-number count)))))\r
++\r
+ (defun notmuch-hello-query-counts (query-list &rest options)\r
+ "Compute list of counts of matched messages from QUERY-LIST.\r
+ \r
+@@ -514,15 +530,8 @@ (defun notmuch-hello-query-counts (query-list &rest options)\r
+ #'identity\r
+ (mapcar\r
+ (lambda (elem)\r
+- (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))\r
+- (search-query (plist-get elem-plist :query))\r
+- (filtered-query (notmuch-hello-filtered-query\r
+- search-query (plist-get options :filter)))\r
+- (message-count (prog1 (read (current-buffer))\r
+- (forward-line 1))))\r
+- (when (and filtered-query (or (plist-get options :show-empty-searches) (> message-count 0)))\r
+- (setq elem-plist (plist-put elem-plist :query filtered-query))\r
+- (plist-put elem-plist :count message-count))))\r
++ (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)))\r
++ (notmuch-hello-batch-message-count elem-plist options)))\r
+ query-list))))\r
+ \r
+ (defun notmuch-hello-insert-buttons (searches)\r
+@@ -558,8 +567,7 @@ (defun notmuch-hello-insert-buttons (searches)\r
+ (oldest-first t)\r
+ (otherwise notmuch-search-oldest-first)))\r
+ (msg-count (plist-get elem :count)))\r
+- (widget-insert (format "%8s "\r
+- (notmuch-hello-nice-number msg-count)))\r
++ (widget-insert (format "%8s " msg-count))\r
+ (widget-create 'push-button\r
+ :notify #'notmuch-hello-widget-search\r
+ :notmuch-search-terms query\r
+-- \r
+1.7.10.4\r
+\r