diff options
| author | Karl Heuer | 1997-11-11 03:26:55 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-11-11 03:26:55 +0000 |
| commit | 7ef5c4312d5fa0fbbfbc6d6f6f50414b5e00b5af (patch) | |
| tree | 4d25da960a2ce9da1127ed74026c60725c203096 /lisp/replace.el | |
| parent | 504af7b2808ff9a2b50078c3dd23dc6a749960fe (diff) | |
| download | emacs-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.el | 28 |
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\".") | |||
| 54 | As each match is found, the user must type a character saying | 54 | As each match is found, the user must type a character saying |
| 55 | what to do with it. For directions, type \\[help-command] at that time. | 55 | what to do with it. For directions, type \\[help-command] at that time. |
| 56 | 56 | ||
| 57 | In Transient Mark mode, if the mark is active, operate on the contents | ||
| 58 | of the region. Otherwise, operate from point to the end of the buffer. | ||
| 59 | |||
| 57 | If `query-replace-interactive' is non-nil, the last incremental search | 60 | If `query-replace-interactive' is non-nil, the last incremental search |
| 58 | string is used as FROM-STRING--you don't have to specify it with the | 61 | string is used as FROM-STRING--you don't have to specify it with the |
| 59 | minibuffer. | 62 | minibuffer. |
| @@ -69,6 +72,7 @@ only matches surrounded by word boundaries. | |||
| 69 | To customize possible responses, change the \"bindings\" in `query-replace-map'." | 72 | To 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'. | |||
| 76 | As each match is found, the user must type a character saying | 80 | As each match is found, the user must type a character saying |
| 77 | what to do with it. For directions, type \\[help-command] at that time. | 81 | what to do with it. For directions, type \\[help-command] at that time. |
| 78 | 82 | ||
| 83 | In Transient Mark mode, if the mark is active, operate on the contents | ||
| 84 | of the region. Otherwise, operate from point to the end of the buffer. | ||
| 85 | |||
| 79 | If `query-replace-interactive' is non-nil, the last incremental search | 86 | If `query-replace-interactive' is non-nil, the last incremental search |
| 80 | regexp is used as REGEXP--you don't have to specify it with the | 87 | regexp is used as REGEXP--you don't have to specify it with the |
| 81 | minibuffer. | 88 | minibuffer. |
| @@ -97,6 +104,9 @@ by spaces. This command works like `query-replace-regexp' except | |||
| 97 | that each successive replacement uses the next successive replacement string, | 104 | that each successive replacement uses the next successive replacement string, |
| 98 | wrapping around from the last such string to the first. | 105 | wrapping around from the last such string to the first. |
| 99 | 106 | ||
| 107 | In Transient Mark mode, if the mark is active, operate on the contents | ||
| 108 | of the region. Otherwise, operate from point to the end of the buffer. | ||
| 109 | |||
| 100 | Non-interactively, TO-STRINGS may be a list of replacement strings. | 110 | Non-interactively, TO-STRINGS may be a list of replacement strings. |
| 101 | 111 | ||
| 102 | If `query-replace-interactive' is non-nil, the last incremental search | 112 | 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. | |||
| 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, |
| 140 | then its replacement is upcased or capitalized.) | 150 | then its replacement is upcased or capitalized.) |
| 141 | 151 | ||
| 152 | In Transient Mark mode, if the mark is active, operate on the contents | ||
| 153 | of the region. Otherwise, operate from point to the end of the buffer. | ||
| 154 | |||
| 142 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace | 155 | Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
| 143 | only matches surrounded by word boundaries. | 156 | only matches surrounded by word boundaries. |
| 144 | 157 | ||
| @@ -166,6 +179,9 @@ In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP, | |||
| 166 | and `\\=\\N' (where N is a digit) stands for | 179 | and `\\=\\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 | ||
| 182 | In Transient Mark mode, if the mark is active, operate on the contents | ||
| 183 | of the region. Otherwise, operate from point to the end of the buffer. | ||
| 184 | |||
| 169 | If `query-replace-interactive' is non-nil, the last incremental search | 185 | If `query-replace-interactive' is non-nil, the last incremental search |
| 170 | regexp is used as REGEXP--you don't have to specify it with the minibuffer. | 186 | regexp 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))))) |