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