How to get elisp backslash window path from elisp

I tried several things on windows with emacs. In my case, I need to return the path to the backslash file from elisp. But elisp always returns a slash path, etc.

(expand-file-name "text.log" "d:\\ProgramData\\temp") => d:/ProgramData/temp/text.log 

My requirement:

 (expand-file-name "text.log" "d:\\ProgramData\\temp") => d:\ProgramData\temp\text.log 

This can be done with a regex, but I need a simpler way.

+6
source share
2 answers

Does convert-standard-filename in (elisp) Standard File Names your needs?

+7
source

Of course (subst-char-in-string ?/ ?\\ <file>) should do the trick. But also note that slashes work almost everywhere on Windows (the only tool that I know that doesn't support them is the default shell (command.com, cmd.exe, or some such name)), so maybe you don’t even need this conversion.

+5
source

Source: https://habr.com/ru/post/911832/


All Articles