From b8e09a3976a846d9119e1f0891b7e88299a8d258 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Sat, 9 May 2015 21:01:04 +0300 Subject: [PATCH] [PATCH] notmuch-emacs-mua: do not create a frame by default with --client --- 41/5b74593cde3479ff6d37f5dc6ff7d286aea7d2 | 194 ++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 41/5b74593cde3479ff6d37f5dc6ff7d286aea7d2 diff --git a/41/5b74593cde3479ff6d37f5dc6ff7d286aea7d2 b/41/5b74593cde3479ff6d37f5dc6ff7d286aea7d2 new file mode 100644 index 000000000..557314af0 --- /dev/null +++ b/41/5b74593cde3479ff6d37f5dc6ff7d286aea7d2 @@ -0,0 +1,194 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by arlo.cworth.org (Postfix) with ESMTP id 1CF696DE0B38 + for ; Sat, 9 May 2015 11:00:50 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.375 +X-Spam-Level: +X-Spam-Status: No, score=0.375 tagged_above=-999 required=5 tests=[AWL=1.095, + RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, + RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled +Received: from arlo.cworth.org ([127.0.0.1]) + by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id lJHtSVJWQngp for ; + Sat, 9 May 2015 11:00:48 -0700 (PDT) +Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com + [74.125.82.44]) by arlo.cworth.org (Postfix) with ESMTPS id BD7FC6DE0B20 for + ; Sat, 9 May 2015 11:00:47 -0700 (PDT) +Received: by wgin8 with SMTP id n8so96791605wgi.0 + for ; Sat, 09 May 2015 11:00:45 -0700 (PDT) +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to + :references; + bh=j/6j5jXpn5apxoH0sd96oVb5Dx5qrbvUS0dtuyyQAjQ=; + b=XCZnWQ6m7S5GuewBDK1hSahNU9s5FKw4CA6s2F+eLzeR3VU/Qivl2SRcL8VI0kA3aH + 61DVS0uZIhmyKu663kDNgyTRUhU33ikoN7KTAfogSbXlw821Sx9MiNfav/bwoJI+pBxD + HFvwqu0+ivudyDz8h1wzJog7i7frn1tjHiOm8z3abmdFXn2VA4PMip1iGXIRd61S+qr2 + +2iqYNK05Q8MpxFYTtnSS8i1snROFmLnzDHdQqPvgm/HSR+YY1POQAym46wGXceNMqKC + 6MLs8wF/+1zDFR0SYniu5ZQwNDGoQ7PJteZxKQlGvUKI+4aFFIPlNcblbHRQ6HWNIVVU + kvFA== +X-Gm-Message-State: + ALoCoQmI+OWS34dc9gKSLxeDkoNtVmKF0SpydCOC0MHhFrxRNJzMcnbK65EaP9o3yqUDkR1ZQCvU +X-Received: by 10.194.134.40 with SMTP id ph8mr6533103wjb.147.1431194444264; + Sat, 09 May 2015 11:00:44 -0700 (PDT) +Received: from localhost (mobile-access-bcee39-176.dhcp.inet.fi. + [188.238.57.176]) + by mx.google.com with ESMTPSA id r9sm14353192wjo.26.2015.05.09.11.00.43 + (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); + Sat, 09 May 2015 11:00:43 -0700 (PDT) +From: Jani Nikula +To: Tomi Ollila , Jani Nikula , + notmuch@notmuchmail.org +Subject: [PATCH] notmuch-emacs-mua: do not create a frame by default with + --client +Date: Sat, 9 May 2015 21:01:04 +0300 +Message-Id: <1431194464-2595-1-git-send-email-jani@nikula.org> +X-Mailer: git-send-email 2.1.4 +In-Reply-To: +References: +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.18 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Sat, 09 May 2015 18:00:50 -0000 + +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 + +v3: fix --create-frame w/o --client parameter check +--- + doc/man1/notmuch-emacs-mua.rst | 14 +++++++++----- + notmuch-emacs-mua | 30 +++++++++++++++++++++--------- + 2 files changed, 30 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=``\ + 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..102410a23f3e 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,15 @@ 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 ++ if [ -z "$USE_EMACSCLIENT" ]; then ++ echo "$0: --create-frame is only applicable with --client." >&2 ++ exit 1 ++ fi ++ ELISP="${ELISP} (setq message-exit-actions (list #'save-buffers-kill-terminal))" ++fi ++ + # End progn. + ELISP="${ELISP})" + +@@ -132,7 +144,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 + -- 2.26.2