[gnu.emacs.bug] suggestion for addition to query replace

kgk@CS.BROWN.EDU (11/14/89)

I would like to propose the addition of new functionality to query
replacement functions so that a user can change the replacement
string/regexp during the query replacement.  By replacement
string/regexp, I mean the string/regexp to replace with, not the
string/regexp being replaced.

This comes in handy on occasions such as the following.  You
duplicate a function definition or paragraph three times.  In the
first copy, you replace all occurrences of x by y, and in the second
all occurrences of x by z, and so on. 

The suggested change can be implemented by the following.  I selected
C-c as the command character to stand for change, but of course, you
are welcome to change it as you see fit.

Keiji Kanazawa

diff -c replace.el-dist replace.el
*** replace.el-dist     Mon Nov 13 11:27:28 1989
--- replace.el  Mon Nov 13 11:30:06 1989
***************
*** 202,207 ****
--- 202,208 ----
  C-r to enter recursive edit (\\[exit-recursive-edit] to get out again),
  C-w to delete match and recursive edit,
  C-l to clear the screen, redisplay, and offer same replacement again,
+ C-c to replace the string or regexp to replace with,
  ! to replace all remaining matches with no more questions,
  ^ to move point back to previous match."
    "Help message while in query-replace")
***************
*** 282,287 ****
--- 283,296 ----
                    ((or (= char ?\177)
                         (= char ?n))
                     (setq done t))
+                   ((= char ?\C-c)
+                    (setq to-string
+                          (read-from-minibuffer (concat "Query replace "
+                                                        (if regexp-flag
+                                                            "regexp "
+                                                            "")
+                                                        from-string
+                                                        " with: "))))
                    ((= char ?\C-l)
                     (recenter nil))
                    ((= char ?\C-r)