From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "adrian@cam.cornell.edu" Newsgroups: gmane.emacs.help Subject: Detecting active server from the shell Date: Tue, 14 Aug 2007 14:59:45 -0700 Organization: http://groups.google.com Message-ID: <1187128785.757502.132420@d55g2000hsg.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1187161063 17223 80.91.229.12 (15 Aug 2007 06:57:43 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 15 Aug 2007 06:57:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 15 08:57:42 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ILCp3-0006Wz-Ez for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Aug 2007 08:57:41 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ILCp2-0006xl-QY for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Aug 2007 02:57:40 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!d55g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 63 Original-NNTP-Posting-Host: 70.177.186.110 Original-X-Trace: posting.google.com 1187128785 27572 127.0.0.1 (14 Aug 2007 21:59:45 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 14 Aug 2007 21:59:45 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.5) Gecko/20070719 Iceweasel/2.0.0.5 (Debian-2.0.0.5-0etch1+lenny1),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: d55g2000hsg.googlegroups.com; posting-host=70.177.186.110; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Original-Xref: shelby.stanford.edu gnu.emacs.help:150971 X-Mailman-Approved-At: Wed, 15 Aug 2007 02:56:19 -0400 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:46552 Archived-At: I upgraded to emacs 22.1.1. I have been using a script that I derived from the emacs.bash script which comes with emacs. My old script's test for the presence of an emacs server fails. The script packaged with my new emacs installation doesn't work either. The file /tmp/ emacs${UID}/server ALWAYS exists, even after I shut down emacs. So the script always runs the client even when no server is present. How can I tell if there is an active server? ## This defines a bash command named `edit' which contacts/resumes an ## existing emacs or starts a new one if none exists. ## One way or another, any arguments are passed to emacs to specify files ## (provided you have loaded `resume.el'). ## This function assumes the emacs program is named `emacs' and is somewhere ## in your load path. If either of these is not true, the most portable ## (and convenient) thing to do is to make an alias called emacs which ## refers to the real program, e.g. ## ## alias emacs=/usr/local/bin/gemacs function edit () { local windowsys="${WINDOW_PARENT+sun}" windowsys="${windowsys:-${DISPLAY+x}}" if [ -n "${windowsys:+set}" ]; then # Do not just test if these files are sockets. On some systems # ordinary files or fifos are used instead. Just see if they exist. if [ -e "${HOME}/.emacs_server" -o -e "/tmp/emacs${UID}/server" ]; then emacsclient "$@" return $? else echo "edit: starting emacs in background..." 1>&2 fi case "${windowsys}" in x ) (emacs "$@" &) ;; sun ) (emacstool "$@" &) ;; esac else if jobs %emacs 2> /dev/null ; then echo "$(pwd)" "$@" >| ${HOME}/.emacs_args && fg %emacs else emacs "$@" fi fi } # arch-tag: 1e1b74b9-bf2c-4b23-870f-9eebff7515cb ### emacs.bash ends here ~ ~