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 62EB7431FDB
\r
6 for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 12:05:11 -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 n5ujKx6bLJFG for <notmuch@notmuchmail.org>;
\r
16 Sat, 15 Dec 2012 12:05:09 -0800 (PST)
\r
17 Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 5B2CA431FCB
\r
20 for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 12:04:44 -0800 (PST)
\r
21 X-AuditID: 12074422-b7fe46d0000008d2-7f-50ccd7db87a6
\r
22 Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])
\r
23 by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id F2.9D.02258.BD7DCC05; Sat, 15 Dec 2012 15:04:43 -0500 (EST)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qBFK4WAF014729;
\r
27 Sat, 15 Dec 2012 15:04:32 -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 qBFK4T5o025684
\r
33 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
34 Sat, 15 Dec 2012 15:04:31 -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 1TjxyG-0007sY-Mr; Sat, 15 Dec 2012 15:04:28 -0500
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH v2 4/7] emacs: Improve error handling for
\r
41 notmuch-call-notmuch-json
\r
42 Date: Sat, 15 Dec 2012 15:04:17 -0500
\r
43 Message-Id: <1355601860-30121-5-git-send-email-amdragon@mit.edu>
\r
44 X-Mailer: git-send-email 1.7.10.4
\r
45 In-Reply-To: <1355601860-30121-1-git-send-email-amdragon@mit.edu>
\r
46 References: <1355601860-30121-1-git-send-email-amdragon@mit.edu>
\r
47 X-Brightmail-Tracker:
\r
48 H4sIAAAAAAAAA+NgFrrEIsWRmVeSWpSXmKPExsUixG6nonv7+pkAg3dP5SxWz+WxuH5zJrPF
\r
49 m5XzWB2YPXbOusvucfjrQhaPZ6tuMQcwR3HZpKTmZJalFunbJXBlvDm7krHgG09F0/2rrA2M
\r
50 c7i6GDk5JARMJFbf3skKYYtJXLi3nq2LkYtDSGAfo8THtp2MEM4GRontbz4wQTiPmCR2NE1j
\r
51 h3DmMkp8mLCYDaSfTUBDYtv+5YwgtoiAtMTOu7PB5jILxElsmfIfKM7BISwQLPH0nz9ImEVA
\r
52 VeLBkz1grbwCDhLHd7+FOkNRovvZBLA4p4CjxMTJu5hAbCGgmtsL5jBNYORfwMiwilE2JbdK
\r
53 NzcxM6c4NVm3ODkxLy+1SNdULzezRC81pXQTIzi4XJR2MP48qHSIUYCDUYmHd0fE6QAh1sSy
\r
54 4srcQ4ySHExKorwZl88ECPEl5adUZiQWZ8QXleakFh9ilOBgVhLhTZoPlONNSaysSi3Kh0lJ
\r
55 c7AoifNeS7npLySQnliSmp2aWpBaBJOV4eBQkuCdeg2oUbAoNT21Ii0zpwQhzcTBCTKcB2j4
\r
56 KZAa3uKCxNzizHSI/ClGXY6GlzeeMgqx5OXnpUqJ8y4EKRIAKcoozYObA0sKrxjFgd4S5t0C
\r
57 UsUDTChwk14BLWECWrLcBmxJSSJCSqqBUT9R3p93gYZf5pYtt2xUPQWO1zps05N6tKmoI/Hn
\r
58 wd5zfxj6c13+L7aYL8BQqtD7YlbeIsX9bA9OPd4nFB19bNrBVz7Kt+LdZolVSP9YWvbso+PK
\r
59 9skXKn5rOspUnmX5cd1IWziLn+tIgoiEd8af17ldiml3N7QvO83JYbrh8nm3sqar79kalFiK
\r
60 MxINtZiLihMBu+HG4OUCAAA=
\r
61 Cc: tomi.ollila@iki.fi
\r
62 X-BeenThere: notmuch@notmuchmail.org
\r
63 X-Mailman-Version: 2.1.13
\r
65 List-Id: "Use and development of the notmuch mail system."
\r
66 <notmuch.notmuchmail.org>
\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
70 List-Post: <mailto:notmuch@notmuchmail.org>
\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
73 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
74 X-List-Received-Date: Sat, 15 Dec 2012 20:05:11 -0000
\r
76 This checks for non-zero exit status from JSON CLI calls and pops up
\r
77 an error buffer with stderr and stdout. A consequence of this is that
\r
78 show and reply now handle errors, rather than ignoring them.
\r
80 emacs/notmuch-lib.el | 22 +++++++++++++++-------
\r
81 1 file changed, 15 insertions(+), 7 deletions(-)
\r
83 diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
\r
84 index f534770..7f7022a 100644
\r
85 --- a/emacs/notmuch-lib.el
\r
86 +++ b/emacs/notmuch-lib.el
\r
87 @@ -375,15 +375,23 @@ contents of ERR-FILE will be included in the error message."
\r
88 "Invoke `notmuch-command' with `args' and return the parsed JSON output.
\r
90 The returned output will represent objects using property lists
\r
91 -and arrays as lists."
\r
92 +and arrays as lists. If notmuch exits with a non-zero status,
\r
93 +this will pop up a buffer containing notmuch's output and signal
\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
103 + (let ((err-file (make-temp-file "nmerr")))
\r
105 + (let ((status (apply #'call-process
\r
106 + notmuch-command nil (list t err-file) nil args)))
\r
107 + (notmuch-check-exit-status status (cons notmuch-command args)
\r
108 + (buffer-string) err-file)
\r
109 + (goto-char (point-min))
\r
110 + (let ((json-object-type 'plist)
\r
111 + (json-array-type 'list)
\r
112 + (json-false 'nil))
\r
114 + (delete-file err-file)))))
\r
116 ;; Compatibility functions for versions of emacs before emacs 23.
\r