From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Allan Gottlieb Newsgroups: gmane.emacs.help Subject: Re: Start the emacs-server once... Date: Thu, 21 Aug 2008 10:41:55 -0400 Message-ID: References: <1219319700.30257.0.camel@pitcairn.cambridgebroadband.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1219329652 8578 80.91.229.12 (21 Aug 2008 14:40:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Aug 2008 14:40:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Aug 21 16:41:45 2008 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 1KWBLA-0001xj-Bj for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 16:40:44 +0200 Original-Received: from localhost ([127.0.0.1]:53533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWBKC-0000ON-V5 for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 10:39:44 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KWBJk-0000K2-8O for help-gnu-emacs@gnu.org; Thu, 21 Aug 2008 10:39:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KWBJg-0000HA-Dl for help-gnu-emacs@gnu.org; Thu, 21 Aug 2008 10:39:15 -0400 Original-Received: from [199.232.76.173] (port=35468 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWBJg-0000H7-86 for help-gnu-emacs@gnu.org; Thu, 21 Aug 2008 10:39:12 -0400 Original-Received: from smtp.cs.nyu.edu ([128.122.80.33]:41722) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KWBJf-0006N7-GQ for help-gnu-emacs@gnu.org; Thu, 21 Aug 2008 10:39:11 -0400 Original-Received: from ajglap.localdomain (ool-4578d291.dyn.optonline.net [69.120.210.145]) (authenticated bits=0) by smtp.cs.nyu.edu (8.14.3/8.13.8) with ESMTP id m7LEdAqZ021866 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Thu, 21 Aug 2008 10:39:10 -0400 (EDT) Original-Received: by ajglap.localdomain (Postfix, from userid 1502) id BC47619D931; Thu, 21 Aug 2008 10:41:55 -0400 (EDT) In-Reply-To: <1219319700.30257.0.camel@pitcairn.cambridgebroadband.com> (Alex Bennee's message of "Thu\, 21 Aug 2008 12\:55\:00 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Solaris 10 (beta) 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:56851 Archived-At: At Thu, 21 Aug 2008 12:55:00 +0100 Alex Bennee wrote: > Hi, > > I want to set-up emacs to start the server once per X sessions (and I > guess once per screen session once I get multi-tty working). However > there doesn't seem to be way to check in emacs if the server is > currently running. > > So far the best I can come up with is having my start-up emacs with the > args: > > emacs --eval (defvar this-is-the-master t) > > And appropriate hackery in the .emacs. Is there a nicer way to deal with > this? I don't know if it is nicer (I suspect it is similar) but I use the following so that the invocation of emacs is not changed. ;; Use emacsclient/emacsserver ;; ;; Using code from Tassilo Horn so a server started on first emacs only ;; The code should remove the file when the server ends. ;; Sometimes the file remains (why?) so I explicitly invoke the removal ;; function from ~/bin/Xinitialize. (defvar ajg-server-lock-file "~/.emacs.d/server.lock" "Emacs server lock file.") (defun ajg-server-start () (interactive) (shell-command (concat "touch " ajg-server-lock-file)) (server-start) (message "Emacs Server started...") (setq frame-title-format '("Emacs (Server): %b <%f>"))) (if (and (not (file-exists-p ajg-server-lock-file)) (not noninteractive)) (ajg-server-start) (message "Emacs Server NOT started, because lockfile exists.") (setq frame-title-format '("Emacs: %b <%f>"))) (defun ajg-server-remove-lock-file () (interactive) (when (boundp 'server-process) (shell-command (concat "rm " ajg-server-lock-file)))) ;; Remove lock file when emacs server ends (add-hook 'kill-emacs-hook 'ajg-server-remove-lock-file) HTH allan