I am very new to Lisp - and Elisp especially - and I have a problem with string handling:
I want to convert a Windows style path to a Unix style path - especially I need to convert a path I get from Visual Studio to a Cygwin path, as I want to be able to open a file from Visual Studio in Emacs (I hope to use emacsclient --eval for this):
The Visual Studio path has the following format:
C:\Users\name\documents\visual studio 2010\projects\test
I want to change it into the appropriate Cygwin path which would be:
/cygdrive/c/Users/name/documents/visual studio 2010/projects/test
However trying the following in the scratch-buffer already fails:
(replace-regexp-in-string "\\" "\/" "C:\users\someone")
(subst-char-in-string ?\ ?/ "C:\users\someone")
>> Debugger entered--Lisp error: (error "Non-hex digit used for Unicode escape")
Is there any way to make Elisp not escape the backslashes in every string?
EDIT:
Here is how I call emacs from Visual Studio via external tools:
emacsclient -d 127.0.0.1:0.0 --eval '(convert-win-to-cygwin-path $(ItemPath))'
$(ItemPath) will be replaced with C:\Users\asf
which I can not influence - so it will pass a String with single backslashes to emacs that I need to modify in emacs.
Can I make emacs KNOW that it needs to make double backslashes out of the single backslashes?
EDIT 2: Solution
I changed the way I attempt to start emacs by actually calling a shell-script that will start emacs - this way I can make sure that emacs gets the right path:
#!/bin/bash
export PATH="/usr/bin/:/bin/:$PATH"
filename=$1
line=$2
column=$3
cyged_path=$(cygpath "$filename")
echo "Cyged path: $cyged_path"
emacsclient -d 127.0.0.1:0.0 -n +$line:$column "$cyged_path"
And I call it from Visual Studio with the following arguments in the external tools window:
Path: <path_to_cygwin>\bin\bash.exe
Arguments: <path_to_script> $(ItemPath) $(CurLine) $(CurCol)