unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: use the originating buffer's working directory for pipe
@ 2014-03-01 13:17 Jani Nikula
  2014-03-02 12:11 ` Tomi Ollila
  2014-03-05  0:06 ` David Bremner
  0 siblings, 2 replies; 3+ messages in thread
From: Jani Nikula @ 2014-03-01 13:17 UTC (permalink / raw)
  To: notmuch

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] emacs: use the originating buffer's working directory for pipe
  2014-03-01 13:17 [PATCH] emacs: use the originating buffer's working directory for pipe Jani Nikula
@ 2014-03-02 12:11 ` Tomi Ollila
  2014-03-05  0:06 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: Tomi Ollila @ 2014-03-02 12:11 UTC (permalink / raw)
  To: Jani Nikula, notmuch

On Sat, Mar 01 2014, Jani Nikula <jani@nikula.org> wrote:

> 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.

LGTM.

Tomi


>
> ---
>
> 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
>
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] emacs: use the originating buffer's working directory for pipe
  2014-03-01 13:17 [PATCH] emacs: use the originating buffer's working directory for pipe Jani Nikula
  2014-03-02 12:11 ` Tomi Ollila
@ 2014-03-05  0:06 ` David Bremner
  1 sibling, 0 replies; 3+ messages in thread
From: David Bremner @ 2014-03-05  0:06 UTC (permalink / raw)
  To: Jani Nikula, notmuch

Jani Nikula <jani@nikula.org> writes:
>
> 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.
>

pushed,

d

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-05  0:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-01 13:17 [PATCH] emacs: use the originating buffer's working directory for pipe Jani Nikula
2014-03-02 12:11 ` Tomi Ollila
2014-03-05  0:06 ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).