unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Jani Nikula <jani@nikula.org>
To: David Bremner <david@tethera.net>, Jani Nikula <jani@nikula.org>,
	notmuch@notmuchmail.org
Cc: Tomi Ollila <tomi.ollila@iki.fi>
Subject: [PATCH v2] notmuch-emacs-mua: do not create a frame by default with --client
Date: Sat,  4 Apr 2015 10:30:06 +0300	[thread overview]
Message-ID: <1428132606-8624-1-git-send-email-jani@nikula.org> (raw)
In-Reply-To: <87d23o4gzd.fsf@maritornes.cs.unb.ca>

Make the default behaviour for --client the same as emacsclient
default: do not create a new frame. Add a new option --create-frame,
passing the same option to emacsclient to create a frame.

---

v2: fix killing frame with --create-frame
---
 doc/man1/notmuch-emacs-mua.rst | 14 +++++++++-----
 notmuch-emacs-mua              | 29 ++++++++++++++++++++---------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/doc/man1/notmuch-emacs-mua.rst b/doc/man1/notmuch-emacs-mua.rst
index 36b51cdc3b18..e39d9e5fba1f 100644
--- a/doc/man1/notmuch-emacs-mua.rst
+++ b/doc/man1/notmuch-emacs-mua.rst
@@ -18,10 +18,6 @@ Supported options for **notmuch-emacs-mua** include
     ``-h, --help``
         Display help.
 
-    ``--client``
-        Use emacsclient, rather than emacs. This will start
-        an emacs daemon process if necessary.
-
     ``-s, --subject=``\ <subject>
         Specify the subject of the message.
 
@@ -38,7 +34,15 @@ Supported options for **notmuch-emacs-mua** include
         Specify a file to include into the body of the message.
 
     ``--no-window-system``
-        Even if a window system is available, use the current terminal
+        Even if a window system is available, use the current terminal.
+
+    ``--client``
+        Use **emacsclient**, rather than **emacs**. This will start
+        an emacs daemon process if necessary.
+
+    ``--create-frame``
+         When --client is specified, create a new frame instead of trying
+         to use the current Emacs frame.
 
     ``--print``
         Output the resulting elisp to stdout instead of evaluating it.
diff --git a/notmuch-emacs-mua b/notmuch-emacs-mua
index 79714305b3e2..90f585b699b8 100755
--- a/notmuch-emacs-mua
+++ b/notmuch-emacs-mua
@@ -34,12 +34,12 @@ EMACS=${EMACS-emacs}
 EMACSCLIENT=${EMACSCLIENT-emacsclient}
 
 PRINT_ONLY=
+NO_WINDOW=
 USE_EMACSCLIENT=
-CLIENT_TYPE="-c"
+CREATE_FRAME=
 
 # The crux of it all: construct an elisp progn and eval it.
 ELISP="(prog1 'done (require 'notmuch) (notmuch-mua-new-mail)"
-ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"
 
 # Short options compatible with mutt(1).
 while getopts :s:c:b:i:h opt; do
@@ -63,7 +63,7 @@ while getopts :s:c:b:i:h opt; do
 		    opt=${opt%%=*}
 		    ;;
 		# Long options without arguments.
-		--help|--print|--no-window-system|--client)
+		--help|--print|--no-window-system|--client|--create-frame)
 		    ;;
 		*)
 		    echo "$0: unknown long option ${opt}, or argument mismatch." >&2
@@ -81,9 +81,6 @@ while getopts :s:c:b:i:h opt; do
 	--help|h)
 	    exec man notmuch-emacs-mua
 	    ;;
-	--client)
-	    USE_EMACSCLIENT="yes"
-	    ;;
 	--subject|s)
 	    ELISP="${ELISP} (message-goto-subject) (insert \"${OPTARG}\")"
 	    ;;
@@ -103,7 +100,13 @@ while getopts :s:c:b:i:h opt; do
 	    PRINT_ONLY=1
 	    ;;
 	--no-window-system)
-	    CLIENT_TYPE="-t"
+	    NO_WINDOW="-nw"
+	    ;;
+	--client)
+	    USE_EMACSCLIENT="yes"
+	    ;;
+	--create-frame)
+	    CREATE_FRAME="--create-frame"
 	    ;;
 	*)
 	    # We should never end up here.
@@ -122,6 +125,14 @@ for arg; do
     ELISP="${ELISP} (message-goto-to) (insert \"${arg}, \")"
 done
 
+# If reusing a frame in emacsclient, don't kill the buffer.
+if [ -n "$CREATE_FRAME" ]; then
+    ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))"
+elif [ -z "$USE_EMACSCLIENT" ]; then
+    echo "$0: --create-frame is only applicable with --client." >&2
+    exit 1
+fi
+
 # End progn.
 ELISP="${ELISP})"
 
@@ -132,7 +143,7 @@ fi
 
 if [ -n "$USE_EMACSCLIENT" ]; then
     # Evaluate the progn.
-    exec ${EMACSCLIENT} ${CLIENT_TYPE} -a '' --eval "${ELISP}"
+    exec ${EMACSCLIENT} ${CREATE_FRAME} ${NO_WINDOW} -a '' --eval "${ELISP}"
 else
-    exec ${EMACS} --eval "${ELISP}"
+    exec ${EMACS} ${NO_WINDOW} --eval "${ELISP}"
 fi
-- 
2.1.4

  reply	other threads:[~2015-04-04  7:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-22 20:14 [PATCH] notmuch-emacs-mua: do not create a frame by default with --client Jani Nikula
2015-03-22 20:35 ` Tomi Ollila
2015-04-01  4:20 ` David Bremner
2015-04-04  7:30   ` Jani Nikula [this message]
2015-04-06 13:04     ` [PATCH v2] " Tomi Ollila
2015-05-09 18:01       ` [PATCH] " Jani Nikula
2015-05-10  5:52         ` David Bremner
2015-05-10 18:45         ` Tomi Ollila
2015-05-11 19:19         ` [PATCH] notmuch-emacs-mua: do not start emacs daemon w/o --create-frame Tomi Ollila
2015-08-02 10:23           ` David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428132606-8624-1-git-send-email-jani@nikula.org \
    --to=jani@nikula.org \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).