From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rupert Swarbrick Newsgroups: gmane.emacs.help Subject: Re: Start the emacs-server once... Date: Fri, 22 Aug 2008 01:26:42 +0100 Organization: albasani.net Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1219365662 4017 80.91.229.12 (22 Aug 2008 00:41:02 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 22 Aug 2008 00:41:02 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Aug 22 02:41:54 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 1KWKip-0003ks-Mr for geh-help-gnu-emacs@m.gmane.org; Fri, 22 Aug 2008 02:41:48 +0200 Original-Received: from localhost ([127.0.0.1]:48685 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KWKhr-0004KH-FW for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Aug 2008 20:40:47 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newsfeed.straub-nv.de!news.albasani.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 81 Original-X-Trace: news.albasani.net XJx1vnf0nV7hM3uMYTGGbsORiXQ6/kzbC4pJBwZY/ligqzQ2v94gJtEzdfbvMPdzofO/z4VtGoiPOlfOQUSDrTfC1S9Hl1/jYzi00YWYnXISfYoUxS7xQQiLXZDSMKfV Original-X-Complaints-To: abuse@albasani.net Original-NNTP-Posting-Date: Fri, 22 Aug 2008 00:26:45 +0000 (UTC) X-User-ID: OF/uIGmmkv/n5+saHRZMZMicSkFex9JrbBCGd0sgAhk= Cancel-Lock: sha1:zAFyLzDH64R+DKzCmLcVD+DYhUM= User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux) X-NNTP-Posting-Host: tm8i7s5eY4w+aaF3VpaU2PatbZbM4fLIcdk4seCm8eo= Original-Xref: news.stanford.edu gnu.emacs.help:161526 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:56869 Archived-At: --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Alex Bennee writes: > 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? > You might be interested in the page on the emacswiki about this [1]. My config is detailed on there (along with lots of other peoples' solutions!). The one thing that I use that I really like is a function called delete-frame-ex, which is hopefully below --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=delete-frame-ex.el (defun buffer-used-elsewhere-p (&optional buf) "Returns true if more than one window is attached to BUF in all frames. If buf is nil or not supplied, search for (CURRENT-BUFFER)." (unless buf (setq buf (current-buffer))) (< 1 (length (get-buffer-window-list buf nil t)))) (defun delete-frame-ex () "Delete frame as normal, unless we're on the last frame, in which case, exit emacs as we would normally do" (interactive) (if (eq (selected-frame) (next-frame (selected-frame) 0)) ;; This is the last frame (save-buffers-kill-emacs) ;; There's more! (unless (buffer-used-elsewhere-p) (kill-buffer nil)) (delete-frame))) --=-=-= I bind this to C-x C-c, which means that you can call the "magic emacs" command on a load of files, edit them in different frames and when you hit C-x C-c, you don't kill something you were working on in a different desktop. For me, this is at least as important as spawning the frames in the first place! Rupert [1] http://www.emacswiki.org/cgi-bin/wiki/GnuClient --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iJwEAQECAAYFAkiuB8MACgkQRtd/pJbYVoYJJwP/eJWoBhyzL13PWYiqaNhJnUJw 5sYokh1HwhHL9ZN84rjjWfi3QK65RD4+jD4QxMafQ9BepsnJaG3f8ZENk6Sh14Mm mDSdJZ8F52zpHYpFqQfdU7toK7GdEYNtfsBO/nmoaV9WWMNuBrx/1s6ZT2cjmY8d adM+Tjg0M73rUJp5diE= =caCu -----END PGP SIGNATURE----- --==-=-=--