[PATCH] emacs: show: stop stderr appearing in buffer
[notmuch-archives.git] / bc / 0dcc1dced64a806ba5f81fdfa1073d069acb73
1 Return-Path: <markwalters1009@gmail.com>\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 AB8E9431FAF\r
6         for <notmuch@notmuchmail.org>; Fri,  6 Sep 2013 14:16:55 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
14         RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
15 Received: from olra.theworths.org ([127.0.0.1])\r
16         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
17         with ESMTP id valSYYqbky0c for <notmuch@notmuchmail.org>;\r
18         Fri,  6 Sep 2013 14:16:48 -0700 (PDT)\r
19 Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com\r
20         [209.85.212.177]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
21         (No client certificate requested)\r
22         by olra.theworths.org (Postfix) with ESMTPS id F3BF4431FAE\r
23         for <notmuch@notmuchmail.org>; Fri,  6 Sep 2013 14:16:47 -0700 (PDT)\r
24 Received: by mail-wi0-f177.google.com with SMTP id cb5so1433993wib.10\r
25         for <notmuch@notmuchmail.org>; Fri, 06 Sep 2013 14:16:45 -0700 (PDT)\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
27         h=from:to:cc:subject:date:message-id;\r
28         bh=SxMCAEyFK6h/zLDEJCbxZ0I/5hgbjBd3YCUszpLZNgs=;\r
29         b=euPEjMdfqB16V26VRQkemTyg0wz6OBGgtRTXyzUAMIOPrYcekAESkxUu/TlLHMMP60\r
30         hyaFbTnN2L3T/HTkEn6HdW0E6yyOTLmcUAN1FQlr3h/lAIc6oCcPJdP7NuDClsmN9IvL\r
31         o3DZcADmtWsq/SaoHJGyhS5bNeRVUzqCwr9GLWu1lIFOc/kLUrv6o1fyUxvmzj0qUW+y\r
32         Js+qnax1+yVnsU2kI9LQplvyups01yCLNy9e2b93Mu9A+9UpXKkVLQZJh1foJCGLWXT/\r
33         Ytyylc6Z/+a22W9bWDfRp7ClJqBDDZwTYlDoF9AsiGsAxQzj7MNJoCDfLgbNpHJ3gkcG\r
34         LkxA==\r
35 X-Received: by 10.180.19.196 with SMTP id h4mr3539696wie.38.1378502205345;\r
36         Fri, 06 Sep 2013 14:16:45 -0700 (PDT)\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
38         by mx.google.com with ESMTPSA id i12sm443431wiw.3.1969.12.31.16.00.00\r
39         (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
40         Fri, 06 Sep 2013 14:16:44 -0700 (PDT)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH] emacs: show: stop stderr appearing in buffer\r
44 Date: Fri,  6 Sep 2013 22:16:38 +0100\r
45 Message-Id: <1378502198-7980-1-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 X-BeenThere: notmuch@notmuchmail.org\r
48 X-Mailman-Version: 2.1.13\r
49 Precedence: list\r
50 List-Id: "Use and development of the notmuch mail system."\r
51         <notmuch.notmuchmail.org>\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
55 List-Post: <mailto:notmuch@notmuchmail.org>\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
58         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
59 X-List-Received-Date: Fri, 06 Sep 2013 21:16:55 -0000\r
60 \r
61 In emacs 24.3+ the stdout/stderr from externally displaying an\r
62 attachment gets inserted into the show buffer. This is caused by\r
63 changes in mm-display-external in mm-decode.el.\r
64 \r
65 Ideally, we would put this output in the notmuch errors buffer but the\r
66 handler is called asynchronously so we don't know when the output will\r
67 appear. Thus if we put it straight into the errors buffer it could get\r
68 interleaved with other errors, otoh we can't easily tell when we\r
69 have got all the error output so can't wait until the process is complete.\r
70 \r
71 This patch just takes the simplest approach and discards the error\r
72 output (which means the behaviour is the same as it was with emacs pre\r
73 24.3).\r
74 ---\r
75 As I say above it would be nice to capture the error output but it\r
76 does not appear to be simple. This is probably worth applying in the\r
77 meantime as we definitely don't want the stderr/stdout appearing in\r
78 the show buffer.\r
79 \r
80 The bug is easy to reproduce: make a script which outputs to stderr or\r
81 stdout and call it on any part with ". o scriptname" (in fact even\r
82 ". o ls" will do!)\r
83 \r
84 Best wishes\r
85 \r
86 Mark\r
87 \r
88 \r
89 \r
90 \r
91 \r
92 \r
93  emacs/notmuch-show.el |    9 ++++++---\r
94  1 files changed, 6 insertions(+), 3 deletions(-)\r
95 \r
96 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
97 index 904b98e..42438ba 100644\r
98 --- a/emacs/notmuch-show.el\r
99 +++ b/emacs/notmuch-show.el\r
100 @@ -2044,9 +2044,12 @@ caller is responsible for killing this buffer as appropriate."\r
101  This ensures that the temporary buffer created for the mm-handle\r
102  is destroyed when FN returns."\r
103    (let ((handle (notmuch-show-current-part-handle)))\r
104 -    (unwind-protect\r
105 -       (funcall fn handle)\r
106 -      (kill-buffer (mm-handle-buffer handle)))))\r
107 +    ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we\r
108 +    ;; call it from a temp-buffer.\r
109 +    (with-temp-buffer\r
110 +      (unwind-protect\r
111 +         (funcall fn handle)\r
112 +       (kill-buffer (mm-handle-buffer handle))))))\r
113  \r
114  (defun notmuch-show-part-button-default (&optional button)\r
115    (interactive)\r
116 -- \r
117 1.7.9.1\r
118 \r