[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: automatic selection of emacsclient/emacs?

From: Thorsten Bonow
Subject: Re: automatic selection of emacsclient/emacs?
Date: Wed, 08 Jun 2005 10:00:58 +0200
User-agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux)

>>>>> "Hattuari" == Hattuari  <address@hidden> writes:

    Hattuari> Is there a clean way to get Emacs to start as a client when there
    Hattuari> is an available server?  I find it moderately annoying to have to
    Hattuari> look around to see if there is already an instance of Emacs
    Hattuari> started in order to determine if I should enter `emacs' or
    Hattuari> `emacsclient'. I much prefer running emacsclient when I already
    Hattuari> have one instance of Emacs running.  One option is to try and
    Hattuari> sniff for emacs with ps and filter out the current processes such
    Hattuari> as grep emacs, and (assuming the script I'm running is also called
    Hattuari> emacs) the launch script.


this has been asked before and several solutions/approaches have been
posted. Try googling around for them.

One is already coming with GNU Emacs: There are emacs.bash/emacs.csh scripts in
the etc sub-directory of the source tree which should do in principal what 
trying to achieve.

    Hattuari> It would seem more correct to directly check to see if the service
    Hattuari> is available.  Is there such a capability?

For this you could try something like

    emacsclient --eval t > /dev/null 2>&1
    echo $?

The exit status $? is only 0 if the client was able to connect to an running
emacs server.

Hope this helps.

For ages now I'm working on a little script which tries to solve this problem in
a more general way (supporting both GNU Emacs/emacsclient and XEmacs/gnuclient),
making it possible to start a mail/news reader from it, open up a new frame/tty
etc. Never got around finishing it since leaving university [7 years ago :-)]

It's basically working, but not nearly finished. If you're interested I can mail
it to you.


Contact information and PGP key at

[Featured Creature]

NAME: Oscar the Grouch

BIO/STATS: Built in 1969, Oscar was originally orange but was changed
           to green very early in his career. He was the first grouch
           in what is now a very large family of grouches.

APPEARANCES: Sesame Street, The Adventures of Elmo in Grouchland, and
             many specials and home videos.

FAMOUS FOR: Living in a trashcan and having a pet elephant and worm.

SPECIAL TALENTS: Being Grouchy, says "Go Away!" losing his patience.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]