From f334e7ae71eccdc86456765f12c160f60ab61f90 Mon Sep 17 00:00:00 2001 From: djcb Date: Tue, 9 Oct 2012 00:15:02 +0300 Subject: [PATCH] * mu4e: fixup directory creation --- mu4e/mu4e-mark.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mu4e/mu4e-mark.el b/mu4e/mu4e-mark.el index c25a9415..ce616817 100644 --- a/mu4e/mu4e-mark.el +++ b/mu4e/mu4e-mark.el @@ -237,7 +237,14 @@ replace them with a _real_ mark (ask the user which one)." (mu4e-mark-set (car markpair) (cdr markpair))))))) mu4e~mark-map))) - + +(defun mu4e~mark-check-target (target) + "Check if the target exists if not, offer to create it." + (let ((fulltarget (concat mu4e-maildir target))) + (if (not (mu4e-create-maildir-maybe fulltarget)) + (mu4e-error "Target dir %s does not exist " fulltarget) + target))) + (defun mu4e-mark-execute-all (&optional no-confirmation) "Execute the actions for all marked messages in this @@ -262,20 +269,16 @@ If NO-CONFIRMATION is non-nil, don't ask user for confirmation." marknum (if (> marknum 1) "s" "")))) (maphash (lambda (docid val) - (let* ((mark (car val)) (target (cdr val)) - (fulltarget (concat mu4e-maildir target))) - ;; check if the target exists; if not, offer to create it - (unless (mu4e-create-maildir-maybe fulltarget) - (mu4e-error "Target dir %s does not exist" fulltarget)) + (let ((mark (car val)) (target (cdr val))) ;; note: whenever you do something with the message, ;; it looses its N (new) flag (case mark - (refile (mu4e~proc-move docid target "-N")) + (refile (mu4e~proc-move docid (mu4e~mark-check-target target) "-N")) (delete (mu4e~proc-remove docid)) (flag (mu4e~proc-move docid nil "+F-u-N")) - (move (mu4e~proc-move docid target "-N")) + (move (mu4e~proc-move docid (mu4e~mark-check-target target) "-N")) (read (mu4e~proc-move docid nil "+S-u-N")) - (trash (mu4e~proc-move docid target "+T-N")) + (trash (mu4e~proc-move docid (mu4e~mark-check-target target) "+T-N")) (unflag (mu4e~proc-move docid nil "-F-N")) (unread (mu4e~proc-move docid nil "-S+u-N")) (otherwise (mu4e-error "Unrecognized mark %S" mark)))))