1
0
mirror of https://github.com/djcb/mu.git synced 2024-06-21 06:56:48 +02:00

mu4e-main: add new method for constructing the maildir list

This method is exactly like `mu4e~main-bookmarks' but for maildirs
instead of bookmarks.
This commit is contained in:
Sean Farley 2020-02-24 13:32:52 -08:00 committed by Dirk-Jan C. Binnema
parent 41f0c5a92a
commit a070cca79d

View File

@ -125,6 +125,7 @@ clicked."
(cl-loop for q in queries
when (string= (plist-get q :query) query)
collect q))
when (not (plist-get bm :hide))
concat (concat
;; menu entry
(mu4e~main-action-str
@ -144,6 +145,39 @@ clicked."
"\n")))
(defun mu4e~main-maildirs ()
"Return a string of maildirs with their counts."
(cl-loop with mds = (mu4e~maildirs-with-query)
with longest = (mu4e~longest-of-maildirs-and-bookmarks)
with queries = (plist-get mu4e~server-props :queries)
for m in mds
for key = (string (plist-get m :key))
for name = (plist-get m :name)
for query = (plist-get m :query)
for qcounts = (and (stringp query)
(cl-loop for q in queries
when (string= (plist-get q :query) query)
collect q))
when (not (plist-get m :hide))
concat (concat
;; menu entry
(mu4e~main-action-str
(concat "\t* [j" key "] " name)
(concat "j" key))
;; append all/unread numbers, if available.
(if qcounts
(let ((unread (plist-get (car qcounts) :unread))
(count (plist-get (car qcounts) :count)))
(format
"%s (%s/%s)"
(make-string (- longest (length name)) ? )
(propertize (number-to-string unread)
'face 'mu4e-header-key-face)
count))
"")
"\n")))
(defun mu4e~key-val (key val &optional unit)
"Return a key / value pair."
(concat
@ -195,6 +229,9 @@ When REFRESH is non nil refresh infos from server."
(propertize " Bookmarks\n\n" 'face 'mu4e-title-face)
(mu4e~main-bookmarks)
"\n"
(propertize " Maildirs\n\n" 'face 'mu4e-title-face)
(mu4e~main-maildirs)
"\n"
(propertize " Misc\n\n" 'face 'mu4e-title-face)
(mu4e~main-action-str "\t* [;]Switch context\n" 'mu4e-context-switch)