diff lisp/server.el @ 108828:87dad1e1c860

Add --parent-id argument to emacsclient. * lib-src/emacsclient.c (longopts, decode_options, print_help_and_exit): New arg `-parent-id'. (main): Send parent-id to Emacs. * lisp/server.el (server-process-filter): Receive parent-id argument from emacsclient. (server-create-window-system-frame): New arg. Pass parent-id as frame parameter.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 29 May 2010 19:50:47 -0400
parents 511da81b16c5
children 71264d39075a
line wrap: on
line diff
--- a/lisp/server.el	Sat May 29 11:57:11 2010 -0700
+++ b/lisp/server.el	Sat May 29 19:50:47 2010 -0400
@@ -711,7 +711,7 @@
                                      (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 parent-id)
   (add-to-list 'frame-inherited-parameters 'client)
   (if (not (fboundp 'make-frame-on-display))
       (progn
@@ -727,12 +727,14 @@
     (let* ((params `((client . ,(if nowait 'nowait proc))
                      ;; This is a leftover, see above.
                      (environment . ,(process-get proc 'env))))
-           (frame (make-frame-on-display
-                   (or display
-                       (frame-parameter nil 'display)
-                       (getenv "DISPLAY")
-                       (error "Please specify display"))
-                   params)))
+	   (display (or display
+			(frame-parameter nil 'display)
+			(getenv "DISPLAY")
+			(error "Please specify display")))
+	   frame)
+      (if parent-id
+	  (push (cons 'parent-id (string-to-number parent-id)) params))
+      (setq frame (make-frame-on-display display params))
       (server-log (format "%s created" frame) proc)
       (select-frame frame)
       (process-put proc 'frame frame)
@@ -900,15 +902,16 @@
 		(coding-system (and (default-value 'enable-multibyte-characters)
 				    (or file-name-coding-system
 					default-file-name-coding-system)))
-		nowait ; t if emacsclient does not want to wait for us.
-		frame ; The frame that was opened for the client (if any).
-		display		     ; Open the frame on this display.
-		dontkill       ; t if the client should not be killed.
+		nowait     ; t if emacsclient does not want to wait for us.
+		frame      ; Frame opened for the client (if any).
+		display    ; Open frame on this display.
+		parent-id  ; Window ID for XEmbed
+		dontkill   ; t if client should not be killed.
 		commands
 		dir
 		use-current-frame
-		tty-name       ;nil, `window-system', or the tty name.
-		tty-type             ;string.
+		tty-name   ; nil, `window-system', or the tty name.
+		tty-type   ; string.
 		files
 		filepos
 		command-line-args-left
@@ -935,6 +938,12 @@
 		  (setq display (pop command-line-args-left))
                   (if (zerop (length display)) (setq display nil)))
 
+		 ;; -parent-id ID:
+		 ;; Open X frame within window ID, via XEmbed.
+		 ((and (equal "-parent-id" arg) command-line-args-left)
+		  (setq parent-id (pop command-line-args-left))
+                  (if (zerop (length parent-id)) (setq parent-id nil)))
+
 		 ;; -window-system:  Open a new X frame.
 		 ((equal "-window-system" arg)
                   (setq dontkill t)
@@ -1039,7 +1048,8 @@
 		    (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
+						       parent-id))
 		   ;; When resuming on a tty, tty-name is nil.
 		   (tty-name
 		    (server-create-tty-frame tty-name tty-type proc))))