In emacs 21.2, M-x compile does not set the EMACS environment variable in the compilation process (which at least 20.7 used to do), and looking at the code it seems as if it's supposed to do this still. To test this, evaluate (compile "export") Note that the TERM env variable is not set properly either. I am attaching a suggested bugfix. My patch does not address the case of the branch that gets run unless (fboundp 'start-process). - Gustav