[Top][All Lists]

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

Re: Detecting if the Emacs server is running

From: PJ Weisberg
Subject: Re: Detecting if the Emacs server is running
Date: Fri, 18 Mar 2011 02:59:02 -0700

On Fri, Mar 18, 2011 at 12:38 AM, PJ Weisberg <address@hidden> wrote:

> Ok, I guess I wasn't clear.  I actually want to do MORE than just make
> a new frame. :-)  Say I run this command:
> emacsclient -a emacs -e "(progn (select-frame (make-frame-on-display
> \"$DISPLAY\")) (insert \"Hello, world!\"))"
> If emacs is running in server mode it does what I wanted (make a
> frame, select it, run some elisp), but if emacs isn't running in
> server mode, I find myself editing a new file named '(progn
> (select-frame (make-frame-on-display ":0.0")) (insert "Hello,
> world!"))'
> Any thoughts on a better way I could go about this?
> Thanks,
> PJ

Ok, I had an idea that seems to work:


lisp="(insert \"Hello, world!\")"

emacsclient -a false --eval "(progn (select-frame
(make-frame-on-display \"$DISPLAY\")) $lisp)" 2>/dev/null

if [ $? != 0 ]; then
    emacs --eval "$lisp"

It feels like a kludge to use -a like that, but it does what I wanted
in the case that I was wondering about.  I'm sure I'll think of more
corner cases (e.g., if ALTERNATE_EDITOR is set to "" in the
environment I should let emacsclient start the server instead of
forcing it to false), but for now I know what I'm doing. :-)


reply via email to

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