[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Detecting if the Emacs server is running
From: |
Deniz Dogan |
Subject: |
Re: Detecting if the Emacs server is running |
Date: |
Fri, 18 Mar 2011 07:47:55 +0100 |
2011/3/18 PJ Weisberg <pjweisberg@gmail.com>:
> 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