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

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

bug#1267: Emacsclient can't find terminal in daemon mode


From: Dan Nicolaescu
Subject: bug#1267: Emacsclient can't find terminal in daemon mode
Date: Wed, 29 Oct 2008 16:06:41 -0700 (PDT)

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






reply via email to

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