1 Return-Path: <amdragon@mit.edu>
\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 2DA56431FC7
\r
6 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:15 -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 s3cBDBYoXoUA for <notmuch@notmuchmail.org>;
\r
16 Sat, 1 Dec 2012 18:40:14 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 84BFB431FBD
\r
20 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 18:40:13 -0800 (PST)
\r
21 X-AuditID: 1209190f-b7fec6d00000090d-86-50babf8c3c95
\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])
\r
23 by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id 5F.F5.02317.C8FBAB05; Sat, 1 Dec 2012 21:40:12 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id qB22eBs1013710;
\r
27 Sat, 1 Dec 2012 21:40:11 -0500
\r
28 Received: from drake.dyndns.org
\r
29 (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com
\r
30 [209.6.116.242]) (authenticated bits=0)
\r
31 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
32 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id qB22e6tc025604
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 1 Dec 2012 21:40:10 -0500 (EST)
\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)
\r
36 (envelope-from <amdragon@mit.edu>)
\r
37 id 1TezTS-0000xk-3Y; Sat, 01 Dec 2012 21:40:06 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 08/10] emacs: Factor out synchronous notmuch JSON invocations
\r
41 Date: Sat, 1 Dec 2012 21:40:00 -0500
\r
42 Message-Id: <1354416002-3557-8-git-send-email-amdragon@mit.edu>
\r
43 X-Mailer: git-send-email 1.7.10.4
\r
44 In-Reply-To: <1354416002-3557-1-git-send-email-amdragon@mit.edu>
\r
45 References: <1354416002-3557-1-git-send-email-amdragon@mit.edu>
\r
46 X-Brightmail-Tracker:
\r
47 H4sIAAAAAAAAA+NgFtrIIsWRmVeSWpSXmKPExsUixCmqrNuzf1eAwf038hbXb85kdmD0eLbq
\r
48 FnMAYxSXTUpqTmZZapG+XQJXxquL7YwFz8UrVjfeYW9gnC/cxcjBISFgInGpLbWLkRPIFJO4
\r
49 cG89WxcjF4eQwD5GiY+NT6Cc9YwSL5+dY4FwHjJJ9B1dAuXMZZRo29/BCtLPJqAhsW3/ckYQ
\r
50 W0RAWmLn3dmsICuYBdQk/nSpgISFBXwllt48xgRiswioSvw9vY0dxOYVsJeY+ABkNcgZihLd
\r
51 zyawgbRyCjhIrOjmAQkLAZX8/32NbQIj/wJGhlWMsim5Vbq5iZk5xanJusXJiXl5qUW6Jnq5
\r
52 mSV6qSmlmxjBISPJv4Px20GlQ4wCHIxKPLyMs3YFCLEmlhVX5h5ilORgUhLlvbIDKMSXlJ9S
\r
53 mZFYnBFfVJqTWnyIUYKDWUmEl8UEKMebklhZlVqUD5OS5mBREue9mnLTX0ggPbEkNTs1tSC1
\r
54 CCYrw8GhJMFbvQ+oUbAoNT21Ii0zpwQhzcTBCTKcB2j4o70gw4sLEnOLM9Mh8qcYFaXEea+B
\r
55 JARAEhmleXC9sJh+xSgO9IowryfICh5gOoDrfgU0mAlo8Jtl20EGlyQipKQaGLNPvb0uUsQ5
\r
56 85PQmtxrS57wNi3rtFuwUGL3nqu3Lixjtr1cfDR23b1tfoXSRh8jG7UWW+6JcTYyn2pedyd9
\r
57 kebHY2wqUtX/zRpnX8/eqrWT+XKXvsEV4TPMHj1VO0949vpoySjYXe6Yf3575uSpKzXNPh0L
\r
58 3paYFhKjLybRUaGyKMBN4VdPoBJLcUaioRZzUXEiAMlW5JjEAgAA
\r
59 X-BeenThere: notmuch@notmuchmail.org
\r
60 X-Mailman-Version: 2.1.13
\r
62 List-Id: "Use and development of the notmuch mail system."
\r
63 <notmuch.notmuchmail.org>
\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
65 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
67 List-Post: <mailto:notmuch@notmuchmail.org>
\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
70 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
71 X-List-Received-Date: Sun, 02 Dec 2012 02:40:15 -0000
\r
73 Previously this code was duplicated between show and reply. This
\r
74 factors out synchronously invoking notmuch and parsing the output as
\r
77 emacs/notmuch-lib.el | 14 ++++++++++++++
\r
78 emacs/notmuch-mua.el | 8 +-------
\r
79 emacs/notmuch-query.el | 11 ++---------
\r
80 3 files changed, 17 insertions(+), 16 deletions(-)
\r
82 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
83 index 49b0da6..31c69dc 100644
\r
84 --- a/emacs/notmuch-lib.el
\r
85 +++ b/emacs/notmuch-lib.el
\r
86 @@ -357,6 +357,20 @@ You may need to restart Emacs or upgrade your notmuch package."))
\r
87 (error "Bad exit status %d" exit-status)))
\r
88 (error "notmuch CLI version mismatch"))
\r
90 +(defun notmuch-call-notmuch-json (&rest args)
\r
91 + "Invoke `notmuch-command' with `args' and return the parsed JSON output.
\r
93 +The returned output will represent objects using property lists
\r
94 +and arrays as lists."
\r
97 + (apply #'call-process notmuch-command nil (list t nil) nil args)
\r
98 + (goto-char (point-min))
\r
99 + (let ((json-object-type 'plist)
\r
100 + (json-array-type 'list)
\r
101 + (json-false 'nil))
\r
104 ;; Compatibility functions for versions of emacs before emacs 23.
\r
106 ;; Both functions here were copied from emacs 23 with the following copyright:
\r
107 diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
\r
108 index 408b49e..ac2d29e 100644
\r
109 --- a/emacs/notmuch-mua.el
\r
110 +++ b/emacs/notmuch-mua.el
\r
111 @@ -158,13 +158,7 @@ list."
\r
112 (setq args (append args (list query-string)))
\r
114 ;; Get the reply object as JSON, and parse it into an elisp object.
\r
115 - (with-temp-buffer
\r
116 - (apply 'call-process (append (list notmuch-command nil (list t nil) nil) args))
\r
117 - (goto-char (point-min))
\r
118 - (let ((json-object-type 'plist)
\r
119 - (json-array-type 'list)
\r
120 - (json-false 'nil))
\r
121 - (setq reply (json-read))))
\r
122 + (setq reply (apply #'notmuch-call-notmuch-json args))
\r
124 ;; Extract the original message to simplify the following code.
\r
125 (setq original (plist-get reply :original))
\r
126 diff --git a/emacs/notmuch-query.el b/emacs/notmuch-query.el
\r
127 index d66baea..e7e3520 100644
\r
128 --- a/emacs/notmuch-query.el
\r
129 +++ b/emacs/notmuch-query.el
\r
130 @@ -29,18 +29,11 @@ A thread is a forest or list of trees. A tree is a two element
\r
131 list where the first element is a message, and the second element
\r
132 is a possibly empty forest of replies.
\r
134 - (let ((args '("show" "--format=json"))
\r
135 - (json-object-type 'plist)
\r
136 - (json-array-type 'list)
\r
137 - (json-false 'nil))
\r
138 + (let ((args '("show" "--format=json")))
\r
139 (if notmuch-show-process-crypto
\r
140 (setq args (append args '("--decrypt"))))
\r
141 (setq args (append args search-terms))
\r
142 - (with-temp-buffer
\r
144 - (apply 'call-process (append (list notmuch-command nil (list t nil) nil) args))
\r
145 - (goto-char (point-min))
\r
147 + (apply #'notmuch-call-notmuch-json args)))
\r
149 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
\r
150 ;; Mapping functions across collections of messages.
\r