--- /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 arlo.cworth.org (Postfix) with ESMTP id 192C16DE1AC9\r
+ for <notmuch@notmuchmail.org>; Sat, 4 Apr 2015 00:29:49 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.543\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.543 tagged_above=-999 required=5 tests=[AWL=1.263, \r
+ RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01,\r
+ RCVD_IN_MSPIKE_WL=-0.01] 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 ZqkBjDkzSkfy for <notmuch@notmuchmail.org>;\r
+ Sat, 4 Apr 2015 00:29:47 -0700 (PDT)\r
+Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
+ [209.85.212.175])\r
+ by arlo.cworth.org (Postfix) with ESMTPS id CDA746DE1AC6\r
+ for <notmuch@notmuchmail.org>; Sat, 4 Apr 2015 00:29:46 -0700 (PDT)\r
+Received: by wixm2 with SMTP id m2so83858163wix.0\r
+ for <notmuch@notmuchmail.org>; Sat, 04 Apr 2015 00:29:43 -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:in-reply-to\r
+ :references;\r
+ bh=Qz4rP+y9WXKCUe/MZ5J1p8CzA4gMfU4l5KKAlESM1zY=;\r
+ b=MiSXFRDD1oUL2QW4JcqqmflBsNxB2Oogeh/Um6Murei0yUcIpSHGTcApYI0Amaif8z\r
+ jIIAK9ELgaoYeSOWMdGtdXhwjziuyb3BZsx2jLbza7ZoP6NHSgTRjoOKGmAW5oP/aIQ+\r
+ 2xjxge2BBnfa6FLn5qEIn5BiXhTdX3fTWRPPnE93f3E71on3Brslen/s2MXI0gagR2vp\r
+ N6YueVW+BdUk9earMY8+jsbiOEvxnHvW2aL0ZrzOnyZIEe8W/AT54glOpb5OaoNfiX+I\r
+ unKSkF3EZzrY2Qw0G9BqeYywvFOOU+i1YddKz13lCdg65Mq8zwZvS7rZoANq2JSGImWH\r
+ vJmA==\r
+X-Gm-Message-State:\r
+ ALoCoQkMLKQexSUul0dYvu7s/Yc+yCIc8sdp8hTfz5b19J7uCQOfSA58S0IZkL6Rx/5xWv+kCdJC\r
+X-Received: by 10.180.82.169 with SMTP id j9mr12210249wiy.40.1428132582410;\r
+ Sat, 04 Apr 2015 00:29:42 -0700 (PDT)\r
+Received: from localhost (mobile-internet-bceee3-101.dhcp.inet.fi.\r
+ [188.238.227.101])\r
+ by mx.google.com with ESMTPSA id cj9sm14504618wjc.42.2015.04.04.00.29.41\r
+ (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\r
+ Sat, 04 Apr 2015 00:29:41 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: David Bremner <david@tethera.net>, Jani Nikula <jani@nikula.org>,\r
+ notmuch@notmuchmail.org\r
+Subject: [PATCH v2] notmuch-emacs-mua: do not create a frame by default with\r
+ --client\r
+Date: Sat, 4 Apr 2015 10:30:06 +0300\r
+Message-Id: <1428132606-8624-1-git-send-email-jani@nikula.org>\r
+X-Mailer: git-send-email 2.1.4\r
+In-Reply-To: <87d23o4gzd.fsf@maritornes.cs.unb.ca>\r
+References: <87d23o4gzd.fsf@maritornes.cs.unb.ca>\r
+Cc: Tomi Ollila <tomi.ollila@iki.fi>\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: Sat, 04 Apr 2015 07:29:49 -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
+v2: fix killing frame with --create-frame\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 79714305b3e2..90f585b699b8 100755\r
+--- a/notmuch-emacs-mua\r
++++ b/notmuch-emacs-mua\r
+@@ -34,12 +34,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
+@@ -63,7 +63,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
+@@ -81,9 +81,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
+@@ -103,7 +100,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
+@@ -122,6 +125,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 [ -n "$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
+@@ -132,7 +143,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