0

Environment variables that points to specific location are of common occurrence. $HOME, $XDG_CACHE_HOME, %LOCALAPPDATA% and many more. It is pretty convenient to open files (and directories) just by typing appropriate variable name.

So I'm searching for a function that could find file (directory) by environment variable name. Generic string expansion in the command buffer could be another option.

4
  • 2
    The values of environment variables can be retrieved in emacs using e.g. (getenv "HOME"). When trying to open a file with C-x C-f you can type $HOME/foo in the minibuffer: that will open the file foo in your home directory. For other cases, see expand-file-name and substitute-in-file-name: a common idiom is (expand-file-name (substitute-in-file-name "$HOME/foo")).
    – NickD
    Dec 14, 2021 at 2:45
  • Shame on me, I tried string expansion in minibuffer and failed. But that was a typo. Actually it all works and my question is irrelevant. Dec 14, 2021 at 18:45
  • Been there, done that :-) Glad it worked out in the end.
    – NickD
    Dec 14, 2021 at 18:48
  • 3
    I’m voting to close this question because it is only based on a usage-error. The questioner has clarified this himself in his own comment.
    – Tobias
    Dec 16, 2021 at 4:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.