Mac – way to reload environment variables in emacs

emacsenvironment-variables

When emacs starts it inherits the environment variables that are set at the time, either in the launching application (Linux) or in a central repository (the Windows registry).

On Windows, environment variables can be set globally. How could I prompt emacs to refresh its list of environment variables ?

I'm also interested on ways to refresh the variables on Linux (those changed in the shell that launched emacs), tough it seems much harder since there is no central repository of environment variables. Maybe by playing with emacsclient ?

Best Answer

Maybe you could create an external script which collects the names and values of environment variables then sends these name-value pairs to the running emacs via emacsclient, so emacs can set its own environment according to the received values with setenv.