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