WIP: asynchronous notmuch-poll in emacs client

Subject: WIP: asynchronous notmuch-poll in emacs client

Date: Sat, 12 Mar 2022 20:53:36 -0500

To: notmuch@notmuchmail.org


From: Preston Miller Firestone

In the emacs client, calls to (notmuch-poll) are sychronous, which means
that all of emacs hangs until notmuch new returns. I tried this little
patch to make it asynchronous, and it seems to work fine. Three
problems, though:

a. notmuch-start-notmuch warns the user about everything, while
notmuch-call-notmuch-process only warns on errors.
b. notmuch-poll-and-refresh-this-buffer doesn't know that notmuch-poll
is now asynchronous and so refreshes too early.
c. The call to notmuch-poll-script is still synchronous, but that's a

I think that the first two problems can be solved by a more
sophisticated sentinel than the one I'm using here, but I'd love to hear
other people's thoughts. Is there a reason that notmuch-poll is

Here's a diff from notmuch-lib.el:

@@ -289,8 +289,11 @@ depending on the value of `notmuch-poll-script'."
       (unless (string-empty-p notmuch-poll-script)
 	(unless (equal (notmuch--call-process notmuch-poll-script nil nil) 0)
 	  (error "Notmuch: poll script `%s' failed!" notmuch-poll-script)))
-    (notmuch-call-notmuch-process "new"))
-  (message "Polling mail...done"))
+    (notmuch-start-notmuch "poll"
+			   nil
+			   (lambda (proc string)
+			     (message "Polling mail...done"))
+			   "new")))
 (defun notmuch-bury-or-kill-this-buffer ()
   "Undisplay the current buffer.

notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org