Subject: Re: bug#14708: 24.2; query-replace-regexp when match and replacement are the same

From: Josh <[email-masked]>
Date: Mon, 24 Jun 2013 09:19:18 -0700

On Mon, Jun 24, 2013 at 4:44 AM, Ed Avis <[email-masked]> wrote:
> Do M-x query-replace-regexp and enter ' +' as the regexp and ' '
> as the replacement text.  Emacs matches each sequence of one or
> more space characters, as specified in the regexp, and asks whether
> to replace it.

Why not target two or more spaces in the search expression, i.e. "  +"?

> However, for many of the cases the replacement text will be the same
> as the match, so it makes no difference whether you replace or not.
> Since the aim of query-replace-regexp is primarily to do a search
> and replace, not to find all places in the buffer where a regexp
> matches, it should instead skip over those cases and only ask about
> places where replacing will make a difference.

I wouldn't like it if Emacs were to behave that way, because when
confirming a replacement would result in no change to the text it often
indicates a broken regexp (as in this case) that I want to know about.