From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Klaus Zeitler Newsgroups: gmane.emacs.help Subject: Re: server-start preempted by other emacs window Date: 29 Jan 2004 08:19:59 +0100 Organization: Lucent Technologies Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1075361507 5266 80.91.224.253 (29 Jan 2004 07:31:47 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 29 Jan 2004 07:31:47 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 29 08:31:40 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 1Am6eK-0003fm-00 for ; Thu, 29 Jan 2004 08:31:40 +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 1Am6di-0003Cu-Ub for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Jan 2004 02:31:03 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!info1.fnal.gov!nntp-server.caltech.edu!news.uchicago.edu!yellow.newsread.com!netaxs.com!newsread.com!feed1.newsreader.com!newsreader.com!zeus.visi.com!news-out.visi.com!petbe.visi.com!ash.uu.net!netnews.proxy.lucent.com!news Original-Newsgroups: gnu.emacs.help Original-Lines: 57 Original-NNTP-Posting-Host: sfsw51.de.lucent.com X-Windows: the first fully modular software disaster. User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 Original-Xref: shelby.stanford.edu gnu.emacs.help:120555 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:16501 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:16501 >>>>> "John" == John Russell writes: John> John> Is there a way to have emacs check to see if another server process John> is running before it runs server-start? John> John> My issue is that if I have one emacs window open (my IDE) and then I'm not sure what you mean with window here. I guess you mean a 2nd emacs. For emacs a window is something different. John> open another one for gnus, the last one opened always destroys any John> server process in existence. So all emacsclient calls go to the gnus John> window, and when that window gets closed, there is no longer any John> server running at all. I've been using the following for years. I'm using gnuserv/gnudoit instead of the standard emacsclient. It's been a long time that I've used emacsclient, and IIRC old versions could only accept a file and no elisp code. I think that was the reason why I switched to gnuserv/gnudoit. Thus I'm not sure if one can do this similar with emacsclient. I think at least CVS emacs has an improved emacsclient. ;; The following function allows to check if a server process is already running ;; (in case we start more than one emacs) (defun gnuserv-running-p () "Checks whether a useful gnuserv is already running" (let ((output "") (proc (condition-case () (start-process "gnudoit" nil "gnudoit" "1234") (error nil)))) (if proc (progn (set-process-filter proc (function (lambda (proc string) (setq output (concat output string))))) ;; wait for output from gnudoit with a timeout of 4 seconds (accept-process-output proc 4) (set-process-filter proc nil) ;;(message "server check returns: '%s'" output) (eq (string-match "1234" output) 0))))) (if (gnuserv-running-p) (message "Server is already running") (gnuserv-start)) HTH Klaus -- ------------------------------------------ | Klaus Zeitler Lucent Technologies | ------------------------------------------ --- My opinions may have changed, but not the fact that I am right.