From bd96dbc0a377c8d97875985d820979077a4f46db Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Thu, 19 Jan 2017 22:47:02 -0500 Subject: gnus-pipe-to-project: Handle directory in shell command Let-binding default-directory shouldn't be expected to work because gnus-summary-pipe-output and gnus-summary-save-in-pipe do a good amount of buffer switching when setting up for the shell command. Append the directory change to the command instead. --- lisp/km-mail.el | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lisp/km-mail.el b/lisp/km-mail.el index 5746a3e..b3c5585 100644 --- a/lisp/km-mail.el +++ b/lisp/km-mail.el @@ -131,12 +131,19 @@ to group buffer instead of moving to next group." (defun km/gnus-pipe-to-project () "Call `gnus-summary-pipe-output' in project root." (interactive) - (let ((default-directory (completing-read - "Project: " - (projectile-relevant-known-projects))) - (gnus-summary-pipe-output-default-command - (or gnus-summary-pipe-output-default-command - "git am"))) + (let ((gnus-summary-pipe-output-default-command + (format "cd %s && %s" + (completing-read "Project: " + (projectile-relevant-known-projects)) + (cond + ((not gnus-summary-pipe-output-default-command) + "git am") + ((string-match "\\`cd .* && \\(.*\\)" + gnus-summary-pipe-output-default-command) + (match-string-no-properties + 1 gnus-summary-pipe-output-default-command)) + (t + gnus-summary-pipe-output-default-command))))) (call-interactively #'gnus-summary-pipe-output))) -- cgit v1.2.3