unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* replace-match with optional fields
@ 2004-01-05 14:54 Dave Love
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Love @ 2004-01-05 14:54 UTC (permalink / raw)


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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* replace-match with optional fields
@ 2004-01-10  0:44 Luc Teirlinck
  2004-01-11 19:37 ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: Luc Teirlinck @ 2004-01-10  0:44 UTC (permalink / raw)
  Cc: bug-gnu-emacs

I do not know whether it was decided that the behavior of
`replace-match' in the described case should be changed or not.  (I do
not have a particularly strong opinion on this).  But the
documentation is ambiguous either way.  Assuming the decision was to
leave the behavior as is, I propose the following change in the docstring
and would make a similar change in the Elips manual.  (Otherwise, I
would recommend other doc fixes.)

===File ~/search.c-diff=====================================
*** search.c.~1.175.~	Tue Sep  2 08:19:06 2003
--- search.c	Fri Jan  9 15:38:35 2004
***************
*** 2179,2185 ****
  Otherwise treat `\\' as special:
    `\\&' in NEWTEXT means substitute original matched text.
    `\\N' means substitute what matched the Nth `\\(...\\)'.
!        If Nth parens didn't match, substitute nothing.
    `\\\\' means insert one `\\'.
  Case conversion does not apply to these substitutions.
  
--- 2179,2185 ----
  Otherwise treat `\\' as special:
    `\\&' in NEWTEXT means substitute original matched text.
    `\\N' means substitute what matched the Nth `\\(...\\)'.
!        If Nth parens didn't match, leave the `\\N' unsubstituted.
    `\\\\' means insert one `\\'.
  Case conversion does not apply to these substitutions.
  
============================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: replace-match with optional fields
  2004-01-10  0:44 replace-match with optional fields Luc Teirlinck
@ 2004-01-11 19:37 ` Richard Stallman
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2004-01-11 19:37 UTC (permalink / raw)
  Cc: bug-gnu-emacs, d.love

I fixed this.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-01-11 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-10  0:44 replace-match with optional fields Luc Teirlinck
2004-01-11 19:37 ` Richard Stallman
  -- strict thread matches above, loose matches on Subject: below --
2004-01-05 14:54 Dave Love

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).