help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacsclient frame reuse


From: jem
Subject: emacsclient frame reuse
Date: Tue, 4 Aug 2009 14:07:15 -0700 (PDT)
User-agent: G2/1.0

I've been testing the new 23 build and the --daemon option and have a
question how to get it to operate as I used to have gnuserv working.

Here's the scenario -- I have running in the background an emacs
instance using the --daemon flag.  Now, I want to edit a new file in
an X window frame so I have a script that will launch:

emacsclient -c -n file

This fires a new frame with the file and returns.  Now I want to edit
a second file, in the same frame.  If I use the same command

emacsclient -c -n file2

I get a new frame, where I wanted to share the previous frame.
Instead I have to use

emacsclient -n file2

to reuse the frame.

If I don't have any running frames (either TTY or X) and use the
emacsclient -n file command, there is a quick flash in the terminal
then it goes away as the client assumes TTY and the process
terminates.

I would like to have a single script that I can invoke that will do
the right thing.  If there is no visible frame, use the -c option.  If
there is a visible frame do not use the -c option.   The problem is, I
can't find a way to determine if there is a visible frame.  Because of
the -n option, the previous emacsclient process has exited.

In the older model with gnuserv I was able to add

(setq gnuserv-frame (car (frame-list)))

and my startup script looked like

gunclient -n $@ 2>/dev/null
if [ $? -ne 0 ]
then
       emacs $@ &
fi

which would start emacs if not started (I loaded gnuserv in the
init.el file) or connect to the existing one and share the frame.

How can you detect if there is already a running frame with the newest
version?

Thanks

Jere
~


reply via email to

[Prev in Thread] Current Thread [Next in Thread]