Note that there are some explanatory texts on larger screens.

plurals
  1. POEscaped strings in elisp
    text
    copied!<p>I am very new to Lisp - and Elisp especially - and I have a problem with string handling:</p> <p>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):</p> <p>The Visual Studio path has the following format:</p> <pre><code>C:\Users\name\documents\visual studio 2010\projects\test </code></pre> <p>I want to change it into the appropriate Cygwin path which would be:</p> <pre><code>/cygdrive/c/Users/name/documents/visual studio 2010/projects/test </code></pre> <p>However trying the following in the scratch-buffer already fails:</p> <pre><code>(replace-regexp-in-string "\\" "\/" "C:\users\someone") (subst-char-in-string ?\ ?/ "C:\users\someone") &gt;&gt; Debugger entered--Lisp error: (error "Non-hex digit used for Unicode escape") </code></pre> <p>Is there any way to make Elisp <em>not</em> escape the backslashes in every string?</p> <p><strong>EDIT</strong>: </p> <p>Here is how I call emacs from Visual Studio via external tools:</p> <pre><code>emacsclient -d 127.0.0.1:0.0 --eval '(convert-win-to-cygwin-path $(ItemPath))' </code></pre> <p><em>$(ItemPath)</em> will be replaced with <code>C:\Users\asf</code> which I can not influence - so it will pass a String with single backslashes to emacs that I need to modify in emacs.</p> <p>Can I make emacs KNOW that it needs to make double backslashes out of the single backslashes?</p> <p><strong>EDIT 2: Solution</strong></p> <p>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:</p> <pre><code>#!/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" </code></pre> <p>And I call it from Visual Studio with the following arguments in the external tools window:</p> <pre><code>Path: &lt;path_to_cygwin&gt;\bin\bash.exe Arguments: &lt;path_to_script&gt; $(ItemPath) $(CurLine) $(CurCol) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload