--- /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 A0D856DE13F4\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Aug 2015 00:46:16 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.852\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.852 tagged_above=-999 required=5\r
+ tests=[AWL=-1.026, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+ DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25,\r
+ FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URIBL_SBL=0.644,\r
+ URIBL_SBL_A=0.1] 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 E1MEzIx-1lNm for <notmuch@notmuchmail.org>;\r
+ Mon, 3 Aug 2015 00:46:12 -0700 (PDT)\r
+Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com\r
+ [209.85.212.173])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id C30946DE13DB\r
+ for <notmuch@notmuchmail.org>; Mon, 3 Aug 2015 00:46:11 -0700 (PDT)\r
+Received: by wibxm9 with SMTP id xm9so102121227wib.1\r
+ for <notmuch@notmuchmail.org>; Mon, 03 Aug 2015 00:46:09 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:in-reply-to:references:user-agent:date\r
+ :message-id:mime-version:content-type;\r
+ bh=Ig3og0ZGp/ecJEDzBh4pH9V2ulJBzIR/Dh+lpmP82z0=;\r
+ b=0MhARxu57tFtCmpu5tKrIbHW4nNRpSU+fz0f7AeXKP6TlUbUJGyGPfQIzJP2Y6Agfz\r
+ m+Rg0UTDRncHYL8LtBZybnNMneXI0y2LYrzcAyTfAe+15mgG488lffEvGtKgjN7yizJm\r
+ 23lEpvna9Rw0uueuAVf5Ck9aEeYG44VOFwmC6VzaRx8k+pmP5qbKJ5tKQ3+IRrNWkW9h\r
+ frwT/w7LRuy/h3IML8h5ZXY/gcOnxLGazEd2W/HGdn7bKP8120H/XHh+9i3QRR8kwBMZ\r
+ PvB8UuSvwPWokMDeWp4hxfHwfIPQD+ciZaED33aq1X6zmz3IZENqrLyL0EnjEX/xTZQp\r
+ 3tSg==\r
+X-Received: by 10.194.190.79 with SMTP id go15mr30096970wjc.80.1438587969805; \r
+ Mon, 03 Aug 2015 00:46:09 -0700 (PDT)\r
+Received: from localhost (188.29.71.109.threembb.co.uk. [188.29.71.109])\r
+ by smtp.gmail.com with ESMTPSA id s1sm12148134wix.13.2015.08.03.00.46.07\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Mon, 03 Aug 2015 00:46:09 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] emacs: make modifications to message Fcc vars\r
+ buffer-local\r
+In-Reply-To: <1438422296-29087-3-git-send-email-david@tethera.net>\r
+References: <87vbdrysd7.fsf@qmul.ac.uk>\r
+ <1438422296-29087-1-git-send-email-david@tethera.net>\r
+ <1438422296-29087-3-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.18.1+86~gef5e66a (http://notmuchmail.org) Emacs/23.4.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Mon, 03 Aug 2015 08:46:05 +0100\r
+Message-ID: <873800yfuq.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Mon, 03 Aug 2015 07:46:16 -0000\r
+\r
+\r
+On Sat, 01 Aug 2015, David Bremner <david@tethera.net> wrote:\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
+I think I like this approach: I think we will like the freedom to tweak\r
+message-mode.\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
+These both seem good. At the moment notmuch-fcc-header-setup checks\r
+whether the fcc directory is a valid maildir. This used to be called on\r
+sending but is now called when the message composition is started. I\r
+think it would be better to move it into notmuch-mua-send-and-exit or\r
+(perhaps better) in notmuch-fcc-handler itself (in case the user edits\r
+it).\r
+\r
+> - the name in the mode line is changed, and (sadface) no longer\r
+> matches the menu label.\r
+\r
+Do you mean the buffer name is *mail*? We could just call rename-buffer\r
+somewhere (maybe in our derived mode bit?)\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
+This is a little irritating in case people have customised key bindings\r
+but I don't see a way round it. \r
+\r
+A related case, which we probably should fix, is that C-c C-s is bound to\r
+message send (and don't exit), this probably needs a wrapper too.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+\r
+\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