Allow emacsclient to set parameters of new graphical frames (bug#5864)

* 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.
This commit is contained in:
Andreas Rottmann 2011-06-25 11:05:48 -07:00 committed by Glenn Morris
parent 919bbce05b
commit 18a4ce5ea1
9 changed files with 62 additions and 3 deletions

View 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> 2011-06-09 Glenn Morris <rgm@gnu.org>
* custom.texi (Specifying File Variables): * custom.texi (Specifying File Variables):

View 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 argument while supplying the @samp{-c} option, the new frame displays
the @samp{*scratch*} buffer (@pxref{Buffers}). 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} @item -d @var{display}
@itemx --display=@var{display} @itemx --display=@var{display}
Tell Emacs to open the given files on the X display @var{display} Tell Emacs to open the given files on the X display @var{display}

View 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> 2011-03-07 Chong Yidong <cyd@stupidchicken.com>
* Version 23.3 released. * Version 23.3 released.

View file

@ -58,6 +58,9 @@ daemon mode and emacsclient will try to connect to it.
.B -c, \-\-create-frame .B -c, \-\-create-frame
create a new frame instead of trying to use the current Emacs frame create a new frame instead of trying to use the current Emacs frame
.TP .TP
.B \-F, \-\-frame-parameters=ALIST
set the parameters of a newly-created frame.
.TP
.B \-d, \-\-display=DISPLAY .B \-d, \-\-display=DISPLAY
tell the server to display the files on the given display. tell the server to display the files on the given display.
.TP .TP

View file

@ -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 -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 *** If emacsclient shuts down as a result of Emacs signalling an
error, its exit status is 1. error, its exit status is 1.

View 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> 2011-06-10 Paul Eggert <eggert@cs.ucla.edu>
* movemail.c: Fix race condition and related bugs (Bug#8836). * movemail.c: Fix race condition and related bugs (Bug#8836).

View file

@ -160,6 +160,10 @@ const char *server_file = NULL;
/* PID of the Emacs server process. */ /* PID of the Emacs server process. */
int emacs_pid = 0; 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 print_help_and_exit (void) NO_RETURN;
static void fail (void) NO_RETURN; static void fail (void) NO_RETURN;
@ -175,6 +179,7 @@ struct option longopts[] =
{ "nw", no_argument, NULL, 't' }, { "nw", no_argument, NULL, 't' },
{ "create-frame", no_argument, NULL, 'c' }, { "create-frame", no_argument, NULL, 'c' },
{ "alternate-editor", required_argument, NULL, 'a' }, { "alternate-editor", required_argument, NULL, 'a' },
{ "frame-parameters", required_argument, NULL, 'F' },
#ifndef NO_SOCKETS_IN_FILE_SYSTEM #ifndef NO_SOCKETS_IN_FILE_SYSTEM
{ "socket-name", required_argument, NULL, 's' }, { "socket-name", required_argument, NULL, 's' },
#endif #endif
@ -599,6 +604,10 @@ decode_options (int argc, char **argv)
print_help_and_exit (); print_help_and_exit ();
break; break;
case 'F':
frame_parameters = optarg;
break;
default: default:
message (TRUE, "Try `%s --help' for more information\n", progname); message (TRUE, "Try `%s --help' for more information\n", progname);
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
@ -1630,6 +1639,13 @@ main (int argc, char **argv)
send_to_emacs (emacs_socket, " "); 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. /* If using the current frame, send tty information to Emacs anyway.
In daemon mode, Emacs may need to occupy this tty if no other In daemon mode, Emacs may need to occupy this tty if no other
frame is available. */ frame is available. */

View 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> 2011-06-25 Juanma Barranquero <lekktu@gmail.com>
Fix bug#8730, bug#8781. Fix bug#8730, bug#8781.

View file

@ -736,7 +736,8 @@ Server mode runs a process that accepts commands from the
frame)) 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) (add-to-list 'frame-inherited-parameters 'client)
(if (not (fboundp 'make-frame-on-display)) (if (not (fboundp 'make-frame-on-display))
(progn (progn
@ -751,7 +752,8 @@ Server mode runs a process that accepts commands from the
;; killing emacs on that frame. ;; killing emacs on that frame.
(let* ((params `((client . ,(if nowait 'nowait proc)) (let* ((params `((client . ,(if nowait 'nowait proc))
;; This is a leftover, see above. ;; This is a leftover, see above.
(environment . ,(process-get proc 'env)))) (environment . ,(process-get proc 'env))
,@parameters))
(display (or display (display (or display
(frame-parameter nil 'display) (frame-parameter nil 'display)
(getenv "DISPLAY") (getenv "DISPLAY")
@ -832,6 +834,9 @@ The following commands are accepted by the server:
`-current-frame' `-current-frame'
Forbid the creation of new frames. Forbid the creation of new frames.
`-frame-parameters ALIST'
Set the parameters of the created frame.
`-nowait' `-nowait'
Request that the next frame created should not be Request that the next frame created should not be
associated with this client. associated with this client.
@ -940,6 +945,7 @@ The following commands are accepted by the client:
commands commands
dir dir
use-current-frame use-current-frame
frame-parameters ;parameters for newly created frame
tty-name ; nil, `window-system', or the tty name. tty-name ; nil, `window-system', or the tty name.
tty-type ; string. tty-type ; string.
files files
@ -960,6 +966,13 @@ The following commands are accepted by the client:
;; -current-frame: Don't create frames. ;; -current-frame: Don't create frames.
(`"-current-frame" (setq use-current-frame t)) (`"-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: ;; -display DISPLAY:
;; Open X frames on the given display instead of the default. ;; Open X frames on the given display instead of the default.
(`"-display" (`"-display"
@ -1075,7 +1088,8 @@ The following commands are accepted by the client:
(if display (server-select-display display))) (if display (server-select-display display)))
((eq tty-name 'window-system) ((eq tty-name 'window-system)
(server-create-window-system-frame display nowait proc (server-create-window-system-frame display nowait proc
parent-id)) parent-id
frame-parameters))
;; When resuming on a tty, tty-name is nil. ;; When resuming on a tty, tty-name is nil.
(tty-name (tty-name
(server-create-tty-frame tty-name tty-type proc)))) (server-create-tty-frame tty-name tty-type proc))))