1 Return-Path: <jani@nikula.org>
\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 0C9AF429E25
\r
6 for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 13:48:29 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 bsS+-TrbXBI1 for <notmuch@notmuchmail.org>;
\r
16 Sun, 11 Dec 2011 13:48:28 -0800 (PST)
\r
17 Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com
\r
18 [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 29EB7431FB6
\r
21 for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 13:48:28 -0800 (PST)
\r
22 Received: by eaan11 with SMTP id n11so681245eaa.26
\r
23 for <notmuch@notmuchmail.org>; Sun, 11 Dec 2011 13:48:25 -0800 (PST)
\r
24 Received: by 10.213.108.142 with SMTP id f14mr1162030ebp.80.1323640105319;
\r
25 Sun, 11 Dec 2011 13:48:25 -0800 (PST)
\r
26 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.
\r
28 by mx.google.com with ESMTPS id 17sm66496406eej.3.2011.12.11.13.48.22
\r
29 (version=SSLv3 cipher=OTHER); Sun, 11 Dec 2011 13:48:23 -0800 (PST)
\r
30 From: Jani Nikula <jani@nikula.org>
\r
31 To: notmuch@notmuchmail.org
\r
32 Subject: [PATCH] emacs: support "notmuch new" as a notmuch-poll-script
\r
33 Date: Sun, 11 Dec 2011 23:48:20 +0200
\r
34 Message-Id: <1323640100-18326-1-git-send-email-jani@nikula.org>
\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: Sun, 11 Dec 2011 21:48:29 -0000
\r
50 Let notmuch-poll-script be a function as well as a string. Make default
\r
51 value nil instead of an empty string, but allow "" for backwards
\r
52 compatibility. Add a notmuch poll function to call "notmuch new" using the
\r
53 configured notmuch-command.
\r
55 This allows taking better advantage of the "notmuch new" hooks from emacs
\r
56 without intermediate scripts.
\r
58 Signed-off-by: Jani Nikula <jani@nikula.org>
\r
60 emacs/notmuch.el | 44 ++++++++++++++++++++++++++++++++------------
\r
61 1 files changed, 32 insertions(+), 12 deletions(-)
\r
63 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
64 index 8936149..6c7e800 100644
\r
65 --- a/emacs/notmuch.el
\r
66 +++ b/emacs/notmuch.el
\r
67 @@ -965,28 +965,48 @@ same relative position within the new buffer."
\r
68 (notmuch-search query oldest-first target-thread target-line continuation)
\r
69 (goto-char (point-min))))
\r
71 -(defcustom notmuch-poll-script ""
\r
72 - "An external script to incorporate new mail into the notmuch database.
\r
73 +(defcustom notmuch-poll-script nil
\r
74 + "A script or a function to incorporate new mail into the notmuch database.
\r
76 -If this variable is non empty, then it should name a script to be
\r
77 -invoked by `notmuch-search-poll-and-refresh-view' and
\r
78 -`notmuch-hello-poll-and-update' (each have a default keybinding
\r
79 -of 'G'). The script could do any of the following depending on
\r
80 +This variable can be set to a function or the name of an external
\r
81 +script to be invoked by `notmuch-search-poll-and-refresh-view'
\r
82 +and `notmuch-hello-poll-and-update' (each have a default
\r
83 +keybinding of 'G'). Set to nil to do nothing.
\r
85 +The function or script could do any of the following depending on
\r
88 1. Invoke a program to transfer mail to the local mail store
\r
89 2. Invoke \"notmuch new\" to incorporate the new mail
\r
90 -3. Invoke one or more \"notmuch tag\" commands to classify the mail"
\r
92 +3. Invoke one or more \"notmuch tag\" commands to classify the mail
\r
94 +You can also choose to use \"notmuch new\" through the provided
\r
95 +`notmuch-poll-script-notmuch-new' function, and have the
\r
96 +\"notmuch new\" hooks perform the actions above."
\r
97 + :type '(choice (const :tag "Not set" nil)
\r
98 + (const :tag "Notmuch new" notmuch-poll-script-notmuch-new)
\r
99 + (function :tag "Custom function"
\r
100 + :value notmuch-poll-script-notmuch-new)
\r
101 + (string :tag "Custom script"))
\r
104 +(defun notmuch-poll-script-notmuch-new ()
\r
105 + "Run \"notmuch new\"."
\r
106 + (call-process notmuch-command nil nil nil "new"))
\r
108 (defun notmuch-poll ()
\r
109 - "Run external script to import mail.
\r
110 + "Run external script or call a function to import mail.
\r
112 -Invokes `notmuch-poll-script' if it is not set to an empty string."
\r
113 +Invokes `notmuch-poll-script', which can be a function or the
\r
114 +name of an external script. Does nothing if `notmuch-poll-script'
\r
115 +is nil or an empty string."
\r
117 - (if (not (string= notmuch-poll-script ""))
\r
118 - (call-process notmuch-poll-script nil nil)))
\r
120 + ((stringp notmuch-poll-script)
\r
121 + (if (not (string= notmuch-poll-script "")) ;; for backwards compatibility
\r
122 + (call-process notmuch-poll-script nil nil)))
\r
123 + ((functionp notmuch-poll-script)
\r
124 + (funcall notmuch-poll-script))))
\r
126 (defun notmuch-search-poll-and-refresh-view ()
\r
127 "Invoke `notmuch-poll' to import mail, then refresh the current view."
\r