[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
accessing environment variable
From: |
Stephan Hennig |
Subject: |
accessing environment variable |
Date: |
Mon, 10 Sep 2007 15:57:14 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.0 Hamster/2.1.0.1501 |
Hi,
what is the preferred way to access an environment variable from within
the .emacs file?
I want to avoid writing hard coded paths into my .emacs file that had to
be adjusted after each update of, e.g., gs. I've found the getenv
function should do what I want:
> getenv is an interactive compiled Lisp function in `env.el'.
> (getenv variable)
>
> Get the value of environment variable variable.
> variable should be a string. Value is nil if variable is undefined in
> the environment. Otherwise, value is a string.
>
> This function consults the variable `process-environment'
> for its value.
Since environment variable GS_PROG points to the GhostScript binary,
i.e., is of the pattern "path\to\gs\gswin32c.exe", I've tried various
combinations (quoting, escaping and parenthesizing) of
(getenv GS_PROG)
but I always get an error
> Printing...
> apply: Searching for program: no such file or directory, (getenv GS_PROG)
or similar in the *Message* buffer. It seems to me getenv isn't
executed, but treated literally in this context. How do I correctly
refer to an environment variable here?
Best regards,
Stephan Hennig
Windows XP,
This is GNU Emacs 22.1.50.1 (i386-mingw-nt5.1.2600) of 2007-07-07 on
NEUTRINO
>From my .emacs:
;;
;; Emacs Customization
;;
(custom-set-variables
[...]
'(ps-lpr-command "(getenv GS_PROG)")
[...]
- accessing environment variable,
Stephan Hennig <=