views:

19

answers:

2

I need to produce a string with emacs lisp, in which, there must contain double-quote '"'. By studying the string syntax of emacs lisp, I thought "\"" would represent such double-quote. But to my surprise, I the following expression (concat "\"") produced "\"" the '\' being not desired.

Please teach me how I can produce a pure double quote in a string?

Thanks in advance.

Yu

A: 

The expression of (concat "\"") would produce the expected result of single double-quote '"'.

I was confused with the evaluation result in interactive emacs-lisp buffer, which uses emacs-lisp's string representation syntax. In which, a double-quote is represented as "\"".

In the actual execution, it would yield the correct result of a double-quote.

Sorry for the trouble!

Yu Shen

Yu Shen
Well, accept an answer and get this over with :-)
pst
+1  A: 

You're seeing the output in the minibuffer, correct?

There isn't a '\' in the string data. Note the function result in the minibuffer is surrounded by quotes. It is showing you a representation of the string, not just its data.

To show you that the quote inside is part of the data and not a terminator for the string, it escapes the contained quote when printing it.

Try (insert "\""). This will print the value of the string at the current location of the mark, which will be just the quote mark.

Michael Speer