respect +afew feature flag + fix sync buffer kill
This commit is contained in:
parent
ce65645fb8
commit
96dcb4c0d9
2 changed files with 34 additions and 24 deletions
|
@ -29,31 +29,41 @@
|
||||||
(doom-kill-matching-buffers "^\\*notmuch")
|
(doom-kill-matching-buffers "^\\*notmuch")
|
||||||
(+workspace/delete "*MAIL*"))
|
(+workspace/delete "*MAIL*"))
|
||||||
|
|
||||||
|
(defun notmuch-get-sync-command ()
|
||||||
|
(let ((afew-cmd "afew -a -t")
|
||||||
|
(sync-cmd (pcase +notmuch-sync-backend
|
||||||
|
(`gmi
|
||||||
|
(concat "cd " +notmuch-mail-folder " && gmi sync && notmuch new"))
|
||||||
|
(`mbsync
|
||||||
|
"mbsync -a && notmuch new")
|
||||||
|
(`mbsync-xdg
|
||||||
|
"mbsync -c \"$XDG_CONFIG_HOME\"/isync/mbsyncrc -a && notmuch new")
|
||||||
|
(`offlineimap
|
||||||
|
"offlineimap && notmuch new")
|
||||||
|
(`custom +notmuch-sync-command))))
|
||||||
|
(if (featurep! +afew)
|
||||||
|
(format "%s && %s" sync-cmd afew-cmd)
|
||||||
|
sync-cmd)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +notmuch/update ()
|
(defun +notmuch/update ()
|
||||||
|
"Sync notmuch emails with server."
|
||||||
(interactive)
|
(interactive)
|
||||||
;; create output buffer and jump to beginning
|
(with-current-buffer (compile (notmuch-get-sync-command))
|
||||||
(let ((buf (get-buffer-create "*notmuch update*")))
|
(let ((w (get-buffer-window (current-buffer))))
|
||||||
(with-current-buffer buf
|
(select-window w)
|
||||||
(erase-buffer))
|
(add-hook
|
||||||
(pop-to-buffer buf nil t)
|
'compilation-finish-functions
|
||||||
(set-process-sentinel
|
(lambda (buf status)
|
||||||
(start-process-shell-command
|
(if (equal status "finished\n")
|
||||||
"notmuch update" buf
|
(progn
|
||||||
(pcase +notmuch-sync-backend
|
(delete-window w)
|
||||||
(`gmi
|
(kill-buffer buf)
|
||||||
(concat "cd " +notmuch-mail-folder " && gmi push && gmi pull && notmuch new && afew -a -t"))
|
(notmuch-refresh-all-buffers)
|
||||||
(`mbsync
|
(message "Notmuch sync successful"))
|
||||||
"mbsync -a && notmuch new && afew -a -t")
|
(user-error "Failed to sync notmuch data")))
|
||||||
(`mbsync-xdg
|
nil
|
||||||
"mbsync -c \"$XDG_CONFIG_HOME\"/isync/mbsyncrc -a && notmuch new && afew -a -t")
|
'local))))
|
||||||
(`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 ()
|
||||||
|
|
|
@ -64,9 +64,9 @@
|
||||||
#'hide-mode-line-mode)
|
#'hide-mode-line-mode)
|
||||||
|
|
||||||
(map! :localleader
|
(map! :localleader
|
||||||
:map (notmuch-search-mode-map notmuch-tree-mode-map notmuch-show-mode-map)
|
:map (notmuch-hello-mode-map notmuch-search-mode-map notmuch-tree-mode-map notmuch-show-mode-map)
|
||||||
:desc "Compose email" "c" #'+notmuch/compose
|
:desc "Compose email" "c" #'+notmuch/compose
|
||||||
:desc "Fetch new email" "u" #'+notmuch/update
|
:desc "Sync email" "u" #'+notmuch/update
|
||||||
:desc "Quit notmuch" "q" #'+notmuch/quit
|
:desc "Quit notmuch" "q" #'+notmuch/quit
|
||||||
:map notmuch-search-mode-map
|
:map notmuch-search-mode-map
|
||||||
:desc "Mark as deleted" "d" #'+notmuch/search-delete
|
:desc "Mark as deleted" "d" #'+notmuch/search-delete
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue