From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Rottmann Newsgroups: gmane.emacs.bugs Subject: bug#5864: 23.1; [PATCH] emacsclient support for setting frame parameters Date: Thu, 08 Apr 2010 17:50:46 +0200 Message-ID: <87zl1e6izt.fsf@delenn.lan> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1270787295 27737 80.91.229.12 (9 Apr 2010 04:28:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 9 Apr 2010 04:28:15 +0000 (UTC) To: 5864@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Apr 09 06:28:13 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O05pE-0007Gf-V1 for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Apr 2010 06:28:13 +0200 Original-Received: from localhost ([127.0.0.1]:50505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O05pE-0006fN-8g for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Apr 2010 00:28:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nzucx-0008D8-ER for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2010 12:30:47 -0400 Original-Received: from [140.186.70.92] (port=39872 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nzuc5-000836-K4 for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2010 12:30:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nzuas-0007Np-PG for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2010 12:28:48 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60947) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nzuaq-0007Mz-CU for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2010 12:28:37 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1NzuMj-00050n-UU; Thu, 08 Apr 2010 12:14:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andreas Rottmann Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Apr 2010 16:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 5864 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.127074323619257 (code B ref -1); Thu, 08 Apr 2010 16:14:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Apr 2010 16:13:56 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NzuMd-00050Y-Ic for submit@debbugs.gnu.org; Thu, 08 Apr 2010 12:13:56 -0400 Original-Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nzu0e-0004r3-91 for submit@debbugs.gnu.org; Thu, 08 Apr 2010 11:51:13 -0400 Original-Received: from lists.gnu.org ([199.232.76.165]:45114) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Nzu0Z-0000jn-Js for submit@debbugs.gnu.org; Thu, 08 Apr 2010 11:51:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nzu0Z-00037z-8h for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2010 11:51:07 -0400 Original-Received: from [140.186.70.92] (port=49365 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nzu0Q-00035B-My for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2010 11:51:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nzu0O-0002gp-IS for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2010 11:50:58 -0400 Original-Received: from mail.gmx.net ([213.165.64.20]:44353) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1Nzu0O-0002gX-4u for bug-gnu-emacs@gnu.org; Thu, 08 Apr 2010 11:50:56 -0400 Original-Received: (qmail invoked by alias); 08 Apr 2010 15:50:53 -0000 Original-Received: from 83-215-154-5.hage.dyn.salzburg-online.at (EHLO nathot.lan) [83.215.154.5] by mail.gmx.net (mp016) with SMTP; 08 Apr 2010 17:50:53 +0200 X-Authenticated: #3102804 X-Provags-ID: V01U2FsdGVkX19YYYMWoCxY9Yqm+IZWMqEFZ06S28Pig6XfPF0yQj sru7+vSPu+fbna Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by nathot.lan (Postfix) with ESMTP id 47CEE51B7B for ; Thu, 8 Apr 2010 17:50:52 +0200 (CEST) Original-Received: from nathot.lan ([127.0.0.1]) by localhost (nathot.lan [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eiDvEo2aAiIe for ; Thu, 8 Apr 2010 17:50:47 +0200 (CEST) Original-Received: from delenn.lan (delenn.lan [192.168.3.11]) by nathot.lan (Postfix) with ESMTP id B373B51B79 for ; Thu, 8 Apr 2010 17:50:47 +0200 (CEST) Original-Received: by delenn.lan (Postfix, from userid 1000) id 8B6D874DEB; Thu, 8 Apr 2010 17:50:46 +0200 (CEST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.75 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Mailman-Approved-At: Thu, 08 Apr 2010 12:13:54 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 08 Apr 2010 12:14:01 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Mailman-Approved-At: Fri, 09 Apr 2010 00:28:07 -0400 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:36116 Archived-At: --=-=-= 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=frame-params.patch Content-Description: --frame-parameters option for emacsclient 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)))) --=-=-= Regards, Rotty -- Andreas Rottmann -- --=-=-=--