diff options
| author | Ravi R Kiran <aine.marina@gmail.com> | 2021-08-23 02:52:13 (GMT) |
|---|---|---|
| committer | Ravi R Kiran <aine.marina@gmail.com> | 2021-08-23 02:52:13 (GMT) |
| commit | 89e27d124124156a01a228f785aa240e531afc35 (patch) | |
| tree | 4be3f0720cd983a7237d0eeaceb5b049dad18046 | |
| parent | fe136a73609933ebcec16e81b8d742b29fa50e19 (diff) | |
| download | dotemacs-89e27d124124156a01a228f785aa240e531afc35.zip dotemacs-89e27d124124156a01a228f785aa240e531afc35.tar.gz dotemacs-89e27d124124156a01a228f785aa240e531afc35.tar.bz2 | |
Save last fetch contexts
| -rw-r--r-- | lisp/ravi-init-mu.el | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lisp/ravi-init-mu.el b/lisp/ravi-init-mu.el index c16db6b..1b26582 100644 --- a/lisp/ravi-init-mu.el +++ b/lisp/ravi-init-mu.el @@ -96,22 +96,25 @@ ;; Poll accounts only as often as necessary (defvar ravi/mu4e-get-mail-attempts 0 "Number of attempts so far to get mail") + (defvar ravi/mu4e-last-fetched-contexts nil + "The contexts for the last fetch") (defun ravi/check-whether-to-get-mail-for-account (context) (let* ((account-interval (when (mu4e-context-vars context) (assq 'ravi/account-update-interval (mu4e-context-vars context)))) (account-update-interval (if account-interval (cdr account-interval) 1))) - (if (and (> account-update-interval 0) (= (% ravi/mu4e-get-mail-attempts account-update-interval) 0)) - (concat " " (cdr (assq 'ravi/account-name (mu4e-context-vars context)))) - ""))) + (and (> account-update-interval 0) (= (% ravi/mu4e-get-mail-attempts account-update-interval) 0)))) (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 - mu4e-contexts ""))) + (let* ((contexts-to-get (seq-filter #'ravi/check-whether-to-get-mail-for-account mu4e-contexts)) + (context-string (mapconcat (lambda (ctx) + (alist-get 'ravi/account-name + (mu4e-context-vars ctx))) + contexts-to-get " "))) (setq ravi/mu4e-get-mail-attempts (1+ ravi/mu4e-get-mail-attempts)) - (if (= (length ravi/all-channels) 0) - "true" ;; do nothing command - (concat "mbsync -q -q" ravi/all-channels) - ))) + (setq ravi/mu4e-last-fetched-contexts contexts-to-get) + (if contexts-to-get + (concat "mbsync -q -q " context-string) + "true"))) ;; do nothing command (add-hook 'mu4e-update-pre-hook (lambda () (setq mu4e-get-mail-command (ravi/get-mu4e-get-mail-command)) |
