summaryrefslogtreecommitdiffstats
path: root/ravi-init-mu.el
diff options
context:
space:
mode:
authorRavi R Kiran <aine.marina@gmail.com>2014-07-14 04:02:37 (GMT)
committerRavi R Kiran <aine.marina@gmail.com>2014-07-14 04:02:37 (GMT)
commit5af7ab8b827c83d1193c2ee867a686d1407b29f3 (patch)
treebeace1fcdf564925855cce391eb618864e61a660 /ravi-init-mu.el
parentac402b4cb60fe54afecdc3888ed8d35e26316245 (diff)
downloaddotemacs-5af7ab8b827c83d1193c2ee867a686d1407b29f3.zip
dotemacs-5af7ab8b827c83d1193c2ee867a686d1407b29f3.tar.gz
dotemacs-5af7ab8b827c83d1193c2ee867a686d1407b29f3.tar.bz2
Different update rates for different accounts
Diffstat (limited to 'ravi-init-mu.el')
-rw-r--r--ravi-init-mu.el24
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)