From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Reuben Thomas Newsgroups: gmane.emacs.bugs Subject: Re: How to run server-start only if not already running? Date: Tue, 6 Nov 2007 23:46:01 +0000 (GMT) Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Trace: ger.gmane.org 1194392788 29289 80.91.229.12 (6 Nov 2007 23:46:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 6 Nov 2007 23:46:28 +0000 (UTC) Cc: Emacs Bugs To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Nov 07 00:46:31 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 1IpY7n-0002LP-Td for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 Nov 2007 00:46:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpY7c-0006cP-Nc for geb-bug-gnu-emacs@m.gmane.org; Tue, 06 Nov 2007 18:46:16 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IpY7W-0006aW-QO for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2007 18:46:10 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IpY7V-0006ZS-F1 for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2007 18:46:10 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IpY7V-0006ZK-01 for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2007 18:46:09 -0500 Original-Received: from pelican.sc3d.org ([216.184.201.86]) by monty-python.gnu.org with esmtps (SSL 3.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IpY7T-0002cL-6y for bug-gnu-emacs@gnu.org; Tue, 06 Nov 2007 18:46:07 -0500 DomainKey-Signature: a=rsa-sha1; s=key1024; d=sc3d.org; c=nofws; q=dns; b=hdZlxuhkru2xuOHDs73LircHR7GediP6Hh9q2Ks/0+VLJBQnPkZDxPLfpEpUxhDLl+zX/IFsdQ+zsT8z7Ai9YTi0sV46jEADHhcjc6yiQeuk2fFtby1P8oYT+KieSK0Hu2DoFqoXIgl9as/O3YcS2uX/DQYPUzx8letYpe3TfvU= Original-Received: from localhost (cpc4-hitc1-0-0-cust477.lutn.cable.ntl.com [86.11.13.222]) by pelican.sc3d.org (pf ESMTP spamd IP-based SPAM blocker) with ASMTP (SSL) id LIA68704; Tue, 06 Nov 2007 18:46:04 -0500 X-X-Sender: rrt@localhost.localdomain In-Reply-To: X-detected-kernel: by monty-python.gnu.org: Windows 2000 SP4, XP SP1+ 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:16930 Archived-At: On Wed, 7 Nov 2007, Andreas Schwab wrote: > (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) I needed to add (require 'server) to the start. After that it does exactly what I want, thanks. -- http://rrt.sc3d.org/ | punline, n. a punch line that really hurts