all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Check for other running emacs sessions?
@ 2006-04-05 23:11 noreply
  2006-04-05 23:39 ` Pascal Bourguignon
  2006-04-06 12:49 ` kgold
  0 siblings, 2 replies; 7+ messages in thread
From: noreply @ 2006-04-05 23:11 UTC (permalink / raw)


Hello,

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?

Thank you for any thoughts or suggestions.

Brian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Check for other running emacs sessions?
  2006-04-05 23:11 Check for other running emacs sessions? noreply
@ 2006-04-05 23:39 ` Pascal Bourguignon
  2006-04-06 12:49 ` kgold
  1 sibling, 0 replies; 7+ messages in thread
From: Pascal Bourguignon @ 2006-04-05 23:39 UTC (permalink / raw)


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!"

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Check for other running emacs sessions?
  2006-04-05 23:11 Check for other running emacs sessions? noreply
  2006-04-05 23:39 ` Pascal Bourguignon
@ 2006-04-06 12:49 ` kgold
  2006-04-06 14:00   ` Lennart Borgman
       [not found]   ` <mailman.122.1144332075.9609.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 7+ messages in thread
From: kgold @ 2006-04-06 12:49 UTC (permalink / raw)


A better solution is to run only one emacs server and connect multiple 
clients to it.  That is, start gnuserv as part of your login script. 
Use gnuclient to edit files.

The main advantage is that the client starts much faster than the server.

noreply@u.wasshington.edu wrote:
> Hello,
> 
> 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?
> 
> Thank you for any thoughts or suggestions.
> 
> Brian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Check for other running emacs sessions?
  2006-04-06 12:49 ` kgold
@ 2006-04-06 14:00   ` Lennart Borgman
  2006-04-06 16:32     ` Reiner Steib
       [not found]   ` <mailman.122.1144332075.9609.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Lennart Borgman @ 2006-04-06 14:00 UTC (permalink / raw)
  Cc: help-gnu-emacs

kgold wrote:
> A better solution is to run only one emacs server and connect multiple 
> clients to it.  That is, start gnuserv as part of your login script. 
> Use gnuclient to edit files.
>
> The main advantage is that the client starts much faster than the server.

Another advantage is that you can not by mistake open a file twice.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Check for other running emacs sessions?
  2006-04-06 14:00   ` Lennart Borgman
@ 2006-04-06 16:32     ` Reiner Steib
  0 siblings, 0 replies; 7+ messages in thread
From: Reiner Steib @ 2006-04-06 16:32 UTC (permalink / raw)


On Thu, Apr 06 2006, Lennart Borgman wrote:

> Another advantage is that you can not by mistake open a file twice.

When I try to edit a file in two Emacs sessions, I get:

,----
| gnus-fun.el locked by ste@bridgekee... (pid 19380): (s, q, p, ?)?
`----

,----
| It has been detected that you want to modify a file that someone else has
| already started modifying in EMACS.
| 
| You can <s>teal the file; The other user becomes the
|   intruder if (s)he ever unmodifies the file and then changes it again.
| You can <p>roceed; you edit at your own (and the other user's) risk.
| You can <q>uit; don't modify this file.nil
`----

See the function `ask-user-about-lock'.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Check for other running emacs sessions?
       [not found]   ` <mailman.122.1144332075.9609.help-gnu-emacs@gnu.org>
@ 2006-04-06 20:23     ` noreply
  2006-04-06 21:24       ` Lennart Borgman
  0 siblings, 1 reply; 7+ messages in thread
From: noreply @ 2006-04-06 20:23 UTC (permalink / raw)


Lennart Borgman <lennart.borgman.073@student.lu.se> writes:

> kgold wrote:
>> A better solution is to run only one emacs server and connect
>> multiple clients to it.  That is, start gnuserv as part of your
>> login script. Use gnuclient to edit files.
>>
>> The main advantage is that the client starts much faster than the server.

It is only a good solution to run one emacs and multiple clients if
you don't ever run anything that ties emacs up.  If emacs is doing
something or waiting for a process to complete, you often cannot work
on any other buffers under that instance of emacs.  I don't like not
being able to update my calendar because gnus is checking my mail, for
example.

> Another advantage is that you can not by mistake open a file twice.

This is a disadvantage, but a minor one to me.  I segregate tasks
under different instances of emacs, so it doesn't happen much.

Brian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Check for other running emacs sessions?
  2006-04-06 20:23     ` noreply
@ 2006-04-06 21:24       ` Lennart Borgman
  0 siblings, 0 replies; 7+ messages in thread
From: Lennart Borgman @ 2006-04-06 21:24 UTC (permalink / raw)
  Cc: help-gnu-emacs

noreply@yeahoo.com wrote:
>> Another advantage is that you can not by mistake open a file twice.
>>     
>
> This is a disadvantage, but a minor one to me.  I segregate tasks
> under different instances of emacs, so it doesn't happen much.
>
> Brian
>   
One solution that you perhaps can use is to start a first instance of 
Emacs that runs gnuserv and then from within Emacs start other instances 
that does not run gnuserv. I sometimes do that.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-04-06 21:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-05 23:11 Check for other running emacs sessions? noreply
2006-04-05 23:39 ` Pascal Bourguignon
2006-04-06 12:49 ` kgold
2006-04-06 14:00   ` Lennart Borgman
2006-04-06 16:32     ` Reiner Steib
     [not found]   ` <mailman.122.1144332075.9609.help-gnu-emacs@gnu.org>
2006-04-06 20:23     ` noreply
2006-04-06 21:24       ` Lennart Borgman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.