Mercurial > emacs
changeset 20248:b87f3ba0e1d7
(perform-replace): In Transient Mark mode, if
region is active, only search the region.
(query-replace, etc.): Doc fixes.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 11 Nov 1997 03:26:55 +0000 |
parents | 7cb27e61a1d5 |
children | c42156dab61b |
files | lisp/replace.el |
diffstat | 1 files changed, 27 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/replace.el Tue Nov 11 03:24:18 1997 +0000 +++ b/lisp/replace.el Tue Nov 11 03:26:55 1997 +0000 @@ -54,6 +54,9 @@ 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 @@ 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 @@ 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 @@ 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 @@ \(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 @@ 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 @@ (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 @@ (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 @@ (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)))))