anchor.diff:  
   (define-command isearch-replace-highlight () ()
     (let ((buffer (current-buffer)))
  -    (unless (isearch-visible-overlays buffer)
  -      (return-from isearch-replace-highlight))
  -    (let ((string (prompt-for-string "Replace: "))
  -          (p (current-point))
  -          (start)
  -          (end))
  -      (if (buffer-mark-p buffer)
  -          (setf start (copy-point (region-beginning buffer) :temporary)
  -                end (region-end buffer))
  -          (setf start (buffer-start-point buffer)
  -                end (buffer-end-point buffer)))
  -      (save-excursion
  -        (dolist (overlay (isearch-overlays buffer))
  -          (when (and (point<= start (overlay-start overlay))
  -                     (point<= (overlay-end overlay) end))
  -            (move-point p (overlay-start overlay))
  -            (delete-between-points (overlay-start overlay) (overlay-end overlay))
  -            (insert-string p string)))
  -        (isearch-reset-overlays buffer)))))
  +    (let ((old-string (buffer-value buffer 'isearch-redisplay-string)))
  +      (unless old-string
  +        (return-from isearch-replace-highlight))
  +      (let ((new-string (prompt-for-string "Replace: "))
  +            start end)
  +        (if (buffer-mark-p buffer)
  +            (setf start (copy-point (region-beginning buffer) :temporary)
  +                  end (region-end buffer))
  +            (setf start (buffer-start-point buffer)
  +                  end (buffer-end-point buffer)))
  +        (save-excursion
  +          (query-replace-internal old-string
  +                                  new-string
  +                                  *isearch-search-forward-function*
  +                                  *isearch-search-backward-function*
  +                                  nil))))))
   
   (define-command isearch-next-highlight (n) ("p")
     (when (isearch-visible-overlays (current-buffer))
  
positive.code:                    (if (point< mark-point (buffer-point buffer))
                         (query-replace-internal-body mark-point
                                                      (buffer-point buffer)
                                                      before after)
                         (query-replace-internal-body (buffer-point buffer)
                                                      mark-point
                                                      before after)))
                   (query-replace-internal-body (buffer-point buffer)
                                                nil
                                                before after))))
        (isearch-reset-overlays buffer))))
  
  (define-key *global-keymap* "M-%" 'query-replace)
  
negative.code:   (query-replace-internal before
                            after
                            #'search-forward
                            #'search-backward
                            t))
  
  (define-command query-replace-regexp (before after)
      ((read-query-replace-args))
    (query-replace-internal before
                            after
                            #'search-forward-regexp
                            #'search-backward-regexp
                            t))
  
  (define-command query-replace-symbol (before after)
      ((read-query-replace-args))
    (query-replace-internal before
                            after
                            #'search-forward-symbol
                            #'search-backward-symbol
                            t))
  