aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/replace.el
diff options
context:
space:
mode:
authorKarl Heuer1997-11-11 03:26:55 +0000
committerKarl Heuer1997-11-11 03:26:55 +0000
commit7ef5c4312d5fa0fbbfbc6d6f6f50414b5e00b5af (patch)
tree4d25da960a2ce9da1127ed74026c60725c203096 /lisp/replace.el
parent504af7b2808ff9a2b50078c3dd23dc6a749960fe (diff)
downloademacs-7ef5c4312d5fa0fbbfbc6d6f6f50414b5e00b5af.tar.gz
emacs-7ef5c4312d5fa0fbbfbc6d6f6f50414b5e00b5af.zip
(perform-replace): In Transient Mark mode, if
region is active, only search the region. (query-replace, etc.): Doc fixes.
Diffstat (limited to 'lisp/replace.el')
-rw-r--r--lisp/replace.el28
1 files changed, 27 insertions, 1 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 278fe0ecb1f..be006618d83 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -54,6 +54,9 @@ That becomes the \"string to replace\".")
54As each match is found, the user must type a character saying 54As each match is found, the user must type a character saying
55what to do with it. For directions, type \\[help-command] at that time. 55what to do with it. For directions, type \\[help-command] at that time.
56 56
57In Transient Mark mode, if the mark is active, operate on the contents
58of the region. Otherwise, operate from point to the end of the buffer.
59
57If `query-replace-interactive' is non-nil, the last incremental search 60If `query-replace-interactive' is non-nil, the last incremental search
58string is used as FROM-STRING--you don't have to specify it with the 61string is used as FROM-STRING--you don't have to specify it with the
59minibuffer. 62minibuffer.
@@ -69,6 +72,7 @@ only matches surrounded by word boundaries.
69To customize possible responses, change the \"bindings\" in `query-replace-map'." 72To customize possible responses, change the \"bindings\" in `query-replace-map'."
70 (interactive (query-replace-read-args "Query replace" nil)) 73 (interactive (query-replace-read-args "Query replace" nil))
71 (perform-replace from-string to-string t nil arg)) 74 (perform-replace from-string to-string t nil arg))
75
72(define-key esc-map "%" 'query-replace) 76(define-key esc-map "%" 'query-replace)
73 77
74(defun query-replace-regexp (regexp to-string &optional arg) 78(defun query-replace-regexp (regexp to-string &optional arg)
@@ -76,6 +80,9 @@ To customize possible responses, change the \"bindings\" in `query-replace-map'.
76As each match is found, the user must type a character saying 80As each match is found, the user must type a character saying
77what to do with it. For directions, type \\[help-command] at that time. 81what to do with it. For directions, type \\[help-command] at that time.
78 82
83In Transient Mark mode, if the mark is active, operate on the contents
84of the region. Otherwise, operate from point to the end of the buffer.
85
79If `query-replace-interactive' is non-nil, the last incremental search 86If `query-replace-interactive' is non-nil, the last incremental search
80regexp is used as REGEXP--you don't have to specify it with the 87regexp is used as REGEXP--you don't have to specify it with the
81minibuffer. 88minibuffer.
@@ -97,6 +104,9 @@ by spaces. This command works like `query-replace-regexp' except
97that each successive replacement uses the next successive replacement string, 104that each successive replacement uses the next successive replacement string,
98wrapping around from the last such string to the first. 105wrapping around from the last such string to the first.
99 106
107In Transient Mark mode, if the mark is active, operate on the contents
108of the region. Otherwise, operate from point to the end of the buffer.
109
100Non-interactively, TO-STRINGS may be a list of replacement strings. 110Non-interactively, TO-STRINGS may be a list of replacement strings.
101 111
102If `query-replace-interactive' is non-nil, the last incremental search 112If `query-replace-interactive' is non-nil, the last incremental search
@@ -139,6 +149,9 @@ are non-nil and FROM-STRING has no uppercase letters.
139\(Preserving case means that if the string matched is all caps, or capitalized, 149\(Preserving case means that if the string matched is all caps, or capitalized,
140then its replacement is upcased or capitalized.) 150then its replacement is upcased or capitalized.)
141 151
152In Transient Mark mode, if the mark is active, operate on the contents
153of the region. Otherwise, operate from point to the end of the buffer.
154
142Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace 155Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
143only matches surrounded by word boundaries. 156only matches surrounded by word boundaries.
144 157
@@ -166,6 +179,9 @@ In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP,
166and `\\=\\N' (where N is a digit) stands for 179and `\\=\\N' (where N is a digit) stands for
167 whatever what matched the Nth `\\(...\\)' in REGEXP. 180 whatever what matched the Nth `\\(...\\)' in REGEXP.
168 181
182In Transient Mark mode, if the mark is active, operate on the contents
183of the region. Otherwise, operate from point to the end of the buffer.
184
169If `query-replace-interactive' is non-nil, the last incremental search 185If `query-replace-interactive' is non-nil, the last incremental search
170regexp is used as REGEXP--you don't have to specify it with the minibuffer. 186regexp is used as REGEXP--you don't have to specify it with the minibuffer.
171 187
@@ -650,6 +666,9 @@ which will run faster and probably do exactly what you want."
650 (replace-count 0) 666 (replace-count 0)
651 (nonempty-match nil) 667 (nonempty-match nil)
652 668
669 ;; If non-nil, it is marker saying where in the buffer to stop.
670 (limit nil)
671
653 ;; Data for the next match. If a cons, it has the same format as 672 ;; Data for the next match. If a cons, it has the same format as
654 ;; (match-data); otherwise it is t if a match is possible at point. 673 ;; (match-data); otherwise it is t if a match is possible at point.
655 (match-again t) 674 (match-again t)
@@ -658,6 +677,13 @@ which will run faster and probably do exactly what you want."
658 (if query-flag 677 (if query-flag
659 (substitute-command-keys 678 (substitute-command-keys
660 "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) ")))) 679 "Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) "))))
680
681 ;; If region is active, in Transient Mark mode, operate on region.
682 (if (and transient-mark-mode mark-active)
683 (progn
684 (setq limit (copy-marker (region-end)))
685 (goto-char (region-beginning))
686 (deactivate-mark)))
661 (if (stringp replacements) 687 (if (stringp replacements)
662 (setq next-replacement replacements) 688 (setq next-replacement replacements)
663 (or repeat-count (setq repeat-count 1))) 689 (or repeat-count (setq repeat-count 1)))
@@ -684,7 +710,7 @@ which will run faster and probably do exactly what you want."
684 (progn 710 (progn
685 (forward-char 1) 711 (forward-char 1)
686 (not (eobp)))) 712 (not (eobp))))
687 (funcall search-function search-string nil t) 713 (funcall search-function search-string limit t)
688 ;; For speed, use only integers and 714 ;; For speed, use only integers and
689 ;; reuse the list used last time. 715 ;; reuse the list used last time.
690 (match-data t real-match-data))))) 716 (match-data t real-match-data)))))