[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

C.5 Environment Variables

The environment is a feature of the operating system; it consists of a collection of variables with names and values. Each variable is called an environment variable; environment variable names are case-sensitive, and it is conventional to use upper case letters only. The values are all text strings.

What makes the environment useful is that subprocesses inherit the environment automatically from their parent process. This means you can set up an environment variable in your login shell, and all the programs you run (including Emacs) will automatically see it. Subprocesses of Emacs (such as shells, compilers, and version-control software) inherit the environment from Emacs, too.

Inside Emacs, the command M-x getenv gets the value of an environment variable. M-x setenv sets a variable in the Emacs environment. (Environment variable substitutions with ‘$’ work in the value just as in file names; see File Names with $.)

The way to set environment variables outside of Emacs depends on the operating system, and especially the shell that you are using. For example, here's how to set the environment variable ORGANIZATION to ‘not very much’ using Bash:

 
export ORGANIZATION="not very much"

and here's how to do it in csh or tcsh:

 
setenv ORGANIZATION "not very much"

When Emacs is using the X Window System, various environment variables that control X work for Emacs as well. See the X documentation for more information.


[ < ] [ > ]   [ << ] [Plus haut] [ >> ]         [Top] [Table des matières] [Index] [ ? ]

Ce document a été généré par Eric Reinbold le 23 Février 2009 en utilisant texi2html 1.78.