mirror of https://github.com/djcb/mu.git
mu4e-folders: use mu4e-read-option
This commit is contained in:
parent
edb8cf17a9
commit
a8c0bbd390
|
@ -93,7 +93,7 @@ Return the corresponding query. The bookmark are as defined in
|
||||||
(plist-get bm :name))
|
(plist-get bm :name))
|
||||||
(plist-get bm :query)))
|
(plist-get bm :query)))
|
||||||
(mu4e-filter-single-key (mu4e-bookmarks)))))
|
(mu4e-filter-single-key (mu4e-bookmarks)))))
|
||||||
(mu4e-read-option bmarks prompt)))
|
(mu4e-read-option prompt bmarks)))
|
||||||
|
|
||||||
(defun mu4e-get-bookmark-query (kar)
|
(defun mu4e-get-bookmark-query (kar)
|
||||||
"Get the corresponding bookmarked query for shortcut KAR.
|
"Get the corresponding bookmarked query for shortcut KAR.
|
||||||
|
|
|
@ -228,7 +228,8 @@ Do so recursively and produce a list of relative paths."
|
||||||
(mu4e-join-paths path mdir) nil
|
(mu4e-join-paths path mdir) nil
|
||||||
"^[^.]\\|\\.[^.][^.]" t))))
|
"^[^.]\\|\\.[^.][^.]" t))))
|
||||||
(dolist (dentry dentries)
|
(dolist (dentry dentries)
|
||||||
(when (or (and (booleanp (cadr dentry)) (cadr dentry)) (file-directory-p (mu4e-join-paths path (car dentry))))
|
(when (or (and (booleanp (cadr dentry)) (cadr dentry))
|
||||||
|
(file-directory-p (mu4e-join-paths path (car dentry))))
|
||||||
(if (file-accessible-directory-p
|
(if (file-accessible-directory-p
|
||||||
(mu4e-join-paths (mu4e-root-maildir) mdir (car dentry) "cur"))
|
(mu4e-join-paths (mu4e-root-maildir) mdir (car dentry) "cur"))
|
||||||
(setq dirs
|
(setq dirs
|
||||||
|
@ -271,38 +272,30 @@ the list of maildirs will not change until you restart mu4e."
|
||||||
mu4e-maildir-list)
|
mu4e-maildir-list)
|
||||||
|
|
||||||
(defun mu4e-ask-maildir (prompt)
|
(defun mu4e-ask-maildir (prompt)
|
||||||
"Ask the user for a shortcut (using PROMPT).
|
"Ask the user for a maildir (using PROMPT).
|
||||||
As per (mu4e-maildir-shortcuts), then return the corresponding
|
|
||||||
folder name. If the special shortcut \"o\" (for _o_ther) is used,
|
If the special shortcut \"o\" (for _o_ther) is used, or
|
||||||
or if (mu4e-maildir-shortcuts) evaluates to nil, let user choose
|
if (mu4e-maildir-shortcuts) evaluates to nil, let user choose
|
||||||
from all maildirs under `mu4e-maildir'."
|
from all maildirs under `mu4e-maildir'."
|
||||||
(let ((prompt (mu4e-format "%s" prompt)))
|
(let* ((options
|
||||||
(if (not (mu4e-maildir-shortcuts))
|
(seq-map (lambda (md)
|
||||||
(substring-no-properties
|
(cons
|
||||||
(funcall mu4e-completing-read-function prompt (mu4e-get-maildirs)))
|
(format "%c%s" (plist-get md :key)
|
||||||
(let* ((mlist (append
|
(or (plist-get md :name)
|
||||||
(mu4e-filter-single-key (mu4e-maildir-shortcuts))
|
(plist-get md :maildir)))
|
||||||
'((:maildir "ther" :key ?o))))
|
(plist-get md :maildir)))
|
||||||
(fnames
|
(mu4e-filter-single-key (mu4e-maildir-shortcuts))))
|
||||||
(mapconcat
|
(response
|
||||||
(lambda (item)
|
(if (not options)
|
||||||
(concat
|
'other
|
||||||
"["
|
(mu4e-read-option prompt
|
||||||
(propertize (make-string 1 (plist-get item :key))
|
(append options
|
||||||
'face 'mu4e-highlight-face)
|
'(("oOther..." . 'other)))))))
|
||||||
"]"
|
(if (eq response 'other)
|
||||||
(plist-get item :maildir)))
|
(funcall mu4e-completing-read-function prompt
|
||||||
mlist ", "))
|
(mu4e-get-maildirs) nil nil
|
||||||
(kar (read-char (concat prompt fnames))))
|
mu4e-maildir-initial-input)
|
||||||
(if (member kar '(?/ ?o)) ;; user chose 'other'?
|
response)))
|
||||||
(substring-no-properties
|
|
||||||
(funcall mu4e-completing-read-function prompt
|
|
||||||
(mu4e-get-maildirs) nil nil
|
|
||||||
mu4e-maildir-initial-input))
|
|
||||||
(or (plist-get
|
|
||||||
(seq-find (lambda (item) (= kar (plist-get item :key)))
|
|
||||||
(mu4e-maildir-shortcuts)) :maildir)
|
|
||||||
(mu4e-warn "Unknown shortcut '%c'" kar)))))))
|
|
||||||
|
|
||||||
(defun mu4e-ask-maildir-check-exists (prompt)
|
(defun mu4e-ask-maildir-check-exists (prompt)
|
||||||
"Like `mu4e-ask-maildir', PROMPT for existence of the maildir.
|
"Like `mu4e-ask-maildir', PROMPT for existence of the maildir.
|
||||||
|
|
Loading…
Reference in New Issue