anchor.diff:                        ((char= c #\!)
                          (setf pass-through t)))))))))
   
  -(defun query-replace-internal (before after search-forward-function search-backward-function query)
  +(defun query-replace-internal (before after search-forward-function search-backward-function
  +                               &key query (start nil start-p) (end nil end-p))
     (let ((buffer (current-buffer)))
       (unwind-protect
            (let ((*isearch-search-forward-function* search-forward-function)
                  (*isearch-search-backward-function* search-backward-function))
              (when (and before after)
  -             (if (buffer-mark-p buffer)
  -                 (with-point ((mark-point (buffer-mark buffer) :right-inserting))
  -                   (if (point< mark-point (buffer-point buffer))
  -                       (query-replace-internal-body mark-point
  -                                                    (buffer-point buffer)
  -                                                    before after query)
  -                       (query-replace-internal-body (buffer-point buffer)
  -                                                    mark-point
  -                                                    before after query)))
  -                 (query-replace-internal-body (buffer-point buffer)
  -                                              nil before after query))))
  +             (cond ((or start-p end-p)
  +                    (with-point ((s (or start (buffer-start-point (current-buffer))))
  +                                 (e (or end (buffer-end-point (current-buffer)))))
  +                      (query-replace-internal-body s e before after query)))
  +                   ((buffer-mark-p buffer)
  +                    (with-point ((mark-point (buffer-mark buffer) :right-inserting))
  +                      (cond ((point< mark-point (buffer-point buffer))
  +                             (query-replace-internal-body mark-point
  +                                                          (buffer-point buffer)
  +                                                          before after query))
  +                            (t
  +                             (query-replace-internal-body (buffer-point buffer)
  +                                                          mark-point
  +                                                          before after query)))))
  +                   (t (query-replace-internal-body (buffer-point buffer)
  +                                                   nil before after query)))))
         (isearch-reset-overlays buffer))))
   
   (define-key *global-keymap* "M-%" 'query-replace)
  
positive.code:                           after
                            #'search-forward-symbol
                            #'search-backward-symbol
                            t))
  
negative.code:                           after
                            #'search-forward
                            #'search-backward
                            :query t))
  
  (define-command query-replace-regexp (before after)
      ((read-query-replace-args))
  