From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Juanma Barranquero" Newsgroups: gmane.emacs.devel Subject: Re: emacsclient's option decoding code Date: Tue, 11 Nov 2008 16:37:43 +0100 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1226418123 30651 80.91.229.12 (11 Nov 2008 15:42:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Nov 2008 15:42:03 +0000 (UTC) Cc: cyd@stupidchicken.com, emacs-devel@gnu.org To: "Eli Zaretskii" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 11 16:43:00 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KzvKX-0002e1-0s for ged-emacs-devel@m.gmane.org; Tue, 11 Nov 2008 16:39:01 +0100 Original-Received: from localhost ([127.0.0.1]:54191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KzvJP-0004s3-6s for ged-emacs-devel@m.gmane.org; Tue, 11 Nov 2008 10:37:51 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KzvJK-0004pX-DK for emacs-devel@gnu.org; Tue, 11 Nov 2008 10:37:46 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KzvJJ-0004nn-EO for emacs-devel@gnu.org; Tue, 11 Nov 2008 10:37:45 -0500 Original-Received: from [199.232.76.173] (port=40575 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KzvJJ-0004ne-BD for emacs-devel@gnu.org; Tue, 11 Nov 2008 10:37:45 -0500 Original-Received: from yx-out-1718.google.com ([74.125.44.157]:27660) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KzvJJ-0002TG-C7 for emacs-devel@gnu.org; Tue, 11 Nov 2008 10:37:45 -0500 Original-Received: by yx-out-1718.google.com with SMTP id 34so1240131yxf.66 for ; Tue, 11 Nov 2008 07:37:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=JcdpDgGbbFfD9rnSW8Z4DpZZCn80Z2lWndUoYhVYAe4=; b=S9JthU6FoBDlCEjr2yNtQM7LG6zq+14c1EymBloxe6AYU0ErXSCtJYNZY9v6TZQCJ8 j/4p3lS8KDnEBRBF+M7DqP0VsYcc5kV6sulbRKwGJ6VH4gdWlT7d6Swx/bCgU1cFoH8Q eEAvpy8bMEtFaubXjmJp9JJ3Tz2JjA/63s7/4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=ZvQWkU/1lcmmwaPEbxwHYgt1e9YxSVbAsn6HQOLmT5cluzevwvg4SU1w2XkjmLDIQT 83pKHnp/ncECc2ZSIbTEemCIN3Pzu5BzRwZBbc+FG+VQMJNbbtiXSbhwFAM+HV9MYMkH QHX7FzZ5vCqRih7FA6tlu1SD87e0ikxCq/gkY= Original-Received: by 10.100.168.18 with SMTP id q18mr3027469ane.7.1226417863422; Tue, 11 Nov 2008 07:37:43 -0800 (PST) Original-Received: by 10.100.13.13 with HTTP; Tue, 11 Nov 2008 07:37:43 -0800 (PST) In-Reply-To: Content-Disposition: inline X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:105563 Archived-At: On Tue, Nov 11, 2008 at 10:39, Juanma Barranquero 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 * 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 * 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 * 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));