unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Ed Avis <eda@waniasset.com>, jlf@foxtail.org, monnier@iro.umontreal.ca
Cc: 14708@debbugs.gnu.org
Subject: bug#14708: 24.2; query-replace-regexp when match and replacement are the same
Date: Tue, 25 Jun 2013 07:10:20 -0700 (PDT)	[thread overview]
Message-ID: <df0ed89b-5598-41fe-b991-bddb22647071@default> (raw)
In-Reply-To: <7E039918541B4C4183BFDB8F015C74300E9E08@WCL-EXCH02.wcl.local>

> I wouldn't say that the regexp in this case is broken - only suboptimal. The
> user entered something correct, to replace all sequences of spaces by a
> single space. If done as a global replace without confirmation, you wouldn't
> even notice. The user asked for confirmation of each change to end up with
> the right text in the buffer, not as an academic exercise in finding the
> best possible regexp.
> 
> So prompting for each no-op match is not really helping the user. I can see
> that sometimes you might use query-replace-regexp as a debugging aid (though
> surely a simple search without replacement would be better). But even then
> it would be enough just to flag up one case where match=replacement, not
> request y or n for each one, since they are all identical. (Here I am
> assuming no capturing groups.)
> 
> So maybe the answer is to flag the first no-op match but then skip the rest.

Haven't been following this thread, so excuse if I misunderstand.

It would be wrong, IMHO, to simply skip ANY matches, e.g., because the occurrence precisely matches the replacement string.

This could be an optional behavior, but it certainly should not simply replace the longstanding behavior.

Why?  Because query replacing is not just about replacing.  It can be about checking occurrences (all of them).  It can involve stopping and doing something (e.g. editing the occurrence in a different way from the replacement text, or editing surrounding text).  And that "stopping" can be either via recursive edit (allowing q-r resuming) or simply stopping altogether (and perhaps restarting, at the same spot or elsewhere).

In sum, there is a lot more to a q-r interaction than simply y/n replacement.  Do not mess up what has already been available.  If you like, provide an option (on the fly via a key or via a user option) to do what you request.  But please do not just replace the existing, rich behavior.





  reply	other threads:[~2013-06-25 14:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24 11:44 bug#14708: 24.2; query-replace-regexp when match and replacement are the same Ed Avis
2013-06-24 16:19 ` Josh
2013-06-24 16:30   ` Ed Avis
2013-06-24 17:01     ` Andreas Schwab
2013-06-25  1:49 ` Stefan Monnier
2013-06-25  4:17   ` Josh Feinstein
2013-06-25  6:56     ` Ed Avis
2013-06-25 14:10       ` Drew Adams [this message]
2013-06-25 15:03         ` Josh
2013-06-25 13:39     ` Stefan Monnier
2013-06-25 14:59       ` Josh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=df0ed89b-5598-41fe-b991-bddb22647071@default \
    --to=drew.adams@oracle.com \
    --cc=14708@debbugs.gnu.org \
    --cc=eda@waniasset.com \
    --cc=jlf@foxtail.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).