aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorMiles Bader2007-03-04 06:19:40 +0000
committerMiles Bader2007-03-04 06:19:40 +0000
commit70fff7b1002401c91fe8d6df6491e1ae1f71e02c (patch)
treee348ed422579ef028033ea51045d35d2a8f09ba3 /lisp/replace.el
parent9e53076ea9d9f18f9fbdf28d79958691720b446f (diff)
parentd2d64bc314369ffd3f97f029e26f9650b76b8302 (diff)
downloademacs-70fff7b1002401c91fe8d6df6491e1ae1f71e02c.tar.gz
emacs-70fff7b1002401c91fe8d6df6491e1ae1f71e02c.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 653-661) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 203-206) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-180
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el62
1 files changed, 33 insertions, 29 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 9790dacd82b..5b970681ea7 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1423,8 +1423,10 @@ make, or the user didn't cancel the call."
1423 1423
1424 (message 1424 (message
1425 (if query-flag 1425 (if query-flag
1426 (substitute-command-keys 1426 (apply 'propertize
1427 "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")))) 1427 (substitute-command-keys
1428 "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")
1429 minibuffer-prompt-properties))))
1428 1430
1429 ;; If region is active, in Transient Mark mode, operate on region. 1431 ;; If region is active, in Transient Mark mode, operate on region.
1430 (when start 1432 (when start
@@ -1466,27 +1468,35 @@ make, or the user didn't cancel the call."
1466 ;; otherwise, search for a match after moving forward 1468 ;; otherwise, search for a match after moving forward
1467 ;; one char if progress is required. 1469 ;; one char if progress is required.
1468 (setq real-match-data 1470 (setq real-match-data
1469 (if (consp match-again) 1471 (cond ((consp match-again)
1470 (progn (goto-char (nth 1 match-again)) 1472 (goto-char (nth 1 match-again))
1471 (replace-match-data t 1473 (replace-match-data
1472 real-match-data 1474 t real-match-data match-again))
1473 match-again)) 1475 ;; MATCH-AGAIN non-nil means accept an
1474 (and (or match-again 1476 ;; adjacent match.
1475 ;; MATCH-AGAIN non-nil means we 1477 (match-again
1476 ;; accept an adjacent match. If 1478 (and
1477 ;; we don't, move one char to the 1479 (funcall search-function search-string
1478 ;; right. This takes us a 1480 limit t)
1479 ;; character too far at the end, 1481 ;; For speed, use only integers and
1480 ;; but this is undone after the 1482 ;; reuse the list used last time.
1481 ;; while-loop. 1483 (replace-match-data t real-match-data)))
1482 (progn 1484 ((and (< (1+ (point)) (point-max))
1483 (forward-char 1) 1485 (or (null limit)
1484 (not (or (eobp) 1486 (< (1+ (point)) limit)))
1485 (and limit (>= (point) limit)))))) 1487 ;; If not accepting adjacent matches,
1486 (funcall search-function search-string limit t) 1488 ;; move one char to the right before
1487 ;; For speed, use only integers and 1489 ;; searching again. Undo the motion
1488 ;; reuse the list used last time. 1490 ;; if the search fails.
1489 (replace-match-data t real-match-data))))) 1491 (let ((opoint (point)))
1492 (forward-char 1)
1493 (if (funcall
1494 search-function search-string
1495 limit t)
1496 (replace-match-data
1497 t real-match-data)
1498 (goto-char opoint)
1499 nil))))))
1490 1500
1491 ;; Record whether the match is nonempty, to avoid an infinite loop 1501 ;; Record whether the match is nonempty, to avoid an infinite loop
1492 ;; repeatedly matching the same empty string. 1502 ;; repeatedly matching the same empty string.
@@ -1702,12 +1712,6 @@ make, or the user didn't cancel the call."
1702 (match-data t))) 1712 (match-data t)))
1703 stack))))) 1713 stack)))))
1704 1714
1705 ;; The code preventing adjacent regexp matches in the condition
1706 ;; of the while-loop above will haven taken us one character
1707 ;; beyond the last replacement. Undo that.
1708 (when (and regexp-flag (not match-again) (> replace-count 0))
1709 (backward-char 1))
1710
1711 (replace-dehighlight)) 1715 (replace-dehighlight))
1712 (or unread-command-events 1716 (or unread-command-events
1713 (message "Replaced %d occurrence%s" 1717 (message "Replaced %d occurrence%s"