Mercurial > emacs
comparison lisp/replace.el @ 16713:490b479ce48a
(perform-replace): Delete the code that checked
whether the regexp could match again right after this match.
It made the loop too slow.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 18 Dec 1996 02:22:34 +0000 |
parents | 394ac4b8dcef |
children | cdc897a9054f |
comparison
equal
deleted
inserted
replaced
16712:aad91ec41fa4 | 16713:490b479ce48a |
---|---|
527 (keep-going t) | 527 (keep-going t) |
528 (stack nil) | 528 (stack nil) |
529 (next-rotate-count 0) | 529 (next-rotate-count 0) |
530 (replace-count 0) | 530 (replace-count 0) |
531 (lastrepl nil) ;Position after last match considered. | 531 (lastrepl nil) ;Position after last match considered. |
532 (match-again t) | |
533 (message | 532 (message |
534 (if query-flag | 533 (if query-flag |
535 (substitute-command-keys | 534 (substitute-command-keys |
536 "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")))) | 535 "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")))) |
537 (if (stringp replacements) | 536 (if (stringp replacements) |
554 ;; the previous match, but it did not match there | 553 ;; the previous match, but it did not match there |
555 ;; before the replacement was done, ignore the match. | 554 ;; before the replacement was done, ignore the match. |
556 (if (or (eq lastrepl (point)) | 555 (if (or (eq lastrepl (point)) |
557 (and regexp-flag | 556 (and regexp-flag |
558 (eq lastrepl (match-beginning 0)) | 557 (eq lastrepl (match-beginning 0)) |
559 (not match-again))) | 558 (eq lastrepl (match-end 0)))) |
560 (if (eobp) | 559 (if (eobp) |
561 nil | 560 nil |
562 ;; Don't replace the null string | 561 ;; Don't replace the null string |
563 ;; right after end of previous replacement. | 562 ;; right after end of previous replacement. |
564 (forward-char 1) | 563 (forward-char 1) |
565 (funcall search-function search-string nil t)) | 564 (funcall search-function search-string nil t)) |
566 t)) | 565 t)) |
567 | 566 |
568 ;; Save the data associated with the real match. | |
569 (setq real-match-data (match-data)) | |
570 | |
571 ;; Before we make the replacement, decide whether the search string | |
572 ;; can match again just after this match. | |
573 (if regexp-flag | |
574 (setq match-again (looking-at search-string))) | |
575 ;; If time for a change, advance to next replacement string. | 567 ;; If time for a change, advance to next replacement string. |
576 (if (and (listp replacements) | 568 (if (and (listp replacements) |
577 (= next-rotate-count replace-count)) | 569 (= next-rotate-count replace-count)) |
578 (progn | 570 (progn |
579 (setq next-rotate-count | 571 (setq next-rotate-count |
580 (+ next-rotate-count repeat-count)) | 572 (+ next-rotate-count repeat-count)) |
581 (setq next-replacement (nth replacement-index replacements)) | 573 (setq next-replacement (nth replacement-index replacements)) |
582 (setq replacement-index (% (1+ replacement-index) (length replacements))))) | 574 (setq replacement-index (% (1+ replacement-index) (length replacements))))) |
583 (if (not query-flag) | 575 (if (not query-flag) |
584 (progn | 576 (progn |
585 (store-match-data real-match-data) | |
586 (replace-match next-replacement nocasify literal) | 577 (replace-match next-replacement nocasify literal) |
587 (setq replace-count (1+ replace-count))) | 578 (setq replace-count (1+ replace-count))) |
588 (undo-boundary) | 579 (undo-boundary) |
589 (let (done replaced key def) | 580 (let (done replaced key def) |
581 (setq real-match-data (match-data)) | |
590 ;; Loop reading commands until one of them sets done, | 582 ;; Loop reading commands until one of them sets done, |
591 ;; which means it has finished handling this occurrence. | 583 ;; which means it has finished handling this occurrence. |
592 (while (not done) | 584 (while (not done) |
593 (store-match-data real-match-data) | 585 (store-match-data real-match-data) |
594 (replace-highlight (match-beginning 0) (match-end 0)) | 586 (replace-highlight (match-beginning 0) (match-end 0)) |
656 ((eq def 'recenter) | 648 ((eq def 'recenter) |
657 (recenter nil)) | 649 (recenter nil)) |
658 ((eq def 'edit) | 650 ((eq def 'edit) |
659 (store-match-data | 651 (store-match-data |
660 (prog1 (match-data) | 652 (prog1 (match-data) |
661 (save-excursion (recursive-edit)))) | 653 (save-excursion (recursive-edit))))) |
662 ;; Before we make the replacement, | |
663 ;; decide whether the search string | |
664 ;; can match again just after this match. | |
665 (if regexp-flag | |
666 (setq match-again (looking-at search-string)))) | |
667 ((eq def 'delete-and-edit) | 654 ((eq def 'delete-and-edit) |
668 (delete-region (match-beginning 0) (match-end 0)) | 655 (delete-region (match-beginning 0) (match-end 0)) |
669 (store-match-data | 656 (store-match-data |
670 (prog1 (match-data) | 657 (prog1 (match-data) |
671 (save-excursion (recursive-edit)))) | 658 (save-excursion (recursive-edit)))) |