From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thorsten Bonow Newsgroups: gmane.emacs.help Subject: Re: automatic selection of emacsclient/emacs? Date: Wed, 08 Jun 2005 10:00:58 +0200 Message-ID: <87k6l5e0qt.fsf@herrrossi.mmweg.rwth-aachen.de> References: <2cydneqEPbdzxTvfRVn-uw@speakeasy.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1118218361 692 80.91.229.2 (8 Jun 2005 08:12:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 8 Jun 2005 08:12:41 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Jun 08 10:12:38 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DfveQ-0004f7-Ue for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Jun 2005 10:11:03 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dfvl6-0006fB-Rc for geh-help-gnu-emacs@m.gmane.org; Wed, 08 Jun 2005 04:17:57 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!fu-berlin.de!uni-berlin.de!news.dfncis.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 62 Original-X-Trace: news.dfncis.de 9+iaiDwDzUnAcgK8fG145Qv2IWXlJPosloknudErpP9VdrtRCS6uyq32Cq User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:kYvcc3lZjR6uqgRIvHPjRWTZvzE= Original-Xref: shelby.stanford.edu gnu.emacs.help:131870 Original-To: help-gnu-emacs@gnu.org 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:27338 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:27338 >>>>> "Hattuari" == Hattuari 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. Hi, 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 you're 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. Toto -- Contact information and PGP key at http://www-users.rwth-aachen.de/thorsten.bonow [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.