--- /dev/null
+Return-Path: <schnouki@schnouki.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 88ED1431FD0\r
+ for <notmuch@notmuchmail.org>; Tue, 25 Oct 2011 00:41:31 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.1\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.1 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1]\r
+ 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 TFk8uuePvlyu for <notmuch@notmuchmail.org>;\r
+ Tue, 25 Oct 2011 00:41:31 -0700 (PDT)\r
+Received: from ks3536.kimsufi.com (schnouki.net [87.98.217.222])\r
+ by olra.theworths.org (Postfix) with ESMTP id CD3A9431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 25 Oct 2011 00:41:30 -0700 (PDT)\r
+Received: from localhost.localdomain (thor.loria.fr [152.81.12.250])\r
+ by ks3536.kimsufi.com (Postfix) with ESMTPSA id 2667D6A0005;\r
+ Tue, 25 Oct 2011 09:41:30 +0200 (CEST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=schnouki.net;\r
+ s=key-schnouki; t=1319528490;\r
+ bh=5vrxszd3ckHNYDrSoHoSTFUNrnBGXJn8Zfrwm52XPbI=;\r
+ h=From:To:Subject:Date:Message-Id:In-Reply-To:References;\r
+ b=c9n8i8VwDM3YMebzPSMTMa8fxvDkVthOeBF9nPme9KCH4shj+IunuBXFp0usvOJW7\r
+ 3BUs4iXj3ch+YGFbD+364oJyXlientx8nrs9TqKfNEmaiIqKfTc2h6FHVCu20bsb29\r
+ 5NGIG6bkIggRBz8Jf0mz0ma6V8tSW4H2WrQy1bLQ=\r
+From: Thomas Jost <schnouki@schnouki.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: Let the user choose where to compose new mails\r
+Date: Tue, 25 Oct 2011 09:41:04 +0200\r
+Message-Id: <1319528464-22654-1-git-send-email-schnouki@schnouki.net>\r
+X-Mailer: git-send-email 1.7.7\r
+In-Reply-To: <87pqhlh64c.fsf@thor.loria.fr>\r
+References: <87pqhlh64c.fsf@thor.loria.fr>\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: Tue, 25 Oct 2011 07:41:31 -0000\r
+\r
+---\r
+ emacs/notmuch-mua.el | 37 +++++++++++++++++++++++++++++++++++--\r
+ 1 files changed, 35 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
+index 8824b08..ebc922f 100644\r
+--- a/emacs/notmuch-mua.el\r
++++ b/emacs/notmuch-mua.el\r
+@@ -31,6 +31,34 @@\r
+ :group 'notmuch\r
+ :type 'hook)\r
+ \r
++(defvar notmuch-mua-switch-function nil\r
++ "Function used to switch and display the mail buffer. This is\r
++ normally set by `notmuch-mua-compose-in'.")\r
++(defvar notmuch-mua-dedicated-flag nil\r
++ "Flag to pass to `set-window-dedicated-p' in the mail buffer.\r
++ This is normally set by `notmuch-mua-compose-in'.")\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 `new-window' or `new-frame', the\r
++ mail buffer will be displayer in a new window/frame that will\r
++ be destroyed when the buffer is killed. You may want to\r
++ customize `message-kill-buffer-on-exit' accordingly."\r
++ :group 'notmuch\r
++ :type 'symbol\r
++ :set (lambda (sym val)\r
++ (cond ((eq val 'current-window)\r
++ (setq notmuch-mua-switch-function nil\r
++ notmuch-mua-dedicated-flag nil))\r
++ ((eq val 'new-window)\r
++ (setq notmuch-mua-switch-function 'switch-to-buffer-other-window\r
++ notmuch-mua-dedicated-flag 1))\r
++ ((eq val 'new-frame)\r
++ (setq notmuch-mua-switch-function 'switch-to-buffer-other-frame\r
++ notmuch-mua-dedicated-flag 1))\r
++ (t (error (concat "Bad value for notmuch-mua-compose-in: "\r
++ (symbol-value val)))))))\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
+@@ -99,7 +127,8 @@ list."\r
+ ((same-window-regexps '("\\*mail .*")))\r
+ (notmuch-mua-mail (mail-header 'to headers)\r
+ (mail-header 'subject headers)\r
+- (message-headers-to-generate headers t '(to subject))))\r
++ (message-headers-to-generate headers t '(to subject))\r
++ nil notmuch-mua-switch-function))\r
+ ;; insert the message body - but put it in front of the signature\r
+ ;; if one is present\r
+ (goto-char (point-max))\r
+@@ -112,6 +141,8 @@ list."\r
+ (message-goto-body))\r
+ \r
+ (defun notmuch-mua-forward-message ()\r
++ (when notmuch-mua-switch-function\r
++ (funcall notmuch-mua-switch-function (current-buffer)))\r
+ (message-forward)\r
+ \r
+ (when notmuch-mua-user-agent-function\r
+@@ -121,6 +152,7 @@ list."\r
+ (message-sort-headers)\r
+ (message-hide-headers)\r
+ (set-buffer-modified-p nil)\r
++ (set-window-dedicated-p (selected-window) notmuch-mua-dedicated-flag)\r
+ \r
+ (message-goto-to))\r
+ \r
+@@ -143,6 +175,7 @@ list."\r
+ (message-sort-headers)\r
+ (message-hide-headers)\r
+ (set-buffer-modified-p nil)\r
++ (set-window-dedicated-p (selected-window) notmuch-mua-dedicated-flag)\r
+ \r
+ (message-goto-to))\r
+ \r
+@@ -199,7 +232,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-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.7\r
+\r