--- /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 5A2246DE17E9\r
+ for <notmuch@notmuchmail.org>; Tue, 4 Aug 2015 13:06:39 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.146\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.146 tagged_above=-999 required=5 tests=[AWL=0.136, \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 NW9EfkXjpW5A for <notmuch@notmuchmail.org>;\r
+ Tue, 4 Aug 2015 13:06:37 -0700 (PDT)\r
+Received: from gitolite.debian.net (gitolite.debian.net [87.98.215.224])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id DBB0F6DE1AA6\r
+ for <notmuch@notmuchmail.org>; Tue, 4 Aug 2015 13:06:36 -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 1ZMiSJ-0002om-DA; Tue, 04 Aug 2015 20:04:59 +0000\r
+Received: (nullmailer pid 11585 invoked by uid 1000); Tue, 04 Aug 2015\r
+ 20:04:31 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: David Bremner <david@tethera.net>, Mark Walters\r
+ <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] emacs: make modifications to message Fcc vars\r
+ buffer-local\r
+Date: Tue, 4 Aug 2015 22:04:19 +0200\r
+Message-Id: <1438718659-11522-2-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <1438718659-11522-1-git-send-email-david@tethera.net>\r
+References: <87fv4093sl.fsf@maritornes.cs.unb.ca>\r
+ <1438718659-11522-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: Tue, 04 Aug 2015 20:06:39 -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
+- user bindings to C-c C-s and C-c C-s in message-mode-map are\r
+ overridden. The user can override them in notmuch-message-mode-map,\r
+ but then they're on their own for Fcc handling.\r
+---\r
+ emacs/notmuch-maildir-fcc.el | 23 +++++++++--------------\r
+ emacs/notmuch-mua.el | 15 +++++++++++++--\r
+ test/test-lib.sh | 4 ++--\r
+ 3 files changed, 24 insertions(+), 18 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 1018321..803459a 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -268,9 +268,13 @@ Note that these functions use `mail-citation-hook' if that is non-nil."\r
+ (message-goto-body)\r
+ (set-buffer-modified-p nil))\r
+ \r
+-(define-derived-mode notmuch-message-mode message-mode "Notmuch Message"\r
++(define-derived-mode notmuch-message-mode message-mode "Message[Notmuch]"\r
+ "Notmuch message composition mode. Mostly like `message-mode'")\r
+ \r
++(define-key notmuch-message-mode-map (kbd "C-c C-c") #'notmuch-mua-send-and-exit)\r
++(define-key notmuch-message-mode-map (kbd "C-c C-s") #'notmuch-mua-send)\r
++\r
++\r
+ (defun notmuch-mua-mail (&optional to subject other-headers &rest other-args)\r
+ "Invoke the notmuch mail composition window.\r
+ \r
+@@ -288,6 +292,7 @@ OTHER-ARGS are passed through to `message-mail'."\r
+ \r
+ (apply #'message-mail to subject other-headers other-args)\r
+ (notmuch-message-mode)\r
++ (notmuch-fcc-header-setup)\r
+ (message-sort-headers)\r
+ (message-hide-headers)\r
+ (set-buffer-modified-p nil)\r
+@@ -401,7 +406,13 @@ 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-send (&optional arg)\r
++ (interactive "P")\r
++ (let ((message-fcc-handler-function #'notmuch-fcc-handler))\r
++ (message-send 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 db3b6aa..eeb5487 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