[Top][All Lists]

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

bug#6390: Should not regexp-quote quote newline?

From: Lennart Borgman
Subject: bug#6390: Should not regexp-quote quote newline?
Date: Thu, 10 Jun 2010 17:34:46 +0200

On Thu, Jun 10, 2010 at 5:22 PM, Drew Adams <address@hidden> wrote:
>> (setq x (regexp-quote "a
>> b"))
>> (message "length x=%d" (length x))
>> The length of x will be 3 because the string returned
>> by regexp-quote includes a newline.
>> Would it not be more practical if the result was "a\nb"?
> I, for one, do not understand you.

Yes, I saw that Andreas probably did not get either what I wanted to say.

I checked the length because looking at x is a bit frustrating because
of the translations between newline <-> \n that might occur.

> (setq y "a
> b")
> (setq x (regexp-quote y))
> (setq z "a\nb")
> (equal x y) = (equal x z) = t
> (length x) = (length z) = 3
> What are you trying to say?

That the regexp-quoted string includes the new line character instead
of the two chararcers \n.

The latter is more practical in many situations since this is a regexp.

> And what does it mean to "quote newline"?

Replacing newline char with \n.

You can of course do that yourself, but I really see no reason why
regexp-quote should not do it. (Yes, the regexp works just as well
with newline in it as the two chars \n in it.)

Perhaps people wants it this way, but then I would suggest that the
doc strings tells about the current behaviour.

Maybe there should be a function `string-quote' that does replacements
of newline => \n etc?

> Please try to explain clearly what the problem is that you see, or what you 
> are
> trying to do that does not succeed as you expect.

reply via email to

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