Allow emacsclient to set parameters of new graphical frames (bug#5864)
authorAndreas Rottmann <a.rottmann@gmx.at>
Sat, 25 Jun 2011 18:05:48 +0000 (11:05 -0700)
committerGlenn Morris <rgm@gnu.org>
Sat, 25 Jun 2011 18:05:48 +0000 (11:05 -0700)
* lib-src/emacsclient.c (longopts, decode_options, main): Add frame-parameters.

* lisp/server.el (server-create-window-system-frame): Add parameters arg.
(server-process-filter): Doc fix.  Handle frame-parameters.

* doc/emacs/misc.texi (emacsclient Options): Mention --frame-parameters.
* doc/man/emacsclient.1: Mention --frame-parameters.

* etc/NEWS: Mention this.

doc/emacs/ChangeLog
doc/emacs/misc.texi
doc/man/ChangeLog
doc/man/emacsclient.1
etc/NEWS
lib-src/ChangeLog
lib-src/emacsclient.c
lisp/ChangeLog
lisp/server.el

index 8853eb0..ab0abcd 100644 (file)
@@ -1,3 +1,7 @@
+2011-06-25  Andreas Rottmann  <a.rottmann@gmx.at>
+
+       * misc.texi (emacsclient Options): Mention --frame-parameters.
+
 2011-06-09  Glenn Morris  <rgm@gnu.org>
 
        * custom.texi (Specifying File Variables):
index 290e5dc..f83ac38 100644 (file)
@@ -1623,6 +1623,11 @@ text-only terminal frame (@pxref{Frames}).  If you omit a filename
 argument while supplying the @samp{-c} option, the new frame displays
 the @samp{*scratch*} buffer (@pxref{Buffers}).
 
+@item -F
+@itemx --frame-parameters=@var{alist}
+Set the parameters for a newly-created graphical frame
+(@pxref{Frame Parameters}).
+
 @item -d @var{display}
 @itemx --display=@var{display}
 Tell Emacs to open the given files on the X display @var{display}
index 06ff578..88f70e4 100644 (file)
@@ -1,3 +1,7 @@
+2011-06-25  Andreas Rottmann  <a.rottmann@gmx.at>
+
+       * emacsclient.1: Mention --frame-parameters.
+
 2011-03-07  Chong Yidong  <cyd@stupidchicken.com>
 
        * Version 23.3 released.
index cae4d76..4843053 100644 (file)
@@ -58,6 +58,9 @@ daemon mode and emacsclient will try to connect to it.
 .B -c, \-\-create-frame
 create a new frame instead of trying to use the current Emacs frame
 .TP
+.B \-F, \-\-frame-parameters=ALIST
+set the parameters of a newly-created frame.
+.TP
 .B \-d, \-\-display=DISPLAY
 tell the server to display the files on the given display.
 .TP
index 243058a..32e4a0d 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -84,6 +84,10 @@ client frame in parent X window ID, via XEmbed.  This works like the
 +++
 *** New emacsclient argument -q/--quiet suppresses some status messages.
 
++++
+*** New emacsclient argument --frame-parameters can be used to set the
+frame parameters of a newly-created graphical frame.
+
 *** If emacsclient shuts down as a result of Emacs signalling an
 error, its exit status is 1.
 
index ec123e8..99ec98d 100644 (file)
@@ -1,3 +1,7 @@
+2011-06-25  Andreas Rottmann  <a.rottmann@gmx.at>
+
+       * emacsclient.c (longopts, decode_options, main): Add frame-parameters.
+
 2011-06-10  Paul Eggert  <eggert@cs.ucla.edu>
 
        * movemail.c: Fix race condition and related bugs (Bug#8836).
index c334fb6..56535a0 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
@@ -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);
@@ -1630,6 +1639,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.  */
index 4fec617..bccbe93 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-25  Andreas Rottmann  <a.rottmann@gmx.at>
+
+       * server.el (server-create-window-system-frame): Add parameters arg.
+       (server-process-filter): Doc fix.  Handle frame-parameters.
+
 2011-06-25  Juanma Barranquero  <lekktu@gmail.com>
 
        Fix bug#8730, bug#8781.
index 04d3569..42da7a2 100644 (file)
@@ -736,7 +736,8 @@ Server mode runs a process that accepts commands from the
 
     frame))
 
-(defun server-create-window-system-frame (display nowait proc parent-id)
+(defun server-create-window-system-frame (display nowait proc parent-id
+                                                 &optional parameters)
   (add-to-list 'frame-inherited-parameters 'client)
   (if (not (fboundp 'make-frame-on-display))
       (progn
@@ -751,7 +752,8 @@ Server mode runs a process that accepts commands from the
     ;; killing emacs on that frame.
     (let* ((params `((client . ,(if nowait 'nowait proc))
                      ;; This is a leftover, see above.
-                     (environment . ,(process-get proc 'env))))
+                     (environment . ,(process-get proc 'env))
+                     ,@parameters))
           (display (or display
                        (frame-parameter nil 'display)
                        (getenv "DISPLAY")
@@ -832,6 +834,9 @@ The following commands are accepted by the server:
 `-current-frame'
   Forbid the creation of new frames.
 
+`-frame-parameters ALIST'
+  Set the parameters of the created frame.
+
 `-nowait'
   Request that the next frame created should not be
   associated with this client.
@@ -940,6 +945,7 @@ The following commands are accepted by the client:
                commands
                dir
                use-current-frame
+               frame-parameters  ;parameters for newly created frame
                tty-name   ; nil, `window-system', or the tty name.
                tty-type   ; string.
                files
@@ -960,6 +966,13 @@ The following commands are accepted by the client:
                 ;; -current-frame:  Don't create frames.
                 (`"-current-frame" (setq use-current-frame t))
 
+                ;; -frame-parameters: Set frame parameters
+                (`"-frame-parameters"
+                 (let ((alist (pop args-left)))
+                   (if coding-system
+                       (setq alist (decode-coding-string alist coding-system)))
+                   (setq frame-parameters (car (read-from-string alist)))))
+
                 ;; -display DISPLAY:
                 ;; Open X frames on the given display instead of the default.
                 (`"-display"
@@ -1075,7 +1088,8 @@ The following commands are accepted by the client:
                    (if display (server-select-display display)))
                   ((eq tty-name 'window-system)
                    (server-create-window-system-frame display nowait proc
-                                                      parent-id))
+                                                      parent-id
+                                                      frame-parameters))
                   ;; When resuming on a tty, tty-name is nil.
                   (tty-name
                    (server-create-tty-frame tty-name tty-type proc))))