mirror of https://github.com/djcb/mu.git
mu4e-folder: make mu4e-cache-maildir-list a defcustom, t
turn it on by default; and let mu4e-create-maildir-maybe clear the cache when a new dir is created.
This commit is contained in:
parent
47f8f8c382
commit
9a1733e29d
|
@ -149,6 +149,20 @@ mime-type are nill."
|
||||||
:group 'mu4e-folders
|
:group 'mu4e-folders
|
||||||
:safe 'stringp)
|
:safe 'stringp)
|
||||||
|
|
||||||
|
(defvar mu4e-maildir-list nil
|
||||||
|
"Cached list of maildirs.")
|
||||||
|
|
||||||
|
(defcustom mu4e-cache-maildir-list t
|
||||||
|
"Whether to cache the list of maildirs.
|
||||||
|
Set it to t if you find that generating the list on the fly is
|
||||||
|
too slow.
|
||||||
|
|
||||||
|
If you do so, you can set `mu4e-maildir-list' to nil to force
|
||||||
|
regenerating the cache the next time `mu4e-get-maildirs' gets
|
||||||
|
called."
|
||||||
|
:type 'boolean
|
||||||
|
:group 'mu4e-folders)
|
||||||
|
|
||||||
|
|
||||||
(defun mu4e-maildir-shortcuts ()
|
(defun mu4e-maildir-shortcuts ()
|
||||||
"Get `mu4e-maildir-shortcuts' in the (new) format.
|
"Get `mu4e-maildir-shortcuts' in the (new) format.
|
||||||
|
@ -216,9 +230,11 @@ to create it; otherwise return nil."
|
||||||
;; even when the maildir already seems to exist,
|
;; even when the maildir already seems to exist,
|
||||||
;; call mkdir for a deeper check. However only get an update
|
;; call mkdir for a deeper check. However only get an update
|
||||||
;; when the maildir is totally new.
|
;; when the maildir is totally new.
|
||||||
(mu4e--server-mkdir dir (not seems-to-exist)) t)))
|
(mu4e--server-mkdir dir (not seems-to-exist))
|
||||||
|
(setq mu4e-maildir-list nil) ;; clear cache
|
||||||
|
t)))
|
||||||
|
|
||||||
(defun mu4e~get-maildirs-1 (path mdir)
|
(defun mu4e--get-maildirs-1 (path mdir)
|
||||||
"Get maildirs for MDIR under PATH.
|
"Get maildirs for MDIR under PATH.
|
||||||
Do so recursively and produce a list of relative paths."
|
Do so recursively and produce a list of relative paths."
|
||||||
(let ((dirs)
|
(let ((dirs)
|
||||||
|
@ -237,25 +253,15 @@ Do so recursively and produce a list of relative paths."
|
||||||
(unless (member (car dentry) '("cur" "new" "tmp"))
|
(unless (member (car dentry) '("cur" "new" "tmp"))
|
||||||
(setq dirs
|
(setq dirs
|
||||||
(append dirs
|
(append dirs
|
||||||
(mu4e~get-maildirs-1
|
(mu4e--get-maildirs-1
|
||||||
path (mu4e-join-paths mdir (car dentry))))))))
|
path (mu4e-join-paths mdir (car dentry))))))))
|
||||||
dirs))
|
dirs))
|
||||||
|
|
||||||
(defvar mu4e-cache-maildir-list nil
|
|
||||||
"Whether to cache the list of maildirs.
|
|
||||||
Set it to t if you find that generating the list on the fly is
|
|
||||||
too slow. If you do, you can set `mu4e-maildir-list' to nil to
|
|
||||||
force regenerating the cache the next time `mu4e-get-maildirs'
|
|
||||||
gets called.")
|
|
||||||
|
|
||||||
(defvar mu4e-maildir-list nil
|
|
||||||
"Cached list of maildirs.")
|
|
||||||
|
|
||||||
(defun mu4e-get-maildirs ()
|
(defun mu4e-get-maildirs ()
|
||||||
"Get maildirs under `mu4e-maildir'.
|
"Get maildirs under `mu4e-maildir'.
|
||||||
Do so recursively, and produce a list of relative paths (ie.,
|
Do so recursively, and produce a list of relative paths (ie.,
|
||||||
/archive, /sent etc.). Most of the work is done in
|
/archive, /sent etc.). Most of the work is done in
|
||||||
`mu4e~get-maildirs-1'. Note, these results are /cached/ if
|
`mu4e--get-maildirs-1'. Note, these results are /cached/ if
|
||||||
`mu4e-cache-maildir-list' is customized to non-nil. In that case,
|
`mu4e-cache-maildir-list' is customized to non-nil. In that case,
|
||||||
the list of maildirs will not change until you restart mu4e."
|
the list of maildirs will not change until you restart mu4e."
|
||||||
(unless (and mu4e-maildir-list mu4e-cache-maildir-list)
|
(unless (and mu4e-maildir-list mu4e-cache-maildir-list)
|
||||||
|
@ -266,7 +272,7 @@ the list of maildirs will not change until you restart mu4e."
|
||||||
(mu4e-join-paths
|
(mu4e-join-paths
|
||||||
(mu4e-root-maildir) "cur"))
|
(mu4e-root-maildir) "cur"))
|
||||||
'("/"))
|
'("/"))
|
||||||
(mu4e~get-maildirs-1 (mu4e-root-maildir) "/"))
|
(mu4e--get-maildirs-1 (mu4e-root-maildir) "/"))
|
||||||
(lambda (s1 s2)
|
(lambda (s1 s2)
|
||||||
(string< (downcase s1) (downcase s2))))))
|
(string< (downcase s1) (downcase s2))))))
|
||||||
mu4e-maildir-list)
|
mu4e-maildir-list)
|
||||||
|
@ -290,11 +296,12 @@ from all maildirs under `mu4e-maildir'."
|
||||||
'other
|
'other
|
||||||
(mu4e-read-option prompt
|
(mu4e-read-option prompt
|
||||||
(append options
|
(append options
|
||||||
'(("oOther..." . 'other)))))))
|
'(("oOther..." . other)))))))
|
||||||
(if (eq response 'other)
|
(if (eq response 'other)
|
||||||
(funcall mu4e-completing-read-function prompt
|
(progn
|
||||||
(mu4e-get-maildirs) nil nil
|
(funcall mu4e-completing-read-function prompt
|
||||||
mu4e-maildir-initial-input)
|
(mu4e-get-maildirs) nil nil
|
||||||
|
mu4e-maildir-initial-input))
|
||||||
response)))
|
response)))
|
||||||
|
|
||||||
(defun mu4e-ask-maildir-check-exists (prompt)
|
(defun mu4e-ask-maildir-check-exists (prompt)
|
||||||
|
|
Loading…
Reference in New Issue