Search code examples
emacsemacs24

Can I use environmental variables in find-file?


I'd like to use environmental variables in find-file command. Something like this:

C-x C-f $ENV_VAR/foo.txt

Does find-file have this functionality? What is the syntax?


Solution

  • As Barmar said, it works as you say... as far as you are not using ido or similar.

    Type C-h k C-x C-f to know if you are using any enhanced wrapper for find-file, like for instance ido.

    If you are using ido, you can type C-f in the prompt to revert back temporarily to the old plain find-file prompt, where you can type for instance $HO <tab> (to complete to $HOME), then write something like /.pro <tab> to complete to $HOME/.profile, etc.

    If you were using another, you should check the documentation because they probably have a fallback method to.