* mu4e: offer to create target dirs when they do not exist yet

This commit is contained in:
djcb 2012-10-09 00:03:24 +03:00
parent a7f974d207
commit 23fc0b4a63
3 changed files with 12 additions and 3 deletions

View File

@ -237,6 +237,8 @@ replace them with a _real_ mark (ask the user which one)."
(mu4e-mark-set (car markpair) (cdr markpair))))))) (mu4e-mark-set (car markpair) (cdr markpair)))))))
mu4e~mark-map))) mu4e~mark-map)))
(defun mu4e-mark-execute-all (&optional no-confirmation) (defun mu4e-mark-execute-all (&optional no-confirmation)
"Execute the actions for all marked messages in this "Execute the actions for all marked messages in this
buffer. After the actions have been executed succesfully, the 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" "")))) marknum (if (> marknum 1) "s" ""))))
(maphash (maphash
(lambda (docid val) (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, ;; note: whenever you do something with the message,
;; it looses its N (new) flag ;; it looses its N (new) flag
(case mark (case mark

View File

@ -361,6 +361,8 @@ or (:error ) sexp, which are handled my `mu4e-update-func' and
`mu4e-error-func', respectively." `mu4e-error-func', respectively."
(unless (or maildir flags) (unless (or maildir flags)
(mu4e-error "At least one of maildir and flags must be specified")) (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)) (let* ((idparam (mu4e--docid-msgid-param docid-or-msgid))
(flagstr (flagstr
(when flags (when flags

View File

@ -127,8 +127,9 @@ see its docstring)."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun mu4e-create-maildir-maybe (dir) (defun mu4e-create-maildir-maybe (dir)
"Offer to create DIR if it does not exist yet. Return t if the "Offer to create maildir DIR (full filesystem path) if it does
dir already existed, or has been created, nil otherwise." 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))) (if (and (file-exists-p dir) (not (file-directory-p dir)))
(mu4e-error "%s exists, but is not a directory." dir)) (mu4e-error "%s exists, but is not a directory." dir))
(cond (cond