* check whether emacs session is running under local X server
@ 2006-09-27 20:59 Roland Winkler
2006-09-27 22:39 ` Eric Hanchrow
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Roland Winkler @ 2006-09-27 20:59 UTC (permalink / raw)
In my .emacs I would like to distinguish between an emacs session
running under the local X server and an emacs session running under
a remote X server. I expect that the $DISPLAY variable can do the
job. But I am not familiar with the details.
(Once upon a time I set $DISPLAY manually. Nowadays I use ssh which
handles $DISPLAY for me, but I do not understand the scheme it uses.)
What can I do?
Thanks,
Roland
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: check whether emacs session is running under local X server
2006-09-27 20:59 check whether emacs session is running under local X server Roland Winkler
@ 2006-09-27 22:39 ` Eric Hanchrow
[not found] ` <mailman.7518.1159397614.9609.help-gnu-emacs@gnu.org>
2006-09-28 1:10 ` Glenn Morris
2 siblings, 0 replies; 7+ messages in thread
From: Eric Hanchrow @ 2006-09-27 22:39 UTC (permalink / raw)
>>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
Roland> In my .emacs I would like to distinguish between an emacs
Roland> session running under the local X server and an emacs
Roland> session running under a remote X server. I expect that
Roland> the $DISPLAY variable can do the job. But I am not
Roland> familiar with the details. (Once upon a time I set
Roland> $DISPLAY manually. Nowadays I use ssh which handles
Roland> $DISPLAY for me, but I do not understand the scheme it
Roland> uses.)
I don't think there's a 100% foolproof way, but here's how I do it:
(Isn't this awful?)
(let ((x-running-locally
(and
(boundp 'window-system)
(or (eq (assoc-default 'window-system (frame-parameters current-frame)) 'x)
(and (assq 'font (frame-parameters current-frame))
(assq 'display (frame-parameters current-frame))))
(getenv "DISPLAY")
(let ((display-data (split-string (getenv "DISPLAY") ":")))
(if (= 1 (length display-data)) ; e.g. ("0")
;; e.g. ("offby1" "0")
(setq display-data (cons (car (split-string (system-name) "\\.")) display-data))
(let* ((display-host (nth 0 display-data))
(display-number (car (read-from-string (nth 1 display-data)))))
;; display numbers >=10 imply we're using SSH from a remote
;; machine
(and (< display-number 10)
;; (string-equal (downcase (car (split-string display-host "\\.")))
;; (downcase (car (split-string (system-name)"\\."))))
))))))
))
--
When it comes to electronic voting, most liberals are just plain
old-fashioned nuts.
-- Joe Andrew, former chairman of the Democratic National
Committee
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: check whether emacs session is running under local X server
[not found] ` <mailman.7518.1159397614.9609.help-gnu-emacs@gnu.org>
@ 2006-09-27 23:44 ` Roland Winkler
2006-09-28 3:10 ` Eric Hanchrow
0 siblings, 1 reply; 7+ messages in thread
From: Roland Winkler @ 2006-09-27 23:44 UTC (permalink / raw)
Eric Hanchrow <offby1@blarg.net> writes:
> (Isn't this awful?)
I had expected something like this...
> (or (eq (assoc-default 'window-system (frame-parameters current-frame)) 'x)
What is the value of current-frame? The return value of (selected-frame)?
Thanks,
Roland
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: check whether emacs session is running under local X server
2006-09-27 20:59 check whether emacs session is running under local X server Roland Winkler
2006-09-27 22:39 ` Eric Hanchrow
[not found] ` <mailman.7518.1159397614.9609.help-gnu-emacs@gnu.org>
@ 2006-09-28 1:10 ` Glenn Morris
2006-09-28 1:56 ` Roland Winkler
2006-09-28 3:12 ` Eric Hanchrow
2 siblings, 2 replies; 7+ messages in thread
From: Glenn Morris @ 2006-09-28 1:10 UTC (permalink / raw)
Roland Winkler wrote:
> In my .emacs I would like to distinguish between an emacs session
> running under the local X server and an emacs session running under
> a remote X server. I expect that the $DISPLAY variable can do the
> job. But I am not familiar with the details.
> (Once upon a time I set $DISPLAY manually. Nowadays I use ssh which
> handles $DISPLAY for me, but I do not understand the scheme it uses.)
I just check whether the SSH_CLIENT environment variable is set or
not.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: check whether emacs session is running under local X server
2006-09-28 1:10 ` Glenn Morris
@ 2006-09-28 1:56 ` Roland Winkler
2006-09-28 3:12 ` Eric Hanchrow
1 sibling, 0 replies; 7+ messages in thread
From: Roland Winkler @ 2006-09-28 1:56 UTC (permalink / raw)
Glenn Morris <rgm+news@stanford.edu> writes:
>> In my .emacs I would like to distinguish between an emacs session
>> running under the local X server and an emacs session running under
>> a remote X server. I expect that the $DISPLAY variable can do the
>> job. But I am not familiar with the details.
>> (Once upon a time I set $DISPLAY manually. Nowadays I use ssh which
>> handles $DISPLAY for me, but I do not understand the scheme it uses.)
>
> I just check whether the SSH_CLIENT environment variable is set or
> not.
Thanks a lot! It seems that this is exactly what I was looking for.
Roland
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: check whether emacs session is running under local X server
2006-09-27 23:44 ` Roland Winkler
@ 2006-09-28 3:10 ` Eric Hanchrow
0 siblings, 0 replies; 7+ messages in thread
From: Eric Hanchrow @ 2006-09-28 3:10 UTC (permalink / raw)
>>>>> "Roland" == Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
>> (or (eq (assoc-default 'window-system (frame-parameters
>> current-frame)) 'x)
Roland> What is the value of current-frame? The return value of
Roland> (selected-frame)?
Oops! Yes.
--
The woods aren't any drier than they were in 2000, but there
are a lot more people with matches.
-- Doug Chapin, Electionline.org
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: check whether emacs session is running under local X server
2006-09-28 1:10 ` Glenn Morris
2006-09-28 1:56 ` Roland Winkler
@ 2006-09-28 3:12 ` Eric Hanchrow
1 sibling, 0 replies; 7+ messages in thread
From: Eric Hanchrow @ 2006-09-28 3:12 UTC (permalink / raw)
>>>>> "GM" == Glenn Morris <rgm+news@stanford.edu> writes:
GM> I just check whether the SSH_CLIENT environment variable is
GM> set or not.
Wish I'd thought of that :-)
--
The woods aren't any drier than they were in 2000, but there
are a lot more people with matches.
-- Doug Chapin, Electionline.org
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-09-28 3:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-27 20:59 check whether emacs session is running under local X server Roland Winkler
2006-09-27 22:39 ` Eric Hanchrow
[not found] ` <mailman.7518.1159397614.9609.help-gnu-emacs@gnu.org>
2006-09-27 23:44 ` Roland Winkler
2006-09-28 3:10 ` Eric Hanchrow
2006-09-28 1:10 ` Glenn Morris
2006-09-28 1:56 ` Roland Winkler
2006-09-28 3:12 ` Eric Hanchrow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).