unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eddie Hillenbrand <eh88@nau.edu>
To: 11033@debbugs.gnu.org
Subject: bug#11033: emacsclient: create a new frame only if one doesn't exist
Date: Fri, 16 Mar 2012 16:18:33 -0700	[thread overview]
Message-ID: <F35C856C-8718-4B88-922F-68088892BDA8@nau.edu> (raw)

I'm using emacsclient with emacs --daemon, but I find myself wanting a
different behavior than the standard options provide.

It would be nice if emacsclient could create a window system frame
only when one doesn't exist and if one does exist simply reuse that
frame.

I know I can get this behavior by initially invoking emacsclient with
-c and then subsequently invoking it without the -c, however I'd
prefer not to think about whether I need to include the -c when
opening files.

server-window was suggested as a possible way to get this
behavior. After inspection of lisp/server.el and trying a few test
cases I found that the server-window variable is not inspected until
after frames are created, thus the best I could do with server-window
is destroy the newly created frame which would be clunky IMHO.

Additionally, lisp/server.el is now lexically scoped (it wasn't in
Emacs 23) so server-window can't access tty-name to check if the
client is requesting a window system frame or a tty frame. The
variable is also not inspected when a file argument is not
provided. But I digress.

As an example:

$ Emacs.app/Contents/MacOS/Emacs -Q --daemon
$ Emacs.app/Contents/MacOS/bin/emacsclient -c -n
Insert and evaluate the following in the scratch buffer:
(setq server-window
      (lambda (next-buffer)
      	(message "SERVER-WINDOW")))
$ Emacs.app/Contents/MacOS/bin/emacsclient -c -n ~/a.txt
Prints the following in *Messages*:
When done with this frame, type C-x 5 0
SERVER-WINDOW

That demonstrates that the frame is created before server-window is
called. So server-window can't be made to provide the desired
behavior.

It is possible to use emacsclient's --eval option to provide this
behavior, but it is extremely ugly. Plus it occurred to me that this
behavior may be general enough to include in emacsclient as a standard
option and would be much cleaner.

I'm proposing adding a -C option to emacsclient that would "create a
new frame if one doesn't exist otherwise use the current Emacs frame."
I'd be happy to make the required changes and submit a patch.

Thanks,

Eddie


In GNU Emacs 24.0.94.1 (x86_64-apple-darwin11.3.0, NS apple-appkit-1138.32)
 of 2012-03-16 on lore.local
Windowing system distributor `Apple', version 10.3.1138
Configured using:
 `configure '--with-ns''






             reply	other threads:[~2012-03-16 23:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16 23:18 Eddie Hillenbrand [this message]
2021-06-08 13:36 ` bug#11033: (no subject) Peter Oliver
2021-06-08 13:43 ` Peter Oliver
2021-06-09  9:32   ` bug#11033: emacsclient: create a new frame only if one doesn't exist Lars Ingebrigtsen
2021-06-22 10:51     ` Peter Oliver
2021-06-22 13:21       ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F35C856C-8718-4B88-922F-68088892BDA8@nau.edu \
    --to=eh88@nau.edu \
    --cc=11033@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).