From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: Check for other running emacs sessions? Date: Thu, 06 Apr 2006 01:39:57 +0200 Organization: Informatimago Message-ID: <87bqvfbnhu.fsf@thalassa.informatimago.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1144280516 25188 80.91.229.2 (5 Apr 2006 23:41:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 5 Apr 2006 23:41:56 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 06 01:41:49 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FRHcJ-0008Tq-6t for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Apr 2006 01:40:51 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FRHcI-0007LY-QJ for geh-help-gnu-emacs@m.gmane.org; Wed, 05 Apr 2006 19:40:50 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 69 Original-X-Trace: individual.net UaUmElpB+pYY6oqXfQ/cNAGnHjkYP5bAkgjV+rCERI2yYed/F0 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:szPNPHWUX/mD9txM6oRc4pgrXxA= Original-Xref: shelby.stanford.edu gnu.emacs.help:138559 Original-To: help-gnu-emacs@gnu.org 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:34177 Archived-At: noreply@u.wasshington.edu writes: > I typically have three different instances of emacs running at the > same time. I'd like to put something in my .emacs file to check if > another instance is running and if so, not do something > (activate-appt). I haven't been able to find anything on it, but > perhaps I'm not using the right terms. Is there a way to do this in > emacs, or should I call a shell script that greps for 'emacs' in ps > output? Here is what I do: - I launch my various emacs with different command line arguments: ---(erc)---------------------- #!/bin/bash EMACS=/usr/local/bin/emacs export EMACS_BG=\#fcccfefeebb7 exec $EMACS --eval "(irc)" ---(gnus)---------------------- #!/bin/bash EMACS=/usr/local/bin/emacs export EMACS_BG=\#ccccfefeebb7 exec $EMACS --eval "(gnus)" ------------------------------- - in ~/.emacs, I test command-line-args to detect which emacs is running: (defvar pjb:+pvs-is-running+ ) (cond ((and (boundp 'x-resource-name) (string-equal x-resource-name "pvs")) ;; pvs uses emacs as user interface, but launches it with a different X ;; resource name. ;; --> do nothing more. ) ((member "(gnus)" command-line-args) (milliways-schedule (lambda () (set-frame-name "GNUS"))) (set-background-color "#ccccfefeebb7") (setf *frame-server-job-ticket* "~/frame-gnus")) ((member "(irc)" command-line-args) (milliways-schedule (lambda () (set-frame-name "ERC"))) (setf *frame-server-job-ticket* "~/frame-erc")) (t ; normal emacs (milliways-schedule (lambda () (set-frame-name "PGM"))) (server-start) (setf (getenv "CVSEDITOR") "emacsclient" (getenv "EDITOR") "emacsclient" (getenv "VISUAL") "emacsclient") (setf *frame-server-job-ticket* "~/frame-emacs"))) ----------------------------------------- You could try to process ps output, but be careful that other users may be running their own instances of emacs! -- __Pascal Bourguignon__ http://www.informatimago.com/ "You question the worthiness of my code? I should kill you where you stand!"