mu4e: tweak query-items refreshing

Try to make it a bit less confusing. The baseline becomes a bit more
implicit, and a `g` in the main view refreshes / resets.
This commit is contained in:
Dirk-Jan C. Binnema 2023-01-16 00:10:12 +02:00
parent eb691f8f31
commit 22b2d44b96
5 changed files with 15 additions and 24 deletions

View File

@ -1541,7 +1541,6 @@ region if there is a region, then move to the next message."
(interactive)
(mu4e-mark-handle-when-leaving)
(quit-window t)
(mu4e--query-items-reset-baseline)
(mu4e--main-view))

View File

@ -105,12 +105,6 @@ the personal addresses."
(current-time-string baseline-t)
"Never"))))
(defun mu4e--main-reset-baseline()
"Reset the query baseline."
(interactive)
(mu4e--query-items-reset-baseline)
(revert-buffer))
(defvar mu4e-main-mode-map
(let ((map (make-sparse-keymap)))
@ -121,7 +115,6 @@ the personal addresses."
(define-key map "f" #'smtpmail-send-queued-mail)
;;
(define-key map "U" #'mu4e-update-mail-and-index)
(define-key map "R" #'mu4e--main-reset-baseline)
(define-key map (kbd "C-S-u") #'mu4e-update-mail-and-index)
;; for terminal users
(define-key map (kbd "C-c C-u") #'mu4e-update-mail-and-index)
@ -168,8 +161,8 @@ the personal addresses."
(mu4e-update-minor-mode)
(setq-local revert-buffer-function
(lambda (_ignore-auto _noconfirm)
;; the query results will trigger a redraw
(mu4e--query-items-refresh)))
;; reset the baseline and get updated results.
(mu4e--query-items-refresh 'reset-baseline)))
(add-hook 'mu4e-query-items-updated-hook
(lambda ()
(when (get-buffer mu4e-main-buffer-name)
@ -291,12 +284,6 @@ character of the keyboard shortcut
(mu4e--main-action-str "\t* [U]pdate email & database\n"
#'mu4e-update-mail-and-index)
(mu4e--main-action-str (propertize
"\t* [R]eset baseline\n"
'help-echo
(mu4e--baseline-time-string))
#'mu4e--main-reset-baseline)
;; show the queue functions if `smtpmail-queue-dir' is defined
(if (file-directory-p smtpmail-queue-dir)
(mu4e--main-view-queue)
@ -359,9 +346,11 @@ character of the keyboard shortcut
(declare-function mu4e--start "mu4e")
(defun mu4e--main-view ()
(defun mu4e--main-view (&optional refresh)
"(Re)create the mu4e main-view, and switch to it.
With non-nil REFRESH, refresh queries and baseline first.
If `mu4e-split-view' equals \='single-window, show a mu4e menu
instead."
(if (eq mu4e-split-view 'single-window)
@ -371,6 +360,8 @@ instead."
;; `mu4e--main-view' is called from `mu4e--start', so don't call it a
;; second time here i.e. do not refresh unless specified explicitly with
;; REFRESH arg.
(when refresh
(mu4e--query-items-refresh 'reset-baseline))
(with-current-buffer buf
(mu4e--main-redraw-buffer))
(mu4e-display-buffer buf t)))
@ -390,8 +381,7 @@ instead."
(if smtpmail-queue-mail "queued" "sent directly")))
(unless (or (eq mu4e-split-view 'single-window)
(not (buffer-live-p (get-buffer mu4e-main-buffer-name))))
(with-current-buffer mu4e-main-buffer-name
(revert-buffer))))
(mu4e--main-redraw-buffer)))
(defun mu4e--main-menu ()
"The mu4e main menu in the mini-buffer."

View File

@ -128,8 +128,11 @@ If ITEMS does not yet have a favorite item, pick the first."
(propertize (number-to-string count)
'help-echo "Total number")))))
(defun mu4e--query-items-refresh()
"Get the latest query data from the mu4e server."
(defun mu4e--query-items-refresh (&optional reset-baseline)
"Get the latest query data from the mu4e server.
With RESET-BASELINE, reset the baseline first."
(when reset-baseline
(mu4e--query-items-reset-baseline))
(mu4e--server-queries
;; note: we must apply the rewrite function here, since the query does not go
;; through mu4e-search.

View File

@ -268,7 +268,8 @@ chance."
(mu4e-setq-if-nil mu4e-contacts-func #'mu4e--update-contacts)
(mu4e-setq-if-nil mu4e-info-func #'mu4e--info-handler)
(mu4e-setq-if-nil mu4e-pong-func #'mu4e--default-handler)
(mu4e-setq-if-nil mu4e-queries-func #'mu4e--query-items-queries-handler))
(mu4e-setq-if-nil mu4e-queries-func #'mu4e--query-items-queries-handler))
(defun mu4e-clear-caches ()
"Clear any cached resources."

View File

@ -735,7 +735,6 @@ The main view looks something like the following:
* [;]Switch context
* [U]pdate email & database
* [R]eset query-results baseline
* toggle [m]ail sending mode (currently direct)
* [f]lush 1 queued mail
@ -1012,7 +1011,6 @@ a execute some custom action on a header
| pipe message through shell command
C-+,C-- increase / decrease the number of headers shown
H get help
C-c C-r reset query results baseline
C-S-u update mail & reindex
C-c C-u update mail & reindex
q leave the headers buffer