[comp.emacs] Am I using SunView or X-windows?

agw@convent.columbia.edu (Art Werschulz) (06/24/88)

Hi.

I would like to be able to setq a variable to one value if my emacs
was called as an emacstool via SunView (a/k/a suntools) and to another
value if my emacs was called via X-windows.

Any suggestions?
	Art Werschulz

 	ARPAnet:  agw@columbia.edu
	USEnet:   ... seismo!columbia!agw
	BITnet:   agw@columbia.edu
	CCNET:    agw@garfield
	ATTnet:   Columbia University (212) 280-3610 280-2736
		  Fordham University  (212) 841-5323 841-5396

meissner@xyzzy.UUCP (Michael Meissner) (06/26/88)

In article <5724@columbia.edu> agw@columbia.edu (Art Werschulz) writes:
| Hi.
| 
| I would like to be able to setq a variable to one value if my emacs
| was called as an emacstool via SunView (a/k/a suntools) and to another
| value if my emacs was called via X-windows.

I use the following (with some stuff deleted) in my .emacs file:

(defvar terminal-type     (getenv "TERM") "Terminal type.")

(defvar terminal-dg       nil "True if the terminal is a DG terminal.")
(defvar terminal-dec      nil "true if the terminal is a DEC terminal.")
(defvar terminal-sun      nil "True if the terminal is a sun terminal.")
(defvar terminal-suntools nil "True if running under suntools.")
(defvar terminal-x        nil "True if running under X windows.")

(if (string-match "^sun" terminal-type)
    (progn
      (setq terminal-sun t)
      (if (and (fboundp 'sun-window-init)
               (>= (sun-window-init) 0))

		 (progn
		   (setq terminal-suntools t)
		   (global-set-key "\C-z" 'suntools-icon)
		 )
      )
    )

    (if window-system
      (setq terminal-x t))

    (progn
      (if (or (string-match "[dD][1-4][0-9][0-9]" terminal-type)
	      (string-match "605[x3]" terminal-type)
	      (string-match "[gG][35]00" terminal-type))
	  	 (setq terminal-dg t))

      (if (string-match "vt[1-9][0-9][0-9]" terminal-type)
	  	 (progn
		   (setq terminal-dec t)
		   (setq term-setup-hook 'enable-arrow-keys)
		 )
      )

      (setq display-time-day-and-date nil)
      (display-time)
    )
)
Michael Meissner, Data General.

Uucp:	...!mcnc!rti!xyzzy!meissner
Arpa:	meissner@dg-rtp.DG.COM   (or) meissner%dg-rtp.DG.COM@relay.cs.net
-- 
Michael Meissner, Data General.

Uucp:	...!mcnc!rti!xyzzy!meissner
Arpa:	meissner@dg-rtp.DG.COM   (or) meissner%dg-rtp.DG.COM@relay.cs.net

guy@hobbes.ksr.com (Guy Hillyer) (06/26/88)

In article <5724@columbia.edu> agw@columbia.edu (Art Werschulz) writes:
>I would like to be able to setq a variable to one value if my emacs
>was called as an emacstool via SunView (a/k/a suntools) and to another
>value if my emacs was called via X-windows.

Here's how I do it:

(cond ((equal window-system 'x) (x-startup))
      ((getenv "WINDOW_PARENT") (suntools-startup)))

where x-startup and suntools-startup are functions that perform
window-system-specific initialization.  It's unfortunate that the
window-system variable is not set correctly when running under
suntools; I take this as further discouragment by FSF from using a
proprietary window system when you can get X for free.

In any case, the use of the WINDOW_PARENT environment variable is a
little suspect.  It may be more appropriate to use
WMGR_ENV_PLACEHOLDER instead.  In practice, both are present in the
environment when a process is the child of a shelltool.

    	    	    	    	Guy Hillyer
    	    	    	    	Kendall Square Research Corporation
    	    	    	    	ksr!guy@harvard.harvard.edu

michael@pbinfo.uucp (Michael Schmidt) (06/27/88)

In article <5724@columbia.edu>, agw@convent (Art Werschulz) writes:
>I would like to be able to setq a variable to one value if my emacs
>was called as an emacstool via SunView (a/k/a suntools) and to another
>value if my emacs was called via X-windows.

At least with X you ask for the variable "window-system":

(if (eq window-system 'x)
    (progn
      (x-set-bell t)))


	Michael Schmidt
-- 
    Michael Schmidt, Universitaet-GH Paderborn, FB 17, Warburger Str.100,
                     D-4790 Paderborn, West Germany
Mail:   michael@pbinfo.UUCP         or          michael%pbinfo@uunet.uu.net

janssen@titan.SW.MCC.COM (Bill Janssen) (06/30/88)

Probably easier just to "cond" on terminal-type.  Anyway:

In article <932@xyzzy.UUCP>, meissner@xyzzy.UUCP (Michael Meissner) writes:
>     (if window-system
>       (setq terminal-x t))

This would be more safely written as

	(if (eq window-system 'x)
	  (setq terminal-x t))

as the 18.51 patches for NeWS set the window-system var to 'news (or is
it 'NeWS?)

Bill

janssen@titan.SW.MCC.COM (Bill Janssen) (06/30/88)

In article <363@ksr.UUCP>, guy@hobbes.ksr.com (Guy Hillyer) writes:
> In article <5724@columbia.edu> agw@columbia.edu (Art Werschulz) writes:
> >I would like to be able to setq a variable to one value if my emacs
> >was called as an emacstool via SunView (a/k/a suntools) and to another
> >value if my emacs was called via X-windows.
> 
> Here's how I do it:
> 
> (cond ((equal window-system 'x) (x-startup))
>       ((getenv "WINDOW_PARENT") (suntools-startup)))
...
> In any case, the use of the WINDOW_PARENT environment variable is a
> little suspect.  It may be more appropriate to use
> WMGR_ENV_PLACEHOLDER instead.  In practice, both are present in the
> environment when a process is the child of a shelltool.

Unfortunately, I run X in overview mode over sunview, and though I can
detect the X, I can't detect the SunView, which I start from a different
X, so that DISPLAY and WINDOW_foo and WMGR_foo are all set.  GNU Emacs
doesn't know how to resolve that, either, so it can't set "window-system".
In any case, GNU Emacs running in a shelltool is not really running under
a window system.  Emacstool, however, could set an environment flag that
Emacs could pick up on, with a single line

	putenv ("EMACSTOOL=T");

before starting the emacs.  This would then give GNU Emacs something to
key off, so that it could set the "window-system" var properly.  Of course,
you can modify your local copies of emacstool.c and emacs/src/emacs.c to
do this.

Bill