]> git.eshelyaron.com Git - emacs.git/commitdiff
(server-process-filter): In daemon mode, default to emacsclient's tty
authorChong Yidong <cyd@stupidchicken.com>
Thu, 30 Oct 2008 15:50:01 +0000 (15:50 +0000)
committerChong Yidong <cyd@stupidchicken.com>
Thu, 30 Oct 2008 15:50:01 +0000 (15:50 +0000)
if not opening a new frame and only the terminal-frame is available.

lisp/server.el

index 57d23183d2c628b8dfa00c3840439db178a40f11..ae1202e9e9e2fc0cb4132511e3fdde20ea4022b7 100644 (file)
@@ -810,6 +810,7 @@ The following commands are accepted by the client:
                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,7 +831,7 @@ The following commands are accepted by the client:
                 ((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 use-current-frame t))
 
                 ;; -display DISPLAY:
                 ;; Open X frames on the given display instead of the default.
@@ -874,7 +875,8 @@ The following commands are accepted by the client:
                        (cdr command-line-args-left))
                   (setq tty-name (pop command-line-args-left)
                        tty-type (pop command-line-args-left)
-                       dontkill t))
+                       dontkill (or dontkill
+                                    (not use-current-frame))))
 
                 ;; -position LINE[:COLUMN]:  Set point to the given
                 ;;  position in the next file.
@@ -902,6 +904,8 @@ The following commands are accepted by the client:
                 ;; -eval EXPR:  Evaluate a Lisp expression.
                 ((and (equal "-eval" arg)
                        command-line-args-left)
+                 (if use-current-frame
+                     (setq use-current-frame 'always))
                  (lexical-let ((expr (pop command-line-args-left)))
                    (if coding-system
                        (setq expr (decode-coding-string expr coding-system)))
@@ -926,12 +930,20 @@ The following commands are accepted by the client:
                 ;; 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))))
+           (setq frame
+                 (cond
+                  ((and use-current-frame
+                        (or (eq use-current-frame 'always)
+                            ;; We can't use the Emacs daemon's
+                            ;; terminal frame.
+                            (not (and (= (length (frame-list)) 1)
+                                      (eq (selected-frame)
+                                          terminal-frame)))))
+                   (setq tty-name nil)
+                   (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