help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: server-start preempted by other emacs window


From: Klaus Zeitler
Subject: Re: server-start preempted by other emacs window
Date: 29 Jan 2004 08:19:59 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>>>>> "John" == John Russell <jorussel@cisco.com> 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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]