From 520fca41d6ca6cc860c1f03c76cd472ea149e33a Mon Sep 17 00:00:00 2001 From: Juanma Barranquero Date: Sun, 4 Dec 2011 18:13:01 +0100 Subject: [PATCH] Fix emacsclient bug where "-n -c" does not open a new frame on Windows. * lib-src/emacsclient.c (decode_options) [WINDOWSNT]: Don't force tty = 0; instead, treat both -c and -t as always requesting a new "tty" frame, and let server.el decide which kind is actually required. Reported by Uwe Siart in this thread: http://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00303.html * lisp/server.el (server-delete-client): On Windows, do not try to delete the only terminal. (server-process-filter): On Windows, treat requests for a tty frame as if they were for a GUI frame if the running server is in GUI mode. --- lib-src/ChangeLog | 8 ++++++++ lib-src/emacsclient.c | 24 ++++++++++++++++-------- lisp/ChangeLog | 7 +++++++ lisp/server.el | 18 ++++++++++++------ 4 files changed, 43 insertions(+), 14 deletions(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 1eb67eb6c7..922a96ad19 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,11 @@ +2011-12-04 Juanma Barranquero + + * emacsclient.c (decode_options) [WINDOWSNT]: Don't force tty = 0; + instead, treat both -c and -t as always requesting a new "tty" frame, + and let server.el decide which kind is actually required. + Reported by Uwe Siart in this thread: + http://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00303.html + 2011-11-30 Chong Yidong * emacsclient.c (main): Condition last change on WINDOWSNT diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 0ae1f0bdde..5e1c2d61b8 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -638,6 +638,22 @@ decode_options (int argc, char **argv) if (display && strlen (display) == 0) display = NULL; +#ifdef WINDOWSNT + /* Emacs on Windows does not support GUI and console frames in the same + instance. So, it makes sense to treat the -t and -c options as + equivalent, and open a new frame regardless of whether the running + instance is GUI or console. Ideally, we would only set tty = 1 when + the instance is running in a console, but alas we don't know that. + The simplest workaround is to always ask for a tty frame, and let + server.el check whether it makes sense. */ + if (tty || !current_frame) + { + display = (const char *) ttyname; + current_frame = 0; + tty = 1; + } +#endif + /* If no display is available, new frames are tty frames. */ if (!current_frame && !display) tty = 1; @@ -654,14 +670,6 @@ decode_options (int argc, char **argv) an empty string"); exit (EXIT_FAILURE); } - - /* TTY frames not supported on Windows. Continue using GUI rather than - forcing the user to change their command-line. This is required since - tty is set above if certain options are given and $DISPLAY is not set, - which is not obvious to users. */ - if (tty) - tty = 0; - #endif /* WINDOWSNT */ } diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c77ace6d48..3d09a225da 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2011-12-04 Juanma Barranquero + + * server.el (server-delete-client): On Windows, do not try to delete + the only terminal. + (server-process-filter): On Windows, treat requests for a tty frame as + if they were for a GUI frame if the running server is in GUI mode. + 2011-12-03 Glenn Morris * textmodes/texinfmt.el (batch-texinfo-format): Doc fix. (Bug#10207) diff --git a/lisp/server.el b/lisp/server.el index e02f63a826..edd8f2afa9 100644 --- a/lisp/server.el +++ b/lisp/server.el @@ -307,11 +307,13 @@ Updates `server-clients'." (setq server-clients (delq proc server-clients)) - ;; Delete the client's tty. - (let ((terminal (process-get proc 'terminal))) - ;; Only delete the terminal if it is non-nil. - (when (and terminal (eq (terminal-live-p terminal) t)) - (delete-terminal terminal))) + ;; Delete the client's tty, except on Windows (both GUI and console), + ;; where there's only one terminal and does not make sense to delete it. + (unless (eq system-type 'windows-nt) + (let ((terminal (process-get proc 'terminal))) + ;; Only delete the terminal if it is non-nil. + (when (and terminal (eq (terminal-live-p terminal) t)) + (delete-terminal terminal)))) ;; Delete the client's process. (if (eq (process-status proc) 'open) @@ -1035,7 +1037,11 @@ The following commands are accepted by the client: (setq tty-name (pop args-left) tty-type (pop args-left) dontkill (or dontkill - (not use-current-frame)))) + (not use-current-frame))) + ;; On Windows, emacsclient always asks for a tty frame. + ;; If running a GUI server, force the frame type to GUI. + (when (eq window-system 'w32) + (push "-window-system" args-left))) ;; -position LINE[:COLUMN]: Set point to the given ;; position in the next file. -- 2.20.1