GNU bug report logs - #11033
emacsclient: create a new frame only if one doesn't exist

Previous Next

Package: emacs;

Reported by: Eddie Hillenbrand <eh88 <at> nau.edu>

Date: Fri, 16 Mar 2012 23:54:02 UTC

Severity: wishlist

Tags: patch

Merged with 31098, 31435

Found in versions 25.2, 27.0.50

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11033 in the body.
You can then email your comments to 11033 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11033; Package emacs. (Fri, 16 Mar 2012 23:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Eddie Hillenbrand <eh88 <at> nau.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 16 Mar 2012 23:54:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Eddie Hillenbrand <eh88 <at> nau.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: emacsclient: create a new frame only if one doesn't exist
Date: Fri, 16 Mar 2012 16:18:33 -0700
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''





Forcibly Merged 11033 31098. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 08 Apr 2018 19:49:02 GMT) Full text and rfc822 format available.

Merged 11033 31098 31435. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 12 May 2018 16:29:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11033; Package emacs. (Tue, 08 Jun 2021 13:38:02 GMT) Full text and rfc822 format available.

Message #12 received at 11033 <at> debbugs.gnu.org (full text, mbox):

From: Peter Oliver <p.d.oliver <at> mavit.org.uk>
To: 11033 <at> debbugs.gnu.org
Date: Tue, 8 Jun 2021 14:36:40 +0100 (BST)
The reporter suggests adding a new option to emacsclient to achieve their preferred behaviour.  However, the current behaviour, when emacs is run as a daemon, has no current frames, and emacsclient is not run on a TTY, is for the file to be opened in the daemon but not displayed to the user.  I find it hard to see why anyone would want that, so think that the suggested behaviour should be the default in that case.

-- 
Peter Oliver




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11033; Package emacs. (Tue, 08 Jun 2021 13:44:02 GMT) Full text and rfc822 format available.

Message #15 received at 11033 <at> debbugs.gnu.org (full text, mbox):

From: Peter Oliver <p.d.oliver <at> mavit.org.uk>
To: 11033 <at> debbugs.gnu.org
Date: Tue, 8 Jun 2021 14:43:02 +0100 (BST)
[Message part 1 (text/plain, inline)]
Attached is a patch which causes emacs to try to create a new GUI frame if there are no existing frames and the current TTY is unusable.

This only works if emacsclient tells us which display to use, and currently it only does that if --display=… is specified.  This is fine for my purposes, but we might want to look at having it pass along $DISPLAY in more situations.

I have submitted copyright assignment paperwork but am currently waiting to hear back.

-- 
Peter Oliver
[0001-If-the-daemon-s-TTY-is-our-only-frame-create-a-new-f.patch (text/plain, attachment)]

Added tag(s) patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 09 Jun 2021 09:31:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11033; Package emacs. (Wed, 09 Jun 2021 09:33:01 GMT) Full text and rfc822 format available.

Message #20 received at 11033 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Peter Oliver <p.d.oliver <at> mavit.org.uk>
Cc: 11033 <at> debbugs.gnu.org
Subject: Re: bug#11033: emacsclient: create a new frame only if one doesn't
 exist
Date: Wed, 09 Jun 2021 11:32:45 +0200
Peter Oliver <p.d.oliver <at> mavit.org.uk> writes:

> Attached is a patch which causes emacs to try to create a new GUI
> frame if there are no existing frames and the current TTY is unusable.

Makes sense to me.

> I have submitted copyright assignment paperwork but am currently
> waiting to hear back.

Let us know when the paperwork's final (in case we miss it), and we'll
get the patch applied.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11033; Package emacs. (Tue, 22 Jun 2021 10:53:01 GMT) Full text and rfc822 format available.

Message #23 received at 11033 <at> debbugs.gnu.org (full text, mbox):

From: Peter Oliver <p.d.oliver <at> mavit.org.uk>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 11033 <at> debbugs.gnu.org
Subject: Re: bug#11033: emacsclient: create a new frame only if one doesn't
 exist
Date: Tue, 22 Jun 2021 11:51:59 +0100 (BST)
On Wed, 9 Jun 2021, Lars Ingebrigtsen wrote:

> Peter Oliver <p.d.oliver <at> mavit.org.uk> writes:
>
>> I have submitted copyright assignment paperwork but am currently
>> waiting to hear back.
>
> Let us know when the paperwork's final (in case we miss it), and we'll
> get the patch applied.

The paperwork is now complete.  Thanks.

-- 
Peter Oliver




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11033; Package emacs. (Tue, 22 Jun 2021 13:23:02 GMT) Full text and rfc822 format available.

Message #26 received at 11033 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Peter Oliver <p.d.oliver <at> mavit.org.uk>
Cc: 11033 <at> debbugs.gnu.org
Subject: Re: bug#11033: emacsclient: create a new frame only if one doesn't
 exist
Date: Tue, 22 Jun 2021 15:21:54 +0200
Peter Oliver <p.d.oliver <at> mavit.org.uk> writes:

> The paperwork is now complete.  Thanks.

And I've now pushed your patch to Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 28.1, send any further explanations to 11033 <at> debbugs.gnu.org and Eddie Hillenbrand <eh88 <at> nau.edu> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 22 Jun 2021 13:23:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 21 Jul 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 278 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.