[PATCH v2 2/7] emacs: Use unified error handling in notmuch-call-notmuch-process
[notmuch-archives.git] / c1 / e3074eeb28b907622fdec1f45f7fc6346ffd16
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 E4DBD431FC0\r
6         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 12:04:34 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 54otia3fd5XB for <notmuch@notmuchmail.org>;\r
16         Sat, 15 Dec 2012 12:04:34 -0800 (PST)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id CF3AE431FBC\r
20         for <notmuch@notmuchmail.org>; Sat, 15 Dec 2012 12:04:33 -0800 (PST)\r
21 X-AuditID: 1209190e-b7f516d0000008e4-e5-50ccd7d1e208\r
22 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id 9E.06.02276.1D7DCC05; Sat, 15 Dec 2012 15:04:33 -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 qBFK4W5Q014181; \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 qBFK4SQZ025682\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-0007sT-Jq; 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 2/7] emacs: Use unified error handling in\r
41         notmuch-call-notmuch-process\r
42 Date: Sat, 15 Dec 2012 15:04:15 -0500\r
43 Message-Id: <1355601860-30121-3-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+NgFjrGIsWRmVeSWpSXmKPExsUixCmqrHvx+pkAg1UfpCxWz+WxuH5zJrPF\r
49         m5XzWB2YPXbOusvucfjrQhaPZ6tuMQcwR3HZpKTmZJalFunbJXBlrLz3k6ngAE/Fod55bA2M\r
50         c7i6GDk5JARMJP4cOcMOYYtJXLi3nq2LkYtDSGAfo8SOs53MIAkhgQ2MEk/nGkEkHjFJrOr4\r
51         yAjhzGWU6L0yHayKTUBDYtv+5YwgtoiAtMTOu7NZQWxmgTiJLVP+g8WFBSIlDm+7CWazCKhK\r
52         LNyxmA3E5hVwkFi48hnUGYoS3c8mgMU5BRwlJk7exQRxhYPE7QVzmCYw8i9gZFjFKJuSW6Wb\r
53         m5iZU5yarFucnJiXl1qka6yXm1mil5pSuokRHFySfDsYvx5UOsQowMGoxMO7I+J0gBBrYllx\r
54         Ze4hRkkOJiVR3ozLZwKE+JLyUyozEosz4otKc1KLDzFKcDArifAmzQfK8aYkVlalFuXDpKQ5\r
55         WJTEea+k3PQXEkhPLEnNTk0tSC2CycpwcChJ8AoBo0hIsCg1PbUiLTOnBCHNxMEJMpwHaDgH\r
56         SA1vcUFibnFmOkT+FKOilDivHUhCACSRUZoH1wuL/leM4kCvCPN+uAZUxQNMHHDdr4AGMwEN\r
57         Xm4DNrgkESEl1cAYcHzTS8dfa6wNHq/5x/Lg4gP+ta8sAmdbGtR9Z+T8mu238n2C4IbuQ2tn\r
58         ffRPudfRanNpvaKH8hLWov/B27XUw+9cjfIqT+O5eO3Vk17jWB++3KdWr3y/vTzR7C6lJJMX\r
59         vP5odEbC3Sn+VpsaLGf8PvDdYod7qka2qoSVlGtWG++ps1eEvu9UYinOSDTUYi4qTgQA24gY\r
60         4dkCAAA=\r
61 Cc: tomi.ollila@iki.fi\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\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:04:35 -0000\r
75 \r
76 This makes notmuch-call-notmuch-process use the unified CLI error\r
77 handling, which basically refines the error handling this function\r
78 already did.\r
79 ---\r
80  emacs/notmuch.el |   20 +++++++-------------\r
81  1 file changed, 7 insertions(+), 13 deletions(-)\r
82 \r
83 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
84 index f9454d8..9da8df4 100644\r
85 --- a/emacs/notmuch.el\r
86 +++ b/emacs/notmuch.el\r
87 @@ -536,19 +536,13 @@ If BARE is set then do not prefix with \"thread:\""\r
88  (defun notmuch-call-notmuch-process (&rest args)\r
89    "Synchronously invoke \"notmuch\" with the given list of arguments.\r
90  \r
91 -Output from the process will be presented to the user as an error\r
92 -and will also appear in a buffer named \"*Notmuch errors*\"."\r
93 -  (let ((error-buffer (get-buffer-create "*Notmuch errors*")))\r
94 -    (with-current-buffer error-buffer\r
95 -       (erase-buffer))\r
96 -    (if (eq (apply 'call-process notmuch-command nil error-buffer nil args) 0)\r
97 -       (point)\r
98 -      (progn\r
99 -       (with-current-buffer error-buffer\r
100 -         (let ((beg (point-min))\r
101 -               (end (- (point-max) 1)))\r
102 -           (error (buffer-substring beg end))\r
103 -           ))))))\r
104 +If notmuch exits with a non-zero status, output from the process\r
105 +will appear in a buffer named \"*Notmuch errors*\" and an error\r
106 +will be signaled."\r
107 +  (with-temp-buffer\r
108 +    (let ((status (apply #'call-process notmuch-command nil t nil args)))\r
109 +      (notmuch-check-exit-status status (cons notmuch-command args)\r
110 +                                (buffer-string)))))\r
111  \r
112  (defun notmuch-search-set-tags (tags &optional pos)\r
113    (let ((new-result (plist-put (notmuch-search-get-result pos) :tags tags)))\r
114 -- \r
115 1.7.10.4\r
116 \r