diff options
| -rw-r--r-- | ravi-init-mu.el | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/ravi-init-mu.el b/ravi-init-mu.el index f26bcd2..53dcbd2 100644 --- a/ravi-init-mu.el +++ b/ravi-init-mu.el @@ -109,7 +109,29 @@ (setq mu4e-mu-binary (ravi/emacs-file "site-lisp/mu/mu/mu")) (setq mu4e-maildir "~/.mail") - ;; Currently, poll all accounts all the time == to do: fix mail intervals per account + ;; Poll accounts only as often as necessary + (defvar ravi/mu4e-get-mail-attempts 0 + "Number of attempts so far to get mail") + (defun ravi/check-whether-to-get-mail-for-account (account-info) + (let* ((account-interval (assq 'ravi/account-update-interval account-info)) + (account-update-interval (if account-interval (cadr account-interval) 1))) + (if (= (% ravi/mu4e-get-mail-attempts account-update-interval) 0) + (concat " " (car account-info)) + ""))) + (defun ravi/get-mu4e-get-mail-command () + "Figure out arguments to mbsync" + (let ((ravi/all-channels (mapconcat 'ravi/check-whether-to-get-mail-for-account + ravi/mu4e-account-alist ""))) + (setq ravi/mu4e-get-mail-attempts (1+ ravi/mu4e-get-mail-attempts)) + (if (= (length ravi/all-channels) 0) + "true" ;; do nothing command + (concat (ravi/emacs-file "site-lisp/isync/src/mbsync") " -q -q" ravi/all-channels) + ))) + (add-hook 'mu4e-update-pre-hook + (lambda () + (setq mu4e-get-mail-command (ravi/get-mu4e-get-mail-command)))) + ;(message "%d: '%s'" ravi/mu4e-get-mail-attempts (ravi/get-mu4e-get-mail-command)) + ;; Default update command if something goes wrong (setq mu4e-get-mail-command (concat (ravi/emacs-file "site-lisp/isync/src/mbsync") " -a -q -q")) (setq mu4e-update-interval ravi/mu4e-update-interval) (setq mu4e-change-filenames-when-moving t) |
