Subject: bug#21684: 25.0.50; undo in query-replace w/o exit

From: Tino Calancha <[email-masked]>
Date: Mon, 19 Oct 2015 10:20:25 +0900 (JST)

> What change in functionality is being considered here?

Hi Richard,

the purpose is provide 'undo' into `query-replace'/`query-replace-regexp'.
Original code do not support such functionality in a convenient way.

For instance, in the scratch buffer:
M-x query-replace RET f RET @ RET [space] RET [space] RET C-/
(C-/ undo last replacement but end session: [space] would insert one space)

Indeed, you may correct last replacement with existing code without exit current
search replace, as follows:

I)
M-x query-replace RET f RET @ RET [space] RET [space] "^" C-r
(now you can edit last replacement; comeback to query-replace session with C-M-c)
C-M-c [space] [space] ...

This seems too complicated/slow to just undo last 1-2 replacements.

In my experience as an user 99% of the times, the situation is that i hit [space]
many times and fast, and then i realize i just want to undo last 1-2 
replacements and keep going. It would be useful if that can be done just 
with one key.

The patch replace-3.patch in this thread implements such interactive undo and binds
the new funtionality to keys "u" and "U".

Every time you hit "u" the latest replacement is undo: now you can hit "n" to skip
it (tipically) or [space] to replace it again, or maybe "u" to undo 
another previous replacement (if any). The query-replace session is not 
exit.

Tino