Operating System Environment
============================
Emacs provides access to variables in the operating system
environment through various functions. These variables include the
name of the system, the user's UID, and so on.
- Variable: system-configuration
This variable holds the GNU configuration name for the
hardware/software configuration of your system, as a string. The
convenient way to test parts of this string is with `string-match'.
- Variable: system-type
The value of this variable is a symbol indicating the type of
operating system Emacs is operating on. Here is a table of the
possible values:
`alpha-vms'
VMS on the Alpha.
`aix-v3'
AIX.
`berkeley-unix'
Berkeley BSD.
`dgux'
Data General DGUX operating system.
`gnu'
the GNU system (using the GNU kernel, which consists of the
HURD and Mach).
`gnu/linux'
A GNU/Linux system--that is, a variant GNU system, using the
Linux kernel. (These systems are the ones people often call
"Linux," but actually Linux is just the kernel, not the whole
system.)
`hpux'
Hewlett-Packard HPUX operating system.
`irix'
Silicon Graphics Irix system.
`ms-dos'
Microsoft MS-DOS "operating system." Emacs compiled with
DJGPP for MS-DOS binds `system-type' to `ms-dos' even when
you run it on MS-Windows.
`next-mach'
NeXT Mach-based system.
`rtu'
Masscomp RTU, UCB universe.
`unisoft-unix'
UniSoft UniPlus.
`usg-unix-v'
AT&T System V.
`vax-vms'
VAX VMS.
`windows-nt'
Microsoft windows NT. The same executable supports Windows
9X, but the value of `system-type' is `windows-nt' in either
case.
`xenix'
SCO Xenix 386.
We do not wish to add new symbols to make finer distinctions
unless it is absolutely necessary! In fact, we hope to eliminate
some of these alternatives in the future. We recommend using
`system-configuration' to distinguish between different operating
systems.
- Function: system-name
This function returns the name of the machine you are running on.
(system-name)
=> "www.gnu.org"
The symbol `system-name' is a variable as well as a function. In
fact, the function returns whatever value the variable `system-name'
currently holds. Thus, you can set the variable `system-name' in case
Emacs is confused about the name of your system. The variable is also
useful for constructing frame titles (Note:Frame Titles).
- Variable: mail-host-address
If this variable is non-`nil', it is used instead of `system-name'
for purposes of generating email addresses. For example, it is
used when constructing the default value of `user-mail-address'.
Note:User Identification. (Since this is done when Emacs
starts up, the value actually used is the one saved when Emacs was
dumped. Note:Building Emacs.)
- Command: getenv var
This function returns the value of the environment variable VAR,
as a string. Within Emacs, the environment variable values are
kept in the Lisp variable `process-environment'.
(getenv "USER")
=> "lewis"
lewis@slug[10] % printenv
PATH=.:/user/lewis/bin:/usr/bin:/usr/local/bin
USER=lewis
TERM=ibmapa16
SHELL=/bin/csh
HOME=/user/lewis
- Command: setenv variable value
This command sets the value of the environment variable named
VARIABLE to VALUE. Both arguments should be strings. This
function works by modifying `process-environment'; binding that
variable with `let' is also reasonable practice.
- Variable: process-environment
This variable is a list of strings, each describing one environment
variable. The functions `getenv' and `setenv' work by means of
this variable.
process-environment
=> ("l=/usr/stanford/lib/gnuemacs/lisp"
"PATH=.:/user/lewis/bin:/usr/class:/nfsusr/local/bin"
"USER=lewis"
"TERM=ibmapa16"
"SHELL=/bin/csh"
"HOME=/user/lewis")
- Variable: path-separator
This variable holds a string which says which character separates
directories in a search path (as found in an environment
variable). Its value is `":"' for Unix and GNU systems, and `";"'
for MS-DOS and MS-Windows.
- Function: parse-colon-path path
This function takes a search path string such as would be the
value of the `PATH' environment variable, and splits it at the
separators, returning a list of directory names. `nil' in this
list stands for "use the current directory." Although the
function's name says "colon," it actually uses the value of
`path-separator'.
(parse-colon-path ":/foo:/bar")
=> (nil "/foo/" "/bar/")
- Variable: invocation-name
This variable holds the program name under which Emacs was
invoked. The value is a string, and does not include a directory
name.
- Variable: invocation-directory
This variable holds the directory from which the Emacs executable
was invoked, or perhaps `nil' if that directory cannot be
determined.
- Variable: installation-directory
If non-`nil', this is a directory within which to look for the
`lib-src' and `etc' subdirectories. This is non-`nil' when Emacs
can't find those directories in their standard installed
locations, but can find them in a directory related somehow to the
one containing the Emacs executable.
- Function: load-average &optional use-float
This function returns the current 1-minute, 5-minute, and
15-minute load averages, in a list.
By default, the values are integers that are 100 times the system
load averages, which indicate the average number of processes
trying to run. If USE-FLOAT is non-`nil', then they are returned
as floating point numbers and without multiplying by 100.
(load-average)
=> (169 48 36)
(load-average t)
=> (1.69 0.48 0.36)
lewis@rocky[5] % uptime
11:55am up 1 day, 19:37, 3 users,
load average: 1.69, 0.48, 0.36
- Function: emacs-pid
This function returns the process ID of the Emacs process.
- Variable: tty-erase-char
This variable holds the erase character that was selected in the
system's terminal driver, before Emacs was started.
- Function: setprv privilege-name &optional setp getprv
This function sets or resets a VMS privilege. (It does not exist
on other systems.) The first argument is the privilege name, as a
string. The second argument, SETP, is `t' or `nil', indicating
whether the privilege is to be turned on or off. Its default is
`nil'. The function returns `t' if successful, `nil' otherwise.
If the third argument, GETPRV, is non-`nil', `setprv' does not
change the privilege, but returns `t' or `nil' indicating whether
the privilege is currently enabled.