From fe6cbf5949495eb72a69cef122d3cd1436d28f17 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sun, 13 Dec 2020 17:06:11 +0100 Subject: [PATCH] Use mu4e-query-rewrite-function also for computing bookmark counts Until now, the bookmark queries were sent to mu in their original form. Thus, if you have `mu4e-query-rewrite-function` set, the numbers shown next to the bookmarks didn't reflect the actual number of query results you'd get when opening a bookmark view. With this commit, the `mu4e-query-rewrite-function` is applied and the result is sent to mu for evaluation (in `mu4e~start`) and the likewise the rewritten queries are used to find the matching one in the last query results (in `mu4e~main-bookmarks`). * mu4e/mu4e-utils.el (mu4e~start): Send the rewritten queries for evaluation to mu. * mu4e/mu4e-main.el (mu4e~main-bookmarks): Compare last mu query results with rewritten queries. --- mu4e/mu4e-main.el | 3 ++- mu4e/mu4e-utils.el | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mu4e/mu4e-main.el b/mu4e/mu4e-main.el index 90dfd0af..7e4b756d 100644 --- a/mu4e/mu4e-main.el +++ b/mu4e/mu4e-main.el @@ -125,7 +125,8 @@ clicked." for bm in bmks for key = (string (plist-get bm :key)) for name = (plist-get bm :name) - for query = (plist-get bm :query) + for query = (funcall (or mu4e-query-rewrite-function #'identity) + (plist-get bm :query)) for qcounts = (and (stringp query) (cl-loop for q in queries when (string= diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index d1151f93..cd4d5b71 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -826,7 +826,9 @@ When successful, call FUNC (if non-nil) afterwards." (setq mu4e-pong-func (lambda (info) (mu4e~pong-handler info func))) (mu4e~proc-ping (mapcar ;; send it a list of queries we'd like to see read/unread info for - (lambda (bm) (plist-get bm :query)) + (lambda (bm) + (funcall (or mu4e-query-rewrite-function #'identity) + (plist-get bm :query))) ;; exclude bookmarks that are not strings, and with certain flags (seq-filter (lambda (bm) (and (stringp (plist-get bm :query))