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

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

Re: Daemon and client: Only open new frame if there isn't one already?


From: Hugo Heden
Subject: Re: Daemon and client: Only open new frame if there isn't one already?
Date: Fri, 13 Mar 2009 12:08:26 +0100

On Fri, Mar 13, 2009 at 10:35 AM, Eli Zaretskii <address@hidden> wrote:
>> Date: Fri, 13 Mar 2009 00:44:25 +0100
>> From: Hugo Heden <address@hidden>
>> Cc: address@hidden
>>
>> >> Is there a way for emacsclient to ask the daemon to make a new frame
>> >
>> > Have you invoked
>> >
>> >        emacsclient --help
>> >
>> > Yes, in GNU Emacs 23.0.91 it can!
>> >
>>
>> Yes, thanks Peter, I have, but this is not what I want to do:
>>   "-c, --create-frame Create a new frame instead of trying to use the
>> current Emacs frame"
>>
>> What I want is a command line option (or some hacky script ) to
>> automatically create a new frame only if there is no frame currently
>> open. If there is a frame already, that frame should automatically be
>> reused.
>
> But the above portion of the emacsclient help message seems to mean
> that emacsclient already does what you want by default.  That's why
> you need the -c option to override that default and create a new
> frame even if one already exist.
>
> Doesn't the default work for you?  Perhaps you should report a bug,
> then.
>

Thanks all! I have diffuculties explaining what I am looking for.


1) I already have a daemon running, so that is not the problem. (Yes,
the alternate-editor option is good for that)


2) The --create-frame option creates a new frame yes, but it does so
every time the option is used. And that is a problem for me :-) I want
max *one* frame open at any given time!


3) Ok ok -- I *could* use my brain to manually do this:

   if( there-is-a-frame-currently-open )
     open-the-file-*without*-the-[--create-frame]-option
   else
     open-the-file-*with*-the-[--create-frame]-option
  endif

 --that would achieve what I am looking for.


4) But that would be a little to much waste of brain power! My problem
is that I do not want to have to remeber whether I already have a
frame open or not. The if-statement above is just too much for me to
bare. So I would want to write a little script that *autoamtiaclly*
achieve the above logic..

The cleanest solution would be to always invoke emacsclient with an
--eval option, something like this:

  emacsclient --eval "( unless( x-display-list ) make-frame ) "

or this:

  emacsclient.emacs-snapshot --eval "(unless(x-display-list)(new-frame))"

-- but I can't figure out how to write that eval (neither of the above
will work)..


5) This is similar to how I use Firefox: When I click on a link in a
mail, that link opens in a new tab in a currently existing frame..
unless there isn't one, in which case a new frame is automatically
opened.


Hmm, is this clearer? Any ideas?


Best regards

Hugo Heden




reply via email to

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