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 ;;;###autoload
(defun +notmuch/update () (defun +notmuch/update ()
(interactive) (interactive)
(start-process-shell-command ;; create output buffer and jump to beginning
"notmuch update" nil (let ((buf (get-buffer-create "*notmuch update*")))
(pcase +notmuch-sync-backend (with-current-buffer buf
(`gmi (erase-buffer))
(concat "cd " +notmuch-mail-folder " && gmi push && gmi pull && notmuch new && afew -a -t")) (pop-to-buffer buf nil t)
(`mbsync (set-process-sentinel
"mbsync -a && notmuch new && afew -a -t") (start-process-shell-command
(`mbsync-xdg "notmuch update" buf
"mbsync -c \"$XDG_CONFIG_HOME\"/isync/mbsyncrc -a && notmuch new && afew -a -t") (pcase +notmuch-sync-backend
(`offlineimap (`gmi
"offlineimap && notmuch new && afew -a -t")))) (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 ;;;###autoload
(defun +notmuch/search-delete () (defun +notmuch/search-delete ()

View file

@ -5,6 +5,9 @@
(defvar +notmuch-sync-backend 'gmi (defvar +notmuch-sync-backend 'gmi
"Which backend to use. Can be either gmi, mbsync, offlineimap or nil (manual).") "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" (defvar +notmuch-mail-folder "~/.mail/account.gmail"
"Where your email folder is located (for use with gmailieer).") "Where your email folder is located (for use with gmailieer).")