Re: WIP: asynchronous notmuch-poll in emacs client

Subject: Re: WIP: asynchronous notmuch-poll in emacs client

Date: Sat, 12 Aug 2023 10:02:27 -0700

To: Preston Miller Firestone,


From: Jon Rubens

Preston Miller Firestone <> writes:

> a. notmuch-start-notmuch warns the user about everything, while
> notmuch-call-notmuch-process only warns on errors.
I don’t see any errors using a nearly similar approach. This might be from more async support in emacs.

> b. notmuch-poll-and-refresh-this-buffer doesn't know that notmuch-poll
> is now asynchronous and so refreshes too early.
I adjusted your sentinel to handle the refresh.
Had to take the refresh call out of notmuch-poll.

> c. The call to notmuch-poll-script is still synchronous, but that's a
> WIP. 
That variable is deprecated now so probably not worth fixing?

modified   emacs/notmuch-lib.el
@@ -278,6 +278,7 @@ displays both values separately."

;;; Commands

 (defun notmuch-poll ()
   "Run \"notmuch new\" or an external script to import mail.

@@ -289,8 +290,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 "*notmuch-sync*"
+ nil
+ (lambda (proc string)
+ (notmuch-refresh-this-buffer)
+ (message "Polling mail async...done")) "new")))

  (defun notmuch-bury-or-kill-this-buffer ()
    "Undisplay the current buffer.
@@ -467,7 +471,8 @@ of its command symbol."
   "Invoke `notmuch-poll' to import mail, then refresh the current buffer."
- (notmuch-refresh-this-buffer))
+ ;; (notmuch-refresh-this-buffer)
+ )

  (defun notmuch-refresh-all-buffers ()
    "Invoke `notmuch-refresh-this-buffer' on all notmuch major-mode buffers.

Jon Rubens
notmuch mailing list --
To unsubscribe send an email to