--- /dev/null
+Return-Path: <jani@nikula.org>\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 8E0FE431FBF\r
+ for <notmuch@notmuchmail.org>; Sun, 22 Mar 2015 13:14:15 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 1.738\r
+X-Spam-Level: *\r
+X-Spam-Status: No, score=1.738 tagged_above=-999 required=5\r
+ tests=[DNS_FROM_AHBL_RHSBL=2.438, RCVD_IN_DNSWL_LOW=-0.7]\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 puO0+LDqRKhM for <notmuch@notmuchmail.org>;\r
+ Sun, 22 Mar 2015 13:14:12 -0700 (PDT)\r
+Received: from mail-we0-f178.google.com (mail-we0-f178.google.com\r
+ [74.125.82.178]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 2CAF6431FBC\r
+ for <notmuch@notmuchmail.org>; Sun, 22 Mar 2015 13:14:11 -0700 (PDT)\r
+Received: by webee49 with SMTP id ee49so12857002web.2\r
+ for <notmuch@notmuchmail.org>; Sun, 22 Mar 2015 13:14:10 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=1e100.net; s=20130820;\r
+ h=x-gm-message-state:from:to:cc:subject:date:message-id;\r
+ bh=oAboX8COGcDdCna+9MXMvbW1nNZWWeNtyrOwhvZ10W4=;\r
+ b=XyP+UtK9wc3EKJw13xZqBXuuu97+g+sqiDl43n40ncphkRsODeWBxoiNyf19Nf2Wqs\r
+ hfCeVqHByomEM+7660k3gLksIJ8YJ6okOQs07baFT0Fu+nwOpCAQEU8lWLu5zzUjEr+X\r
+ 83xD9dHcJXtgreIKZWHhcpeQNqLD5L3TNQv3s9tfmkHRNulHtuq63N/jWEEnbgJBRnM6\r
+ gjcuugXg73O+kfQTU9g37fT1GnwzkjW9fKtJMIHow30DLRQAE8tUUf/bzPKDG9CVQiK+\r
+ 8G0tau3Hqk4g7YGbZL3w9W9JO12SRg/nutcWF2cIDbfiVFKoB1GbtMUbPM9Nw+i/1Q1R\r
+ n/rw==\r
+X-Gm-Message-State:\r
+ ALoCoQkjuGS+Lo46FFSzEQU6J65+hDezf+s6HBC5jQNm7Cx4f9CpCXccoUyZL1YCguyZbx+Xu1xY\r
+X-Received: by 10.180.207.227 with SMTP id lz3mr13430518wic.47.1427055250708; \r
+ Sun, 22 Mar 2015 13:14:10 -0700 (PDT)\r
+Received: from localhost (mobile-internet-bcee3b-76.dhcp.inet.fi.\r
+ [188.238.59.76])\r
+ by mx.google.com with ESMTPSA id o10sm4295654wiy.18.2015.03.22.13.14.09\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sun, 22 Mar 2015 13:14:09 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] notmuch-emacs-mua: do not create a frame by default with\r
+ --client\r
+Date: Sun, 22 Mar 2015 22:14:29 +0200\r
+Message-Id: <1427055269-4742-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\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: Sun, 22 Mar 2015 20:14:15 -0000\r
+\r
+Make the default behaviour for --client the same as emacsclient\r
+default: do not create a new frame. Add a new option --create-frame,\r
+passing the same option to emacsclient to create a frame.\r
+\r
+---\r
+\r
+With this, 'notmuch-emacs-mua --client' does what I want, which was\r
+not possible with any combination of options before. Please see if you\r
+can still do what you want!\r
+---\r
+ doc/man1/notmuch-emacs-mua.rst | 14 +++++++++-----\r
+ notmuch-emacs-mua | 29 ++++++++++++++++++++---------\r
+ 2 files changed, 29 insertions(+), 14 deletions(-)\r
+\r
+diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst\r
+index 36b51cdc3b18..e39d9e5fba1f 100644\r
+--- a/doc/man1/notmuch-emacs-mua.rst\r
++++ b/doc/man1/notmuch-emacs-mua.rst\r
+@@ -18,10 +18,6 @@ Supported options for **notmuch-emacs-mua** include\r
+ ``-h, --help``\r
+ Display help.\r
+ \r
+- ``--client``\r
+- Use emacsclient, rather than emacs. This will start\r
+- an emacs daemon process if necessary.\r
+-\r
+ ``-s, --subject=``\ <subject>\r
+ Specify the subject of the message.\r
+ \r
+@@ -38,7 +34,15 @@ Supported options for **notmuch-emacs-mua** include\r
+ Specify a file to include into the body of the message.\r
+ \r
+ ``--no-window-system``\r
+- Even if a window system is available, use the current terminal\r
++ Even if a window system is available, use the current terminal.\r
++\r
++ ``--client``\r
++ Use **emacsclient**, rather than **emacs**. This will start\r
++ an emacs daemon process if necessary.\r
++\r
++ ``--create-frame``\r
++ When --client is specified, create a new frame instead of trying\r
++ to use the current Emacs frame.\r
+ \r
+ ``--print``\r
+ Output the resulting elisp to stdout instead of evaluating it.\r
+diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua\r
+index 13f67bee4417..68c2643df581 100755\r
+--- a/notmuch-emacs-mua\r
++++ b/notmuch-emacs-mua\r
+@@ -31,12 +31,12 @@ EMACS=${EMACS-emacs}\r
+ EMACSCLIENT=${EMACSCLIENT-emacsclient}\r
+ \r
+ PRINT_ONLY=\r
++NO_WINDOW=\r
+ USE_EMACSCLIENT=\r
+-CLIENT_TYPE="-c"\r
++CREATE_FRAME=\r
+ \r
+ # The crux of it all: construct an elisp progn and eval it.\r
+ ELISP="(prog1 'done (require 'notmuch) (notmuch-mua-new-mail)"\r
+-ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"\r
+ \r
+ # Short options compatible with mutt(1).\r
+ while getopts :s:c:b:i:h opt; do\r
+@@ -60,7 +60,7 @@ while getopts :s:c:b:i:h opt; do\r
+ opt=${opt%%=*}\r
+ ;;\r
+ # Long options without arguments.\r
+- --help|--print|--no-window-system|--client)\r
++ --help|--print|--no-window-system|--client|--create-frame)\r
+ ;;\r
+ *)\r
+ echo "$0: unknown long option ${opt}, or argument mismatch." >&2\r
+@@ -80,9 +80,6 @@ while getopts :s:c:b:i:h opt; do\r
+ --help|h)\r
+ exec man notmuch-emacs-mua\r
+ ;;\r
+- --client)\r
+- USE_EMACSCLIENT="yes"\r
+- ;;\r
+ --subject|s)\r
+ ELISP="${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"\r
+ ;;\r
+@@ -102,7 +99,13 @@ while getopts :s:c:b:i:h opt; do\r
+ PRINT_ONLY=1\r
+ ;;\r
+ --no-window-system)\r
+- CLIENT_TYPE="-t"\r
++ NO_WINDOW="-nw"\r
++ ;;\r
++ --client)\r
++ USE_EMACSCLIENT="yes"\r
++ ;;\r
++ --create-frame)\r
++ CREATE_FRAME="--create-frame"\r
+ ;;\r
+ *)\r
+ # We should never end up here.\r
+@@ -121,6 +124,14 @@ for arg; do\r
+ ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"\r
+ done\r
+ \r
++# If reusing a frame in emacsclient, don't kill the buffer.\r
++if [ -z "$CREATE_FRAME" ]; then\r
++ ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"\r
++elif [ -z "$USE_EMACSCLIENT" ]; then\r
++ echo "$0: --create-frame is only applicable with --client." >&2\r
++ exit 1\r
++fi\r
++\r
+ # End progn.\r
+ ELISP="${ELISP})"\r
+ \r
+@@ -131,7 +142,7 @@ fi\r
+ \r
+ if [ -n "$USE_EMACSCLIENT" ]; then\r
+ # Evaluate the progn.\r
+- exec ${EMACSCLIENT} ${CLIENT_TYPE} -a '' --eval "${ELISP}"\r
++ exec ${EMACSCLIENT} ${CREATE_FRAME} ${NO_WINDOW} -a '' --eval "${ELISP}"\r
+ else\r
+- exec ${EMACS} --eval "${ELISP}"\r
++ exec ${EMACS} ${NO_WINDOW} --eval "${ELISP}"\r
+ fi\r
+-- \r
+2.1.4\r
+\r