* fetchmail returns non-zero when there is no mail; try to handle this a bit

more gracefully by showing (possible) 'errors for 5 seconds in the update buffer
This commit is contained in:
djcb
2012-04-16 23:09:42 +03:00
parent 127a9108fb
commit 2ac3a63f98
2 changed files with 19 additions and 14 deletions

View File

@ -319,15 +319,19 @@ processing takes part in the background, unless buf is non-nil."
mu4e-update-mail-name buf mu4e-get-mail-command)))
(message "Retrieving mail...")
(set-process-sentinel proc
(lambda (proc msg)
(lambda (proc msg)
(let* ((status (process-status proc))
(code (process-exit-status proc))
;; sadly, fetchmail returns '1' when there is no mail; this is not really
;; an error of course, but it's hard to distinguish from a genuine error
(maybe-error (or (not (eq status 'exit)) (/= code 0))))
(message nil)
(if (or (not (eq status 'exit)) (/= code 0))
(message "Some error occured while retrieving mail")
(progn ;; update went well, now rerun the index
(mu4e-proc-index mu4e-maildir)
(let ((buf (process-buffer proc)))
(when (buffer-live-p buf)
(message nil)
;; there may be an error, give the user up to 5 seconds to check
(when maybe-error
(sit-for 5))
(mu4e-proc-index mu4e-maildir)
(let ((buf (process-buffer proc)))
(when (buffer-live-p buf)
(kill-buffer buf))))))))