Mercurial > emacs
comparison lisp/replace.el @ 6707:31fce442168a
Doc fixes.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 06 Apr 1994 21:19:48 +0000 |
parents | 85dc25d7ea6c |
children | dd74576b79f6 |
comparison
equal
deleted
inserted
replaced
6706:b7b510d4e406 | 6707:31fce442168a |
---|---|
43 (defun query-replace (from-string to-string &optional arg) | 43 (defun query-replace (from-string to-string &optional arg) |
44 "Replace some occurrences of FROM-STRING with TO-STRING. | 44 "Replace some occurrences of FROM-STRING with TO-STRING. |
45 As each match is found, the user must type a character saying | 45 As each match is found, the user must type a character saying |
46 what to do with it. For directions, type \\[help-command] at that time. | 46 what to do with it. For directions, type \\[help-command] at that time. |
47 | 47 |
48 Preserves case in each replacement if case-replace and case-fold-search | 48 Preserves case in each replacement if `case-replace' and `case-fold-search' |
49 are non-nil and FROM-STRING has no uppercase letters. | 49 are non-nil and FROM-STRING has no uppercase letters. |
50 Third arg DELIMITED (prefix arg if interactive) non-nil means replace | 50 Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
51 only matches surrounded by word boundaries. | 51 only matches surrounded by word boundaries. |
52 | 52 |
53 To customize possible responses, change the \"bindings\" in `query-replace-map'." | 53 To customize possible responses, change the \"bindings\" in `query-replace-map'." |
54 (interactive (query-replace-read-args "Query replace")) | 54 (interactive (query-replace-read-args "Query replace")) |
55 (perform-replace from-string to-string t nil arg) | 55 (perform-replace from-string to-string t nil arg) |
59 (defun query-replace-regexp (regexp to-string &optional arg) | 59 (defun query-replace-regexp (regexp to-string &optional arg) |
60 "Replace some things after point matching REGEXP with TO-STRING. | 60 "Replace some things after point matching REGEXP with TO-STRING. |
61 As each match is found, the user must type a character saying | 61 As each match is found, the user must type a character saying |
62 what to do with it. For directions, type \\[help-command] at that time. | 62 what to do with it. For directions, type \\[help-command] at that time. |
63 | 63 |
64 Preserves case in each replacement if case-replace and case-fold-search | 64 Preserves case in each replacement if `case-replace' and `case-fold-search' |
65 are non-nil and REGEXP has no uppercase letters. | 65 are non-nil and REGEXP has no uppercase letters. |
66 Third arg DELIMITED (prefix arg if interactive) non-nil means replace | 66 Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
67 only matches surrounded by word boundaries. | 67 only matches surrounded by word boundaries. |
68 In TO-STRING, \\& means insert what matched REGEXP, | 68 In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP, |
69 and \\=\\<n> means insert what matched <n>th \\(...\\) in REGEXP." | 69 and `\\=\\N' (where N is a digit) stands for |
70 whatever what matched the Nth `\\(...\\)' in REGEXP." | |
70 (interactive (query-replace-read-args "Query replace regexp")) | 71 (interactive (query-replace-read-args "Query replace regexp")) |
71 (perform-replace regexp to-string t t arg) | 72 (perform-replace regexp to-string t t arg) |
72 (or unread-command-events (message "Done"))) | 73 (or unread-command-events (message "Done"))) |
73 | 74 |
74 (defun map-query-replace-regexp (regexp to-strings &optional arg) | 75 (defun map-query-replace-regexp (regexp to-strings &optional arg) |
111 | 112 |
112 (defun replace-string (from-string to-string &optional delimited) | 113 (defun replace-string (from-string to-string &optional delimited) |
113 "Replace occurrences of FROM-STRING with TO-STRING. | 114 "Replace occurrences of FROM-STRING with TO-STRING. |
114 Preserve case in each match if `case-replace' and `case-fold-search' | 115 Preserve case in each match if `case-replace' and `case-fold-search' |
115 are non-nil and FROM-STRING has no uppercase letters. | 116 are non-nil and FROM-STRING has no uppercase letters. |
116 Third arg DELIMITED (prefix arg if interactive) non-nil means replace | 117 Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
117 only matches surrounded by word boundaries. | 118 only matches surrounded by word boundaries. |
118 | 119 |
119 This function is usually the wrong thing to use in a Lisp program. | 120 This function is usually the wrong thing to use in a Lisp program. |
120 What you probably want is a loop like this: | 121 What you probably want is a loop like this: |
121 (while (search-forward OLD-STRING nil t) | 122 (while (search-forward FROM-STRING nil t) |
122 (replace-match REPLACEMENT nil t)) | 123 (replace-match TO-STRING nil t)) |
123 which will run faster and will not set the mark or print anything." | 124 which will run faster and will not set the mark or print anything." |
124 (interactive (query-replace-read-args "Replace string")) | 125 (interactive (query-replace-read-args "Replace string")) |
125 (perform-replace from-string to-string nil nil delimited) | 126 (perform-replace from-string to-string nil nil delimited) |
126 (or unread-command-events (message "Done"))) | 127 (or unread-command-events (message "Done"))) |
127 | 128 |
128 (defun replace-regexp (regexp to-string &optional delimited) | 129 (defun replace-regexp (regexp to-string &optional delimited) |
129 "Replace things after point matching REGEXP with TO-STRING. | 130 "Replace things after point matching REGEXP with TO-STRING. |
130 Preserve case in each match if case-replace and case-fold-search | 131 Preserve case in each match if `case-replace' and `case-fold-search' |
131 are non-nil and REGEXP has no uppercase letters. | 132 are non-nil and REGEXP has no uppercase letters. |
132 Third arg DELIMITED (prefix arg if interactive) non-nil means replace | 133 Third arg DELIMITED (prefix arg if interactive), if non-nil, means replace |
133 only matches surrounded by word boundaries. | 134 only matches surrounded by word boundaries. |
134 In TO-STRING, \\& means insert what matched REGEXP, | 135 In TO-STRING, `\\&' stands for whatever matched the whole of REGEXP, |
135 and \\=\\<n> means insert what matched <n>th \\(...\\) in REGEXP. | 136 and `\\=\\N' (where N is a digit) stands for |
137 whatever what matched the Nth `\\(...\\)' in REGEXP." | |
136 | 138 |
137 This function is usually the wrong thing to use in a Lisp program. | 139 This function is usually the wrong thing to use in a Lisp program. |
138 What you probably want is a loop like this: | 140 What you probably want is a loop like this: |
139 (while (re-search-forward REGEXP nil t) | 141 (while (re-search-forward REGEXP nil t) |
140 (replace-match REPLACEMENT nil nil)) | 142 (replace-match TO-STRING nil nil)) |
141 which will run faster and will not set the mark or print anything." | 143 which will run faster and will not set the mark or print anything." |
142 (interactive (query-replace-read-args "Replace regexp")) | 144 (interactive (query-replace-read-args "Replace regexp")) |
143 (perform-replace regexp to-string nil t delimited) | 145 (perform-replace regexp to-string nil t delimited) |
144 (or unread-command-events (message "Done"))) | 146 (or unread-command-events (message "Done"))) |
145 | 147 |