From: Julian Bradfield <jcb+xeb(a)jcbradfield.org>
Date: Sun, 11 Jan 2009 22:26:27 +0000
On 2009-01-11, Aidan Kehoe <kehoea(a)parhasard.net> wrote:
(let ((print-readably nil)
console-details)
(setq console-details
(prin1-to-string
(device-console (frame-device (selected-frame)))))
(if (string-match "#<x-console on
\"\\([^\"]+\\)"
console-details)
(setenv "DISPLAY" (match-string 1 console-details))
(setenv "DISPLAY" original-display))))))
Unfortunately, thereâs no nicer way to get the string display name
that a
given console thinks itâs connected to. Maybe we should change that.
This is what I do in my .emacs :
; this overrides make-x-device so as to store the original display
argument
; used to create it. Why? Because device-x-display doesn't exist,
documentation
; notwithstanding, and we need it to pass to external programs.
I just traced make-x-device, just to verify the display argument
1 -> make-x-device: display="localhost:10.0"
1 <- make-x-device: #<x-device on "localhost:10.0" 0x1d41f0>
device-connection returns the display of a device.
(and (eq (frame-type (selected-frame)) 'x)
(device-connection (frame-device (selected-frame))))
==>
"localhost:10.0"
(defvar x-device-display-alist nil)
; make it robust against repeated loads of .emacs!
(when (and (fboundp 'make-x-device) (not (fboundp
'real-make-x-device)))
(add-hook 'delete-device-hook
(lambda (d) (setq x-device-display-alist
(remassoc d x-device-display-alist))))
(fset 'real-make-x-device (symbol-function 'make-x-device))
(defun make-x-device (&optional display)
"Create a new device connected to DISPLAY, recording DISPLAY in
x-device-display-alist."
(let ((d (real-make-x-device display)))
(setq x-device-display-alist (cons (cons d display)
x-device-display-alist))
d))
;; this returns nil for the initial device, but that's ok, because
;; then the functions will use DISPLAY anyway.
(defun device-x-display (device)
"Return display used to create device."
(cdr-safe (assoc device x-device-display-alist)))
)
I think your code can be replaced by the following:
(defun device-x-display (device)
"Return display used to create device."
(and (eq (device-type device) 'x)
(device-connection device)))
(device-x-display (frame-device (selected-frame)))
"localhost:10.0"
-jeff
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-beta