--- /dev/null
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 848C06DE0319\r
+ for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 16:03:18 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.335\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.335 tagged_above=-999 required=5 tests=[AWL=0.235,\r
+ DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7,\r
+ RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 0DZc6Jm-rST1 for <notmuch@notmuchmail.org>;\r
+ Fri, 10 Jun 2016 16:03:10 -0700 (PDT)\r
+Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com\r
+ [74.125.82.65]) by arlo.cworth.org (Postfix) with ESMTPS id 7EDBF6DE00DF for\r
+ <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 16:03:05 -0700 (PDT)\r
+Received: by mail-wm0-f65.google.com with SMTP id n184so1713859wmn.1\r
+ for <notmuch@notmuchmail.org>; Fri, 10 Jun 2016 16:03:05 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=IndlDcsn9t+LchHWSRIMysZ6P5+h3eusanbeUDDJETU=;\r
+ b=WRzaZUkb6hIMvZ8TmgIQen70et+FxJ9A3ajToNCnsyWPlg/5zziV62JqrdfaDg4b/2\r
+ wm7XEmIzQBkImozpB9wzBXIUNbLcHxsKOL39Z8qGFHji6ymBhHcSPFCsYTQgkF/LEfxr\r
+ l/8/Y1FhSLrShVWaEBwLSpT6fmcxHVFErzZBta/neJb10zNJiTaR+I0YLVUoW94+gMFm\r
+ BSk5KTH76EzKhu5xSVNnufJbZQdhoxwTF3p50SyDmkwInwVRDkRXOOZnanf99qVHayc7\r
+ D0P4rESxwCMfv7oPN3SLw5Otg37CuZ5VX3VjfBTtQ/hSX57LARlzhHuxFs1lqCgSuEIq\r
+ ZAoQ==\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\r
+ :references;\r
+ bh=IndlDcsn9t+LchHWSRIMysZ6P5+h3eusanbeUDDJETU=;\r
+ b=OkRXeiAQp5b1Nx76TOdhzUn+iVWdheGYImw4CgjdWMe/pLccFHewPcjvkYxhBEiLik\r
+ yxaVNiNjz9xF4E+ttb4dFC2Qi3KiD6K7879BSrGoUSIN+LEXlKFBSTeEldwzoNExOJI5\r
+ BSGB+d8DPYRQ++3s/n58FIvndWlmECB1KgrzSDvFND8tsBBOb63IIf3z4WZ49NHBkE3B\r
+ cAv7BfifOZKhLzrGNfDYvdgNKT4y0vnKOSie02jQqUeU6atej74u5ysOr+UqUymjLNZB\r
+ s/XR5ENc0ehlQve6Go8nnfn6c8xFY+obPln06lMHX7fWhMpI7OusPFIOax1hbZKja7uz\r
+ mqig==\r
+X-Gm-Message-State:\r
+ ALyK8tIVz1j7mEJu97Su1Lh3juS5h9m6JlJRVLS0xqH2qm0Qn1B4ffLDExJgUAijrErrjg==\r
+X-Received: by 10.194.192.193 with SMTP id hi1mr4081178wjc.4.1465599784031;\r
+ Fri, 10 Jun 2016 16:03:04 -0700 (PDT)\r
+Received: from localhost (5751dfa2.skybroadband.com. [87.81.223.162])\r
+ by smtp.gmail.com with ESMTPSA id 124sm1266181wml.12.2016.06.10.16.03.03\r
+ (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Fri, 10 Jun 2016 16:03:03 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/6] emacs: maildir-fcc: prepare for use of notmuch insert\r
+Date: Sat, 11 Jun 2016 00:02:48 +0100\r
+Message-Id: <1465599772-10297-3-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1465599772-10297-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1465599772-10297-1-git-send-email-markwalters1009@gmail.com>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 10 Jun 2016 23:03:18 -0000\r
+\r
+We move some code around in preparation for the use of notmuch\r
+insert. In particular, we move the check for a valid maildir for the\r
+fcc to when the message is sent rather than when the fcc header is\r
+inserted. The main motivation is consistency with the insert version\r
+(coming later) where we cannot check the validity until send.\r
+\r
+We allow the user some chance to correct the header; the choice here\r
+is intended to be consistent with the insert version to come.\r
+---\r
+ emacs/notmuch-maildir-fcc.el | 69 ++++++++++++++++++++++++++++----------------\r
+ 1 file changed, 44 insertions(+), 25 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el\r
+index bbf6132..835258f 100644\r
+--- a/emacs/notmuch-maildir-fcc.el\r
++++ b/emacs/notmuch-maildir-fcc.el\r
+@@ -65,11 +65,9 @@ yet when sending a mail."\r
+ :require 'notmuch-fcc-initialization\r
+ :group 'notmuch-send)\r
+ \r
+-(defun notmuch-fcc-handler (destdir)\r
+- "Write buffer to `destdir', marking it as sent\r
+ \r
+-Intended to be dynamically bound to `message-fcc-handler-function'"\r
+- (notmuch-maildir-fcc-write-buffer-to-maildir destdir t))\r
++;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
++;; Functions which set up the fcc header in the message buffer.\r
+ \r
+ (defun notmuch-fcc-header-setup ()\r
+ "Add an Fcc header to the current message buffer.\r
+@@ -110,27 +108,25 @@ by notmuch-mua-mail"\r
+ (error "Invalid `notmuch-fcc-dirs' setting (neither string nor list)")))))\r
+ \r
+ (when subdir\r
+- (message-add-header\r
+- (concat "Fcc: "\r
+- (file-truename\r
+- ;; If the resulting directory is not an absolute path,\r
+- ;; prepend the standard notmuch database path.\r
+- (if (= (elt subdir 0) ?/)\r
+- subdir\r
+- (concat (notmuch-database-path) "/" subdir)))))\r
+- \r
+- ;; finally test if fcc points to a valid maildir\r
+- (let ((fcc-header (message-field-value "Fcc")))\r
+- (unless (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)\r
+- (cond ((not (file-writable-p fcc-header))\r
+- (error (format "No permission to create %s, which does not exist"\r
+- fcc-header)))\r
+- ((y-or-n-p (format "%s is not a maildir. Create it? "\r
+- fcc-header))\r
+- (notmuch-maildir-fcc-create-maildir fcc-header))\r
+- (t\r
+- (error "Message not sent"))))))))\r
+- \r
++ (notmuch-maildir-add-file-style-fcc-header subdir))))\r
++\r
++(defun notmuch-maildir-add-file-style-fcc-header (subdir)\r
++ (message-add-header\r
++ (concat "Fcc: "\r
++ (file-truename\r
++ ;; If the resulting directory is not an absolute path,\r
++ ;; prepend the standard notmuch database path.\r
++ (if (= (elt subdir 0) ?/)\r
++ subdir\r
++ (concat (notmuch-database-path) "/" subdir))))))\r
++\r
++(defun notmuch-fcc-handler (fcc-header)\r
++ "Store message with file fcc."\r
++ (notmuch-maildir-fcc-file-fcc fcc-header))\r
++\r
++;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
++;; Functions for saving a message using file fcc.\r
++\r
+ (defun notmuch-maildir-fcc-host-fixer (hostname)\r
+ (replace-regexp-in-string "/\\|:"\r
+ (lambda (s)\r
+@@ -192,6 +188,29 @@ if successful, nil if not."\r
+ (concat destdir "/tmp/" msg-id)\r
+ (concat destdir "/cur/" msg-id ":2," (when mark-seen "S"))))\r
+ \r
++(defun notmuch-maildir-fcc-file-fcc (fcc-header)\r
++ "Write the message to the file specified by FCC-HEADER.\r
++\r
++It offers the user a chance to correct the header, or filesystem,\r
++if needed."\r
++ (if (notmuch-maildir-fcc-dir-is-maildir-p fcc-header)\r
++ (notmuch-maildir-fcc-write-buffer-to-maildir fcc-header 't)\r
++ ;; The fcc-header is not a valid maildir see if the user wants to\r
++ ;; fix it in some way.\r
++ (let* ((prompt (format "Fcc %s is not a maildir: (r)etry, (c)reate folder, (i)gnore, or (e)dit the header? "\r
++ fcc-header))\r
++ (response (read-char-choice prompt '(?r ?c ?i ?e))))\r
++ (case response\r
++ (?r (notmuch-maildir-fcc-file-fcc fcc-header))\r
++ (?c (if (file-writable-p fcc-header)\r
++ (notmuch-maildir-fcc-create-maildir fcc-header)\r
++ (message "No permission to create %s." fcc-header)\r
++ (sit-for 2))\r
++ (notmuch-maildir-fcc-file-fcc fcc-header))\r
++ (?i 't)\r
++ (?e (notmuch-maildir-fcc-file-fcc\r
++ (read-from-minibuffer "Fcc header: " fcc-header)))))))\r
++\r
+ (defun notmuch-maildir-fcc-write-buffer-to-maildir (destdir &optional mark-seen)\r
+ "Writes the current buffer to maildir destdir. If mark-seen is\r
+ non-nil, it will write it to cur/, and mark it as read. It should\r
+-- \r
+2.1.4\r
+\r