comparison lisp/replace.el @ 95604:664723b81c00

(replace-search-function, replace-re-search-function): New vars. (perform-replace): Use them.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 06 Jun 2008 20:32:11 +0000
parents ee5932bf781d
children b5e89d359b84
comparison
equal deleted inserted replaced
95603:e9435fc29a56 95604:664723b81c00
1484 noedit nil))) 1484 noedit nil)))
1485 (set-match-data match-data) 1485 (set-match-data match-data)
1486 (replace-match newtext fixedcase literal) 1486 (replace-match newtext fixedcase literal)
1487 noedit) 1487 noedit)
1488 1488
1489 (defvar replace-search-function 'search-forward
1490 "Function to use when searching for strings to replace.
1491 It is used by `query-replace' and `replace-string', and is called
1492 with three arguments, as if it were `search-forward'.")
1493
1494 (defvar replace-re-search-function 're-search-forward
1495 "Function to use when searching for regexps to replace.
1496 It is used by `query-replace-regexp', `replace-regexp',
1497 `query-replace-regexp-eval', and `map-query-replace-regexp'. It
1498 is called with three arguments, as if it were `search-forward'.")
1499
1489 (defun perform-replace (from-string replacements 1500 (defun perform-replace (from-string replacements
1490 query-flag regexp-flag delimited-flag 1501 query-flag regexp-flag delimited-flag
1491 &optional repeat-count map start end) 1502 &optional repeat-count map start end)
1492 "Subroutine of `query-replace'. Its complexity handles interactive queries. 1503 "Subroutine of `query-replace'. Its complexity handles interactive queries.
1493 Don't use this in your own program unless you want to query and set the mark 1504 Don't use this in your own program unless you want to query and set the mark
1509 (if (and case-fold-search search-upper-case) 1520 (if (and case-fold-search search-upper-case)
1510 (isearch-no-upper-case-p from-string regexp-flag) 1521 (isearch-no-upper-case-p from-string regexp-flag)
1511 case-fold-search)) 1522 case-fold-search))
1512 (nocasify (not (and case-replace case-fold-search))) 1523 (nocasify (not (and case-replace case-fold-search)))
1513 (literal (or (not regexp-flag) (eq regexp-flag 'literal))) 1524 (literal (or (not regexp-flag) (eq regexp-flag 'literal)))
1514 (search-function (if regexp-flag 're-search-forward 'search-forward)) 1525 (search-function
1526 (if regexp-flag
1527 replace-re-search-function
1528 replace-search-function))
1515 (search-string from-string) 1529 (search-string from-string)
1516 (real-match-data nil) ; The match data for the current match. 1530 (real-match-data nil) ; The match data for the current match.
1517 (next-replacement nil) 1531 (next-replacement nil)
1518 ;; This is non-nil if we know there is nothing for the user 1532 ;; This is non-nil if we know there is nothing for the user
1519 ;; to edit in the replacement. 1533 ;; to edit in the replacement.