95 |
|
|
96 |
To customize possible responses, change the \"bindings\" in `query-replace-map'." |
To customize possible responses, change the \"bindings\" in `query-replace-map'." |
97 |
(interactive (query-replace-read-args "Query replace" nil)) |
(interactive (query-replace-read-args "Query replace" nil)) |
98 |
(perform-replace from-string to-string start end t nil delimited)) |
(perform-replace from-string to-string t nil delimited nil nil start end)) |
99 |
|
|
100 |
(define-key esc-map "%" 'query-replace) |
(define-key esc-map "%" 'query-replace) |
101 |
|
|
122 |
and `\\=\\N' (where N is a digit) stands for |
and `\\=\\N' (where N is a digit) stands for |
123 |
whatever what matched the Nth `\\(...\\)' in REGEXP." |
whatever what matched the Nth `\\(...\\)' in REGEXP." |
124 |
(interactive (query-replace-read-args "Query replace regexp" t)) |
(interactive (query-replace-read-args "Query replace regexp" t)) |
125 |
(perform-replace regexp to-string start end t t delimited)) |
(perform-replace regexp to-string t t delimited nil nil start end)) |
126 |
(define-key esc-map [?\C-%] 'query-replace-regexp) |
(define-key esc-map [?\C-%] 'query-replace-regexp) |
127 |
|
|
128 |
(defun query-replace-regexp-eval (regexp to-expr &optional delimited start end) |
(defun query-replace-regexp-eval (regexp to-expr &optional delimited start end) |
172 |
(replace-match-string-symbols to) |
(replace-match-string-symbols to) |
173 |
(list from (car to) current-prefix-arg start end))) |
(list from (car to) current-prefix-arg start end))) |
174 |
(perform-replace regexp (cons 'replace-eval-replacement to-expr) |
(perform-replace regexp (cons 'replace-eval-replacement to-expr) |
175 |
start end t t delimited)) |
t t delimited nil nil start end)) |
176 |
|
|
177 |
(defun map-query-replace-regexp (regexp to-strings &optional n start end) |
(defun map-query-replace-regexp (regexp to-strings &optional n start end) |
178 |
"Replace some matches for REGEXP with various strings, in rotation. |
"Replace some matches for REGEXP with various strings, in rotation. |
223 |
(1+ (string-match " " to-strings)))) |
(1+ (string-match " " to-strings)))) |
224 |
(setq replacements (append replacements (list to-strings)) |
(setq replacements (append replacements (list to-strings)) |
225 |
to-strings "")))) |
to-strings "")))) |
226 |
(perform-replace regexp replacements start end t t nil n))) |
(perform-replace regexp replacements t t nil n nil start end))) |
227 |
|
|
228 |
(defun replace-string (from-string to-string &optional delimited start end) |
(defun replace-string (from-string to-string &optional delimited start end) |
229 |
"Replace occurrences of FROM-STRING with TO-STRING. |
"Replace occurrences of FROM-STRING with TO-STRING. |
251 |
\(You may need a more complex loop if FROM-STRING can match the null string |
\(You may need a more complex loop if FROM-STRING can match the null string |
252 |
and TO-STRING is also null.)" |
and TO-STRING is also null.)" |
253 |
(interactive (query-replace-read-args "Replace string" nil)) |
(interactive (query-replace-read-args "Replace string" nil)) |
254 |
(perform-replace from-string to-string start end nil nil delimited)) |
(perform-replace from-string to-string nil nil delimited nil nil start end)) |
255 |
|
|
256 |
(defun replace-regexp (regexp to-string &optional delimited start end) |
(defun replace-regexp (regexp to-string &optional delimited start end) |
257 |
"Replace things after point matching REGEXP with TO-STRING. |
"Replace things after point matching REGEXP with TO-STRING. |
278 |
(replace-match TO-STRING nil nil)) |
(replace-match TO-STRING nil nil)) |
279 |
which will run faster and will not set the mark or print anything." |
which will run faster and will not set the mark or print anything." |
280 |
(interactive (query-replace-read-args "Replace regexp" t)) |
(interactive (query-replace-read-args "Replace regexp" t)) |
281 |
(perform-replace regexp to-string start end nil t delimited)) |
(perform-replace regexp to-string nil t delimited nil nil start end)) |
282 |
|
|
283 |
|
|
284 |
(defvar regexp-history nil |
(defvar regexp-history nil |
870 |
(aset data 2 (if (consp next) next (aref data 3)))))) |
(aset data 2 (if (consp next) next (aref data 3)))))) |
871 |
(car (aref data 2))) |
(car (aref data 2))) |
872 |
|
|
873 |
(defun perform-replace (from-string replacements start end |
(defun perform-replace (from-string replacements |
874 |
query-flag regexp-flag delimited-flag |
query-flag regexp-flag delimited-flag |
875 |
&optional repeat-count map) |
&optional repeat-count map start end) |
876 |
"Subroutine of `query-replace'. Its complexity handles interactive queries. |
"Subroutine of `query-replace'. Its complexity handles interactive queries. |
877 |
Don't use this in your own program unless you want to query and set the mark |
Don't use this in your own program unless you want to query and set the mark |
878 |
just as `query-replace' does. Instead, write a simple loop like this: |
just as `query-replace' does. Instead, write a simple loop like this: |