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

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

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))
concat (concat
;; menu entry ;; menu entry
(mu4e~main-action-str (mu4e~main-action-str
(concat "\t* [b" (make-string 1 key) "] " name) (concat "\t* [b" key "] " name)
(concat "b" (make-string 1 key))) (concat "b" key))
;; append all/unread numbers, if available. ;; append all/unread numbers, if available.
(if qcounts (if qcounts
(let ((unread (propertize (format "%s" (plist-get (car qcounts) :unread)) (let ((unread (plist-get (car qcounts) :unread))
'face 'mu4e-header-key-face)) (count (plist-get (car qcounts) :count)))
(count (propertize(format "%s" (plist-get (car qcounts) :count)) (format
'face 'default))) "%s (%s/%s)"
(concat " (" unread "/" count ")")) (make-string (- longest (length name)) ? )
""))))) (propertize (number-to-string unread)
(mu4e-bookmarks) "\n")) 'face 'mu4e-header-key-face)
count))
"")
"\n")))
;; NEW ;; NEW