--- /dev/null
+Return-Path: <jrollins@finestructure.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 91BFE431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 13:42:20 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 0SU9PyfyWMDj for <notmuch@notmuchmail.org>;\r
+ Sat, 14 Apr 2012 13:42:19 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+ [131.215.239.19])\r
+ by olra.theworths.org (Postfix) with ESMTP id CC493431FAE\r
+ for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 13:42:19 -0700 (PDT)\r
+Received: from fire-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+ by fire-doxen-postvirus (Postfix) with ESMTP id 7584A2E50E6E\r
+ for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 13:42:19 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on fire-doxen by amavisd-new\r
+Received: from finestructure.net (unknown [76.89.193.65])\r
+ (Authenticated sender: jrollins)\r
+ by fire-doxen-submit (Postfix) with ESMTP id 7A3722E50E76\r
+ for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 13:42:17 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+ id 2F8F945D; Sat, 14 Apr 2012 13:42:17 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v5] emacs: Let the user choose where to compose new mails\r
+Date: Sat, 14 Apr 2012 13:42:17 -0700\r
+Message-Id: <1334436137-6099-1-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.9.5\r
+In-Reply-To: <1334434815-7657-1-git-send-email-jrollins@finestructure.net>\r
+References: <1334434815-7657-1-git-send-email-jrollins@finestructure.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\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, 14 Apr 2012 20:42:20 -0000\r
+\r
+From: Thomas Jost <schnouki@schnouki.net>\r
+\r
+Introduce a new defcustom notmuch-mua-compose-in that allows users to\r
+specify where new mails are composed, either in the current window or\r
+in a new window or frame.\r
+\r
+Signed-off-by: Jameson Rollins <jrollins@finestructure.net>\r
+---\r
+There was a small bug in the previous rebased version of this patch\r
+that this new version fixes. Sorry about the noise.\r
+\r
+I also updated the subject line to indicate that this is in fact the\r
+fifth version of this patch.\r
+\r
+ emacs/notmuch-mua.el | 40 ++++++++++++++++++++++++++++++++++++++--\r
+ 1 file changed, 38 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 87bd88d..1fb59de 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -36,6 +36,21 @@\r
+ :group 'notmuch-send\r
+ :group 'notmuch-hooks)\r
+ \r
++(defcustom notmuch-mua-compose-in 'current-window\r
++ "Where to create the mail buffer used to compose a new message.\r
++ Possible values are `current-window' (default), `new-window'\r
++ and `new-frame'. If set to `current-window', the mail buffer\r
++ will be displayed in the current window, so the old buffer will\r
++ be restored when the mail buffer is killed. If set to\r
++ `new-window' or `new-frame', the mail buffer will be displayed\r
++ in a new window/frame that will be destroyed when the buffer is\r
++ killed. You may want to customize `message-kill-buffer-on-exit'\r
++ accordingly."\r
++ :group 'notmuch\r
++ :type '(choice (const :tag "Compose in the current window" current-window)\r
++ (const :tag "Compose mail in a new window" new-window)\r
++ (const :tag "Compose mail in a new frame" new-frame)))\r
++\r
+ (defcustom notmuch-mua-user-agent-function 'notmuch-mua-user-agent-full\r
+ "Function used to generate a `User-Agent:' string. If this is\r
+ `nil' then no `User-Agent:' will be generated."\r
+@@ -55,6 +70,23 @@ list."\r
+ \r
+ ;;\r
+ \r
++(defun notmuch-mua-get-switch-function ()\r
++ "Get a switch function according to `notmuch-mua-compose-in'."\r
++ (cond ((eq notmuch-mua-compose-in 'current-window)\r
++ 'switch-to-buffer)\r
++ ((eq notmuch-mua-compose-in 'new-window)\r
++ 'switch-to-buffer-other-window)\r
++ ((eq notmuch-mua-compose-in 'new-frame)\r
++ 'switch-to-buffer-other-frame)\r
++ (t (error "Invalid value for `notmuch-mua-compose-in'"))))\r
++\r
++(defun notmuch-mua-maybe-set-window-dedicated ()\r
++ "Set the selected window as dedicated according to\r
++`notmuch-mua-compose-in'."\r
++ (when (or (eq notmuch-mua-compose-in 'new-frame)\r
++ (eq notmuch-mua-compose-in 'new-window))\r
++ (set-window-dedicated-p (selected-window) t)))\r
++\r
+ (defun notmuch-mua-user-agent-full ()\r
+ "Generate a `User-Agent:' string suitable for notmuch."\r
+ (concat (notmuch-mua-user-agent-notmuch)\r
+@@ -148,7 +180,8 @@ list."\r
+ collect pair)))\r
+ (notmuch-mua-mail (plist-get reply-headers :To)\r
+ (plist-get reply-headers :Subject)\r
+- (notmuch-headers-plist-to-alist reply-headers))))\r
++ (notmuch-headers-plist-to-alist reply-headers)\r
++ nil (notmuch-mua-get-switch-function))))\r
+ \r
+ ;; Insert the message body - but put it in front of the signature\r
+ ;; if one is present\r
+@@ -186,6 +219,7 @@ list."\r
+ (set-buffer-modified-p nil))\r
+ \r
+ (defun notmuch-mua-forward-message ()\r
++ (funcall (notmuch-mua-get-switch-function) (current-buffer))\r
+ (message-forward)\r
+ \r
+ (when notmuch-mua-user-agent-function\r
+@@ -195,6 +229,7 @@ list."\r
+ (message-sort-headers)\r
+ (message-hide-headers)\r
+ (set-buffer-modified-p nil)\r
++ (notmuch-mua-maybe-set-window-dedicated)\r
+ \r
+ (message-goto-to))\r
+ \r
+@@ -217,6 +252,7 @@ OTHER-ARGS are passed through to `message-mail'."\r
+ (message-sort-headers)\r
+ (message-hide-headers)\r
+ (set-buffer-modified-p nil)\r
++ (notmuch-mua-maybe-set-window-dedicated)\r
+ \r
+ (message-goto-to))\r
+ \r
+@@ -273,7 +309,7 @@ the From: address first."\r
+ (let ((other-headers\r
+ (when (or prompt-for-sender notmuch-always-prompt-for-sender)\r
+ (list (cons 'From (notmuch-mua-prompt-for-sender))))))\r
+- (notmuch-mua-mail nil nil other-headers)))\r
++ (notmuch-mua-mail nil nil other-headers nil (notmuch-mua-get-switch-function))))\r
+ \r
+ (defun notmuch-mua-new-forward-message (&optional prompt-for-sender)\r
+ "Invoke the notmuch message forwarding window.\r
+-- \r
+1.7.9.5\r
+\r