mirror of https://github.com/djcb/mu.git
mu4e: tweak main-view updating
This commit is contained in:
parent
d7eed9e9ff
commit
74fb72035a
|
@ -1541,6 +1541,8 @@ region if there is a region, then move to the next message."
|
||||||
(interactive)
|
(interactive)
|
||||||
(mu4e-mark-handle-when-leaving)
|
(mu4e-mark-handle-when-leaving)
|
||||||
(quit-window t)
|
(quit-window t)
|
||||||
|
;; clear the decks before going to the main-view
|
||||||
|
(mu4e--query-items-refresh 'reset-baseline)
|
||||||
(mu4e--main-view))
|
(mu4e--main-view))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -121,10 +121,7 @@ the personal addresses."
|
||||||
|
|
||||||
(define-key map "S" #'mu4e-kill-update-mail)
|
(define-key map "S" #'mu4e-kill-update-mail)
|
||||||
(define-key map (kbd "C-S-u") #'mu4e-update-mail-and-index)
|
(define-key map (kbd "C-S-u") #'mu4e-update-mail-and-index)
|
||||||
(define-key map ";"
|
(define-key map ";" #'mu4e-context-switch)
|
||||||
(lambda()(interactive)
|
|
||||||
(mu4e-context-switch)(revert-buffer)))
|
|
||||||
|
|
||||||
(define-key map "$" #'mu4e-show-log)
|
(define-key map "$" #'mu4e-show-log)
|
||||||
(define-key map "A" #'mu4e-about)
|
(define-key map "A" #'mu4e-about)
|
||||||
(define-key map "N" #'mu4e-news)
|
(define-key map "N" #'mu4e-news)
|
||||||
|
@ -162,11 +159,7 @@ the personal addresses."
|
||||||
(setq-local revert-buffer-function
|
(setq-local revert-buffer-function
|
||||||
(lambda (_ignore-auto _noconfirm)
|
(lambda (_ignore-auto _noconfirm)
|
||||||
;; reset the baseline and get updated results.
|
;; reset the baseline and get updated results.
|
||||||
(mu4e--query-items-refresh 'reset-baseline)))
|
(mu4e--query-items-refresh 'reset-baseline))))
|
||||||
(add-hook 'mu4e-query-items-updated-hook
|
|
||||||
(lambda ()
|
|
||||||
(when (get-buffer mu4e-main-buffer-name)
|
|
||||||
(mu4e--main-redraw-buffer))) nil t))
|
|
||||||
|
|
||||||
(defun mu4e--main-action-str (str &optional func-or-shortcut)
|
(defun mu4e--main-action-str (str &optional func-or-shortcut)
|
||||||
"Highlight the first occurrence of [.] in STR.
|
"Highlight the first occurrence of [.] in STR.
|
||||||
|
@ -246,8 +239,10 @@ character of the keyboard shortcut
|
||||||
(current-time-string baseline-t)
|
(current-time-string baseline-t)
|
||||||
"Never"))))
|
"Never"))))
|
||||||
|
|
||||||
(defun mu4e--main-redraw-buffer ()
|
(defun mu4e--main-redraw ()
|
||||||
"Redraw the main buffer."
|
"Redraw the main buffer if there is one.
|
||||||
|
Otherwise, do nothing."
|
||||||
|
(when (buffer-live-p (get-buffer mu4e-main-buffer-name))
|
||||||
(with-current-buffer mu4e-main-buffer-name
|
(with-current-buffer mu4e-main-buffer-name
|
||||||
(let* ((inhibit-read-only t)
|
(let* ((inhibit-read-only t)
|
||||||
(pos (point))
|
(pos (point))
|
||||||
|
@ -278,10 +273,7 @@ character of the keyboard shortcut
|
||||||
"\n"
|
"\n"
|
||||||
(propertize " Misc\n\n" 'face 'mu4e-title-face)
|
(propertize " Misc\n\n" 'face 'mu4e-title-face)
|
||||||
|
|
||||||
(mu4e--main-action-str "\t* [;]Switch context\n"
|
(mu4e--main-action-str "\t* [;]Switch context\n" #'mu4e-context-switch)
|
||||||
(lambda()(interactive)
|
|
||||||
(mu4e-context-switch)(revert-buffer)))
|
|
||||||
|
|
||||||
(mu4e--main-action-str "\t* [U]pdate email & database\n"
|
(mu4e--main-action-str "\t* [U]pdate email & database\n"
|
||||||
#'mu4e-update-mail-and-index)
|
#'mu4e-update-mail-and-index)
|
||||||
;; show the queue functions if `smtpmail-queue-dir' is defined
|
;; show the queue functions if `smtpmail-queue-dir' is defined
|
||||||
|
@ -314,7 +306,8 @@ character of the keyboard shortcut
|
||||||
"of mu's addresses; add it with 'mu init
|
"of mu's addresses; add it with 'mu init
|
||||||
--my-address='") user-mail-address)))
|
--my-address='") user-mail-address)))
|
||||||
(mu4e-main-mode)
|
(mu4e-main-mode)
|
||||||
(goto-char pos))))
|
(goto-char pos)))))
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e--main-view-queue ()
|
(defun mu4e--main-view-queue ()
|
||||||
"Display queue-related actions in the main view."
|
"Display queue-related actions in the main view."
|
||||||
|
@ -346,24 +339,17 @@ character of the keyboard shortcut
|
||||||
|
|
||||||
(declare-function mu4e--start "mu4e")
|
(declare-function mu4e--start "mu4e")
|
||||||
|
|
||||||
(defun mu4e--main-view (&optional refresh)
|
(defun mu4e--main-view ()
|
||||||
"(Re)create the mu4e main-view, and switch to it.
|
"(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
|
If `mu4e-split-view' equals \='single-window, show a mu4e menu
|
||||||
instead."
|
instead."
|
||||||
(if (eq mu4e-split-view 'single-window)
|
(if (eq mu4e-split-view 'single-window)
|
||||||
(mu4e--main-menu)
|
(mu4e--main-menu)
|
||||||
(let ((buf (get-buffer-create mu4e-main-buffer-name))
|
(let ((buf (get-buffer-create mu4e-main-buffer-name))
|
||||||
(inhibit-read-only t))
|
(inhibit-read-only t))
|
||||||
;; `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
|
(with-current-buffer buf
|
||||||
(mu4e--main-redraw-buffer))
|
(mu4e--main-redraw))
|
||||||
(mu4e-display-buffer buf t)))
|
(mu4e-display-buffer buf t)))
|
||||||
|
|
||||||
(goto-char (point-min)))
|
(goto-char (point-min)))
|
||||||
|
@ -381,7 +367,7 @@ instead."
|
||||||
(if smtpmail-queue-mail "queued" "sent directly")))
|
(if smtpmail-queue-mail "queued" "sent directly")))
|
||||||
(unless (or (eq mu4e-split-view 'single-window)
|
(unless (or (eq mu4e-split-view 'single-window)
|
||||||
(not (buffer-live-p (get-buffer mu4e-main-buffer-name))))
|
(not (buffer-live-p (get-buffer mu4e-main-buffer-name))))
|
||||||
(mu4e--main-redraw-buffer)))
|
(mu4e--main-redraw)))
|
||||||
|
|
||||||
(defun mu4e--main-menu ()
|
(defun mu4e--main-menu ()
|
||||||
"The mu4e main menu in the mini-buffer."
|
"The mu4e main menu in the mini-buffer."
|
||||||
|
|
18
mu4e/mu4e.el
18
mu4e/mu4e.el
|
@ -152,16 +152,17 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
||||||
(mu4e--context-autoswitch nil mu4e-context-policy))
|
(mu4e--context-autoswitch nil mu4e-context-policy))
|
||||||
(setq mu4e-pong-func
|
(setq mu4e-pong-func
|
||||||
(lambda (info) (mu4e--pong-handler info func)))
|
(lambda (info) (mu4e--pong-handler info func)))
|
||||||
|
;; show some notification?
|
||||||
|
(when mu4e-notification-support
|
||||||
|
(add-hook 'mu4e-query-items-updated-hook #'mu4e--notification))
|
||||||
;; modeline support
|
;; modeline support
|
||||||
(when mu4e-modeline-support
|
(when mu4e-modeline-support
|
||||||
(mu4e--modeline-register #'mu4e--bookmarks-modeline-item 'global)
|
(mu4e--modeline-register #'mu4e--bookmarks-modeline-item 'global)
|
||||||
(mu4e-modeline-mode)
|
(mu4e-modeline-mode)
|
||||||
(add-hook 'mu4e-query-items-updated-hook
|
(add-hook 'mu4e-query-items-updated-hook #'mu4e--modeline-update))
|
||||||
#'mu4e--modeline-update))
|
|
||||||
(mu4e-modeline-mode (if mu4e-modeline-support 1 -1))
|
(mu4e-modeline-mode (if mu4e-modeline-support 1 -1))
|
||||||
(when mu4e-notification-support
|
;; redraw main buffer if there is one.
|
||||||
(add-hook 'mu4e-query-items-updated-hook
|
(add-hook 'mu4e-query-items-updated-hook #'mu4e--main-redraw)
|
||||||
#'mu4e--notification))
|
|
||||||
(mu4e--server-ping)
|
(mu4e--server-ping)
|
||||||
;; maybe request the list of contacts, automatically refreshed after
|
;; maybe request the list of contacts, automatically refreshed after
|
||||||
;; reindexing
|
;; reindexing
|
||||||
|
@ -173,10 +174,9 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
||||||
(cancel-timer mu4e--update-timer)
|
(cancel-timer mu4e--update-timer)
|
||||||
(setq mu4e--update-timer nil))
|
(setq mu4e--update-timer nil))
|
||||||
(mu4e-clear-caches)
|
(mu4e-clear-caches)
|
||||||
(remove-hook 'mu4e-query-items-updated-hook
|
(remove-hook 'mu4e-query-items-updated-hook #'mu4e--main-redraw)
|
||||||
#'mu4e--modeline-update)
|
(remove-hook 'mu4e-query-items-updated-hook #'mu4e--modeline-update)
|
||||||
(remove-hook 'mu4e-query-items-updated-hook
|
(remove-hook 'mu4e-query-items-updated-hook #'mu4e--notification)
|
||||||
#'mu4e--notification)
|
|
||||||
(mu4e-kill-update-mail)
|
(mu4e-kill-update-mail)
|
||||||
(mu4e-modeline-mode -1)
|
(mu4e-modeline-mode -1)
|
||||||
(mu4e--server-kill)
|
(mu4e--server-kill)
|
||||||
|
|
Loading…
Reference in New Issue