Merge from trunk.
[bpt/emacs.git] / lib-src / emacsclient.c
index 2aabc52..2af139a 100644 (file)
@@ -160,6 +160,10 @@ const char *server_file = NULL;
 /* PID of the Emacs server process.  */
 int emacs_pid = 0;
 
+/* If non-NULL, a string that should form a frame parameter alist to
+   be used for the new frame */
+const char *frame_parameters = NULL;
+
 static void print_help_and_exit (void) NO_RETURN;
 static void fail (void) NO_RETURN;
 
@@ -175,6 +179,7 @@ struct option longopts[] =
   { "nw",      no_argument,       NULL, 't' },
   { "create-frame", no_argument,   NULL, 'c' },
   { "alternate-editor", required_argument, NULL, 'a' },
+  { "frame-parameters", required_argument, NULL, 'F' },
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
   { "socket-name",     required_argument, NULL, 's' },
 #endif
@@ -526,9 +531,9 @@ decode_options (int argc, char **argv)
     {
       int opt = getopt_long_only (argc, argv,
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
-                            "VHneqa:s:f:d:tc",
+                            "VHneqa:s:f:d:F:tc",
 #else
-                            "VHneqa:f:d:tc",
+                            "VHneqa:f:d:F:tc",
 #endif
                             longopts, 0);
 
@@ -599,6 +604,10 @@ decode_options (int argc, char **argv)
          print_help_and_exit ();
          break;
 
+        case 'F':
+          frame_parameters = optarg;
+          break;
+
        default:
          message (TRUE, "Try `%s --help' for more information\n", progname);
          exit (EXIT_FAILURE);
@@ -643,6 +652,14 @@ 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 */
 }
 
@@ -665,6 +682,8 @@ The following OPTIONS are accepted:\n\
 -nw, -t, --tty                 Open a new Emacs frame on the current terminal\n\
 -c, --create-frame     Create a new frame instead of trying to\n\
                        use the current Emacs frame\n\
+-F ALIST, --frame-parameters=ALIST\n\
+                       Set the parameters of a new frame\n\
 -e, --eval             Evaluate the FILE arguments as ELisp expressions\n\
 -n, --no-wait          Don't wait for the server to return\n\
 -q, --quiet            Don't display messages on success\n\
@@ -1098,7 +1117,7 @@ find_tty (const char **tty_type, const char **tty_name, int noabort)
    0 - success: none of the above */
 
 static int
-socket_status (char *name)
+socket_status (const char *name)
 {
   struct stat statbfr;
 
@@ -1630,6 +1649,13 @@ main (int argc, char **argv)
       send_to_emacs (emacs_socket, " ");
     }
 
+  if (frame_parameters && !current_frame)
+    {
+      send_to_emacs (emacs_socket, "-frame-parameters ");
+      quote_argument (emacs_socket, frame_parameters);
+      send_to_emacs (emacs_socket, " ");
+    }
+
   /* If using the current frame, send tty information to Emacs anyway.
      In daemon mode, Emacs may need to occupy this tty if no other
      frame is available.  */