From: jari.aalto@poboxes.com (Jari Aalto+mail.linux)
Subject: Re: server-start preempted by other emacs window
Date: Sun, 08 Feb 2004 11:50:14 +0200 [thread overview]
Message-ID: <isih5295.fsf@blue.sea.net> (raw)
In-Reply-To: 87ad46ob01.fsf@herrrossi.mmweg.rwth-aachen.de
* Thu 2004-01-29 Thorsten Bonow <thorsten.bonow <AT> post.rwth-aachen.de>
* <http://groups.google.com/groups?oi=djq&as_umsgid=%3C87ad46ob01.fsf@herrrossi.mmweg.rwth-aachen.de>
| >>>>> "Stefan" == Stefan Monnier <monnier <AT> 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 <AT> 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/
next prev parent reply other threads:[~2004-02-08 9:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-28 16:34 server-start preempted by other emacs window John Russell
2004-01-28 18:33 ` Stefan Monnier
2004-01-28 20:33 ` John Russell
2004-01-29 16:52 ` Stefan Monnier
2004-01-29 18:39 ` Thorsten Bonow
2004-01-29 21:11 ` kgold
2004-02-08 9:50 ` Jari Aalto+mail.linux [this message]
2004-01-28 18:43 ` Kevin Rodgers
2004-01-28 20:31 ` John Russell
2004-01-29 7:19 ` Klaus Zeitler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=isih5295.fsf@blue.sea.net \
--to=jari.aalto@poboxes.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).