better handle maildir cache
- get an updated maildir list after indexing - add mu4e-added items to the list opportunistically Remove mu4e-clear-caches / mu4e-cache-maildir-list to mu4e-obsolete.el Fixes #2537.
This commit is contained in:
@ -162,17 +162,6 @@ mime-type are nil."
|
||||
(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 ()
|
||||
"Get `mu4e-maildir-shortcuts' in the (new) format.
|
||||
@ -204,19 +193,19 @@ the result."
|
||||
(or val (mu4e-error "%S evaluates to nil" foldervar)))))
|
||||
|
||||
(defun mu4e-get-drafts-folder (&optional msg)
|
||||
"Get the drafts folder, optionallly based on MSG.
|
||||
"Get the drafts folder, optionally based on MSG.
|
||||
See `mu4e-drafts-folder'." (mu4e--get-folder 'mu4e-drafts-folder msg))
|
||||
|
||||
(defun mu4e-get-refile-folder (&optional msg)
|
||||
"Get the folder for refiling, optionallly based on MSG.
|
||||
"Get the folder for refiling, optionally based on MSG.
|
||||
See `mu4e-refile-folder'." (mu4e--get-folder 'mu4e-refile-folder msg))
|
||||
|
||||
(defun mu4e-get-sent-folder (&optional msg)
|
||||
"Get the sent folder, optionallly based on MSG.
|
||||
"Get the sent folder, optionally based on MSG.
|
||||
See `mu4e-sent-folder'." (mu4e--get-folder 'mu4e-sent-folder msg))
|
||||
|
||||
(defun mu4e-get-trash-folder (&optional msg)
|
||||
"Get the trash folder, optionallly based on MSG.
|
||||
"Get the trash folder, optionally based on MSG.
|
||||
See `mu4e-trash-folder'." (mu4e--get-folder 'mu4e-trash-folder msg))
|
||||
|
||||
;;; Maildirs
|
||||
@ -237,11 +226,9 @@ to create it; otherwise return nil."
|
||||
(let ((seems-to-exist (file-directory-p dir)))
|
||||
(when (or seems-to-exist
|
||||
(yes-or-no-p (mu4e-format "%s does not exist yet. Create now?" dir)))
|
||||
;; even when the maildir already seems to exist,
|
||||
;; call mkdir for a deeper check. However only get an update
|
||||
;; when the maildir is totally new.
|
||||
;; even when the maildir already seems to exist, call mkdir for a deeper
|
||||
;; check. However only get an update when the maildir is totally new.
|
||||
(mu4e--server-mkdir dir (not seems-to-exist))
|
||||
(setq mu4e-maildir-list nil) ;; clear cache
|
||||
t)))
|
||||
|
||||
(defun mu4e-get-maildirs ()
|
||||
|
||||
@ -224,5 +224,11 @@
|
||||
(define-obsolete-function-alias 'mu4e-quote-for-modeline
|
||||
'mu4e--modeline-quote-and-truncate "1.9.16")
|
||||
|
||||
;; mu4e-folder
|
||||
(make-obsolete-variable 'mu4e-cache-maildir-list "No longer used" "1.11.15")
|
||||
|
||||
;; mu4e.
|
||||
(make-obsolete 'mu4e-clear-caches "No longer used" "1.11.15")
|
||||
|
||||
(provide 'mu4e-obsolete)
|
||||
;;; mu4e-obsolete.el ends here
|
||||
|
||||
@ -643,7 +643,13 @@ the directory time stamp."
|
||||
|
||||
(defun mu4e--server-mkdir (path &optional update)
|
||||
"Create a new maildir-directory at filesystem PATH.
|
||||
When UPDATE is non-nil, send a update when completed."
|
||||
When UPDATE is non-nil, send a update when completed.
|
||||
PATH must be below the root-maildir."
|
||||
;; handle maildir cache
|
||||
(if (not (string-prefix-p (mu4e-root-maildir) path))
|
||||
(mu4e-error "Cannot create maildir outside root-maildir")
|
||||
(add-to-list 'mu4e-maildir-list ;; update cache
|
||||
(substring path (length (mu4e-root-maildir)))))
|
||||
(mu4e--server-call-mu `(mkdir
|
||||
:path ,path
|
||||
:update ,(or update nil))))
|
||||
|
||||
17
mu4e/mu4e.el
17
mu4e/mu4e.el
@ -160,7 +160,12 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
||||
(when mu4e--update-timer
|
||||
(cancel-timer mu4e--update-timer)
|
||||
(setq mu4e--update-timer nil))
|
||||
(mu4e-clear-caches)
|
||||
|
||||
(setq ;; clear some caches
|
||||
mu4e-maildir-list nil
|
||||
mu4e--contacts-set nil
|
||||
mu4e--contacts-tstamp "0")
|
||||
|
||||
(remove-hook 'mu4e-query-items-updated-hook #'mu4e--main-redraw)
|
||||
(remove-hook 'mu4e-query-items-updated-hook #'mu4e--modeline-update)
|
||||
(remove-hook 'mu4e-query-items-updated-hook #'mu4e--notification)
|
||||
@ -229,7 +234,8 @@ Otherwise, check requirements, then start mu4e. When successful, invoke
|
||||
mu4e-message-changed-hook)
|
||||
(unless (and (not (string= mu4e--contacts-tstamp "0"))
|
||||
(zerop (plist-get info :updated)))
|
||||
(mu4e--request-contacts-maybe))
|
||||
(mu4e--request-contacts-maybe)
|
||||
(mu4e--server-data 'maildirs)) ;; update maildir list
|
||||
(mu4e--main-redraw))))
|
||||
((plist-get info :message)
|
||||
(mu4e-index-message "%s" (plist-get info :message))))))
|
||||
@ -253,13 +259,6 @@ chance."
|
||||
(mu4e-setq-if-nil mu4e-pong-func #'mu4e--default-handler)
|
||||
|
||||
(mu4e-setq-if-nil mu4e-queries-func #'mu4e--query-items-queries-handler))
|
||||
|
||||
(defun mu4e-clear-caches ()
|
||||
"Clear any cached resources."
|
||||
(setq
|
||||
mu4e-maildir-list nil
|
||||
mu4e--contacts-set nil
|
||||
mu4e--contacts-tstamp "0"))
|
||||
|
||||
;;;
|
||||
(provide 'mu4e)
|
||||
|
||||
Reference in New Issue
Block a user