[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Check for other running emacs sessions?
From: |
Pascal Bourguignon |
Subject: |
Re: Check for other running emacs sessions? |
Date: |
Thu, 06 Apr 2006 01:39:57 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
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!"