[comp.emacs] exec-path and process-environment in gnu-18.53

mlm@cs.brown.edu (04/25/89)

Elisp Gurus,

I am using gnuemacs distribution 18.53, and i need to change the PATH
used when emacs spawns subprocesses.  Specifically, i want the compile
library to use one of two paths, depending on which source directory i
am compiling in.  Changing the exec-path has proved futile so far, so
i'd sure appreciate some help.  I have changed both exec-path and
process-environment to no avail.  Whenever i start up a process, it
always inherits the environment of the original emacs.  Is there no
way to change the environment of an already-executing emacs?

The simplest way to observe this is to change exec-path and/or
process-environment by hand and then start up a shell from within
emacs and say 'echo $PATH'.  Emacs seems to have completely ignored
the changes made to the elisp environment.

Oh well,
-matt
_________________________________________________________________________
{ decvax,ihnp4,allegra,uunet }! brunix ! mnp      Matthew Nicholas Pappas
or mnp @ {cs.brown.edu, browncs.bitnet }                Brown University

jr@bbn.com (John Robinson) (04/26/89)

In article <MLM.89Apr24195252@transit.cs.brown.edu>, mlm@doorknob writes:
>Elisp Gurus,
>I am using gnuemacs distribution 18.53, and i need to change the PATH
>used when emacs spawns subprocesses.

Generally, there are two answers.

1.  Compile emacs with the MAINTAIN_ENVIRONMENT variable set.  This
will bring in a function (setenv) like (getenv) for you to use from
elisp.

2.  For interactive shells, emacs looks for files ~/.emacs_sh or
~/.emacs_csh and feeds them to the shell when it is started.

3.  You may be able to manipulate the command that is executed to be,
e.g., (depending on your shell-file-name variable)

  "PATH=extra/dir/:$PATH make -k"

or

  "setenv PATH (extra/dir/ $PATH); make -k"

This you can do once when you run M-X compile; it will remember the
last command in compile-command it issued and default to it next time.
You can set it from your .emacs.  You may be able to imbed a
conditional so that it checks pwd and reacts accordingly.

Did I say two ways?  Silly me...

>				       Specifically, i want the compile
>library to use one of two paths, depending on which source directory i
>am compiling in.

Isn't it better to do this in your Makefile?  Then you can compile
correctly when you are outside emacs (oh, I get it :-)

>			         I have changed both exec-path and
>process-environment to no avail.

Hmmm, that should have worked, according to the documentation...  But,
these could be buffer-local variables, which might throw you off the
scent.

>				   Whenever i start up a process, it
>always inherits the environment of the original emacs.  Is there no
>way to change the environment of an already-executing emacs?

See above.
--
/jr
jr@bbn.com or bbn!jr
C'mon big money!