(defvar replace-search-function
(lambda (str limit)
(search-forward str limit t))
- "Function used by perform-replace to search forward for a string. It will be
+ "Function used by perform-replace to search forward for a string. It will be
called with two arguments: the string to search for and a limit bounding the
search.")
(defun occur-mode-mouse-goto (event)
"Go to the occurrence highlighted by mouse.
-This function is only reasonable when bound to a mouse key in the occur buffer"
+This function should be bound to a mouse key in the `*Occur*' buffer."
(interactive "e")
(let ((window-save (selected-window))
(frame-save (selected-frame)))
If a match spreads across multiple lines, all those lines are shown.
-If variable `list-matching-lines-whole-buffer' is non-nil, the entire buffer is
-searched, otherwise search begins at point.
+If variable `list-matching-lines-whole-buffer' is non-nil, the entire
+buffer is searched, otherwise search begins at point.
Each line is displayed with NLINES lines before and after, or -NLINES
before if NLINES is negative.
(insert "--------\n"))
(setq first nil)
(insert-buffer-substring buffer start end)
- (set-marker final-context-start
+ (set-marker final-context-start
(- (point) (- end (match-end 0))))
(backward-char (- end start))
(setq tem (if (< nlines 0) (- nlines) nlines))
(if (null tag)
(setq tag (format "%5d" this-linenum)))
(insert tag ?:)
- ;; FSFmacs --
+ ;; FSFmacs --
;; we handle this using mode-motion-highlight-line, above.
;; (put-text-property (save-excursion
;; (beginning-of-line)
;; It would be nice to use \\[...], but there is no reasonable way
;; to make that display both SPC and Y.
(defconst query-replace-help
- (purecopy
- "Type Space or `y' to replace one match, Delete or `n' to skip to next,
+ "Type Space or `y' to replace one match, Delete or `n' to skip to next,
RET or `q' to exit, Period to replace one match and exit,
Comma to replace but not move point immediately,
C-r to enter recursive edit (\\[exit-recursive-edit] to get out again),
C-l to clear the frame, redisplay, and offer same replacement again,
! to replace all remaining matches with no more questions,
^ to move point back to previous match."
-)
+
"Help message while in query-replace")
(defvar query-replace-map nil
(define-key map "\C-]" 'quit)
;FSFmacs (define-key map "\e" 'exit-prefix)
(define-key map [escape] 'exit-prefix)
-
+
(setq query-replace-map map)))
;; isearch-mode is dumped, so don't autoload.
;; XEmacs
(defun perform-replace-next-event (event)
- (if isearch-highlight
+ (if search-highlight
(let ((aborted t))
(unwind-protect
(progn
(while (re-search-forward \"foo[ \t]+bar\" nil t)
(replace-match \"foobar\" nil nil))
which will run faster and probably do exactly what you want.
-When searching for a match, this function use `replace-search-function' and `replace-re-search-function'"
+When searching for a match, this function uses
+`replace-search-function' and `replace-re-search-function'."
(or map (setq map query-replace-map))
(let* ((event (make-event))
(nocasify (not (and case-fold-search case-replace
(string-equal from-string
(downcase from-string)))))
(literal (not regexp-flag))
- (search-function (if regexp-flag
- replace-re-search-function
+ (search-function (if regexp-flag
+ replace-re-search-function
replace-search-function))
(search-string from-string)
(real-match-data nil) ; the match data for the current match
;; Loop finding occurrences that perhaps should be replaced.
(while (and keep-going
(not (eobp))
+ (or (null limit) (< (point) limit))
(let ((case-fold-search qr-case-fold-search))
(funcall search-function search-string limit))
;; If the search string matches immediately after
(and regexp-flag
(eq lastrepl (match-beginning 0))
(not match-again)))
- (if (eobp)
+ (if (or (eobp)
+ (and limit (>= (point) limit)))
nil
- ;; Don't replace the null string
+ ;; Don't replace the null string
;; right after end of previous replacement.
(forward-char 1)
(let ((case-fold-search qr-case-fold-search))
;; Before we make the replacement, decide whether the search string
;; can match again just after this match.
(if regexp-flag
- (progn
+ (progn
(setq match-again (looking-at search-string))
;; XEmacs addition
(store-match-data real-match-data)))