From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Deniz Dogan Newsgroups: gmane.emacs.help Subject: Re: Detecting if the Emacs server is running Date: Fri, 18 Mar 2011 07:47:55 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1300430931 10513 80.91.229.12 (18 Mar 2011 06:48:51 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 18 Mar 2011 06:48:51 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: PJ Weisberg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 18 07:48:47 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q0TUM-0005Ny-5V for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Mar 2011 07:48:46 +0100 Original-Received: from localhost ([127.0.0.1]:52329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q0TUL-00044B-HN for geh-help-gnu-emacs@m.gmane.org; Fri, 18 Mar 2011 02:48:45 -0400 Original-Received: from [140.186.70.92] (port=33452 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q0TTv-000446-U6 for help-gnu-emacs@gnu.org; Fri, 18 Mar 2011 02:48:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q0TTt-0005te-Sc for help-gnu-emacs@gnu.org; Fri, 18 Mar 2011 02:48:19 -0400 Original-Received: from mail-iy0-f169.google.com ([209.85.210.169]:34409) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q0TTt-0005tU-PS for help-gnu-emacs@gnu.org; Fri, 18 Mar 2011 02:48:17 -0400 Original-Received: by iyf13 with SMTP id 13so4547147iyf.0 for ; Thu, 17 Mar 2011 23:48:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=c06ZC7LWXI80+Vqx94dr9CDhUpjNE068ZSxdimcyLV4=; b=MkcHburyBQPVwPKDGqeXAiSSe4jGQPsXo1XAVQNPZvpUx2dFU5MZAm3dc70r3w0BCb Aa+d0qDfS1QBVWs986TFdNLZms8ktVBX4EGhNUoIzjbuXDyZq+5iLmQFoD+RmHWU/L/L 7lkYph0vLv1c0Ihrfa2oPIt5U3jVHBl4pHUko= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=U+2ZUSEzWbxlraAcQijaE5AmFhxo4DCtxBHczy6URsFdq85TaEhKCn3LFk3EIC0JIB Jiw1yARki+uF1e5U8BWKsX2SuIojvGcDVldss12YZjFoXBp46leU3J27e5wqs6uTNhcB KeDW476anWbBdquAasYzHmOURmk8bBOsyqMdE= Original-Received: by 10.231.82.70 with SMTP id a6mr615255ibl.165.1300430896897; Thu, 17 Mar 2011 23:48:16 -0700 (PDT) Original-Received: by 10.231.199.77 with HTTP; Thu, 17 Mar 2011 23:47:55 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.169 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:80221 Archived-At: 2011/3/18 PJ Weisberg : > Is there a way, in GNU/Linux, to detect whether Emacs is running in > server mode from a shell script? > > I'd like to write a script that creates a new frame with emacsclient > if the user is already running an emacs server, but just starts up a > regular Emacs instance if he isn't. > See e.g. (info "(emacs) emacsclient Options"). The other optional arguments recognized by `emacsclient' are listed below: `-a COMMAND' `--alternate-editor=COMMAND' Specify a command to run if `emacsclient' fails to contact Emacs. This is useful when running `emacsclient' in a script. For example, the following setting for the `EDITOR' environment variable will always give you an editor, even if no Emacs server is running: EDITOR="emacsclient --alternate-editor emacs +%d %s" As a special exception, if COMMAND is the empty string, then `emacsclient' starts Emacs in daemon mode and then tries connecting again. The environment variable `ALTERNATE_EDITOR' has the same effect as the `-a' option. If both are present, the latter takes precedence. -- Deniz Dogan