From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.bugs Subject: Re: How to run server-start only if not already running? Date: Wed, 07 Nov 2007 00:35:47 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1194392174 27505 80.91.229.12 (6 Nov 2007 23:36:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 6 Nov 2007 23:36:14 +0000 (UTC) Cc: Emacs Bugs To: Reuben Thomas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 07 00:36:17 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IpXxs-0007t6-30 for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Nov 2007 00:36:12 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpXxh-0001j0-4O for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Nov 2007 18:36:01 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IpXxb-0001ht-D9 for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2007 18:35:55 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IpXxZ-0001hh-1c for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2007 18:35:54 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpXxY-0001he-RL for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2007 18:35:52 -0500 Original-Received: from ns.suse.de ([195.135.220.2] helo=mx1.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IpXxX-0007Pe-Vp for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2007 18:35:52 -0500 Original-Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 536091891D; Wed, 7 Nov 2007 00:35:48 +0100 (CET) X-Yow: NOW, I'm taking the NEXT FLIGHT to ACAPULCO so I can write POEMS about BROKEN GUITAR STRINGS and sensuous PRE-TEENS!! In-Reply-To: (Reuben Thomas's message of "Tue\, 6 Nov 2007 21\:41\:42 +0000 \(GMT\)") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.1 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:16927 Archived-At: Reuben Thomas writes: > Sometimes, normally by error, I start a second Emacs. Since my .emacs r= uns > server-start, this overrides the server I run in my normally-running > Emacs. After quitting the erroneously-started Emacs, I no longer have a > server and need manually to restart it. Is there some way to run > server-start in my .emacs only if there's no server currently? It'd be > nice to make this easy! I'm using this: (when (and (file-exists-p (expand-file-name server-name server-socket-dir= )) (let ((status (call-process "/usr/bin/lsof" nil nil nil (expand-file-name server-name server-socket-dir)))) (or (not (numberp status)) (equal status 0)))) (setq server-name (format "%s-%d" server-name (emacs-pid))) (add-hook 'kill-emacs-hook (lambda () (condition-case nil (delete-file (expand-file-name server-name server-socket-dir)) (error nil))))) (server-start) > Possibly alternatively, it'd be nice to enable emacsclient to start a > server process if there's already a running Emacs but no server running= in > it. Kinda chicken-and-egg: how do you contact the running Emacs without the server? Andreas. --=20 Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstra=DFe 5, 90409 N=FCrnberg, Germany PGP key fingerprint =3D 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED= 5 "And now for something completely different."