--- /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 45279431FC3\r
+ for <notmuch@notmuchmail.org>; Sun, 31 Mar 2013 02:46:30 -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 2H8MENHFpXB5 for <notmuch@notmuchmail.org>;\r
+ Sun, 31 Mar 2013 02:46:29 -0700 (PDT)\r
+Received: from mail-la0-f45.google.com (mail-la0-f45.google.com\r
+ [209.85.215.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A3F94429E35\r
+ for <notmuch@notmuchmail.org>; Sun, 31 Mar 2013 02:46:24 -0700 (PDT)\r
+Received: by mail-la0-f45.google.com with SMTP id er20so1462708lab.32\r
+ for <notmuch@notmuchmail.org>; Sun, 31 Mar 2013 02:46:23 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=google.com; s=20120113;\r
+ h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to\r
+ :references:in-reply-to:references:x-gm-message-state;\r
+ bh=2xAOn7Li7EL6Z30EI/5y7AAh4fM0Ecb7KaJmOTAgp20=;\r
+ b=W5CWbcXahFMus7Gq5a9fyEYVENtdAnwcyZ9vxCb0dku/bZqmCDqOzd/X7eccjLqVPm\r
+ OEuOUHac2J/JBmRjaPocJ7O8Hlg0fgez5J6DGmeXCtkYkR/DqDQted+78NAXkjUKNCyk\r
+ MelQwjLaISrTIw2RRpvkwvC5yOn7JF8CENP+ag18TK1glG6ChGftfeB3sAHSfnHnQ/Fl\r
+ FC8eKF/ubdvsMe6qc4zunbjcIiohTyUBzeqNAgb7Zc+FHTlXYEr7QvFvNTLBczHok/so\r
+ j58rW/dy9JR6GjLu+GyY/53tWzkpGuIuRkcpPgGxDJvgjIwbEE22UXKRCsuG6QzdemCK\r
+ Opwg==\r
+X-Received: by 10.112.99.5 with SMTP id em5mr4078672lbb.1.1364723183195;\r
+ Sun, 31 Mar 2013 02:46:23 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw4-50df51-27.dhcp.inet.fi.\r
+ [80.223.81.27])\r
+ by mx.google.com with ESMTPS id q9sm3742335lbz.3.2013.03.31.02.46.21\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sun, 31 Mar 2013 02:46:22 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 6/6] emacs: hello: use batch count\r
+Date: Sun, 31 Mar 2013 12:46:03 +0300\r
+Message-Id:\r
+ <e1ccb1853bb692eb95ee4ed92c485ffe7bfecf5d.1364722841.git.jani@nikula.org>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <cover.1364722841.git.jani@nikula.org>\r
+References: <cover.1364722841.git.jani@nikula.org>\r
+In-Reply-To: <cover.1364722841.git.jani@nikula.org>\r
+References: <cover.1364722841.git.jani@nikula.org>\r
+X-Gm-Message-State:\r
+ ALoCoQky46uejxIIOpQHNk9P4qWHh79OIsgh42X1tMLdrRgNC/yrLZw53iTmDcIACCmZfG7CTf7D\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\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, 31 Mar 2013 09:46:30 -0000\r
+\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+\r
+This modifies notmuch hello to use the new count --batch\r
+functionality. It should give exactly the same results as before but\r
+under many conditions it should be much faster. In particular it is\r
+much faster for remote use.\r
+\r
+The code is a little ugly as it has to do some working out of the\r
+query when asking the query and some when dealing with the result.\r
+However, the code path is exactly the same in both local and remote\r
+use.\r
+---\r
+ emacs/notmuch-hello.el | 52 +++++++++++++++++++++++++++++-------------------\r
+ 1 file changed, 32 insertions(+), 20 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 00b78e1..cda79f1 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -381,26 +381,38 @@ The result is the list of elements of the form (NAME QUERY COUNT).\r
+ The values :show-empty-searches, :filter and :filter-count from\r
+ options will be handled as specified for\r
+ `notmuch-hello-insert-searches'."\r
+- (notmuch-remove-if-not\r
+- #'identity\r
+- (mapcar\r
+- (lambda (elem)\r
+- (let* ((name (car elem))\r
+- (query-and-count (if (consp (cdr elem))\r
+- ;; do we have a different query for the message count?\r
+- (cons (second elem) (third elem))\r
+- (cons (cdr elem) (cdr elem))))\r
+- (message-count\r
+- (string-to-number\r
+- (notmuch-saved-search-count\r
+- (notmuch-hello-filtered-query (cdr query-and-count)\r
+- (or (plist-get options :filter-count)\r
+- (plist-get options :filter)))))))\r
+- (and (or (plist-get options :show-empty-searches) (> message-count 0))\r
+- (list name (notmuch-hello-filtered-query\r
+- (car query-and-count) (plist-get options :filter))\r
+- message-count))))\r
+- query-alist)))\r
++ (with-temp-buffer\r
++ (dolist (elem query-alist nil)\r
++ (let ((count-query (if (consp (cdr elem))\r
++ ;; do we have a different query for the message count?\r
++ (third elem)\r
++ (cdr elem))))\r
++ (insert\r
++ (notmuch-hello-filtered-query count-query\r
++ (or (plist-get options :filter-count)\r
++ (plist-get options :filter)))\r
++ "\n")))\r
++\r
++ (call-process-region (point-min) (point-max) notmuch-command\r
++ t t nil "count" "--batch")\r
++ (goto-char (point-min))\r
++\r
++ (notmuch-remove-if-not\r
++ #'identity\r
++ (mapcar\r
++ (lambda (elem)\r
++ (let ((name (car elem))\r
++ (search-query (if (consp (cdr elem))\r
++ ;; do we have a different query for the message count?\r
++ (second elem)\r
++ (cdr elem)))\r
++ (message-count (prog1 (read (current-buffer))\r
++ (forward-line 1))))\r
++ (and (or (plist-get options :show-empty-searches) (> message-count 0))\r
++ (list name (notmuch-hello-filtered-query\r
++ search-query (plist-get options :filter))\r
++ message-count))))\r
++ query-alist))))\r
+ \r
+ (defun notmuch-hello-insert-buttons (searches)\r
+ "Insert buttons for SEARCHES.\r
+-- \r
+1.7.10.4\r
+\r