[Top][All Lists]

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

Re: server-start preempted by other emacs window

From: Jari Aalto+mail.linux
Subject: Re: server-start preempted by other emacs window
Date: Sun, 08 Feb 2004 11:50:14 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (windows-nt) (i386-msvc-nt5.0.2195)

* Thu 2004-01-29 Thorsten Bonow <thorsten.bonow <AT>>
* <>
| >>>>> "Stefan" == Stefan Monnier <monnier <AT>> 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] 
    Or /bin/emacsclient --version                                               
    Report bugs to bug-gnu-emacs <AT> 

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.


Swatch @time
Use Licenses!
Which Licence?
OSI Licences

reply via email to

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