# HG changeset patch # User Chong Yidong # Date 1225381801 0 # Node ID 8ee9512061d40e68c41d581e09fae12f0a4bc353 # Parent 8a8cdf3d59ecdd34f29f7aff7e276433a34ebfe7 (server-process-filter): In daemon mode, default to emacsclient's tty if not opening a new frame and only the terminal-frame is available. diff -r 8a8cdf3d59ec -r 8ee9512061d4 lisp/server.el --- a/lisp/server.el Thu Oct 30 15:49:49 2008 +0000 +++ b/lisp/server.el Thu Oct 30 15:50:01 2008 +0000 @@ -810,6 +810,7 @@ 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 @@ ((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 @@ (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 @@ ;; -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 @@ ;; 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