diff options
-rw-r--r-- | net/jao-maildir.el | 13 |
1 files 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) |