all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#5864: 23.1; [PATCH] emacsclient support for setting frame parameters
@ 2010-04-08 15:50 Andreas Rottmann
  2011-03-08 21:16 ` bug#5864: Update bug information Andreas Rottmann
  2011-06-20 16:04 ` bug#5864: Copyright assignment status Andreas Rottmann
  0 siblings, 2 replies; 10+ messages in thread
From: Andreas Rottmann @ 2010-04-08 15:50 UTC (permalink / raw)
  To: 5864

[-- Attachment #1: Type: text/plain, Size: 488 bytes --]


The attached patch (against recent HEAD) adds a new option
`--frame-parameters' to emacsclient, which allows to set the frame
parameter alist for the to-be-created frame.

This feature is useful for window managers that allow matching on X
properties. Without this patch, it is not possible to influence those
at /frame creation time/, they could only be set after the frame was
already created. This is to late for windowmanagers who match, and
typically do so at frame creation time.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: --frame-parameters option for emacsclient --]
[-- Type: text/x-diff, Size: 4591 bytes --]

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 1e7ec7d..c4aeb68 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -154,6 +154,10 @@ 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;
+
 void print_help_and_exit () NO_RETURN;
 
 struct option longopts[] =
@@ -166,6 +170,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
@@ -587,6 +592,10 @@ decode_options (argc, 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);
@@ -1620,6 +1629,13 @@ main (argc, 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.  */
diff --git a/lisp/server.el b/lisp/server.el
index d36b99c..9a7b4c8 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -708,7 +708,10 @@ Server mode runs a process that accepts commands from the
                                      (number-to-string (emacs-pid)) "\n"))
     frame))
 
-(defun server-create-window-system-frame (display nowait proc)
+(defun server-create-window-system-frame (display 
+                                          nowait
+                                          proc
+                                          &optional parameters)
   (add-to-list 'frame-inherited-parameters 'client)
   (if (not (fboundp 'make-frame-on-display))
       (progn
@@ -723,7 +726,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))
            (frame (make-frame-on-display
                    (or display
                        (frame-parameter nil 'display)
@@ -803,6 +807,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.
@@ -904,6 +911,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
@@ -926,6 +934,13 @@ The following commands are accepted by the client:
 		 ;; -current-frame:  Don't create frames.
 		 ((equal "-current-frame" arg) (setq use-current-frame t))
 
+                 ;; -frame-parameters: Set frame parameters
+                 ((equal "-frame-parameters" arg)
+                  (lexical-let ((alist (pop command-line-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.
 		 ((and (equal "-display" arg) command-line-args-left)
@@ -1036,7 +1051,11 @@ The following commands are accepted by the client:
 		    (setq tty-name nil tty-type nil)
 		    (if display (server-select-display display)))
 		   ((eq tty-name 'window-system)
-		    (server-create-window-system-frame display nowait proc))
+		    (server-create-window-system-frame
+                     display
+                     nowait
+                     proc
+                     frame-parameters))
 		   ;; When resuming on a tty, tty-name is nil.
 		   (tty-name
 		    (server-create-tty-frame tty-name tty-type proc))))

[-- Attachment #3: Type: text/plain, Size: 63 bytes --]


Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#5864: Update bug information
  2010-04-08 15:50 bug#5864: 23.1; [PATCH] emacsclient support for setting frame parameters Andreas Rottmann
@ 2011-03-08 21:16 ` Andreas Rottmann
  2011-04-17  0:34   ` bug#5864: emacsclient support for setting frame parameters Glenn Morris
  2011-06-20 16:04 ` bug#5864: Copyright assignment status Andreas Rottmann
  1 sibling, 1 reply; 10+ messages in thread
From: Andreas Rottmann @ 2011-03-08 21:16 UTC (permalink / raw)
  To: 5864, control

[-- Attachment #1: Type: text/plain, Size: 313 bytes --]

retitle 5864 24.0.50; [PATCH] emacsclient support for setting frame parameters
thanks

Here's an updated version of the patch -- no real changes, but it
resolves a conflict in NEWS and should again apply cleanly against
current trunk (Tue Mar 8 09:33:55 2011 -0800, "Add missing piece of
previous doc/ change").


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: frame-params.diff --]
[-- Type: text/x-diff, Size: 7641 bytes --]

From: Andreas Rottmann <a.rottmann@gmx.at>
Subject: Allow passing frame parameters to emacsclient

Adds a new option `--frame-parameters' to emacsclient, which allows to
set the frame parameter alist for the to-be-created frame.

This feature is useful for window managers that allow matching on X
properties.  Without this patch, it is not possible to influence those
at /frame creation time/, they could only be set after the frame was
already created.  This is too late for windowmanagers who match the X
properties at frame creation time.

* lib-src/emacsclient.c (frame_parameters): New global variable.
  (longopts): New entry "frame-parameters" with short option alias
  'F'.
  (decode_options): Process frame-parameters option.
  (main): Send value of frame-parameters option to emacs if we are
  constructing a new frame.

* lisp/servel.el (server-create-window-system-frame): Add new optional
  argument `parameters' which allows setting additional frame
  parameters.
  (server-process-filter): Handle "-frame-parameters" command, and
  pass its value to `server-create-window-system-frame'

* doc/emacs/misc.texi (Invoking emacsclient): Document the
  "--frame-parameters" option.
* doc/man/emacsclient.1: Ditto.

---
 doc/emacs/misc.texi   |    5 +++++
 doc/man/emacsclient.1 |    3 +++
 etc/NEWS              |    4 ++++
 lib-src/emacsclient.c |   16 ++++++++++++++++
 lisp/server.el        |   23 ++++++++++++++++++++---
 5 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 1299895..5fb3912 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -1622,6 +1622,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. @xref{Frame
+Parameters}.
+
 @item -d @var{display}
 @itemx --display=@var{display}
 Tell Emacs to open the given files on the X display @var{display}
diff --git a/doc/man/emacsclient.1 b/doc/man/emacsclient.1
index cae4d76..4843053 100644
--- a/doc/man/emacsclient.1
+++ b/doc/man/emacsclient.1
@@ -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
diff --git a/etc/NEWS b/etc/NEWS
index 330a3b6..68474ac 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -74,6 +74,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.
 
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index abc9aee..bcb8498 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -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
@@ -600,6 +605,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);
@@ -1631,6 +1640,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.  */
diff --git a/lisp/server.el b/lisp/server.el
index df8cae0..2a883bd 100644
--- a/lisp/server.el
+++ b/lisp/server.el
@@ -728,7 +728,11 @@ 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
@@ -743,7 +747,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")
@@ -825,6 +830,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.
@@ -933,6 +941,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
@@ -953,6 +962,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"
+                 (lexical-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"
@@ -1068,7 +1084,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))))
-- 
tg: (dd5a974..) t/frame-params (depends on: master)

[-- Attachment #3: Type: text/plain, Size: 16 bytes --]


Regards, Rotty

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#5864: emacsclient support for setting frame parameters
  2011-03-08 21:16 ` bug#5864: Update bug information Andreas Rottmann
@ 2011-04-17  0:34   ` Glenn Morris
  2011-04-17  1:07     ` Andreas Rottmann
  0 siblings, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2011-04-17  0:34 UTC (permalink / raw)
  To: Andreas Rottmann; +Cc: 5864


Hi - thanks for the patch and sorry for the delay in getting back to you.
This looks good and I think we should include it. It's probably just
large enough that we should get a copyright assignment (I will send the
form separately). One missing piece: decode_options and
print_help_and_exit in emacsclient.c need updating.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#5864: emacsclient support for setting frame parameters
  2011-04-17  0:34   ` bug#5864: emacsclient support for setting frame parameters Glenn Morris
@ 2011-04-17  1:07     ` Andreas Rottmann
  2011-04-17  2:18       ` Glenn Morris
  2011-05-30 18:26       ` Glenn Morris
  0 siblings, 2 replies; 10+ messages in thread
From: Andreas Rottmann @ 2011-04-17  1:07 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 5864

Glenn Morris <rgm@gnu.org> writes:

> Hi - thanks for the patch and sorry for the delay in getting back to you.
> This looks good and I think we should include it. It's probably just
> large enough that we should get a copyright assignment (I will send the
> form separately). 
>
Cool. I've already received papers from FSF due to another Emacs patch,
I just have to get a disclaimer from my University, and send them back.
I'll notify you when the process is complete.

> One missing piece: decode_options and print_help_and_exit in
> emacsclient.c need updating.
>
Good catch; I'll post an updated patch, probably before I'm on file
wrt. copyright assignment.  I'm not entirely sure about decode_options,
however -- should there really be a short option corresponding to
--frame-parameters, and if so, is 'F' the right choice?  I don't have
any specific preferences on that question.

Regards, Rotty
-- 
Andreas Rottmann -- <http://rotty.yi.org/>





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#5864: emacsclient support for setting frame parameters
  2011-04-17  1:07     ` Andreas Rottmann
@ 2011-04-17  2:18       ` Glenn Morris
  2011-05-30 18:26       ` Glenn Morris
  1 sibling, 0 replies; 10+ messages in thread
From: Glenn Morris @ 2011-04-17  2:18 UTC (permalink / raw)
  To: Andreas Rottmann; +Cc: 5864

Andreas Rottmann wrote:

> I'm not entirely sure about decode_options, however -- should there
> really be a short option corresponding to --frame-parameters, and if
> so, is 'F' the right choice? I don't have any specific preferences on
> that question.

Me neither; but you documented a -F option in other parts of the patch,
and it's not like emacsclient is running short of single letters to use
for options, and -F seems reasonable for `frame-parameters', so why not...





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#5864: emacsclient support for setting frame parameters
  2011-04-17  1:07     ` Andreas Rottmann
  2011-04-17  2:18       ` Glenn Morris
@ 2011-05-30 18:26       ` Glenn Morris
  2011-05-31  1:35         ` Andreas Rottmann
  1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2011-05-30 18:26 UTC (permalink / raw)
  To: Andreas Rottmann; +Cc: 5864


Hello, how is it going with your copyright assignment?
It would be nice to get this into Emacs before the end of June; see

http://lists.gnu.org/archive/html/emacs-devel/2011-05/msg00953.html





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#5864: emacsclient support for setting frame parameters
  2011-05-30 18:26       ` Glenn Morris
@ 2011-05-31  1:35         ` Andreas Rottmann
  0 siblings, 0 replies; 10+ messages in thread
From: Andreas Rottmann @ 2011-05-31  1:35 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 5864

Glenn Morris <rgm@gnu.org> writes:

> Hello, how is it going with your copyright assignment?
>
There is some issues with the disclaimer from my University: basically,
they won't issue such a thing, as they say they're not in a position to
claim copyright in the first place.  The copyright clerk still wants
some clarification on that -- I'll have another call with the legal
department this week, and hopefully get a response that is satisfactory
to the copyright clerk.

> It would be nice to get this into Emacs before the end of June; see
> http://lists.gnu.org/archive/html/emacs-devel/2011-05/msg00953.html
>
I hope to be able to send the papers this week, so this hopefully works
out.

Regards, Rotty (who is amazed about what amounts of bureaucracy a
                few-line patch can involve)
-- 
Andreas Rottmann -- <http://rotty.yi.org/>





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#5864: Copyright assignment status
  2010-04-08 15:50 bug#5864: 23.1; [PATCH] emacsclient support for setting frame parameters Andreas Rottmann
  2011-03-08 21:16 ` bug#5864: Update bug information Andreas Rottmann
@ 2011-06-20 16:04 ` Andreas Rottmann
  2011-06-24  6:36   ` Andreas Rottmann
  1 sibling, 1 reply; 10+ messages in thread
From: Andreas Rottmann @ 2011-06-20 16:04 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 5864

Hi!

Just a heads-up: I sent the papers today, so with some luck, I get the
OK flag from the copyright clerk in about a week -- hopefully that's
still early enough so the patch can make into trunk before the freeze.

Regards, Rotty





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#5864: Copyright assignment status
  2011-06-20 16:04 ` bug#5864: Copyright assignment status Andreas Rottmann
@ 2011-06-24  6:36   ` Andreas Rottmann
  2011-06-25 18:12     ` bug#5864: Glenn Morris
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Rottmann @ 2011-06-24  6:36 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 5864

Andreas Rottmann <a.rottmann@gmx.at> writes:

> Hi!
>
> Just a heads-up: I sent the papers today, so with some luck, I get the
> OK flag from the copyright clerk in about a week -- hopefully that's
> still early enough so the patch can make into trunk before the freeze.
>
I just got a mail from the copyright clerk stating that my papers have
been received, so the patch should be ready-to-go, at least from a legal
POV.  Note that although my status is marked as "expired disclaimer",
this should not affect this patch, as it's been submitted before I was
employed at my current company (i.e. before June 1.).  I'll try to get
and send a disclaimer soonish, in case I submit any patches in the
future.

Regards, Rotty





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#5864:
  2011-06-24  6:36   ` Andreas Rottmann
@ 2011-06-25 18:12     ` Glenn Morris
  0 siblings, 0 replies; 10+ messages in thread
From: Glenn Morris @ 2011-06-25 18:12 UTC (permalink / raw)
  To: 5864-done

Version: 24.1

Andreas Rottmann wrote:

> I just got a mail from the copyright clerk stating that my papers have
> been received, so the patch should be ready-to-go, at least from a legal
> POV.  Note that although my status is marked as "expired disclaimer",
> this should not affect this patch, as it's been submitted before I was
> employed at my current company (i.e. before June 1.).

I was wondering what that meant...

I have applied your patch. Thank you for persevering with this!

Summary: A frame-parameters argument can now be passed to emacsclient to
control the properties of new graphical frames.





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-06-25 18:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-08 15:50 bug#5864: 23.1; [PATCH] emacsclient support for setting frame parameters Andreas Rottmann
2011-03-08 21:16 ` bug#5864: Update bug information Andreas Rottmann
2011-04-17  0:34   ` bug#5864: emacsclient support for setting frame parameters Glenn Morris
2011-04-17  1:07     ` Andreas Rottmann
2011-04-17  2:18       ` Glenn Morris
2011-05-30 18:26       ` Glenn Morris
2011-05-31  1:35         ` Andreas Rottmann
2011-06-20 16:04 ` bug#5864: Copyright assignment status Andreas Rottmann
2011-06-24  6:36   ` Andreas Rottmann
2011-06-25 18:12     ` bug#5864: Glenn Morris

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.