unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Perform mail polling asynchronously
@ 2011-09-05  4:14 Antono Vasiljev
  2012-01-03 16:02 ` David Edmondson
  0 siblings, 1 reply; 6+ messages in thread
From: Antono Vasiljev @ 2011-09-05  4:14 UTC (permalink / raw)
  To: notmuch

  * reimplemented notmuch-poll(&optional callback) so that it
    calls process asynchronously and run callback after process
    finished
  * changed usage of notmuch-poll in notmuch-hello-poll-and-update
    and notmuch-search-poll-and-refresh-view
---
 emacs/notmuch-hello.el |    4 +---
 emacs/notmuch.el       |   33 +++++++++++++++++++++++++++------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
index 65fde75..03739e5 100644
--- a/emacs/notmuch-hello.el
+++ b/emacs/notmuch-hello.el
@@ -304,9 +304,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
 (defun notmuch-hello-poll-and-update ()
   "Invoke `notmuch-poll' to import mail, then refresh the current view."
   (interactive)
-  (notmuch-poll)
-  (notmuch-hello-update))
-
+  (notmuch-poll 'notmuch-hello-update))
 
 (defvar notmuch-hello-mode-map
   (let ((map (make-sparse-keymap)))
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index f11ec24..2c3f8a8 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -954,19 +954,40 @@ the user's needs:
   :type 'string
   :group 'notmuch)
 
-(defun notmuch-poll ()
-  "Run external script to import mail.
 
-Invokes `notmuch-poll-script' if it is not set to an empty string."
+(defun notmuch-poll (&optional poll-callback)
+  "Asyncronously run external script to import mail.
+
+Invokes `notmuch-poll-script' if it is not set to an empty string.
+After script finished `callback' will be called.
+"
   (interactive)
   (if (not (string= notmuch-poll-script ""))
-      (call-process notmuch-poll-script nil nil)))
+      (message "Notmuch: starting mail poll script")
+      (progn
+        (defun notmuch-poll-sentinel (processs event)
+          (if (string-match "^finished" event)
+              (progn
+                (message "Notmuch: poll finished")
+                (if (boundp 'poll-callback)
+                    (poll-callback)))
+            (progn
+              ((message event)
+               (message "Notmuch: something gone wrong when polling mail...")))))
+        (set-process-sentinel
+         (start-process "notmuch-poll"
+                        "*notmuch-poll*"
+                        notmuch-poll-script)
+         'notmuch-poll-sentinel)
+        (switch-to-buffer "*notmuch-poll*")
+        (comint-mode)
+        (switch-to-buffer (other-buffer -1)))))
+
 
 (defun notmuch-search-poll-and-refresh-view ()
   "Invoke `notmuch-poll' to import mail, then refresh the current view."
   (interactive)
-  (notmuch-poll)
-  (notmuch-search-refresh-view))
+  (notmuch-poll 'notmuch-search-refresh-view))
 
 (defun notmuch-search-toggle-order ()
   "Toggle the current search order.
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Perform mail polling asynchronously
  2011-09-05  4:14 [PATCH] Perform mail polling asynchronously Antono Vasiljev
@ 2012-01-03 16:02 ` David Edmondson
  2012-01-06 11:09   ` Antono Vasiljev
  2012-01-06 14:45   ` Jesse Rosenthal
  0 siblings, 2 replies; 6+ messages in thread
From: David Edmondson @ 2012-01-03 16:02 UTC (permalink / raw)
  To: Antono Vasiljev, notmuch

[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

On Mon,  5 Sep 2011 07:14:36 +0300, Antono Vasiljev <self@antono.info> wrote:
>   * reimplemented notmuch-poll(&optional callback) so that it
>     calls process asynchronously and run callback after process
>     finished
>   * changed usage of notmuch-poll in notmuch-hello-poll-and-update
>     and notmuch-search-poll-and-refresh-view

I don't understand the real purpose of this patch.

If the poll script runs asynchronously, won't the notmuch-search output
refresh and jump into my face when I'm busy doing something else? And,
if I'm not busy doing something else, why can't I just wait for the poll
script to complete?

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Perform mail polling asynchronously
  2012-01-03 16:02 ` David Edmondson
@ 2012-01-06 11:09   ` Antono Vasiljev
  2012-01-06 11:25     ` David Edmondson
  2012-01-06 14:45   ` Jesse Rosenthal
  1 sibling, 1 reply; 6+ messages in thread
From: Antono Vasiljev @ 2012-01-06 11:09 UTC (permalink / raw)
  To: David Edmondson; +Cc: notmuch

On Tue, 2012-01-03 at 16:02 +0000, David Edmondson wrote:

> On Mon,  5 Sep 2011 07:14:36 +0300, Antono Vasiljev <self@antono.info> wrote:
> >   * reimplemented notmuch-poll(&optional callback) so that it
> >     calls process asynchronously and run callback after process
> >     finished
> >   * changed usage of notmuch-poll in notmuch-hello-poll-and-update
> >     and notmuch-search-poll-and-refresh-view
> 
> I don't understand the real purpose of this patch.

> If the poll script runs asynchronously, won't the notmuch-search output
> refresh and jump into my face when I'm busy doing something else? And,
> if I'm not busy doing something else, why can't I just wait for the poll
> script to complete?

Sync io sucks.
Just drop it if you do not like. I don't use notmuch anymore so i dont
care.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Perform mail polling asynchronously
  2012-01-06 11:09   ` Antono Vasiljev
@ 2012-01-06 11:25     ` David Edmondson
  0 siblings, 0 replies; 6+ messages in thread
From: David Edmondson @ 2012-01-06 11:25 UTC (permalink / raw)
  To: self; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]

On Fri, 06 Jan 2012 14:09:57 +0300, Antono Vasiljev <self@antono.info> wrote:
> On Tue, 2012-01-03 at 16:02 +0000, David Edmondson wrote:
> 
> > On Mon,  5 Sep 2011 07:14:36 +0300, Antono Vasiljev <self@antono.info> wrote:
> > >   * reimplemented notmuch-poll(&optional callback) so that it
> > >     calls process asynchronously and run callback after process
> > >     finished
> > >   * changed usage of notmuch-poll in notmuch-hello-poll-and-update
> > >     and notmuch-search-poll-and-refresh-view
> > 
> > I don't understand the real purpose of this patch.
> 
> > If the poll script runs asynchronously, won't the notmuch-search output
> > refresh and jump into my face when I'm busy doing something else? And,
> > if I'm not busy doing something else, why can't I just wait for the poll
> > script to complete?
> 
> Sync io sucks.
> Just drop it if you do not like. I don't use notmuch anymore so i dont
> care.

Antono, thanks for replying. I'll mark the patch as 'obsolete'.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Perform mail polling asynchronously
  2012-01-03 16:02 ` David Edmondson
  2012-01-06 11:09   ` Antono Vasiljev
@ 2012-01-06 14:45   ` Jesse Rosenthal
  2012-01-06 15:25     ` David Edmondson
  1 sibling, 1 reply; 6+ messages in thread
From: Jesse Rosenthal @ 2012-01-06 14:45 UTC (permalink / raw)
  To: David Edmondson, notmuch

On Tue, 03 Jan 2012 16:02:43 +0000, David Edmondson <dme@dme.org> wrote:
> On Mon,  5 Sep 2011 07:14:36 +0300, Antono Vasiljev <self@antono.info> wrote:
>
> If the poll script runs asynchronously, won't the notmuch-search output
> refresh and jump into my face when I'm busy doing something else? And,
> if I'm not busy doing something else, why can't I just wait for the poll
> script to complete?

Well, he might have dropped it (and notmuch), but I've been wondering
about the possibilities of this for the emacs client. What I was
imagining was some sort of modeline notifier, like what ERC offers. It
could easily alert you without jumping into your face.

Just musing -- I haven't had time to actually think it all the way
through.

--J

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Perform mail polling asynchronously
  2012-01-06 14:45   ` Jesse Rosenthal
@ 2012-01-06 15:25     ` David Edmondson
  0 siblings, 0 replies; 6+ messages in thread
From: David Edmondson @ 2012-01-06 15:25 UTC (permalink / raw)
  To: Jesse Rosenthal, notmuch

[-- Attachment #1: Type: text/plain, Size: 825 bytes --]

On Fri, 06 Jan 2012 06:45:59 -0800, Jesse Rosenthal <jrosenthal@jhu.edu> wrote:
> On Tue, 03 Jan 2012 16:02:43 +0000, David Edmondson <dme@dme.org> wrote:
> > On Mon,  5 Sep 2011 07:14:36 +0300, Antono Vasiljev <self@antono.info> wrote:
> >
> > If the poll script runs asynchronously, won't the notmuch-search output
> > refresh and jump into my face when I'm busy doing something else? And,
> > if I'm not busy doing something else, why can't I just wait for the poll
> > script to complete?
> 
> Well, he might have dropped it (and notmuch), but I've been wondering
> about the possibilities of this for the emacs client. What I was
> imagining was some sort of modeline notifier, like what ERC offers. It
> could easily alert you without jumping into your face.

It sounds useful, but that patch is not it.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-06 15:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-05  4:14 [PATCH] Perform mail polling asynchronously Antono Vasiljev
2012-01-03 16:02 ` David Edmondson
2012-01-06 11:09   ` Antono Vasiljev
2012-01-06 11:25     ` David Edmondson
2012-01-06 14:45   ` Jesse Rosenthal
2012-01-06 15:25     ` David Edmondson

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).