refresh notmuch buffers after sync and add support for custom sync

This commit is contained in:
Max Nickel 2019-10-23 23:24:56 -04:00
parent 5324cb2fc8
commit d73ebf0815
2 changed files with 25 additions and 11 deletions

View file

@ -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 ()

View file

@ -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).")