From d73ebf0815d08287d351a3f7464a631a05461c79 Mon Sep 17 00:00:00 2001 From: Max Nickel Date: Wed, 23 Oct 2019 23:24:56 -0400 Subject: [PATCH] refresh notmuch buffers after sync and add support for custom sync --- modules/email/notmuch/autoload.el | 33 ++++++++++++++++++++----------- modules/email/notmuch/config.el | 3 +++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/modules/email/notmuch/autoload.el b/modules/email/notmuch/autoload.el index 174df2dc4..25a3f1e3b 100644 --- a/modules/email/notmuch/autoload.el +++ b/modules/email/notmuch/autoload.el @@ -32,17 +32,28 @@ ;;;###autoload (defun +notmuch/update () (interactive) - (start-process-shell-command - "notmuch update" nil - (pcase +notmuch-sync-backend - (`gmi - (concat "cd " +notmuch-mail-folder " && gmi push && gmi pull && notmuch new && afew -a -t")) - (`mbsync - "mbsync -a && notmuch new && afew -a -t") - (`mbsync-xdg - "mbsync -c \"$XDG_CONFIG_HOME\"/isync/mbsyncrc -a && notmuch new && afew -a -t") - (`offlineimap - "offlineimap && notmuch new && afew -a -t")))) + ;; create output buffer and jump to beginning + (let ((buf (get-buffer-create "*notmuch update*"))) + (with-current-buffer buf + (erase-buffer)) + (pop-to-buffer buf nil t) + (set-process-sentinel + (start-process-shell-command + "notmuch update" buf + (pcase +notmuch-sync-backend + (`gmi + (concat "cd " +notmuch-mail-folder " && gmi push && gmi pull && notmuch new && afew -a -t")) + (`mbsync + "mbsync -a && notmuch new && afew -a -t") + (`mbsync-xdg + "mbsync -c \"$XDG_CONFIG_HOME\"/isync/mbsyncrc -a && notmuch new && afew -a -t") + (`offlineimap + "offlineimap && notmuch new && afew -a -t") + (`custom +notmuch-sync-command))) + ;; refresh notmuch buffers if sync was successful + (lambda (_process event) + (if (string= event "finished\n") + (notmuch-refresh-all-buffers)))))) ;;;###autoload (defun +notmuch/search-delete () diff --git a/modules/email/notmuch/config.el b/modules/email/notmuch/config.el index 95a7e2400..6f200dbd3 100644 --- a/modules/email/notmuch/config.el +++ b/modules/email/notmuch/config.el @@ -5,6 +5,9 @@ (defvar +notmuch-sync-backend 'gmi "Which backend to use. Can be either gmi, mbsync, offlineimap or nil (manual).") +(defvar +notmuch-sync-command nil + "Command for custom notmuch sync") + (defvar +notmuch-mail-folder "~/.mail/account.gmail" "Where your email folder is located (for use with gmailieer).")