* WIP: asynchronous notmuch-poll in emacs client
@ 2022-03-13 1:53 Preston Miller Firestone
2022-03-19 11:06 ` David Bremner
2023-08-12 17:02 ` Jon Rubens
0 siblings, 2 replies; 3+ messages in thread
From: Preston Miller Firestone @ 2022-03-13 1:53 UTC (permalink / raw)
To: notmuch
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
WIP.
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
synchronous?
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: WIP: asynchronous notmuch-poll in emacs client
2022-03-13 1:53 WIP: asynchronous notmuch-poll in emacs client Preston Miller Firestone
@ 2022-03-19 11:06 ` David Bremner
2023-08-12 17:02 ` Jon Rubens
1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2022-03-19 11:06 UTC (permalink / raw)
To: Preston Miller Firestone, notmuch
Preston Miller Firestone <0x504d46@disroot.org> writes:
> 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
> synchronous?
For whatever reason (habit?) I don't use notmuch-poll personally, so I
can't offer too much feedback. I do note that it is used in the test
suite, so any asynch behaviour probably needs to be optional.
d
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: WIP: asynchronous notmuch-poll in emacs client
2022-03-13 1:53 WIP: asynchronous notmuch-poll in emacs client Preston Miller Firestone
2022-03-19 11:06 ` David Bremner
@ 2023-08-12 17:02 ` Jon Rubens
1 sibling, 0 replies; 3+ messages in thread
From: Jon Rubens @ 2023-08-12 17:02 UTC (permalink / raw)
To: Preston Miller Firestone, notmuch
[-- Attachment #1: Type: text/plain, Size: 1843 bytes --]
Preston Miller Firestone <0x504d46@disroot.org> 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
+;;;###autoload
(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."
(interactive)
(notmuch-poll)
- (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
[-- Attachment #2: Type: text/plain, Size: 0 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-13 12:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-13 1:53 WIP: asynchronous notmuch-poll in emacs client Preston Miller Firestone
2022-03-19 11:06 ` David Bremner
2023-08-12 17:02 ` Jon Rubens
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).