How to wrap emacs startup with application that dynamically sets particular environment variables?

Eliot Moss moss@cs.umass.edu
Fri Oct 18 22:34:46 GMT 2024


On 10/18/2024 5:36 PM, KARR, DAVID via Cygwin wrote:
> I'm looking at a situation where I'm going to need to write a small application that takes a command line to run, but first gets some data from an external source and sets environment variables from the response, so those variables are set in the subshell it starts.  It would be straightforward to add this to a command line that I run in the shell, but I'd really like to wrap this with my running of Emacs itself.  I currently use the following in my Emacs shortcut:
> 
>      C:\cygwin64\bin\run2.exe --display 127.0.0.1:0.0 /usr/local/bin/emacs.xml
> 
> I see that the "emacs.xml" file allows for some static environment variable values, but that won't help me.  If I simply change the shortcut to this:
> 
>      mywrapper C:\cygwin64\bin\run2.exe --display 127.0.0.1:0.0 /usr/local/bin/emacs.xml
> 
> Where "mywrapper" is the application I'm writing to get the env var settings, will that result in those environment variables being put into the environment of each shell buffer I start from Emacs?
> 

Section C.4 of the online emacs manual syas:

"Subprocesses of Emacs (such as shells, compilers, and version control programs) inherit the environment from Emacs, too."

You can use Emacs functions to change the emacs's environment variables, which would then change what's passed to 
subprocesses (AFAICT).  Emacs saves its *initial* environment, so if you're sensitive to what was passed in, you can 
look there.

That's what I was able to find without digging really deep ...  Eliot Moss




More information about the Cygwin mailing list