GNU bug report logs -
#6390
Should not regexp-quote quote newline?
Previous Next
Full log
Message #20 received at 6390 <at> debbugs.gnu.org (full text, mbox):
On Thu, Jun 10, 2010 at 5:22 PM, Drew Adams <drew.adams <at> oracle.com> 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.
>
>
This bug report was last modified 13 years and 317 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.