diff --git a/mu4e/mu4e-folders.el b/mu4e/mu4e-folders.el index d3d9dcf6..cec99ae1 100644 --- a/mu4e/mu4e-folders.el +++ b/mu4e/mu4e-folders.el @@ -248,37 +248,36 @@ to create it; otherwise return nil." "Get maildirs under `mu4e-maildir'." mu4e-maildir-list) - (defun mu4e-ask-maildir (prompt &optional query-item) "Ask the user for a maildir (using PROMPT). If QUERY-ITEM is non-nil, return the full query-item rather than just the query-string. -If the special shortcut \"o\" (for _o_ther) is used, or -if (mu4e-maildir-shortcuts) evaluates to nil, let user choose -from all maildirs under `mu4e-maildir'. +If the special shortcut \"o\" (for _o_ther) is used, or if there +a no single-key elements in (mu4e-maildir-shortcuts), let user +choose from all maildirs under `mu4e-maildir'. The names of the maildirs are displayed in the minibuffer, suffixed with the short version of the unread counts, as per `mu4e--query-item-display-short-counts'." (let* ((mdirs - (append - (seq-map - (lambda (md) - (let* ((qitem (mu4e--query-item-for-maildir-shortcut md)) - (unreads (mu4e--query-item-display-short-counts qitem))) - (cons - (format "%c%s%s" - (plist-get md :key) - (or (plist-get md :name) - (plist-get md :maildir)) - unreads) md))) - (mu4e-filter-single-key (mu4e-maildir-shortcuts))) - '(("oOther..." . other)))) ;; append "Other" pseudo-maildir - (chosen (mu4e-read-option prompt mdirs)) + (seq-map + (lambda (md) + (let* ((qitem (mu4e--query-item-for-maildir-shortcut md)) + (unreads (mu4e--query-item-display-short-counts qitem))) + (cons + (format "%c%s%s" + (plist-get md :key) + (or (plist-get md :name) + (plist-get md :maildir)) + unreads) md))) + (mu4e-filter-single-key (mu4e-maildir-shortcuts)))) ;; special case: handle pseudo-maildir 'other - (chosen (if (eq chosen 'other) + (mdirs (and mdirs (append mdirs '(("oOther..." . other))))) + (chosen (and mdirs (mu4e-read-option prompt mdirs))) + ;; if chosen nothing or other, ask for more. + (chosen (if (or (not chosen) (eq chosen 'other)) (list :maildir (substring-no-properties (funcall mu4e-completing-read-function prompt @@ -287,9 +286,7 @@ suffixed with the short version of the unread counts, as per chosen))) ;; return either the maildir (as a string), or the corresponding ;; query-item. - (if query-item - chosen - (plist-get chosen :maildir)))) + (if query-item chosen (plist-get chosen :maildir)))) (defun mu4e-ask-maildir-check-exists (prompt) "Like `mu4e-ask-maildir', PROMPT for existence of the maildir.