* Re: x-migrant.el - handle subprocesses over multiple X displays
[not found] ` <87adez3bj4.fsf@camp4.serpentine.com>
@ 2003-04-10 14:06 ` Stefan Monnier <foo@acm.com>
[not found] ` <878yu1q2ag.fsf@camp4.serpentine.com>
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier <foo@acm.com> @ 2003-04-10 14:06 UTC (permalink / raw)
> ;; 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
^ permalink raw reply [flat|nested] 3+ messages in thread