mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 15:21:41 +01:00
emacs: hello: use batch count
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.
This commit is contained in:
parent
360c3c8607
commit
c933e54227
1 changed files with 32 additions and 20 deletions
|
@ -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
|
The values :show-empty-searches, :filter and :filter-count from
|
||||||
options will be handled as specified for
|
options will be handled as specified for
|
||||||
`notmuch-hello-insert-searches'."
|
`notmuch-hello-insert-searches'."
|
||||||
(notmuch-remove-if-not
|
(with-temp-buffer
|
||||||
#'identity
|
(dolist (elem query-alist nil)
|
||||||
(mapcar
|
(let ((count-query (if (consp (cdr elem))
|
||||||
(lambda (elem)
|
;; do we have a different query for the message count?
|
||||||
(let* ((name (car elem))
|
(third elem)
|
||||||
(query-and-count (if (consp (cdr elem))
|
(cdr elem))))
|
||||||
;; do we have a different query for the message count?
|
(insert
|
||||||
(cons (second elem) (third elem))
|
(notmuch-hello-filtered-query count-query
|
||||||
(cons (cdr elem) (cdr elem))))
|
(or (plist-get options :filter-count)
|
||||||
(message-count
|
(plist-get options :filter)))
|
||||||
(string-to-number
|
"\n")))
|
||||||
(notmuch-saved-search-count
|
|
||||||
(notmuch-hello-filtered-query (cdr query-and-count)
|
(call-process-region (point-min) (point-max) notmuch-command
|
||||||
(or (plist-get options :filter-count)
|
t t nil "count" "--batch")
|
||||||
(plist-get options :filter)))))))
|
(goto-char (point-min))
|
||||||
(and (or (plist-get options :show-empty-searches) (> message-count 0))
|
|
||||||
(list name (notmuch-hello-filtered-query
|
(notmuch-remove-if-not
|
||||||
(car query-and-count) (plist-get options :filter))
|
#'identity
|
||||||
message-count))))
|
(mapcar
|
||||||
query-alist)))
|
(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)
|
(defun notmuch-hello-insert-buttons (searches)
|
||||||
"Insert buttons for SEARCHES.
|
"Insert buttons for SEARCHES.
|
||||||
|
|
Loading…
Reference in a new issue