From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Stefan Monnier " Newsgroups: gmane.emacs.help Subject: Re: x-migrant.el - handle subprocesses over multiple X displays Date: 10 Apr 2003 10:06:41 -0400 Organization: Yale University Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <5lr88a30r2.fsf@rum.cs.yale.edu> References: <87adez3bj4.fsf@camp4.serpentine.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1049984391 5825 80.91.224.249 (10 Apr 2003 14:19:51 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Thu, 10 Apr 2003 14:19:51 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 10 16:19:50 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 193ctQ-0001RV-00 for ; Thu, 10 Apr 2003 16:19:08 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 193cpv-0002cp-07 for gnu-help-gnu-emacs@m.gmane.org; Thu, 10 Apr 2003 10:15:31 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!news.ycc.yale.edu!rum.cs.yale.edu!rum.cs.yale.edu Original-Newsgroups: gnu.emacs.sources,gnu.emacs.help Original-Followup-To: gnu.emacs.help Original-Lines: 65 Original-NNTP-Posting-Host: rum.cs.yale.edu User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-Original-NNTP-Posting-Host: rum.cs.yale.edu X-Original-Trace: 10 Apr 2003 10:06:42 -0400, rum.cs.yale.edu Original-Xref: shelby.stanford.edu gnu.emacs.sources:9474 gnu.emacs.help:111847 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:8348 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:8348 > ;; This package advises the Emacs process startup functions, so that > ;; they set up the DISPLAY environment variable correctly. This is > ;; very useful if you run the same Emacs session on multiple X > ;; displays at once, and sometimes need to pop up an X application > ;; from within Emacs. Sounds cool. Maybe this should be integrated directly in the C code. > (defmacro current-x-display-name () > "Return the name of the currently active X display, or nil for none." > (if xm-running-xemacs > '(if (eq (frame-type) 'x) > (device-connection)) > '(frame-parameter nil 'display))) Testing for `xemacs' is generally bad style. How about: (if (fboundp 'device-connection) (defun current-x-display-name () (if (eq (frame-type) 'x) (device-connection))) (defun current-x-display-name () (frame-parameter nil 'display))) or (defun current-x-display-name () "Return the name of the currently active X display, or nil for none." (if (fboundp 'device-connection) (if (eq (frame-type) 'x) (device-connection)) (frame-parameter nil 'display))) > (defmacro with-current-x-display (&rest body) > "Evaluate BODY with the DISPLAY environment variable set correctly. > In this case, we take 'correct' as being the display on which the > frame that currently has the focus is showing." > (let ((dpy (gensym "dpy-"))) Better use `make-symbol' which is more efficient and doesn't require CL. > (process-environment > (if ,dpy > (mapcar (function (lambda (env) > (if (string-match "^DISPLAY=" env) > (concat "DISPLAY=" ,dpy) > env))) > process-environment) > process-environment))) You don't need to replace DISPLAY, you can simply add another one and it will shadow any potential older one: (process-environment (if ,dpy (cons (concat "DISPLAY=" ,dpy) process-environment) process-environment))) > (if xm-running-xemacs Better test for (fboundp 'start-process-internal) and (fboundp 'call-process-internal). Stefan