--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 3A03B431FD2\r
+ for <notmuch@notmuchmail.org>; Mon, 18 Nov 2013 13:16:20 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.224\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.224 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+ HS_INDEX_PARAM=0.023, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id ui-nXO9zz2cp for <notmuch@notmuchmail.org>;\r
+ Mon, 18 Nov 2013 13:16:11 -0800 (PST)\r
+Received: from mail-wi0-f169.google.com (mail-wi0-f169.google.com\r
+ [209.85.212.169]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id AC0A1431FC2\r
+ for <notmuch@notmuchmail.org>; Mon, 18 Nov 2013 13:16:11 -0800 (PST)\r
+Received: by mail-wi0-f169.google.com with SMTP id hj6so472941wib.0\r
+ for <notmuch@notmuchmail.org>; Mon, 18 Nov 2013 13:16:10 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=noe/sahnCw7qjloOrtDWEEy/NHnTaF4kGV0aMotw0a0=;\r
+ b=gHktO7ygmocCh+QizpibRykaVXO0NLg340j5zc3hnTUaQs8PUBC0cRgAHzfpU3klzb\r
+ fjldsPHqk6fTo4CVMxDGEPF9BbZu98oCIbAjWZEPRYvoWn4ia5CI919QixSL992hGAFw\r
+ npNylDJ4XCX6cqxNnxnTTugFtH5Tq1EFBDRxKcu817Z5ViR1NIjemuRMQrt4I+dt69Y0\r
+ OpXQS4OyZelIojQANOD8kUwJ4k8anypOFnfDPnXyXkhbY3LeOPQeorHVeV4U35DYvBn0\r
+ jNVkI9BqIoJs0stzZCneM7Ydr1l36mT9NhezdZz8KS0PnL82F1LFZ6G7n51I48FjrY8I\r
+ KCnA==\r
+X-Received: by 10.180.206.239 with SMTP id lr15mr8534400wic.35.1384809041371; \r
+ Mon, 18 Nov 2013 13:10:41 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+ by mx.google.com with ESMTPSA id\r
+ ll10sm27844079wic.9.2013.11.18.13.10.40 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Mon, 18 Nov 2013 13:10:40 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v2] emacs: show: stop stderr appearing in buffer\r
+Date: Mon, 18 Nov 2013 21:10:33 +0000\r
+Message-Id: <1384809033-27624-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <8761rqvt7f.fsf@zancas.localnet>\r
+References: <8761rqvt7f.fsf@zancas.localnet>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 18 Nov 2013 21:16:20 -0000\r
+\r
+In emacs 24.3+ the stdout/stderr from externally displaying an\r
+attachment gets inserted into the show buffer. This is caused by\r
+changes in mm-display-external in mm-decode.el.\r
+\r
+Ideally, we would put this output in the notmuch errors buffer but the\r
+handler is called asynchronously so we don't know when the output will\r
+appear. Thus if we put it straight into the errors buffer it could get\r
+interleaved with other errors. Also we can't easily tell when we\r
+have got all the error output so can't wait until the process is complete.\r
+\r
+One solution would be to create a new buffer for the stderr of each\r
+attachment viewed. Again, since we can't tell when the process has\r
+finished, we can't close these buffers automatically so this will\r
+leave lots of buffers around.\r
+\r
+Thus we add a debug variable notmuch-show-attachment-debug: it this is\r
+non-nil we create a new buffer for each viewer; if this variable is\r
+nil we just use a temp buffer which means all error output is\r
+discarded (this is the same behaviour as with emacs pre 24.3).\r
+---\r
+\r
+This version just adds a docstring to the debug variable describing\r
+what it does and where the debug data is stored (ie what the buffer\r
+name is).\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+ emacs/notmuch-show.el | 19 ++++++++++++++++++-\r
+ 1 files changed, 18 insertions(+), 1 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index f00273a..784644c 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -159,6 +159,15 @@ indentation."\r
+ (make-variable-buffer-local 'notmuch-show-indent-content)\r
+ (put 'notmuch-show-indent-content 'permanent-local t)\r
+ \r
++(defvar notmuch-show-attachment-debug nil\r
++ "If t log stdout and stderr from attachment handlers\r
++\r
++When set to nil (the default) stdout and stderr from attachment\r
++handlers is discarded. When set to t the stdout and stderr from\r
++each attachment handler is logged in buffers with names beginning\r
++\" *notmuch-part*\". This option requires emacs version at least\r
++24.3 to work.")\r
++\r
+ (defcustom notmuch-show-stash-mlarchive-link-alist\r
+ '(("Gmane" . "http://mid.gmane.org/")\r
+ ("MARC" . "http://marc.info/?i=")\r
+@@ -2089,8 +2098,16 @@ caller is responsible for killing this buffer as appropriate."\r
+ This ensures that the temporary buffer created for the mm-handle\r
+ is destroyed when FN returns."\r
+ (let ((handle (notmuch-show-current-part-handle)))\r
++ ;; emacs 24.3+ puts stdout/stderr into the calling buffer so we\r
++ ;; call it from a temp-buffer, unless\r
++ ;; notmuch-show-attachment-debug is non-nil in which case we put\r
++ ;; it in " *notmuch-part*".\r
+ (unwind-protect\r
+- (funcall fn handle)\r
++ (if notmuch-show-attachment-debug\r
++ (with-current-buffer (generate-new-buffer " *notmuch-part*")\r
++ (funcall fn handle))\r
++ (with-temp-buffer\r
++ (funcall fn handle)))\r
+ (kill-buffer (mm-handle-buffer handle)))))\r
+ \r
+ (defun notmuch-show-part-button-default (&optional button)\r
+-- \r
+1.7.9.1\r
+\r