--- /dev/null
+Return-Path: <bremner@tesseract.cs.unb.ca>\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 206076DE17F0\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Aug 2015 02:47:10 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.153\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.153 tagged_above=-999 required=5 tests=[AWL=0.143, \r
+ T_HEADER_FROM_DIFFERENT_DOMAINS=0.01] 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 rshqtIHSmXOJ for <notmuch@notmuchmail.org>;\r
+ Sat, 1 Aug 2015 02:47:08 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id 5AD726DE17EB\r
+ for <notmuch@notmuchmail.org>; Sat, 1 Aug 2015 02:47:08 -0700 (PDT)\r
+Received: from remotemail by gitolite.debian.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tesseract.cs.unb.ca>)\r
+ id 1ZLTM8-0004tX-30; Sat, 01 Aug 2015 09:45:28 +0000\r
+Received: (nullmailer pid 29361 invoked by uid 1000); Sat, 01 Aug 2015\r
+ 09:45:02 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] emacs: make modifications to message Fcc vars\r
+ buffer-local\r
+Date: Sat, 1 Aug 2015 11:44:56 +0200\r
+Message-Id: <1438422296-29087-3-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1438422296-29087-1-git-send-email-david@tethera.net>\r
+References: <87vbdrysd7.fsf@qmul.ac.uk>\r
+ <1438422296-29087-1-git-send-email-david@tethera.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://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: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 01 Aug 2015 09:47:10 -0000\r
+\r
+Previously we globally modified these variables, which tended to cause\r
+problems for people using message-mode, but not notmuch-mua-mail, to\r
+send mail.\r
+\r
+User visible changes:\r
+\r
+- calling notmuch-fcc-header-setup is no longer optional. OTOH, it\r
+ seems to do the right thing if notmuch-fcc-dirs is set to nil.\r
+\r
+- the Fcc header is visible during message composition\r
+\r
+- the name in the mode line is changed, and (sadface) no longer\r
+ matches the menu label.\r
+\r
+- Previously notmuch-mua-send-and-exit was never called. Either we\r
+ misunderstood define-mail-user-agent, or it had a bug. So there was\r
+ no difference if the user called message-send-and-exit directly. Now\r
+ there will be.\r
+---\r
+ emacs/notmuch-maildir-fcc.el | 23 +++++++++--------------\r
+ emacs/notmuch-mua.el | 6 +++++-\r
+ test/test-lib.sh | 4 ++--\r
+ 3 files changed, 16 insertions(+), 17 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-maildir-fcc.el b/emacs/notmuch-maildir-fcc.el\r
+index 07eedba..c2f2f4c 100644\r
+--- a/emacs/notmuch-maildir-fcc.el\r
++++ b/emacs/notmuch-maildir-fcc.el\r
+@@ -59,23 +59,19 @@ yet when sending a mail."\r
+ :require 'notmuch-fcc-initialization\r
+ :group 'notmuch-send)\r
+ \r
+-(defun notmuch-fcc-initialization ()\r
+- "If notmuch-fcc-directories is set,\r
+- hook them into the message-fcc-handler-function"\r
+- ;; Set up the message-fcc-handler to move mails to the maildir in Fcc\r
+- ;; The parameter is set to mark messages as "seen"\r
+- (setq message-fcc-handler-function\r
+- (lambda (destdir)\r
+- (notmuch-maildir-fcc-write-buffer-to-maildir destdir t)))\r
+- ;; add a hook to actually insert the Fcc header when sending\r
+- (add-hook 'message-header-setup-hook 'notmuch-fcc-header-setup))\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
+ (defun notmuch-fcc-header-setup ()\r
+ "Add an Fcc header to the current message buffer.\r
+ \r
+-Can be added to `message-send-hook' and will set the Fcc header\r
+-based on the values of `notmuch-fcc-dirs'. An existing Fcc header\r
+-will NOT be removed or replaced."\r
++Sets the Fcc header based on the values of `notmuch-fcc-dirs'.\r
++\r
++Originally intended to be use a hook function, but now called directly\r
++by notmuch-mua-mail"\r
+ \r
+ (let ((subdir\r
+ (cond\r
+@@ -213,6 +209,5 @@ return t if successful, and nil otherwise."\r
+ (delete-file (concat destdir "/tmp/" msg-id))))\r
+ t)))\r
+ \r
+-(notmuch-fcc-initialization)\r
+ (provide 'notmuch-maildir-fcc)\r
+ \r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index a7d3eaa..4ae7d1e 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -268,6 +268,8 @@ Note that these functions use `mail-citation-hook' if that is non-nil."\r
+ (define-derived-mode notmuch-compose-mode message-mode "notmuch-compose"\r
+ "Notmuch message composition mode. Mostly like `message-mode'")\r
+ \r
++(define-key notmuch-compose-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)\r
++\r
+ (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)\r
+ "Invoke the notmuch mail composition window.\r
+ \r
+@@ -285,6 +287,7 @@ OTHER-ARGS are passed through to `message-mail'."\r
+ \r
+ (apply #'message-mail to subject other-headers other-args)\r
+ (notmuch-compose-mode)\r
++ (notmuch-fcc-header-setup)\r
+ (message-sort-headers)\r
+ (message-hide-headers)\r
+ (set-buffer-modified-p nil)\r
+@@ -398,7 +401,8 @@ will be addressed to all recipients of the source message."\r
+ \r
+ (defun notmuch-mua-send-and-exit (&optional arg)\r
+ (interactive "P")\r
+- (message-send-and-exit arg))\r
++ (let ((message-fcc-handler-function #'notmuch-fcc-handler))\r
++ (message-send-and-exit arg)))\r
+ \r
+ (defun notmuch-mua-kill-buffer ()\r
+ (interactive)\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 3466e9c..cb8a6cf 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -487,7 +487,7 @@ emacs_deliver_message ()\r
+ (message-goto-body)\r
+ (insert \"${body}\")\r
+ $@\r
+- (message-send-and-exit))"\r
++ (notmuch-mua-send-and-exit))"\r
+ \r
+ # In case message was sent properly, client waits for confirmation\r
+ # before exiting and resuming control here; therefore making sure\r
+@@ -522,7 +522,7 @@ emacs_fcc_message ()\r
+ (message-goto-body)\r
+ (insert \"${body}\")\r
+ $@\r
+- (message-send-and-exit))" || return 1\r
++ (notmuch-mua-send-and-exit))" || return 1\r
+ notmuch new >/dev/null\r
+ }\r
+ \r
+-- \r
+2.1.4\r
+\r