--- /dev/null
+Return-Path: <jani@nikula.org>\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 67B07431FC9\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Mar 2014 05:18:01 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[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 oR2+cZTgg9TP for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Mar 2014 05:17:56 -0800 (PST)\r
+Received: from mail-ea0-f181.google.com (mail-ea0-f181.google.com\r
+ [209.85.215.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id B2017431FC4\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Mar 2014 05:17:55 -0800 (PST)\r
+Received: by mail-ea0-f181.google.com with SMTP id k10so3364208eaj.12\r
+ for <notmuch@notmuchmail.org>; Sat, 01 Mar 2014 05:17:54 -0800 (PST)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
+ bh=1K5GYlm5ETjYKIphLAoXm1D4hYexu0fYaa9esFCwmOA=;\r
+ b=POoV3gOzsc3ZIyYKRWS7SJhXfWGPvVmSLvpBA1lgYybtTWc13TSJkpm9ieLMgF7JC4\r
+ ahQl0YWxt+1N3Io3S/5rM3DpvbIsvOvcyY3Ps2ygY1u2DMws6GfGC0CHcahd4aFNLRsD\r
+ 11hdDVW2dRzoK5Ojpm8oCspddD686hk+ymyKMzHmytsMQ+0rXnhmcP5KgWLSl4M6rdD7\r
+ Fp7RSrUXQRSpQyNXjkPhQRxFoAY0rjgQoxC9l2bciXAUUL3p30c45bH0nrebbITz4WCv\r
+ bmgQboYpI0VcDySLLf6H9N172sr9nGESxqgT1XiXrQw2L+sAg/WDqSGDo4Qqe0L6Qt0W\r
+ YvRA==\r
+X-Gm-Message-State:\r
+ ALoCoQldM/cUBh8+pvcANCHRiRi+rrwaOQq8F7ZN+a/IsYr74nxTN29cYHw1MCIGLHP7Nbvot/c1\r
+X-Received: by 10.14.209.8 with SMTP id r8mr42618eeo.85.1393679873025;\r
+ Sat, 01 Mar 2014 05:17:53 -0800 (PST)\r
+Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi.\r
+ [88.195.111.91])\r
+ by mx.google.com with ESMTPSA id y51sm23463857eeu.0.2014.03.01.05.17.51\r
+ for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 01 Mar 2014 05:17:52 -0800 (PST)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: use the originating buffer's working directory for\r
+ pipe\r
+Date: Sat, 1 Mar 2014 15:17:50 +0200\r
+Message-Id: <1393679870-29557-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 1.8.5.3\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: Sat, 01 Mar 2014 13:18:01 -0000\r
+\r
+Currently notmuch-show-pipe-message runs the command in the working\r
+directory of the *notmuch-pipe* buffer if it exists, and the current\r
+buffer's working directory (which is inherited to the new\r
+*notmuch-pipe* buffer) otherwise. This is all very surprising to the\r
+user, and it's difficult to know or change where the command will be\r
+run.\r
+\r
+Always use the current show buffer's working directory for piping. The\r
+user can check that with M-x pwd and change it with M-x cd. This is\r
+consistent with notmuch-show-pipe-part.\r
+\r
+---\r
+\r
+Mark also suggested printing the working directory in the prompt for\r
+the command to pipe to, but when I tried it I thought the prompt\r
+became too crowded with that. It's also less important now that the\r
+current buffer's working directory is used consistently.\r
+---\r
+ emacs/notmuch-show.el | 6 +++++-\r
+ 1 file changed, 5 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 88752f171930..b8782ddb632e 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -1781,10 +1781,14 @@ message."\r
+ (setq shell-command\r
+ (concat notmuch-command " show --format=raw "\r
+ (shell-quote-argument (notmuch-show-get-message-id)) " | " command)))\r
+- (let ((buf (get-buffer-create (concat "*notmuch-pipe*"))))\r
++ (let ((cwd default-directory)\r
++ (buf (get-buffer-create (concat "*notmuch-pipe*"))))\r
+ (with-current-buffer buf\r
+ (setq buffer-read-only nil)\r
+ (erase-buffer)\r
++ ;; Use the originating buffer's working directory instead of\r
++ ;; that of the pipe buffer.\r
++ (cd cwd)\r
+ (let ((exit-code (call-process-shell-command shell-command nil buf)))\r
+ (goto-char (point-max))\r
+ (set-buffer-modified-p nil)\r
+-- \r
+1.8.5.3\r
+\r