Mercurial > hg > xemacs-beta
comparison lisp/replace.el @ 371:cc15677e0335 r21-2b1
Import from CVS: tag r21-2b1
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:03:08 +0200 |
parents | 1d62742628b6 |
children | a300bb07d72d |
comparison
equal
deleted
inserted
replaced
370:bd866891f083 | 371:cc15677e0335 |
---|---|
375 (defun list-matching-lines (regexp &optional nlines) | 375 (defun list-matching-lines (regexp &optional nlines) |
376 "Show all lines in the current buffer containing a match for REGEXP. | 376 "Show all lines in the current buffer containing a match for REGEXP. |
377 | 377 |
378 If a match spreads across multiple lines, all those lines are shown. | 378 If a match spreads across multiple lines, all those lines are shown. |
379 | 379 |
380 If variable `list-matching-lines-whole-buffer' is non-nil, the entire | 380 If variable `list-matching-lines-whole-buffer' is non-nil, the entire buffer is |
381 buffer is searched, otherwise search begins at point. | 381 searched, otherwise search begins at point. |
382 | 382 |
383 Each line is displayed with NLINES lines before and after, or -NLINES | 383 Each line is displayed with NLINES lines before and after, or -NLINES |
384 before if NLINES is negative. | 384 before if NLINES is negative. |
385 NLINES defaults to `list-matching-lines-default-context-lines'. | 385 NLINES defaults to `list-matching-lines-default-context-lines'. |
386 Interactively it is the prefix arg. | 386 Interactively it is the prefix arg. |
655 (undo-boundary) | 655 (undo-boundary) |
656 (unwind-protect | 656 (unwind-protect |
657 ;; Loop finding occurrences that perhaps should be replaced. | 657 ;; Loop finding occurrences that perhaps should be replaced. |
658 (while (and keep-going | 658 (while (and keep-going |
659 (not (eobp)) | 659 (not (eobp)) |
660 (or (null limit) (< (point) limit)) | |
661 (let ((case-fold-search qr-case-fold-search)) | 660 (let ((case-fold-search qr-case-fold-search)) |
662 (funcall search-function search-string limit t)) | 661 (funcall search-function search-string limit t)) |
663 ;; If the search string matches immediately after | 662 ;; If the search string matches immediately after |
664 ;; the previous match, but it did not match there | 663 ;; the previous match, but it did not match there |
665 ;; before the replacement was done, ignore the match. | 664 ;; before the replacement was done, ignore the match. |
666 (if (or (eq lastrepl (point)) | 665 (if (or (eq lastrepl (point)) |
667 (and regexp-flag | 666 (and regexp-flag |
668 (eq lastrepl (match-beginning 0)) | 667 (eq lastrepl (match-beginning 0)) |
669 (not match-again))) | 668 (not match-again))) |
670 (if (or (eobp) | 669 (if (eobp) |
671 (and limit (>= (point) limit))) | |
672 nil | 670 nil |
673 ;; Don't replace the null string | 671 ;; Don't replace the null string |
674 ;; right after end of previous replacement. | 672 ;; right after end of previous replacement. |
675 (forward-char 1) | 673 (forward-char 1) |
676 (let ((case-fold-search qr-case-fold-search)) | 674 (let ((case-fold-search qr-case-fold-search)) |