Subject: Re: bug#8314: 24.0.50; emacsclient -c does the wrong thing when compiled without X

From: Glenn Morris <[email-masked]>
Date: Fri, 03 Jun 2011 15:49:35 -0400

PJ Weisberg wrote:

> 1) Build emacs with '--with-x=no'.
> 2) Start emacs with '--daemon'.
> 3) From a terminal emulator under X, such as gnome-terminal, with the
> $DISPLAY environment variable set, run 'emacsclient -c'.
>
> Expected: Same behavior as when no display is available, which is to
> fall back to the tty.
> Observed: "Waiting for Emacs..." is printed to the terminal, then
> emacsclient exits with nothing else apparently happening.

I get:

   *ERROR*: Don't know how to create a frame on window system x

which seems reasonable.

If we are allowed to assume that emacsclient is used with the same
version of Emacs as it was compiled with, then it seems easy to get the
behaviour you want, see patch. However, if you want to use the same
emacsclient binary with both Emacs compiled with-x and without-x, then
it won't work. Assuming you use the emacsclient from a build with-x,
though, then you are no worse off than you are now.

I wonder if it would be better to not accept the `-c' option in a
without-x build.

*** lib-src/emacsclient.c	2011-06-01 17:15:27 +0000
--- lib-src/emacsclient.c	2011-06-03 19:16:27 +0000
***************
*** 144,151 ****
  /* The parent window ID, if we are opening a frame via XEmbed.  */
  char *parent_id = NULL;
  
! /* Nonzero means open a new Emacs frame on the current terminal. */
  int tty = 0;
  
  /* If non-NULL, the name of an editor to fallback to if the server
     is not running.  --alternate-editor.   */
--- 144,158 ----
  /* The parent window ID, if we are opening a frame via XEmbed.  */
  char *parent_id = NULL;
  
! /* Nonzero means open a new Emacs frame on the current terminal.
!    If Emacs was built without X, we must do this.
!    (This assumes emacsclient is used with the same version of Emacs
!    as it was compiled with.)  */
! #if defined(HAVE_X_WINDOWS) || defined(HAVE_NS) || defined(WINDOWSNT)
  int tty = 0;
+ #else
+ int tty = 1;
+ #endif
  
  /* If non-NULL, the name of an editor to fallback to if the server
     is not running.  --alternate-editor.   */