From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Thorsten Bonow Newsgroups: gmane.emacs.help Subject: Re: server-start preempted by other emacs window Date: Thu, 29 Jan 2004 19:39:10 +0100 Organization: Aachen University of Technology (RWTH) Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <87ad46ob01.fsf@herrrossi.mmweg.rwth-aachen.de> References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1075402180 371 80.91.224.253 (29 Jan 2004 18:49:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 29 Jan 2004 18:49:40 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 29 19:49:33 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AmHEK-0005BU-00 for ; Thu, 29 Jan 2004 19:49:33 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AmHBy-00066S-Eh for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jan 2004 13:47:06 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news.rwth-aachen.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 58 Original-NNTP-Posting-Host: s3m086.dialup.rwth-aachen.de Original-X-Trace: nets3.rz.RWTH-Aachen.DE 1075401551 26496 137.226.7.86 (29 Jan 2004 18:39:11 GMT) Original-X-Complaints-To: abuse@rwth-aachen.de Original-NNTP-Posting-Date: 29 Jan 2004 18:39:11 GMT User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Rational FORTRAN, linux) Cancel-Lock: sha1:7yXCVo9WygC2sUwI0Z+GUKsSLTQ= Original-Xref: shelby.stanford.edu gnu.emacs.help:120571 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:16517 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:16517 >>>>> "Stefan" == Stefan Monnier writes: >> Is there a way to have emacs check to see if another server >> process is running before it runs server-start? Stefan> Not really. It's pretty tricky to do. One way is to see Stefan> if the socket file is present in /tmp. But then it might Stefan> be left over from a previous Emacs that's not running any Stefan> more. You could try and make sure that Emacs removes the Stefan> socket file when it exits, but if it crashes, you're still Stefan> left with a dead socket in /tmp. A more robust way is to Stefan> check whether you can connect to the socket. In Emacs-CVS Stefan> you could do that with make-network-stream. Stefan> [...] Stefan> Stefan Hi, this was discussed before. I could not find the thread, but since then I have this solution in my .emacs to prevent starting a second server if one is already running: --- cut here --- ;; ** emacsclient (defun my-server-start-filter-function (process output) "Filter function for `my-server-start', which checks for an accessible Emacs process acting as a server by calling `emacsclient --eval t' as an external asynchronous process. Process output is filtered by this function which only calls `server-start' when no server is running, id est the call to emacsclient has failed." (if (equal output "t\n") (message "Not starting server, one instance already running...") (message "Starting server...") (server-start))) ;; (defun my-server-start () "Call `server-start' only if no other accessible Emacs process is already acting as a server for client processes." (let ((process-connection-type nil)) (set-process-filter (start-process "my-process" nil "emacsclient" "--eval" "t") 'my-server-start-filter-function))) ;; (my-server-start) --- cut here --- Toto -- Contact information and PGP key at http://www-users.rwth-aachen.de/thorsten.bonow Daydreaming while smoking cigars can be a fire hazard. It can be as dangerous as drugs and booze unless you know what you're doing. If you know what you're doing, it can be as safe as walking down the street. Friedman, Kinky (1993), When the cat's away. New York (Wings Books), 418