[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
replace-match with optional fields
From: |
Dave Love |
Subject: |
replace-match with optional fields |
Date: |
Mon, 05 Jan 2004 14:54:54 +0000 |
User-agent: |
Gnus/5.1005 (Gnus v5.10.5) Emacs/21.2 (gnu/linux) |
The doc string for replace-match is unclear, and the Lisp manual
doesn't mention this behaviour, but it think it's wrong:
The doc says
`\N' means substitute what matched the Nth `\(...\)'.
If Nth parens didn't match, substitute nothing.
I'd hope `nothing' means `substitute an empty string' rather than
`don't substitute'; I'd guess that was the intention. It's not what
happens, though:
(let ((s "foo"))
(string-match "\\(foo\\).*\\(bar\\)?" s)
(replace-match "1: \\1, 2: \\2" t nil s))
=> "1: foo, 2: \\2"
This behaviour doesn't seem useful, in contrast to substituting an
empty string.
- replace-match with optional fields,
Dave Love <=