help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to concatenate a backslash to a string


From: Robert Thorpe
Subject: Re: How to concatenate a backslash to a string
Date: 27 Nov 2006 09:05:11 -0800
User-agent: G2/1.0

Mirko wrote:
> Hello group.
>
> When in *scratch* I try
> (concat "\\" "%")
> I get "\\%"
>
> But what I really want is to get "\%".   (I am trying to TeXify some
> text and convert %->\%, $->\$, etc).
>
> If I try (concat "\" "%") I get a syntax error because the \ is
> escaping the ".

In Lisp print and read are exact opposites.  What print emits will
produce the same data when read by read.  So, if read needs something
to be quoted then print must quote it.

If you do (concat "\\" %") the resulting string is \% if you do (princ
(concat "\\" "%")) you will see this.

When you just evaluate this though you effectively get (print (concat
"\\" "%")) and print quotes the \ so read can understand it later.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]