From 41e73efd38d90f30d6e564b8ad39d172df9642f5 Mon Sep 17 00:00:00 2001 From: djcb Date: Tue, 29 May 2012 10:12:32 +0200 Subject: [PATCH] * mu4e-utils: cache the list of maildirs in `mu4e-get-maildirs', document this --- emacs/mu4e-utils.el | 22 +++++++++++++++------- emacs/mu4e.texi | 11 +++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/emacs/mu4e-utils.el b/emacs/mu4e-utils.el index 7372658c..b946cc88 100644 --- a/emacs/mu4e-utils.el +++ b/emacs/mu4e-utils.el @@ -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.") diff --git a/emacs/mu4e.texi b/emacs/mu4e.texi index 54ce2b67..7a6937ac 100644 --- a/emacs/mu4e.texi +++ b/emacs/mu4e.texi @@ -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.