* mu4e-utils: cache the list of maildirs in `mu4e-get-maildirs', document this

This commit is contained in:
djcb 2012-05-29 10:12:32 +02:00
parent a019041400
commit 41e73efd38
2 changed files with 24 additions and 9 deletions

View File

@ -172,16 +172,21 @@ paths."
(mu4e~get-maildirs-1 path (concat mdir "/" dir)))))
maildirs))
(defvar mu4e~maildir-list nil "Cached list of maildirs.")
(defun mu4e-get-maildirs (path)
"Get maildirs under path, recursively, as a list of relative
paths (ie., /archive, /sent etc.). Most of the work is done in
`mu4e-get-maildirs-1'."
(sort (mu4e~get-maildirs-1 path)
(lambda (m1 m2)
(when (string= m1 "/")
-1 ;; '/' comes first
(compare-strings m1 0 nil m2 0 nil t)))))
`mu4e-get-maildirs-1'. Note, these results are /cached/, so the
list of maildirs will not change until you restart mu4e."
(unless mu4e~maildir-list
(setq mu4e~maildir-list
(sort (mu4e~get-maildirs-1 path)
(lambda (m1 m2)
(when (string= m1 "/")
-1 ;; '/' comes first
(compare-strings m1 0 nil m2 0 nil t))))))
mu4e~maildir-list)
(defun mu4e-ask-maildir (prompt)
@ -616,10 +621,13 @@ FUNC (if non-nil) afterwards."
"Stop the mu4e session."
(when mu4e-update-timer
(cancel-timer mu4e-update-timer)
(setq mu4e-update-timer nil))
(setq
mu4e-update-timer nil
mu4e~maildir-list nil))
(mu4e~proc-kill)
(kill-buffer))
(defvar mu4e-update-timer nil
"*internal* The mu4e update timer.")

View File

@ -1082,7 +1082,10 @@ list of maildirs you'd like to have quick access to, for example:
This would set @key{i} as a shortcut for the @t{/inbox} folder; so effectively
a query @t{maildir:/inbox}. There is a special shortcut @key{o} for
@emph{other} (so don't use that one for your own shortcuts!), which allows you
to choose from @emph{all} maildirs.
to choose from @emph{all} maildirs. There is support for autocompletion; note
that the list of maildirs is determined when @t{mu4e} starts; if there are
changes in the maildirs while @t{mu4e} is running, you need to restart
@t{mu4e}.
Each of the folder names is relative to your top-level maildir directory; so if
you keep your mail in @file{~/Maildir}, @file{/inbox} would refer to
@ -1490,7 +1493,11 @@ them.
@t{mu4e} loads @t{mu4e-speedbar} automatically; all you need to do to activate
it is @code{M-x speedbar}. Then, when then going to the @ref{Main view}, the
speedbar-frame will be updated with your bookmarks and maildirs.
speedbar-frame will be updated with your bookmarks and maildirs. For speed
reasons, the list of maildirs is determined when @t{mu4e} starts; if the list
of maildirs changes while @t{mu4e} is running, you need to restart @t{mu4e} to
reflect those changes in the speedbar and in other places that use this list,
such as auto-completion when jumping to a maildir.
@code{mu4e-speedbar} was contributed by Antono Vasiljev.