Hej! --------------------------- Background I am used to "live" in Emacs and want to get the same result doing something from within Emacs as doing it from a Windows command prompt. For example (compile "dmake" nil) in Emacs and executing dmake in a Windows command window should give the same result. --------------------------- Example of Problems Emacs replaces the environment variable SHELL at start up in Windows to something like "C:/Program Files (x86)/GNU Emacs 23.4/bin/cmdproxy.exe". Processes started by Emacs will inherit this value. Many utilities uses SHELL. One example is: With " ... cmdproxy.exe" as value of SHELL dmake is configured to use a Kornshell compatible shell. --------------------------- Solution ideas A long time goal should be to avoid changing the environment variable within Emacs. Emacs should (internally) at least not change the value of SHELL. A short time solution is to make the initial environment variable available as stated in http://www.gnu.org/software/emacs/manual/html_node/emacs/Environment.html: "The variable initial-environment stores the initial environment inherited by Emacs". This make it possible in emacs-git/lisp/progmodes/compile.el:1479 (defun compilation-start (command &optional mode name-function highlight-regexp) to use the variable compilation-environment to temporary override the in emacs internal used environment variables. In emacs-git/lisp/progmodes/simple.el:2088 (defun shell-command (command &optional output-buffer error-buffer) the corresponding possibility is however not available. --------------------------- Description of the Bug Below follows a list of steps done at start up. The problem is that step 2) changes the environment variables before step 4) sets the variable initial_environment. 1) The function init_environment is called emacs-git/src/emacs.c:1416 #ifdef MSDOS /* Call early 'cause init_environment needs it. */ init_dosfns (); /* Set defaults for several environment variables. */ if (initialized) init_environment (argc, argv, skip_args); else tzset (); #endif /* MSDOS */ #ifdef WINDOWSNT globals_of_w32 (); /* Initialize environment from registry settings. */ init_environment (argv); init_ntproc (); /* must precede init_editfns. */ #endif 2) The function init_environment changes the environment variables T:/emacs-git/src/w32.c:1528:init_environment (char ** argv) Do a lot of changes to the environment variables. 3) The function set_initial_environment is called to save the "initial_environment" emacs-git/src/emacs.c:1440 /* Initialize and GC-protect Vinitial_environment and Vprocess_environment before set_initial_environment fills them in. */ if (!initialized) syms_of_callproc (); /* egetenv is a pretty low-level facility, which may get called in many circumstances; it seems flimsy to put off initializing it until calling init_callproc. Do not do it when dumping. */ if (initialized || ((strcmp (argv[argc-1], "dump") != 0 && strcmp (argv[argc-1], "bootstrap") != 0))) set_initial_environment (); 4) The variable initial_environment is set by set_initial_environment emacs-git/src/callproc.c:1616 set_initial_environment (void) emacs-git/src/callproc.c:1624 Vinitial_environment = Fcopy_sequence (Vprocess_environment); ----------------------------------------------------- In GNU Emacs 23.4.1 (i386-mingw-nt6.1.7601) of 2012-02-04 on MARVIN Windowing system distributor `Microsoft Corp.', version 6.1.7601 configured using `configure --with-gcc (4.4) --cflags -ID:/devel/emacs/libs/libXpm-3.5.8/include -ID:/devel/emacs/libs/libXpm-3.5.8/src -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include -ID:/devel/emacs/libs/giflib-4.1.4-1/include -ID:/devel/emacs/libs/jpeg-6b-4/include -ID:/devel/emacs/libs/tiff-3.8.2-1/include' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: SVE value of $XMODIFIERS: nil locale-coding-system: cp1252 default enable-multibyte-characters: t Major mode: Lisp Interaction Minor modes in effect: diff-auto-refine-mode: t shell-dirtrack-mode: t delete-selection-mode: t show-paren-mode: t cua-mode: t tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t auto-fill-mode: t Recent input: x r e p o r Recent messages: Loading cua-base...done Loading paren...done userDotEmacs Done Finding all versions of R on your system... Sorry, no version of R could be found on your system. Making completion list... Load-path shadows: None found. Features: (shadow sort mail-extr message ecomplete rfc822 mml mml-sec password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231 rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc time-date mm-util mail-prsvr gmm-utils mailheader canlock sha1 hex-util hashcash mail-utils emacsbug help-mode view psvn byte-opt warnings bytecomp byte-compile derived edmacro kmacro wid-edit log-edit pcvs-util add-log diff-mode easy-mmode pp elp ediff-merg ediff-diff ediff-wind ediff-mult ediff-help ediff-init ediff-util dired tex-mik preview-latex tex-site auto-loads ess-eldoc ess-toolbar ess-mouse mouseme thingatpt browse-url ess-menu ess-swv ess-noweb noweb-font-lock-mode ess-bugs-l essd-els ess-sas-d ess-sas-l ess-sas-a executable shell ess-arc-d ess-vst-d ess-xls-d ess-lsp-l ess-sta-d ess-sta-l cc-vars cc-defs make-regexp ess-sp6w-d ess-sp4-d ess-sp3-d ess-r-d ess-r-args assoc ess-s-l ess-inf ess-utils comint ring ess-mode noweb-mode ess ess-custom regexp-opt ess-compat ess-site htmlize-view easymenu w32-winprint htmlize cl cl-19 delsel server advice help-fns advice-preload paren cua-base cus-start cus-load tooltip ediff-hook vc-hooks lisp-float-type mwheel dos-w32 disp-table ls-lisp w32-win w32-vars tool-bar dnd fontset image fringe lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button minibuffer faces cus-face files text-properties overlay md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process multi-tty emacs)