From 6c12c8b911ad55ef9347ccfc8ed19728cc9090d0 Mon Sep 17 00:00:00 2001 From: Tomi Ollila Date: Wed, 23 Jan 2013 16:13:39 +0200 Subject: [PATCH] Re: [PATCH] emacs: hello: use batch count --- d2/58106b952d735ceed724c51ace9583631e2671 | 151 ++++++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 d2/58106b952d735ceed724c51ace9583631e2671 diff --git a/d2/58106b952d735ceed724c51ace9583631e2671 b/d2/58106b952d735ceed724c51ace9583631e2671 new file mode 100644 index 000000000..77cb984fc --- /dev/null +++ b/d2/58106b952d735ceed724c51ace9583631e2671 @@ -0,0 +1,151 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 4FFC2431FC0 + for ; Wed, 23 Jan 2013 06:13:51 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id q-6M7kcj2iLR for ; + Wed, 23 Jan 2013 06:13:50 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 638D9431FAE + for ; Wed, 23 Jan 2013 06:13:50 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 8D0CD100086; + Wed, 23 Jan 2013 16:13:39 +0200 (EET) +From: Tomi Ollila +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH] emacs: hello: use batch count +In-Reply-To: <1358292247-2059-1-git-send-email-markwalters1009@gmail.com> +References: + <1358292247-2059-1-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.15+11~ge1e719d (http://notmuchmail.org) Emacs/24.2.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Wed, 23 Jan 2013 14:13:51 -0000 + +On Wed, Jan 16 2013, Mark Walters wrote: + +> This modifies notmuch hello to use the new count --batch +> functionality. It should give exactly the same results as before but +> under many conditions it should be much faster. In particular it is +> much faster for remote use. +> +> The code is a little ugly as it has to do some working out of the +> query when asking the query and some when dealing with the result. +> However, the code path is exactly the same in both local and remote +> use. +> --- + +Well, the code Looks Good To Me (not Bad or Ugly). Pretty straightforward +conversion. + +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 + +Tomi + +> +> It's a little ugly but seems to work and does give a useful speedup. +> +> Best wishes +> +> Mark +> +> emacs/notmuch-hello.el | 52 +++++++++++++++++++++++++++++------------------ +> 1 files changed, 32 insertions(+), 20 deletions(-) +> +> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +> index 6db62a0..2244892 100644 +> --- a/emacs/notmuch-hello.el +> +++ b/emacs/notmuch-hello.el +> @@ -381,26 +381,38 @@ The result is the list of elements of the form (NAME QUERY COUNT). +> The values :show-empty-searches, :filter and :filter-count from +> options will be handled as specified for +> `notmuch-hello-insert-searches'." +> - (notmuch-remove-if-not +> - #'identity +> - (mapcar +> - (lambda (elem) +> - (let* ((name (car elem)) +> - (query-and-count (if (consp (cdr elem)) +> - ;; do we have a different query for the message count? +> - (cons (second elem) (third elem)) +> - (cons (cdr elem) (cdr elem)))) +> - (message-count +> - (string-to-number +> - (notmuch-saved-search-count +> - (notmuch-hello-filtered-query (cdr query-and-count) +> - (or (plist-get options :filter-count) +> - (plist-get options :filter))))))) +> - (and (or (plist-get options :show-empty-searches) (> message-count 0)) +> - (list name (notmuch-hello-filtered-query +> - (car query-and-count) (plist-get options :filter)) +> - message-count)))) +> - query-alist))) +> + (with-temp-buffer +> + (dolist (elem query-alist nil) +> + (let ((count-query (if (consp (cdr elem)) +> + ;; do we have a different query for the message count? +> + (third elem) +> + (cdr elem)))) +> + (insert +> + (notmuch-hello-filtered-query count-query +> + (or (plist-get options :filter-count) +> + (plist-get options :filter))) +> + "\n"))) +> + +> + (call-process-region (point-min) (point-max) notmuch-command +> + t t nil "count" "--batch") +> + (goto-char (point-min)) +> + +> + (notmuch-remove-if-not +> + #'identity +> + (mapcar +> + (lambda (elem) +> + (let ((name (car elem)) +> + (search-query (if (consp (cdr elem)) +> + ;; do we have a different query for the message count? +> + (second elem) +> + (cdr elem))) +> + (message-count (prog1 (read (current-buffer)) +> + (forward-line 1)))) +> + (and (or (plist-get options :show-empty-searches) (> message-count 0)) +> + (list name (notmuch-hello-filtered-query +> + search-query (plist-get options :filter)) +> + message-count)))) +> + query-alist)))) +> +> (defun notmuch-hello-insert-buttons (searches) +> "Insert buttons for SEARCHES. +> -- +> 1.7.9.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2