summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-01-19 22:47:02 -0500
committerKyle Meyer <kyle@kyleam.com>2017-01-19 22:47:02 -0500
commitbd96dbc0a377c8d97875985d820979077a4f46db (patch)
tree336969ebe3d9783664a6953a3123358c882c7663 /lisp
parent7f638498ee9241aad59a8a1d971d3f32fc1bc11f (diff)
downloademacs.d-bd96dbc0a377c8d97875985d820979077a4f46db.tar.gz
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/km-mail.el19
1 files 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)))