Re: [PATCH] emacs: hello: use batch count
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 23 Jan 2013 14:13:39 +0000 (16:13 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:19 +0000 (09:53 -0800)
d2/58106b952d735ceed724c51ace9583631e2671 [new file with mode: 0644]

diff --git a/d2/58106b952d735ceed724c51ace9583631e2671 b/d2/58106b952d735ceed724c51ace9583631e2671
new file mode 100644 (file)
index 0000000..77cb984
--- /dev/null
@@ -0,0 +1,151 @@
+Return-Path: <tomi.ollila@iki.fi>\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 4FFC2431FC0\r
+       for <notmuch@notmuchmail.org>; Wed, 23 Jan 2013 06:13:51 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 q-6M7kcj2iLR for <notmuch@notmuchmail.org>;\r
+       Wed, 23 Jan 2013 06:13:50 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 638D9431FAE\r
+       for <notmuch@notmuchmail.org>; Wed, 23 Jan 2013 06:13:50 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+       by guru.guru-group.fi (Postfix) with ESMTP id 8D0CD100086;\r
+       Wed, 23 Jan 2013 16:13:39 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] emacs: hello: use batch count\r
+In-Reply-To: <1358292247-2059-1-git-send-email-markwalters1009@gmail.com>\r
+References: <cover.1358273133.git.jani@nikula.org>\r
+       <1358292247-2059-1-git-send-email-markwalters1009@gmail.com>\r
+User-Agent: Notmuch/0.15+11~ge1e719d (http://notmuchmail.org) Emacs/24.2.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Wed, 23 Jan 2013 16:13:39 +0200\r
+Message-ID: <m27gn4htrg.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Wed, 23 Jan 2013 14:13:51 -0000\r
+\r
+On Wed, Jan 16 2013, Mark Walters <markwalters1009@gmail.com> wrote:\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
+\r
+Well, the code Looks Good To Me (not Bad or Ugly). Pretty straightforward\r
+conversion.\r
+\r
+Can we have newlines in query string^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H\r
+\r
+Tomi\r
+\r
+>\r
+> It's a little ugly but seems to work and does give a useful speedup.\r
+>\r
+> Best wishes\r
+>\r
+> Mark\r
+>\r
+>  emacs/notmuch-hello.el |   52 +++++++++++++++++++++++++++++------------------\r
+>  1 files changed, 32 insertions(+), 20 deletions(-)\r
+>\r
+> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+> index 6db62a0..2244892 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.9.1\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r