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