From 23fc0b4a639801f8c68a63e4c2add268d96ed0d8 Mon Sep 17 00:00:00 2001 From: djcb Date: Tue, 9 Oct 2012 00:03:24 +0300 Subject: [PATCH] * mu4e: offer to create target dirs when they do not exist yet --- mu4e/mu4e-mark.el | 8 +++++++- mu4e/mu4e-proc.el | 2 ++ mu4e/mu4e-utils.el | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mu4e/mu4e-mark.el b/mu4e/mu4e-mark.el index fb39c8d3..c25a9415 100644 --- a/mu4e/mu4e-mark.el +++ b/mu4e/mu4e-mark.el @@ -237,6 +237,8 @@ replace them with a _real_ mark (ask the user which one)." (mu4e-mark-set (car markpair) (cdr markpair))))))) mu4e~mark-map))) + + (defun mu4e-mark-execute-all (&optional no-confirmation) "Execute the actions for all marked messages in this buffer. After the actions have been executed succesfully, the @@ -260,7 +262,11 @@ 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))) + (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)) ;; note: whenever you do something with the message, ;; it looses its N (new) flag (case mark diff --git a/mu4e/mu4e-proc.el b/mu4e/mu4e-proc.el index 3b7cea4d..9903492b 100644 --- a/mu4e/mu4e-proc.el +++ b/mu4e/mu4e-proc.el @@ -361,6 +361,8 @@ or (:error ) sexp, which are handled my `mu4e-update-func' and `mu4e-error-func', respectively." (unless (or maildir flags) (mu4e-error "At least one of maildir and flags must be specified")) + (unless (or (not maildir) (file-exists-p (concat mu4e-maildir "/" maildir "/"))) + (mu4e-error "Target dir does not exist")) (let* ((idparam (mu4e--docid-msgid-param docid-or-msgid)) (flagstr (when flags diff --git a/mu4e/mu4e-utils.el b/mu4e/mu4e-utils.el index 280bb1d0..a8b099c3 100644 --- a/mu4e/mu4e-utils.el +++ b/mu4e/mu4e-utils.el @@ -127,8 +127,9 @@ see its docstring)." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defun mu4e-create-maildir-maybe (dir) - "Offer to create DIR if it does not exist yet. Return t if the -dir already existed, or has been created, nil otherwise." + "Offer to create maildir DIR (full filesystem path) if it does +not exist yet. Return t if the dir already existed, or has been +created, nil otherwise." (if (and (file-exists-p dir) (not (file-directory-p dir))) (mu4e-error "%s exists, but is not a directory." dir)) (cond