1 Return-Path: <self@antono.info>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 07CE9431FD0
\r
6 for <notmuch@notmuchmail.org>; Sun, 4 Sep 2011 21:14:50 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=1.363 tagged_above=-999 required=5
\r
12 tests=[RDNS_DYNAMIC=0.363, TO_NO_BRKTS_DYNIP=1] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id S7lbjL54rjSu for <notmuch@notmuchmail.org>;
\r
16 Sun, 4 Sep 2011 21:14:49 -0700 (PDT)
\r
17 Received: from mail.antono.info (ec2-50-19-243-116.compute-1.amazonaws.com
\r
19 (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
\r
20 (No client certificate requested)
\r
21 by olra.theworths.org (Postfix) with ESMTPS id 8807E431FB6
\r
22 for <notmuch@notmuchmail.org>; Sun, 4 Sep 2011 21:14:49 -0700 (PDT)
\r
23 Received: by mail.antono.info (Postfix, from userid 1003)
\r
24 id A543261477; Mon, 5 Sep 2011 04:15:19 +0000 (UTC)
\r
25 Received: from localhost.localdomain (unknown [178.121.201.33])
\r
26 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
27 (No client certificate requested)
\r
28 by mail.antono.info (Postfix) with ESMTPSA id 2DEE660381;
\r
29 Mon, 5 Sep 2011 04:15:18 +0000 (UTC)
\r
30 From: Antono Vasiljev <self@antono.info>
\r
31 To: notmuch@notmuchmail.org
\r
32 Subject: [PATCH] Perform mail polling asynchronously
\r
33 Date: Mon, 5 Sep 2011 07:14:36 +0300
\r
34 Message-Id: <1315196076-9254-1-git-send-email-self@antono.info>
\r
35 X-Mailer: git-send-email 1.7.5.4
\r
36 X-BeenThere: notmuch@notmuchmail.org
\r
37 X-Mailman-Version: 2.1.13
\r
39 List-Id: "Use and development of the notmuch mail system."
\r
40 <notmuch.notmuchmail.org>
\r
41 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
42 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
43 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
44 List-Post: <mailto:notmuch@notmuchmail.org>
\r
45 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
46 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
47 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
48 X-List-Received-Date: Mon, 05 Sep 2011 04:14:50 -0000
\r
50 * reimplemented notmuch-poll(&optional callback) so that it
\r
51 calls process asynchronously and run callback after process
\r
53 * changed usage of notmuch-poll in notmuch-hello-poll-and-update
\r
54 and notmuch-search-poll-and-refresh-view
\r
56 emacs/notmuch-hello.el | 4 +---
\r
57 emacs/notmuch.el | 33 +++++++++++++++++++++++++++------
\r
58 2 files changed, 28 insertions(+), 9 deletions(-)
\r
60 diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
61 index 65fde75..03739e5 100644
\r
62 --- a/emacs/notmuch-hello.el
\r
63 +++ b/emacs/notmuch-hello.el
\r
64 @@ -304,9 +304,7 @@ should be. Returns a cons cell `(tags-per-line width)'."
\r
65 (defun notmuch-hello-poll-and-update ()
\r
66 "Invoke `notmuch-poll' to import mail, then refresh the current view."
\r
69 - (notmuch-hello-update))
\r
71 + (notmuch-poll 'notmuch-hello-update))
\r
73 (defvar notmuch-hello-mode-map
\r
74 (let ((map (make-sparse-keymap)))
\r
75 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
76 index f11ec24..2c3f8a8 100644
\r
77 --- a/emacs/notmuch.el
\r
78 +++ b/emacs/notmuch.el
\r
79 @@ -954,19 +954,40 @@ the user's needs:
\r
83 -(defun notmuch-poll ()
\r
84 - "Run external script to import mail.
\r
86 -Invokes `notmuch-poll-script' if it is not set to an empty string."
\r
87 +(defun notmuch-poll (&optional poll-callback)
\r
88 + "Asyncronously run external script to import mail.
\r
90 +Invokes `notmuch-poll-script' if it is not set to an empty string.
\r
91 +After script finished `callback' will be called.
\r
94 (if (not (string= notmuch-poll-script ""))
\r
95 - (call-process notmuch-poll-script nil nil)))
\r
96 + (message "Notmuch: starting mail poll script")
\r
98 + (defun notmuch-poll-sentinel (processs event)
\r
99 + (if (string-match "^finished" event)
\r
101 + (message "Notmuch: poll finished")
\r
102 + (if (boundp 'poll-callback)
\r
103 + (poll-callback)))
\r
106 + (message "Notmuch: something gone wrong when polling mail...")))))
\r
107 + (set-process-sentinel
\r
108 + (start-process "notmuch-poll"
\r
110 + notmuch-poll-script)
\r
111 + 'notmuch-poll-sentinel)
\r
112 + (switch-to-buffer "*notmuch-poll*")
\r
114 + (switch-to-buffer (other-buffer -1)))))
\r
117 (defun notmuch-search-poll-and-refresh-view ()
\r
118 "Invoke `notmuch-poll' to import mail, then refresh the current view."
\r
121 - (notmuch-search-refresh-view))
\r
122 + (notmuch-poll 'notmuch-search-refresh-view))
\r
124 (defun notmuch-search-toggle-order ()
\r
125 "Toggle the current search order.
\r