summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2010-04-26 21:33:13 -0400
committerCarl Worth <cworth@cworth.org>2010-04-26 23:06:50 -0700
commit07c8eb1db6ab9a8b2939d656f17f0f836ba05c75 (patch)
treeb31b46d8884c25f2ddc1619a2de31552dd41f232
parent9b85872ed4526688a6195cfa8af19be20ed869c2 (diff)
emacs: add prompt to create maildir for fcc if it does not exist.
If the user specifies a maildir that does not exist, prompt the user to see whether a maildir should be created. This will fail, with the relevant explanation, if the location is not writable, or if a file already exists in that location. If the location is a dir, but not a maildir, this will add /tmp/cur/new to it.
-rw-r--r--emacs/notmuch-maildir-fcc.el26
1 files changed, 22 insertions, 4 deletions
diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el
index 34b1915..6d75b11 100644
--- a/emacs/notmuch-maildir-fcc.el
+++ b/emacs/notmuch-maildir-fcc.el
@@ -72,10 +72,16 @@
(if (eq subdir nil) (setq subdir (car (car notmuch-fcc-dirs))))
(unless (message-fetch-field "fcc")
(message-add-header (concat "Fcc: " message-directory subdir)))
- (unless (notmuch-maildir-fcc-dir-is-maildir-p
- (message-fetch-field "fcc"))
- (error (format "%s is not a maildir." (message-fetch-field "fcc")))))))
-
+ (let ((fcc-header (message-fetch-field "fcc")))
+ (unless (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)
+ (cond ((not (file-writable-p fcc-header))
+ (error (format "%s is not a maildir, but you don't have permission to create one." fcc-header)))
+ ((y-or-n-p (format "%s is not a maildir. Create it? "
+ fcc-header))
+ (notmuch-maildir-fcc-create-maildir fcc-header))
+ (t
+ (error "Not sending message."))))))))
+
(defun notmuch-maildir-fcc-host-fixer (hostname)
(replace-regexp-in-string "/\\|:"
'(lambda (s)
@@ -104,6 +110,18 @@
(file-exists-p (concat dir "/new/"))
(file-exists-p (concat dir "/tmp/"))))
+(defun notmuch-maildir-fcc-create-maildir (path)
+ (cond ((or (not (file-exists-p path)) (file-directory-p path))
+ (make-directory (concat path "/cur/") t)
+ (make-directory (concat path "/new/") t)
+ (make-directory (concat path "/tmp/") t))
+ ((file-regular-p path)
+ (error "%s is a file. Can't creat maildir." path))
+ (t
+ (error "I don't know how to create a maildir here"))))
+
+
+
(defun notmuch-maildir-fcc-save-buffer-to-tmp (destdir)
"Returns the msg id of the message written to the temp directory
if successful, nil if not."