On Wed, Jan 16 2013, Mark Walters <[email protected]> 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
> [email protected]
> http://notmuchmail.org/mailman/listinfo/notmuch
_______________________________________________
notmuch mailing list
[email protected]
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to