summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Heuer <kwzh@gnu.org>1997-11-11 03:26:55 +0000
committerKarl Heuer <kwzh@gnu.org>1997-11-11 03:26:55 +0000
commitc91b0a79097f8f63ec1c1144ee0581486ea54451 (patch)
treef5f81e4a777e82185ab6043842c839b3181d9005
parent7f5391f4f9767c2f8f77e3721efcdd2fb86f6345 (diff)
downloademacs-c91b0a79097f8f63ec1c1144ee0581486ea54451.tar.gz
(perform-replace): In Transient Mark mode, if
region is active, only search the region. (query-replace, etc.): Doc fixes.
-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\".")
As each match is found, the user must type a character saying
what to do with it. For directions, type \\[help-command] at that time.
+In Transient Mark mode, if the mark is active, operate on the contents
+of the region. Otherwise, operate from point to the end of the buffer.
+
If `query-replace-interactive' is non-nil, the last incremental search
string is used as FROM-STRING--you don't have to specify it with the
minibuffer.
@@ -69,6 +72,7 @@ only matches surrounded by word boundaries.
To customize possible responses, change the \"bindings\" in `query-replace-map'."
(interactive (query-replace-read-args "Query replace" nil))
(perform-replace from-string to-string t nil arg))
+
(define-key esc-map "%" 'query-replace)
(defun query-replace-regexp (regexp to-string &optional arg)
@@ -76,6 +80,9 @@ To customize possible responses, change the \"bindings\" in `query-replace-map'.
As each match is found, the user must type a character saying
what to do with it. For directions, type \\[help-command] at that time.
+In Transient Mark mode, if the mark is active, operate on the contents
+of the region. Otherwise, operate from point to the end of the buffer.
+
If `query-replace-interactive' is non-nil, the last incremental search
regexp is used as REGEXP--you don't have to specify it with the
minibuffer.
@@ -97,6 +104,9 @@ by spaces. This command works like `query-replace-regexp' except
that each successive replacement uses the next successive replacement string,
wrapping around from the last such string to the first.
+In Transient Mark mode, if the mark is active, operate on the contents
+of the region. Otherwise, operate from point to the end of the buffer.
+
Non-interactively, TO-STRINGS may be a list of replacement strings.
If `query-replace-interactive' is non-nil, the last incremental search
@@ -139,6 +149,9 @@ are non-nil and FROM-STRING has no uppercase letters.
\(Preserving case means that if the string matched is all caps, or capitalized,
then its replacement is upcased or capitalized.)
+In Transient Mark mode, if the mark is active, operate on the contents
+of the region. Otherwise, operate from point to the end of the buffer.
+
Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace
only matches surrounded by word boundaries.
@@ -166,6 +179,9 @@ In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP,
and `\\=\\N' (where N is a digit) stands for
whatever what matched the Nth `\\(...\\)' in REGEXP.
+In Transient Mark mode, if the mark is active, operate on the contents
+of the region. Otherwise, operate from point to the end of the buffer.
+
If `query-replace-interactive' is non-nil, the last incremental search
regexp is used as REGEXP--you don't have to specify it with the minibuffer.
@@ -650,6 +666,9 @@ which will run faster and probably do exactly what you want."
(replace-count 0)
(nonempty-match nil)
+ ;; If non-nil, it is marker saying where in the buffer to stop.
+ (limit nil)
+
;; Data for the next match. If a cons, it has the same format as
;; (match-data); otherwise it is t if a match is possible at point.
(match-again t)
@@ -658,6 +677,13 @@ which will run faster and probably do exactly what you want."
(if query-flag
(substitute-command-keys
"Query replacing %s with %s: (\\<query-replace-map>\\[help] for help) "))))
+
+ ;; If region is active, in Transient Mark mode, operate on region.
+ (if (and transient-mark-mode mark-active)
+ (progn
+ (setq limit (copy-marker (region-end)))
+ (goto-char (region-beginning))
+ (deactivate-mark)))
(if (stringp replacements)
(setq next-replacement replacements)
(or repeat-count (setq repeat-count 1)))
@@ -684,7 +710,7 @@ which will run faster and probably do exactly what you want."
(progn
(forward-char 1)
(not (eobp))))
- (funcall search-function search-string nil t)
+ (funcall search-function search-string limit t)
;; For speed, use only integers and
;; reuse the list used last time.
(match-data t real-match-data)))))