diff options
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index de3577913c1..2c60cd006f1 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -115,8 +115,11 @@ wants to replace FROM with TO." | |||
| 115 | query-replace-from-history-variable | 115 | query-replace-from-history-variable |
| 116 | nil t t)))) | 116 | nil t t)))) |
| 117 | (if (and (zerop (length from)) lastto lastfrom) | 117 | (if (and (zerop (length from)) lastto lastfrom) |
| 118 | (cons lastfrom | 118 | (progn |
| 119 | (query-replace-compile-replacement lastto regexp-flag)) | 119 | (cons lastfrom |
| 120 | (query-replace-compile-replacement lastto regexp-flag)) | ||
| 121 | (set query-replace-from-history-variable | ||
| 122 | (cdr (symbol-value query-replace-from-history-variable)))) | ||
| 120 | ;; Warn if user types \n or \t, but don't reject the input. | 123 | ;; Warn if user types \n or \t, but don't reject the input. |
| 121 | (and regexp-flag | 124 | (and regexp-flag |
| 122 | (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) | 125 | (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) |
| @@ -214,7 +217,11 @@ Fourth and fifth arg START and END specify the region to operate on. | |||
| 214 | 217 | ||
| 215 | To customize possible responses, change the \"bindings\" in `query-replace-map'." | 218 | To customize possible responses, change the \"bindings\" in `query-replace-map'." |
| 216 | (interactive (let ((common | 219 | (interactive (let ((common |
| 217 | (query-replace-read-args "Query replace" nil))) | 220 | (query-replace-read-args |
| 221 | (if (and transient-mark-mode mark-active) | ||
| 222 | "Query replace in region" | ||
| 223 | "Query replace") | ||
| 224 | nil))) | ||
| 218 | (list (nth 0 common) (nth 1 common) (nth 2 common) | 225 | (list (nth 0 common) (nth 1 common) (nth 2 common) |
| 219 | ;; These are done separately here | 226 | ;; These are done separately here |
| 220 | ;; so that command-history will record these expressions | 227 | ;; so that command-history will record these expressions |
| @@ -274,7 +281,11 @@ text, TO-STRING is actually made a list instead of a string. | |||
| 274 | Use \\[repeat-complex-command] after this command for details." | 281 | Use \\[repeat-complex-command] after this command for details." |
| 275 | (interactive | 282 | (interactive |
| 276 | (let ((common | 283 | (let ((common |
| 277 | (query-replace-read-args "Query replace regexp" t))) | 284 | (query-replace-read-args |
| 285 | (if (and transient-mark-mode mark-active) | ||
| 286 | "Query replace regexp in region" | ||
| 287 | "Query replace regexp") | ||
| 288 | t))) | ||
| 278 | (list (nth 0 common) (nth 1 common) (nth 2 common) | 289 | (list (nth 0 common) (nth 1 common) (nth 2 common) |
| 279 | ;; These are done separately here | 290 | ;; These are done separately here |
| 280 | ;; so that command-history will record these expressions | 291 | ;; so that command-history will record these expressions |
| @@ -420,7 +431,11 @@ which will run faster and will not set the mark or print anything. | |||
| 420 | and TO-STRING is also null.)" | 431 | and TO-STRING is also null.)" |
| 421 | (interactive | 432 | (interactive |
| 422 | (let ((common | 433 | (let ((common |
| 423 | (query-replace-read-args "Replace string" nil))) | 434 | (query-replace-read-args |
| 435 | (if (and transient-mark-mode mark-active) | ||
| 436 | "Replace string in region" | ||
| 437 | "Replace string") | ||
| 438 | nil))) | ||
| 424 | (list (nth 0 common) (nth 1 common) (nth 2 common) | 439 | (list (nth 0 common) (nth 1 common) (nth 2 common) |
| 425 | (if (and transient-mark-mode mark-active) | 440 | (if (and transient-mark-mode mark-active) |
| 426 | (region-beginning)) | 441 | (region-beginning)) |
| @@ -474,7 +489,11 @@ What you probably want is a loop like this: | |||
| 474 | which will run faster and will not set the mark or print anything." | 489 | which will run faster and will not set the mark or print anything." |
| 475 | (interactive | 490 | (interactive |
| 476 | (let ((common | 491 | (let ((common |
| 477 | (query-replace-read-args "Replace regexp" t))) | 492 | (query-replace-read-args |
| 493 | (if (and transient-mark-mode mark-active) | ||
| 494 | "Replace regexp in region" | ||
| 495 | "Replace regexp") | ||
| 496 | t))) | ||
| 478 | (list (nth 0 common) (nth 1 common) (nth 2 common) | 497 | (list (nth 0 common) (nth 1 common) (nth 2 common) |
| 479 | (if (and transient-mark-mode mark-active) | 498 | (if (and transient-mark-mode mark-active) |
| 480 | (region-beginning)) | 499 | (region-beginning)) |