From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: jari.aalto@poboxes.com (Jari Aalto+mail.linux) Newsgroups: gmane.emacs.help Subject: Re: server-start preempted by other emacs window Date: Sun, 08 Feb 2004 11:50:14 +0200 Organization: Private Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <87ad46ob01.fsf@herrrossi.mmweg.rwth-aachen.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1076233630 30978 80.91.224.253 (8 Feb 2004 09:47:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 8 Feb 2004 09:47:10 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 08 10:47:05 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 1AplWr-0006wx-00 for ; Sun, 08 Feb 2004 10:47:05 +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 1AplVT-0007xd-Bj for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Feb 2004 04:45:39 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!bloom-beacon.mit.edu!news2.telebyte.nl!newshub1.home.nl!home.nl!news.cambrium.nl!news.cambrium.nl!fi.sn.net!newsfeed2.fi.sn.net!newsfeed.kolumbus.fi!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 53 Original-NNTP-Posting-Host: a110t7.elisa.omakaista.fi Original-X-Trace: phys-news1.kolumbus.fi 1076233148 5069 81.197.3.110 (8 Feb 2004 09:39:08 GMT) Original-X-Complaints-To: abuse@kolumbus.fi Original-NNTP-Posting-Date: Sun, 8 Feb 2004 09:39:08 +0000 (UTC) User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (windows-nt) (i386-msvc-nt5.0.2195) Cancel-Lock: sha1:VxVkquezy+40Rb0bWZYjfnfK1rU= Original-Xref: shelby.stanford.edu gnu.emacs.help:120759 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:16707 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:16707 * Thu 2004-01-29 Thorsten Bonow post.rwth-aachen.de> * | >>>>> "Stefan" == Stefan Monnier iro.umontreal.ca> writes: | 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) Unfortunately the emacsclient that Cygwin or Debian provides, does not know --eval option. The above code fails, because the filter function expects "t\n", when the real output is: /bin/emacsclient: unrecognized option `--eval' Usage: /bin/emacsclient [-a ALTERNATE-EDITOR] [-n] [--no-wait] [+LINE[:COLUMN]]\ FILENAME Or /bin/emacsclient --version Report bugs to bug-gnu-emacs gnu.org. It seems to be impossible to make and automatic test to see if one Emacs is already running as server. Stefan's remark to upcoming network connection functions offers a solution. Jari -- http://tiny-tools.sourceforge.net/ Swatch @time http://www.mir.com.my/iTime/itime.htm http://www.ryanthiessen.com/swatch/resources.htm Use Licenses! http://www.linuxjournal.com/article.php?sid=6225 Which Licence? http://www.linuxjournal.com/article.php?sid=4825 OSI Licences http://www.opensource.org/licenses/