Ads by Google

Thursday, August 25, 2011

CC Mode 5.32 released

Read the announcement here.  It can be downloaded here.
C Primer Plus (5th Edition)C Programming Language (2nd Edition)Introduction to Java Programming, Comprehensive (8th Edition)

Emacs Environment Variables

This probably pertains more to Win32 Emacs than *nix based Emacs as the problems are likely to manifest in Windows where things land up in places where you least expect it.   At least on *nix systems, the process of finding out which configuration files are read is straightforward from  etc to the shell configuration files( .profile, .rc), in that order.

On Windows, I have no idea where things are read and in what order.   So how do we find out what are the values set for HOME, USER etc on Emacs?

M-x getenv will provide a prompt that lists all the set variables.  It comes with completion, so one should be able to see the entire list of set variables that Emacs has read and is using.  So, if you're wondering where the TEMP files are being stored,a M-x getenv RET TEMP would spit out the value stored by Emacs.

So, that's how one queries for the environment variables but how does one go about changing them?

We use M-x setenv to set the values for the session temporarily as in
M-x setenv RET TERM RET dumb

Please note these changes do impact or change the OS set values but is limited to the current Emacs session.  If you want to make those new values available for all future sessions, add something similar to your  .emacs. For e.g. to set the TERM value, do
(setenv "TERM" "emacs")

A good discussion on using the above information to selectively set certain values can be found on this gmane emacs thread.

The process-environment variable has the list of overridden environment variables for subprocesses to inherit launched from within Emacs.  It would get modified by issuing a setenv command. The doc strings for getenv,setenv (by using C-h f ) has more information on their usage.
Windows 7: The Missing ManualLearning the bash Shell: Unix Shell Programming (In a Nutshell (O'Reilly))