mu4e-utils: add new method to transform `mu4e-maildir-shortcuts'

This will allow iterating over `mu4e-maildir-shortcuts' the same way as
`mu4e-bookmarks' (i.e. adding :name and :query to the plist).
This commit is contained in:
Sean Farley 2020-04-24 22:12:57 -07:00 committed by Dirk-Jan C. Binnema
parent 7ed8d509ee
commit a899dd04f7
1 changed files with 19 additions and 0 deletions

View File

@ -844,6 +844,25 @@ When successful, call FUNC (if non-nil) afterwards."
(kill-buffer))))
(buffer-list)))
(defun mu4e~maildirs-with-query ()
"Return a copy of `mu4e-maildirs-shortcuts' with :query populated.
This is meant to be the exact same data structure as
`mu4e-bookmarks'."
(cl-mapcar
(lambda (m)
(append
;; we want to change the :maildir key to :name, and add a :query key
(list :name (plist-get m :maildir)
:query (format "maildir:\"%s\"" (plist-get m :maildir)))
;; next we want to append any other keys to our previous list (e.g. :hide,
;; :key, etc) but skipping :maildir (since it's renamed to :name)
(cl-loop for (key value) on m by 'cddr
when (not (equal key :maildir))
append (list key value))))
(mu4e-maildir-shortcuts)))
;;; Indexing & Updating