From 63e866091425bff5f292c68b0ba83e9e9fed8b78 Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 2 Dec 2019 14:32:22 +0000 Subject: jao-maildir: callbacks --- net/jao-maildir.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/jao-maildir.el b/net/jao-maildir.el index ed082a0..2c4d67c 100644 --- a/net/jao-maildir.el +++ b/net/jao-maildir.el @@ -50,26 +50,27 @@ (when jao-maildir-debug-p (message "watch: %s: %s" mbox e))) -(defun jao-maildir--watcher (mbox) +(defun jao-maildir--watcher (mbox cb) (lambda (e) (jao-maildir--log-watch e mbox) (when (memq (cadr e) '(created deleted)) (setcdr (assoc mbox jao-maildir-counts) - (jao-maildir--maildir-new-count mbox))))) + (jao-maildir--maildir-new-count mbox)) + (when cb (funcall cb mbox))))) -(defun jao-maildir--setup-watches () +(defun jao-maildir--setup-watches (cb) (jao-maildir-cancel-watchers) (setq jao-maildir--watches (mapcar (lambda (mbox) (file-notify-add-watch (jao-maildir--maildir-new mbox) '(change) - (jao-maildir--watcher mbox))) + (jao-maildir--watcher mbox cb))) jao-maildirs))) -(defun jao-maildir-setup (maildirs) +(defun jao-maildir-setup (maildirs &optional cb) (setq jao-maildirs maildirs) (setq jao-maildir-counts (jao-maildir-counts)) - (jao-maildir--setup-watches)) + (jao-maildir--setup-watches cb)) (provide 'jao-maildir) -- cgit v1.2.3