From ad5f7d8dad744c15074907a2afe76be1552b25a3 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Fri, 31 Jan 2020 00:17:19 +0200 Subject: [PATCH] mu4e: make `mu4e` refresh itself update using the 'ping' function, so read/unread counts get updated. add a 'g' binding for the main-view. --- mu4e/mu4e-main.el | 1 + mu4e/mu4e-utils.el | 40 ++++++++++++++++++---------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/mu4e/mu4e-main.el b/mu4e/mu4e-main.el index 6789907a..ba52b08c 100644 --- a/mu4e/mu4e-main.el +++ b/mu4e/mu4e-main.el @@ -59,6 +59,7 @@ (define-key map "A" 'mu4e-about) (define-key map "N" 'mu4e-news) (define-key map "H" 'mu4e-display-manual) + (define-key map "g" 'mu4e) map) "Keymap for the *mu4e-main* buffer.") diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index 56f74af9..b1b3ce73 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -806,28 +806,24 @@ first. If mu4e is already running, execute function FUNC (if non-nil). Otherwise, check various requireme`'nts, then start mu4e. When successful, call FUNC (if non-nil) afterwards." ;; if we're already running, simply go to the main view - (if (mu4e-running-p) ;; already running? - (when func (funcall func)) ;; yes! run func if defined - (progn - ;; no! try to set a context, do some checks, set up pong handler and ping - ;; the server maybe switch the context - (mu4e~context-autoswitch nil mu4e-context-policy) - (mu4e~check-requirements) - ;; set up the 'pong' handler func - (setq mu4e-pong-func (lambda (props) (mu4e~pong-handler props func))) - ;; wake up server - (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)) - (seq-filter (lambda (bm) ;; exclude bookmarks that are not strings, - ;; and with these flags. - (and (stringp (plist-get bm :query)) - (not (or (plist-get bm :hide) (plist-get bm :hide-unread))))) - (mu4e-bookmarks)))) - ;; maybe request the list of contacts, automatically refresh after - ;; reindexing - (mu4e~request-contacts-maybe)))) + (unless (mu4e-running-p) ;; already running? + ;; no! try to set a context, do some checks, set up pong handler and ping + ;; the server maybe switch the context + (mu4e~context-autoswitch nil mu4e-context-policy) + (mu4e~check-requirements)) + (setq mu4e-pong-func (lambda (props) (mu4e~pong-handler props 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)) + (seq-filter (lambda (bm) ;; exclude bookmarks that are not strings, + ;; and with these flags. + (and (stringp (plist-get bm :query)) + (not (or (plist-get bm :hide) (plist-get bm :hide-unread))))) + (mu4e-bookmarks)))) + ;; maybe request the list of contacts, automatically refreshed after + ;; reindexing + (unless mu4e~contacts (mu4e~request-contacts-maybe))) (defun mu4e-clear-caches () "Clear any cached resources."