[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: initialization elisp for platform ID

From: Tom Roche
Subject: Re: initialization elisp for platform ID
Date: Sun, 4 Nov 2001 12:55:31 -0500 (EST)

I wrote:
> Why doesn't
> (defvar running-on-solaris (string-match "solaris" (getenv "OSTYPE")))
> work? It returns nil even when (much cruft deleted)
> /ncsu/tlroche> printenv
> GROUP=ncsu
> MACHTYPE=sparc
> OSTYPE=solaris
> VENDOR=sun
> (defvar running-on-solaris (eq (getenv "OSTYPE") 'solaris))
> also fails, but running-on-<linux | <<unity-> | windows> all work.

I now know why elisp code is so often studded with whatever-p's.
The code that works follows my .sig. However, I'd still like to know

> * Are there better ways to do what I'm doing?

I've got a lot to learn about elisp.

TIA, address@hidden code follows--------

;; from Red Hat Linux default .emacs
;; Are we running XEmacs or Emacs?
(defconst running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))

;; system testing. Note various tests in use within
;; He tests 'window-system. There is also a 'window-system-version

;; string-match chokes on nil
(defvar OSTYPE (getenv "OSTYPE"))
(if (not OSTYPE) (setq OSTYPE ""))
(defvar OU (getenv "OU"))
(if (not OU) (setq OU ""))

;; Are we running on X Windows?
(defconst running-on-x (eq window-system 'x))

;; Are we running on MS Windows?
(defconst running-on-windows (eq window-system 'w32))

;; Are we running on Unity Windows?
; (defconst running-on-unity-windows (eq (getenv "OU") 'ZenLab))
; (defconst running-on-unity-windows (string-match "ZenLab" OU))
(defconst running-on-unity-windows
  (if (integer-or-marker-p (string-match "ZenLab" OU)) t nil))

;; Are we running on a linux?
; (defconst running-on-linux (string-match "linux" (getenv "OSTYPE")))
; (defconst running-on-linux (string-match "linux" OSTYPE))
(defconst running-on-linux
  (if (integer-or-marker-p (string-match "linux" OSTYPE)) t nil))

;; Are we running on Solaris?
; (defconst running-on-solaris (eq (getenv "OSTYPE") 'solaris))
; (defconst running-on-solaris (string-match "solaris" (getenv "OSTYPE")))
; (defconst running-on-solaris (string-match "solaris" OSTYPE))
(defconst running-on-solaris
  (if (integer-or-marker-p (string-match "solaris" OSTYPE)) t nil))

;; linux uses HOSTNAME, solaris uses HOST
(defvar HOSTNAME (getenv "HOSTNAME"))
(if (not HOSTNAME)
    (if running-on-solaris
        (setq HOSTNAME (getenv "HOST"))
        (setq HOSTNAME "")))

;; Are we running on Unity Solaris?
(defconst running-on-unity-solaris
  (and 'running-on-solaris
;        (string-match "" (getenv "HOSTNAME"))))
;        (string-match "" HOSTNAME)))
       (integer-or-marker-p (string-match "" HOSTNAME))))

;; Are we running in a terminal/in a shell?
(defconst running-on-shell (eq window-system nil))

;; Are we shelling into Americana?
(defconst running-on-americana
  (and 'running-on-linux 'running-on-shell
;     (string-match "" HOSTNAME)))
       (integer-or-marker-p (string-match "" HOSTNAME))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]