Merge pull request #1556 from thierryvolpiatto/align_mu4e_main

mu4e: Rewrite mu4e~main-bookmarks to have bookmarks aligned
This commit is contained in:
Dirk-Jan C. Binnema 2020-01-28 00:39:11 +02:00 committed by GitHub
commit e968f46963
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 25 deletions

View File

@ -108,31 +108,35 @@ clicked."
(defun mu4e~main-bookmarks () (defun mu4e~main-bookmarks ()
;; TODO: it's a bit uncool to hard-code the "b" shortcut... ;; TODO: it's a bit uncool to hard-code the "b" shortcut...
(mapconcat (cl-loop with bmks = (mu4e-bookmarks)
(lambda (bm) with longest = (cl-loop for b in bmks
(unless (plist-get bm :hide) maximize (length (plist-get b :name)))
(let* ((key (plist-get bm :key)) with queries = (plist-get mu4e~server-props :queries)
(name (plist-get bm :name)) for bm in bmks
(query (plist-get bm :query)) for key = (string (plist-get bm :key))
(qcounts (and (stringp query) for name = (plist-get bm :name)
(seq-filter for query = (plist-get bm :query)
(lambda (q) for qcounts = (and (stringp query)
(string= (plist-get q :query) query)) (cl-loop for q in queries
(plist-get mu4e~server-props :queries))))) when (string= (plist-get q :query) query)
(concat collect q))
;; menu entry concat (concat
(mu4e~main-action-str ;; menu entry
(concat "\t* [b" (make-string 1 key) "] " name) (mu4e~main-action-str
(concat "b" (make-string 1 key))) (concat "\t* [b" key "] " name)
;; append all/unread numbers, if available. (concat "b" key))
(if qcounts ;; append all/unread numbers, if available.
(let ((unread (propertize (format "%s" (plist-get (car qcounts) :unread)) (if qcounts
'face 'mu4e-header-key-face)) (let ((unread (plist-get (car qcounts) :unread))
(count (propertize(format "%s" (plist-get (car qcounts) :count)) (count (plist-get (car qcounts) :count)))
'face 'default))) (format
(concat " (" unread "/" count ")")) "%s (%s/%s)"
""))))) (make-string (- longest (length name)) ? )
(mu4e-bookmarks) "\n")) (propertize (number-to-string unread)
'face 'mu4e-header-key-face)
count))
"")
"\n")))
;; NEW ;; NEW