--- /dev/null
+Return-Path: <tomi.ollila@iki.fi>\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 3A6D16DE020B\r
+ for <notmuch@notmuchmail.org>; Thu, 6 Aug 2015 12:09:14 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.25\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.25 tagged_above=-999 required=5 tests=[AWL=-0.146, \r
+ SPF_NEUTRAL=0.652, URIBL_SBL=0.644, URIBL_SBL_A=0.1]\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 HGFhDf0E5kW0 for <notmuch@notmuchmail.org>;\r
+ Thu, 6 Aug 2015 12:09:12 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 7EBA56DE00DE\r
+ for <notmuch@notmuchmail.org>; Thu, 6 Aug 2015 12:09:10 -0700 (PDT)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+ by guru.guru-group.fi (Postfix) with ESMTP id 7DA60100046;\r
+ Thu, 6 Aug 2015 22:08:56 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: David Bremner <david@tethera.net>,\r
+ Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/2] emacs: make modifications to message Fcc vars\r
+ buffer-local\r
+In-Reply-To: <1438718659-11522-2-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
+ <1438718659-11522-2-git-send-email-david@tethera.net>\r
+User-Agent: Notmuch/0.20.2+54~g0bf3ee6 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+ $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+ !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Thu, 06 Aug 2015 22:08:56 +0300\r
+Message-ID: <m2twscdyk7.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\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: Thu, 06 Aug 2015 19:09:14 -0000\r
+\r
+On Tue, Aug 04 2015, David Bremner <david@tethera.net> wrote:\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
+This looks pretty good to me -- one of the above is `C-c C-c` and\r
+capitalization could be consistent in the commit message.\r
+\r
+One thing come to my mind: would it be possible to use buffer-local\r
+variable message-fcc-handler-function in notmuch-message-mode buffers so\r
+that such wrapper functions defined below would not be needed. i.e.\r
+\r
+ (make-local-variable 'message-fcc-handler-function)\r
+ (setq message-fcc-handler-function #'notmuch-fcc-handler)\r
+\r
+(or not? :D)\r
+\r
+one more thing (extra newline) inline below\r
+ \r
+Tomi\r
+\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
+\r
+2 empty lines above -- nowhere else in notmuch-mua.el is such a thing.\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