fix(notmuch): window is not a valid window error on sync end

Notmuch sync process is done asynchronously, but if the user switch to
other buffer before update process, it complains like

```
error in process sentinel: #<window 98> is not a valid window
```

This commit simplifies cleanup process after mail syncing, and still
maintain its functionality.
This commit is contained in:
Hyunggyu Jang 2021-09-17 19:15:57 +09:00 committed by Henrik Lissner
parent c3d237c3f5
commit 7274f73500

View file

@ -60,20 +60,17 @@
"Sync notmuch emails with server." "Sync notmuch emails with server."
(interactive) (interactive)
(with-current-buffer (compile (+notmuch-get-sync-command)) (with-current-buffer (compile (+notmuch-get-sync-command))
(let ((w (get-buffer-window (current-buffer))))
(select-window w)
(add-hook (add-hook
'compilation-finish-functions 'compilation-finish-functions
(lambda (buf status) (lambda (buf status)
(if (equal status "finished\n") (if (equal status "finished\n")
(progn (progn
(delete-window w)
(kill-buffer buf) (kill-buffer buf)
(notmuch-refresh-all-buffers) (notmuch-refresh-all-buffers)
(message "Notmuch sync successful")) (message "Notmuch sync successful"))
(user-error "Failed to sync notmuch data"))) (user-error "Failed to sync notmuch data")))
nil nil
'local)))) 'local)))
;;;###autoload ;;;###autoload
(defun +notmuch/search-delete () (defun +notmuch/search-delete ()