From fdb476e2258866e7028b1a8a47c2d87ded81e53a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 31 Aug 2015 15:07:10 +0100 Subject: [PATCH] mu4e-actions: improve mbox handling for multiple marks This avoids prompting the user over and over if the directory hasn't changed. I've also ensured the paths are escaped with shell-quote-argument. --- mu4e/mu4e-actions.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/mu4e/mu4e-actions.el b/mu4e/mu4e-actions.el index 790e2b00..c4266d9f 100644 --- a/mu4e/mu4e-actions.el +++ b/mu4e/mu4e-actions.el @@ -210,16 +210,22 @@ store your org-contacts." (mu4e-message-field msg :path))))) (defun mu4e-action-git-apply-mbox (msg) - "Apply and commit the git [patch] message." - (let ((path (ido-read-directory-name "Target directory: " - (car ido-work-directory-list) - "~/" t))) - (setf ido-work-directory-list - (cons path (delete path ido-work-directory-list))) + "Apply and commit the git [patch] MSG. + +If the `default-directory' matches the most recent history entry don't +bother asking for the git tree again (useful for bulk actions)." + + (let ((cwd (car ido-work-directory-list))) + (unless (and (stringp cwd) (string= default-directory cwd)) + (setq cwd (ido-read-directory-name "Target directory: " + cwd + "~/" t)) + (setf ido-work-directory-list + (cons cwd (delete cwd ido-work-directory-list)))) (shell-command (format "cd %s; git am %s" - path - (mu4e-message-field msg :path))))) + (shell-quote-argument cwd) + (shell-quote-argument (mu4e-message-field msg :path)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;