mu4e: add support for :favorite bookmark
Show favorite bookmark in main-screen (highlighted) Add baseline-reset when main screen is shown or when the favority bookmark is searched. Some code cleanup
This commit is contained in:
55
mu4e/mu4e.el
55
mu4e/mu4e.el
@ -73,6 +73,7 @@
|
||||
(with-eval-after-load 'desktop
|
||||
(eval '(add-to-list 'desktop-modes-not-to-save 'mu4e-compose-mode)))
|
||||
|
||||
|
||||
;;;###autoload
|
||||
(defun mu4e (&optional background)
|
||||
"If mu4e is not running yet, start it.
|
||||
@ -81,12 +82,11 @@ is non-nil."
|
||||
(interactive "P")
|
||||
;; start mu4e, then show the main view
|
||||
(mu4e--init-handlers)
|
||||
|
||||
;; i.e., only auto update baseline when user explicitly requested
|
||||
(when (and mu4e-main-auto-reset-baseline
|
||||
(not background) (called-interactively-p 'interactive))
|
||||
(mu4e-reset-baseline-query-results))
|
||||
|
||||
(when (or (not mu4e--baseline-tstamp)
|
||||
(and (not background) (called-interactively-p 'interactive)))
|
||||
(mu4e--reset-baseline))
|
||||
(mu4e--modeline-update)
|
||||
(mu4e--start (unless background 'mu4e--main-view)))
|
||||
|
||||
(defun mu4e-quit()
|
||||
@ -138,6 +138,19 @@ Invoke FUNC if non-nil."
|
||||
(lambda () (mu4e-update-mail-and-index
|
||||
mu4e-index-update-in-background)))))))
|
||||
|
||||
(defun mu4e--server-bookmarks-queries()
|
||||
(mu4e--server-queries
|
||||
(mapcar ;; send it a list of queries we'd like to see read/unread info for
|
||||
(lambda (bm)
|
||||
(funcall (or mu4e-query-rewrite-function #'identity)
|
||||
(mu4e--bookmark-query bm)))
|
||||
;; exclude bookmarks with certain flags
|
||||
(seq-filter (lambda (bm)
|
||||
(and (not (or (plist-get bm :hide)
|
||||
(plist-get bm :hide-unread)))))
|
||||
(append (mu4e-bookmarks)
|
||||
(mu4e--maildirs-with-query))))))
|
||||
|
||||
(defun mu4e--queries-handler (_sexp)
|
||||
;; we've received new server-queries; so update the main view
|
||||
;; (if any) and the modeline.
|
||||
@ -164,18 +177,10 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
||||
(unless (mu4e-context-current)
|
||||
(mu4e--context-autoswitch nil mu4e-context-policy))
|
||||
(setq mu4e-pong-func (lambda (info) (mu4e--pong-handler info func)))
|
||||
(mu4e--server-ping
|
||||
(mapcar ;; send it a list of queries we'd like to see read/unread info for
|
||||
(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))
|
||||
(not (or (plist-get bm :hide)
|
||||
(plist-get bm :hide-unread)))))
|
||||
(append (mu4e-bookmarks)
|
||||
(mu4e--maildirs-with-query)))))
|
||||
(mu4e--modeline-register #'mu4e--bookmarks-modeline-item 'global)
|
||||
(mu4e-modeline-mode (if mu4e-modeline-support 1 -1))
|
||||
(mu4e--server-bookmarks-queries)
|
||||
(mu4e--server-ping)
|
||||
;; maybe request the list of contacts, automatically refreshed after
|
||||
;; reindexing
|
||||
(unless mu4e--contacts-set (mu4e--request-contacts-maybe)))
|
||||
@ -186,6 +191,8 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
||||
(cancel-timer mu4e--update-timer)
|
||||
(setq mu4e--update-timer nil))
|
||||
(mu4e-clear-caches)
|
||||
|
||||
(mu4e-modeline-mode -1)
|
||||
(mu4e--server-kill)
|
||||
;; kill all mu4e buffers
|
||||
(mapc
|
||||
@ -205,7 +212,7 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
||||
;;; Handlers
|
||||
(defun mu4e--default-handler (&rest args)
|
||||
"Dummy handler function with arbitrary ARGS."
|
||||
(mu4e-error "Not handled: %S" args))
|
||||
(mu4e-error "Not handled: %s" args))
|
||||
|
||||
(defun mu4e--error-handler (errcode errmsg)
|
||||
"Handler function for showing an error with ERRCODE and ERRMSG."
|
||||
@ -242,6 +249,8 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
||||
"%s completed; checked %d, updated %d, cleaned-up %d"
|
||||
(if mu4e-index-lazy-check "Lazy indexing" "Indexing")
|
||||
checked updated cleaned-up)
|
||||
;; index done; grab updated queries
|
||||
(mu4e--server-bookmarks-queries)
|
||||
(run-hooks 'mu4e-index-updated-hook)
|
||||
;; backward compatibility...
|
||||
(unless (zerop (+ updated cleaned-up))
|
||||
@ -268,11 +277,11 @@ chance."
|
||||
(mu4e-setq-if-nil mu4e-found-func #'mu4e~headers-found-handler)
|
||||
(mu4e-setq-if-nil mu4e-erase-func #'mu4e~headers-clear)
|
||||
|
||||
(mu4e-setq-if-nil mu4e-sent-func #'mu4e--default-handler)
|
||||
(mu4e-setq-if-nil mu4e-compose-func #'mu4e~compose-handler)
|
||||
(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-sent-func #'mu4e--default-handler)
|
||||
(mu4e-setq-if-nil mu4e-compose-func #'mu4e~compose-handler)
|
||||
(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--queries-handler))
|
||||
|
||||
(defun mu4e-clear-caches ()
|
||||
|
||||
Reference in New Issue
Block a user