unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1267: Emacsclient can't find terminal in daemon mode
@ 2008-10-28 23:04 ` Chong Yidong
  2008-10-29 23:06   ` Dan Nicolaescu
  2008-10-30 16:05   ` bug#1267: marked as done (Emacsclient can't find terminal in daemon mode) Emacs bug Tracking System
  0 siblings, 2 replies; 12+ messages in thread
From: Chong Yidong @ 2008-10-28 23:04 UTC (permalink / raw)
  To: emacs-pretest-bug

$ emacs --daemon
$ emacsclient foo.m
Waiting for Emacs...

Emacsclient then stops, waiting indefinitely (IIUC, it opens a frame on
the emacs daemon's "fake" terminal, which is inaccessible to the user).
By contrast, `emacsclient -c foo.m' and `emacsclient -t foo.m' do the
right thing.

I think the Emacs server should do the right thing automatically, but
dunno how hard that would that be to implement.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-28 23:04 ` bug#1267: Emacsclient can't find terminal in daemon mode Chong Yidong
@ 2008-10-29 23:06   ` Dan Nicolaescu
  2008-10-29 23:39     ` Chong Yidong
  2008-10-30  1:05     ` Stefan Monnier
  2008-10-30 16:05   ` bug#1267: marked as done (Emacsclient can't find terminal in daemon mode) Emacs bug Tracking System
  1 sibling, 2 replies; 12+ messages in thread
From: Dan Nicolaescu @ 2008-10-29 23:06 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 1267

Chong Yidong <cyd@stupidchicken.com> writes:

  > $ emacs --daemon
  > $ emacsclient foo.m
  > Waiting for Emacs...
  > 
  > Emacsclient then stops, waiting indefinitely (IIUC, it opens a frame on
  > the emacs daemon's "fake" terminal, which is inaccessible to the user).
  > By contrast, `emacsclient -c foo.m' and `emacsclient -t foo.m' do the
  > right thing.
  > 
  > I think the Emacs server should do the right thing automatically, but
  > dunno how hard that would that be to implement.

In you particular emacsly Emacs uses the "initial frame" to show the
file, which is probably not ideal.
This particular case can be solved by trying to see if the
`(selected-frame)' is FRAME_INITIAL_P (which is not exposed to elisp).
We can guess that if there's no window-system and tty-type frame
parameter we are dealing with the initial frame.

Not sure if this is good enough to cover all possible cases... 


--- server.el.~1.169.~	2008-10-26 09:34:53.000000000 -0700
+++ server.el	2008-10-29 15:46:55.000000000 -0700
@@ -814,6 +814,7 @@ The following commands are accepted by t
 		(files nil)
                 (filepos nil)
 		command-line-args-left
+		crt-frame
 		arg)
 	    ;; Remove this line from STRING.
 	    (setq string (substring string (match-end 0)))
@@ -829,7 +830,7 @@ The following commands are accepted by t
 		 ((equal "-nowait" arg) (setq nowait t))
 
 		 ;; -current-frame:  Don't create frames.
-		 ((equal "-current-frame" arg) (setq tty-name nil))
+		 ((equal "-current-frame" arg) (setq crt-frame t) (setq tty-name nil))
 
 		 ;; -display DISPLAY:
 		 ;; Open X frames on the given display instead of the default.
@@ -925,6 +926,15 @@ The following commands are accepted by t
 		 ;; Unknown command.
 		 (t (error "Unknown command: %s" arg))))
 
+	    (when (and crt-frame (not display))
+	      (let ((sframe (selected-frame)))
+		(unless
+		     (and
+		      ;; X frame
+		      (frame-parameter sframe 'window-system)
+		      ;; tty frame
+		      (frame-parameter sframe 'tty-type))
+		  (error "The current frame cannot be used, use -t or -c"))))
             (setq frame
                   (case tty-name
                     ((nil) (if display (server-select-display display)))
 






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-29 23:06   ` Dan Nicolaescu
@ 2008-10-29 23:39     ` Chong Yidong
  2008-10-30  0:07       ` Dan Nicolaescu
  2008-10-30  1:05     ` Stefan Monnier
  1 sibling, 1 reply; 12+ messages in thread
From: Chong Yidong @ 2008-10-29 23:39 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: 1267

Dan Nicolaescu <dann@ics.uci.edu> writes:

> In you particular emacsly Emacs uses the "initial frame" to show the
> file, which is probably not ideal.
> This particular case can be solved by trying to see if the
> `(selected-frame)' is FRAME_INITIAL_P (which is not exposed to elisp).
> We can guess that if there's no window-system and tty-type frame
> parameter we are dealing with the initial frame.
>
> Not sure if this is good enough to cover all possible cases... 

The patch you sent won't work on a text-only terminal.

I think a better approach is to change emacsclient so that it sends the
tty name/type if it is supposed to "use the current frame" (normally, it
doesn't do this unless the -t option is provided).  Then, the Emacs
server should check whether it can actually use the current frame; if
not, it tries X; if that fails, it falls back on using the tty specified
by emacsclient.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-29 23:39     ` Chong Yidong
@ 2008-10-30  0:07       ` Dan Nicolaescu
  2008-10-30  1:23         ` Chong Yidong
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Nicolaescu @ 2008-10-30  0:07 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 1267

Chong Yidong <cyd@stupidchicken.com> writes:

  > Dan Nicolaescu <dann@ics.uci.edu> writes:
  > 
  > > In you particular emacsly Emacs uses the "initial frame" to show the
  > > file, which is probably not ideal.
  > > This particular case can be solved by trying to see if the
  > > `(selected-frame)' is FRAME_INITIAL_P (which is not exposed to elisp).
  > > We can guess that if there's no window-system and tty-type frame
  > > parameter we are dealing with the initial frame.
  > >
  > > Not sure if this is good enough to cover all possible cases... 
  > 
  > The patch you sent won't work on a text-only terminal.

Have you tried it?  It should throw an error and ask for either -t or -c 


  > I think a better approach is to change emacsclient so that it sends the
  > tty name/type if it is supposed to "use the current frame" (normally, it
  > doesn't do this unless the -t option is provided).  Then, the Emacs
  > server should check whether it can actually use the current frame; if

Please define "whether it can actually use the current frame"

  > not, it tries X; if that fails, it falls back on using the tty specified

Does "it tries X" mean it tries to create an X frame?  That won't be
right, the user might just want to use an existing X frame.  I do that
100 times a day.

  > by emacsclient.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-29 23:06   ` Dan Nicolaescu
  2008-10-29 23:39     ` Chong Yidong
@ 2008-10-30  1:05     ` Stefan Monnier
  2008-10-30  2:15       ` Dan Nicolaescu
  1 sibling, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2008-10-30  1:05 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: Chong Yidong, 1267

> In you particular emacsly Emacs uses the "initial frame" to show the
> file, which is probably not ideal.
> This particular case can be solved by trying to see if the
> `(selected-frame)' is FRAME_INITIAL_P (which is not exposed to elisp).
> We can guess that if there's no window-system and tty-type frame
> parameter we are dealing with the initial frame.

> Not sure if this is good enough to cover all possible cases... 

Maybe we should just check (eq (selected-frame) terminal-frame) ?


        Stefan






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-30  0:07       ` Dan Nicolaescu
@ 2008-10-30  1:23         ` Chong Yidong
  2008-10-30  2:14           ` Dan Nicolaescu
  2008-10-30  2:40           ` Stefan Monnier
  0 siblings, 2 replies; 12+ messages in thread
From: Chong Yidong @ 2008-10-30  1:23 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: 1267

Dan Nicolaescu <dann@ics.uci.edu> writes:

>   > The patch you sent won't work on a text-only terminal.
>
> Have you tried it?  It should throw an error and ask for either -t or -c 
>
>   > not, it tries X; if that fails, it falls back on using the tty
>   > specified
>
> Does "it tries X" mean it tries to create an X frame?  That won't be
> right, the user might just want to use an existing X frame.  I do that
> 100 times a day.

How about just using the tty?

Do we lose anything by making emacsclient use the tty (i.e., the same as
-t) if neither -t nor -c is specified, and the server is a daemon?







^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-30  1:23         ` Chong Yidong
@ 2008-10-30  2:14           ` Dan Nicolaescu
  2008-10-30  3:55             ` Chong Yidong
  2008-10-30  2:40           ` Stefan Monnier
  1 sibling, 1 reply; 12+ messages in thread
From: Dan Nicolaescu @ 2008-10-30  2:14 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 1267

Chong Yidong <cyd@stupidchicken.com> writes:

  > Dan Nicolaescu <dann@ics.uci.edu> writes:
  > 
  > >   > The patch you sent won't work on a text-only terminal.
  > >
  > > Have you tried it?  It should throw an error and ask for either -t or -c 
  > >
  > >   > not, it tries X; if that fails, it falls back on using the tty
  > >   > specified
  > >
  > > Does "it tries X" mean it tries to create an X frame?  That won't be
  > > right, the user might just want to use an existing X frame.  I do that
  > > 100 times a day.
  > 
  > How about just using the tty?
  > 
  > Do we lose anything by making emacsclient use the tty (i.e., the same as
  > -t) if neither -t nor -c is specified, and the server is a daemon?

We do.  If there's already an open frame everything works just fine.
The problem case is when there's no frame.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-30  1:05     ` Stefan Monnier
@ 2008-10-30  2:15       ` Dan Nicolaescu
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Nicolaescu @ 2008-10-30  2:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Chong Yidong, 1267

Stefan Monnier <monnier@iro.umontreal.ca> writes:

  > > In you particular emacsly Emacs uses the "initial frame" to show the
  > > file, which is probably not ideal.
  > > This particular case can be solved by trying to see if the
  > > `(selected-frame)' is FRAME_INITIAL_P (which is not exposed to elisp).
  > > We can guess that if there's no window-system and tty-type frame
  > > parameter we are dealing with the initial frame.
  > 
  > > Not sure if this is good enough to cover all possible cases... 
  > 
  > Maybe we should just check (eq (selected-frame) terminal-frame) ?

Sounds like a good idea.






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-30  1:23         ` Chong Yidong
  2008-10-30  2:14           ` Dan Nicolaescu
@ 2008-10-30  2:40           ` Stefan Monnier
  1 sibling, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2008-10-30  2:40 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Dan Nicolaescu, 1267

>> > The patch you sent won't work on a text-only terminal.
>> 
>> Have you tried it?  It should throw an error and ask for either -t or -c 
>> 
>> > not, it tries X; if that fails, it falls back on using the tty
>> > specified
>> 
>> Does "it tries X" mean it tries to create an X frame?  That won't be
>> right, the user might just want to use an existing X frame.  I do that
>> 100 times a day.

> How about just using the tty?

> Do we lose anything by making emacsclient use the tty (i.e., the same as
> -t) if neither -t nor -c is specified, and the server is a daemon?

Another option is to run frame-initialize (which will open a frame on
either X or tty, IIUC).


        Stefan






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-30  2:14           ` Dan Nicolaescu
@ 2008-10-30  3:55             ` Chong Yidong
  2008-10-30  5:25               ` Dan Nicolaescu
  0 siblings, 1 reply; 12+ messages in thread
From: Chong Yidong @ 2008-10-30  3:55 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: 1267

How bout something on these lines?

The effect is that instead of signalling an error when no -t or -c is
passed and no usable frame exists, Emacs opens the tty of the calling
emacsclient.


*** trunk/lib-src/emacsclient.c.~1.135.~	2008-10-29 11:38:04.000000000 -0400
--- trunk/lib-src/emacsclient.c	2008-10-29 23:10:45.000000000 -0400
***************
*** 1437,1443 ****
        send_to_emacs (emacs_socket, " ");
      }
  
!   if (tty)
      {
        char *type = egetenv ("TERM");
        char *tty_name = NULL;
--- 1437,1443 ----
        send_to_emacs (emacs_socket, " ");
      }
  
!   if (tty || current_frame)
      {
        char *type = egetenv ("TERM");
        char *tty_name = NULL;

*** trunk/lisp/server.el.~1.170.~	2008-10-29 11:38:05.000000000 -0400
--- trunk/lisp/server.el	2008-10-29 23:48:42.000000000 -0400
***************
*** 810,815 ****
--- 810,816 ----
  		dontkill       ; t if the client should not be killed.
                  (commands ())
  		dir
+ 		use-current-frame
                  (tty-name nil)       ;nil, `window-system', or the tty name.
                  tty-type             ;string.
  		(files nil)
***************
*** 830,836 ****
  		 ((equal "-nowait" arg) (setq nowait t))
  
  		 ;; -current-frame:  Don't create frames.
! 		 ((equal "-current-frame" arg) (setq tty-name nil))
  
  		 ;; -display DISPLAY:
  		 ;; Open X frames on the given display instead of the default.
--- 831,837 ----
  		 ((equal "-nowait" arg) (setq nowait t))
  
  		 ;; -current-frame:  Don't create frames.
! 		 ((equal "-current-frame" arg) (setq use-current-frame t))
  
  		 ;; -display DISPLAY:
  		 ;; Open X frames on the given display instead of the default.
***************
*** 926,937 ****
  		 ;; Unknown command.
  		 (t (error "Unknown command: %s" arg))))
  
!             (setq frame
!                   (case tty-name
!                     ((nil) (if display (server-select-display display)))
!                     ((window-system)
!                      (server-create-window-system-frame display nowait proc))
!                     (t (server-create-tty-frame tty-name tty-type proc))))
  
              (process-put
               proc 'continuation
--- 927,940 ----
  		 ;; Unknown command.
  		 (t (error "Unknown command: %s" arg))))
  
! 	    (cond ((and use-current-frame
! 			(not (and (daemonp)
! 				  (= (length (frame-list)) 1)
! 				  (eq (selected-frame) terminal-frame))))
! 		   (if display (server-select-display display)))
! 		  ((eq tty-name 'window-system)
! 		   (server-create-window-system-frame display nowait proc))
! 		  (t (server-create-tty-frame tty-name tty-type proc)))
  
              (process-put
               proc 'continuation






^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: Emacsclient can't find terminal in daemon mode
  2008-10-30  3:55             ` Chong Yidong
@ 2008-10-30  5:25               ` Dan Nicolaescu
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Nicolaescu @ 2008-10-30  5:25 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 1267

Chong Yidong <cyd@stupidchicken.com> writes:

  > How bout something on these lines?

Looks good to me (provided it actually works :-)

  > ! 	    (cond ((and use-current-frame
  > ! 			(not (and (daemonp)
                                    ^^^^^^^^
                                   This can be omitted, terminal-frame
                                   is nil when (daemonp) is nil







^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#1267: marked as done (Emacsclient can't find terminal in  daemon mode)
  2008-10-28 23:04 ` bug#1267: Emacsclient can't find terminal in daemon mode Chong Yidong
  2008-10-29 23:06   ` Dan Nicolaescu
@ 2008-10-30 16:05   ` Emacs bug Tracking System
  1 sibling, 0 replies; 12+ messages in thread
From: Emacs bug Tracking System @ 2008-10-30 16:05 UTC (permalink / raw)
  To: Chong Yidong

[-- Attachment #1: Type: text/plain, Size: 864 bytes --]


Your message dated Thu, 30 Oct 2008 11:57:28 -0400
with message-id <87d4hif53r.fsf@cyd.mit.edu>
and subject line Re: bug#1267: Emacsclient can't find terminal in daemon mode
has caused the Emacs bug report #1267,
regarding Emacsclient can't find terminal in daemon mode
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)


-- 
1267: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=1267
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 2085 bytes --]

From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-pretest-bug@gnu.org
Subject: Emacsclient can't find terminal in daemon mode
Date: Tue, 28 Oct 2008 19:04:48 -0400
Message-ID: <87r660gw33.fsf@cyd.mit.edu>

$ emacs --daemon
$ emacsclient foo.m
Waiting for Emacs...

Emacsclient then stops, waiting indefinitely (IIUC, it opens a frame on
the emacs daemon's "fake" terminal, which is inaccessible to the user).
By contrast, `emacsclient -c foo.m' and `emacsclient -t foo.m' do the
right thing.

I think the Emacs server should do the right thing automatically, but
dunno how hard that would that be to implement.



[-- Attachment #3: Type: message/rfc822, Size: 1742 bytes --]

From: Chong Yidong <cyd@stupidchicken.com>
To: Dan Nicolaescu <dann@ics.uci.edu>
Cc: 1267-done@emacsbugs.donarmstrong.com
Subject: Re: bug#1267: Emacsclient can't find terminal in daemon mode
Date: Thu, 30 Oct 2008 11:57:28 -0400
Message-ID: <87d4hif53r.fsf@cyd.mit.edu>

Dan Nicolaescu <dann@ics.uci.edu> writes:

> Chong Yidong <cyd@stupidchicken.com> writes:
>
>   > How bout something on these lines?
>
> Looks good to me (provided it actually works :-)

I've checked in a similar patch.


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-10-30 16:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87d4hif53r.fsf@cyd.mit.edu>
2008-10-28 23:04 ` bug#1267: Emacsclient can't find terminal in daemon mode Chong Yidong
2008-10-29 23:06   ` Dan Nicolaescu
2008-10-29 23:39     ` Chong Yidong
2008-10-30  0:07       ` Dan Nicolaescu
2008-10-30  1:23         ` Chong Yidong
2008-10-30  2:14           ` Dan Nicolaescu
2008-10-30  3:55             ` Chong Yidong
2008-10-30  5:25               ` Dan Nicolaescu
2008-10-30  2:40           ` Stefan Monnier
2008-10-30  1:05     ` Stefan Monnier
2008-10-30  2:15       ` Dan Nicolaescu
2008-10-30 16:05   ` bug#1267: marked as done (Emacsclient can't find terminal in daemon mode) Emacs bug Tracking System

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).