emacs-devel
[Top][All Lists]
Advanced

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

Re: emacsclient's option decoding code


From: Juanma Barranquero
Subject: Re: emacsclient's option decoding code
Date: Tue, 11 Nov 2008 16:37:43 +0100

On Tue, Nov 11, 2008 at 10:39, Juanma Barranquero <address@hidden> wrote:

> But making an exception for Windows and
> allowing "", or in fact any other value, string or otherwise, is ugly
> and just a consequence of the fact that (frame-parameter nil 'display)
> returns "" on Windows.

AFAICS, the reason Windows frames contain (display . "") is that
`x-open-connection' does not accept DISPLAY == nil on Windows (even if
it would make more sense than ""), because w32_term_init uses DISPLAY
to initialize the terminal name.

The attached patch makes the following changes:

  Window specific:
   - allows `x-open-connection' to accept DISPLAY == nil
   - makes sure that the terminal name is correctly initialized even
if DISPLAY == nil
   - passes nil to `x-open-connection' from w32-initialize-window-system
   - allows "emacsclient --display=XXX"
   - does not force tty for empty DISPLAYs on emacsclient

  Generic:
   - allows DISPLAY == nil in `make-frame-on-display', meaning "current display"
   - does not err out in `server-create-window-system-frame' when
there's no DISPLAY

Consequences:

  Windows specific:
   - (frame-parameter nil 'display) => nil (instead of "")
   - emacsclient --display=WHATEVER => "ERROR*: Invalid display, not
HOST:SERVER or HOST:SERVER.SCREEN"
   - emacsclient --display=:0.0 => "ERROR*: Don't know how to create a
frame on window system x"
   - emacsclient -c  => works

  Generic:
   - (make-frame-on-display nil ...) => (make-frame ...)

>From my (biased) POV, there's mostly advantages: better Windows / X
compatibility, fewer Windows-specific hacks, etc.

Disadvantages:

   - I'm not sure whether "emacsclient -c" with no DISPLAY will do
something different on non-Windows systems (I don't think so, but it'd
be better to try it)

   - Returning nil instead of "" for the 'display frame-parameter on
Windows is not back-compatible; could be a problem for code expecting
it to always be a string, but this is already false on ttys.

  Juanma




2008-11-11  Juanma Barranquero  <address@hidden>

        * term/w32-win.el (w32-initialize-window-system): Pass nil as DISPLAY
        arg to `x-open-connection', not "".

        * frame.el (make-frame-on-display): Don't do anything special for
        Windows; accept a null DISPLAY meaning "use the current frame".

        * server.el (server-create-window-system-frame): Don't err out if
        DISPLAY is null.

2008-11-11  Juanma Barranquero  <address@hidden>

        * w32fns.c (Fx_open_connection): Accept a null display.

        * w32term.c (w32_term_init): If display_name is nil, assign an
        empty string to the terminal name.

2008-11-11  Juanma Barranquero  <address@hidden>

        * emacsclient.c (longopts): Accept "-display" on Windows.
        (decode_options): Don't force tty on Windows when there is no DISPLAY.


Index: lib-src/emacsclient.c
===================================================================
RCS file: /sources/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.140
diff -u -2 -r1.140 emacsclient.c
--- lib-src/emacsclient.c       2 Nov 2008 23:16:33 -0000       1.140
+++ lib-src/emacsclient.c       11 Nov 2008 09:44:07 -0000
@@ -165,7 +165,5 @@
 #endif
   { "server-file",     required_argument, NULL, 'f' },
-#ifndef WINDOWSNT
   { "display", required_argument, NULL, 'd' },
-#endif
   { 0, 0, 0, 0 }
 };
@@ -575,7 +573,9 @@
     display = NULL;

+#ifndef WINDOWSNT
   /* If no display is available, new frames are tty frames.  */
   if (!current_frame && !display)
     tty = 1;
+#endif

   /* --no-wait implies --current-frame on ttys when there are file
Index: lisp/frame.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/frame.el,v
retrieving revision 1.289
diff -u -2 -r1.289 frame.el
--- lisp/frame.el       7 Nov 2008 14:52:04 -0000       1.289
+++ lisp/frame.el       11 Nov 2008 09:44:30 -0000
@@ -617,6 +617,5 @@
         (make-frame `((window-system . ns)
                       (display . ,display) . ,parameters)))
-       ((eq system-type 'windows-nt)
-        ;; On Windows, ignore DISPLAY.
+       ((null display)
         (make-frame parameters))
        (t
Index: lisp/server.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/server.el,v
retrieving revision 1.174
diff -u -2 -r1.174 server.el
--- lisp/server.el      11 Nov 2008 10:51:37 -0000      1.174
+++ lisp/server.el      11 Nov 2008 11:52:32 -0000
@@ -634,6 +634,5 @@
                    (or display
                        (frame-parameter nil 'display)
-                       (getenv "DISPLAY")
-                       (error "Please specify display"))
+                       (getenv "DISPLAY"))
                    params)))
       (server-log (format "%s created" frame) proc)
Index: lisp/term/w32-win.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/term/w32-win.el,v
retrieving revision 1.105
diff -u -2 -r1.105 w32-win.el
--- lisp/term/w32-win.el        11 Aug 2008 01:23:07 -0000      1.105
+++ lisp/term/w32-win.el        11 Nov 2008 12:45:39 -0000
@@ -246,5 +246,5 @@
             (replace-regexp-in-string "[.*]" "-" (invocation-name))))

-  (x-open-connection "" x-command-line-resources
+  (x-open-connection nil x-command-line-resources
                      ;; Exit with a fatal error if this fails and we
                      ;; are the initial display
Index: src/w32fns.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32fns.c,v
retrieving revision 1.349
diff -u -2 -r1.349 w32fns.c
--- src/w32fns.c        30 Oct 2008 01:27:07 -0000      1.349
+++ src/w32fns.c        11 Nov 2008 14:25:43 -0000
@@ -4931,5 +4931,6 @@
     return Qnil;

-  CHECK_STRING (display);
+  if (! NILP (display))
+    CHECK_STRING (display);
   if (! NILP (xrm_string))
     CHECK_STRING (xrm_string);
Index: src/w32term.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32term.c,v
retrieving revision 1.308
diff -u -2 -r1.308 w32term.c
--- src/w32term.c       27 Oct 2008 22:20:27 -0000      1.308
+++ src/w32term.c       11 Nov 2008 15:14:49 -0000
@@ -6181,4 +6181,7 @@

   /* Set the name of the terminal. */
+  if (NILP (display_name))
+    display_name = empty_unibyte_string;
+
   terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
   strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));




reply via email to

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