0

I have this need to let Emacs recognize all the shell environment variables.

The current setup: I use VirtualBox and launch Emacs there to remotely access server files via the Tramp mode. When i do c-x c-f, and type

$RESOURCE_HOME/foo.bar

Emacs can't recognize this path, even if this is a valid path on the server -- $RESOURCE_HOME is a self-defined var.

I know this question's been answered there: How do I make Emacs recognize bash environment variables for compilation? But there are so many self-defined variables that I don't want to write them manually.

I wonder if it's possible to solve it in a better way. NOTE: i'm using Tramp mode, so please clarify your ideas saying vbox machine vs. server machine. Thanks!

Community
  • 1
  • 1
galactica
  • 1,753
  • 2
  • 26
  • 36

1 Answers1

0

Emacs already lets you use envvars like you suggest above. So your problem is that those vars aren't defined in Emacs's environment. Most likely it's because you define those vars in your shell's init file but that you start Emacs from a context where the shell hasn't been involved so those init files haven't been started yet.

If so, a simple fix is to start Emacs from a shell.

Stefan
  • 27,908
  • 4
  • 53
  • 82
  • I did start my emacs from shell, although in which all those vars are not defined -- they're defined in the remote server and i use tramp mode to that server. So you're saying i should download those var definitions to my local machine, so that the shell that launches emacs can see them? – galactica Jul 08 '14 at 19:54
  • Yes. The expansion of envvars in C-x C-f is done locally by Emacs itself rather than by a shell, so the environment in the shell on the remote server is not consulted. – Stefan Jul 08 '14 at 20:24
  • That did not work -- after setting up those vars on local machine and verified them on shell, I launched emacs from the shell and tried to use $RESOURCE_HOME when c-x c-f, emacs didn't recognize/expand it. – galactica Jul 09 '14 at 01:00