diff options
| author | Richard M. Stallman | 2003-03-05 20:51:33 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2003-03-05 20:51:33 +0000 |
| commit | 2f2f7e58d4f712e7728e90d9a30bf8d620af1d54 (patch) | |
| tree | ca5b14c6e4854cfeba1ab1ad20846ceee121855e /lisp/replace.el | |
| parent | 0ebcabe7441957535dd9e5e947df7478bcf63224 (diff) | |
| download | emacs-2f2f7e58d4f712e7728e90d9a30bf8d620af1d54.tar.gz emacs-2f2f7e58d4f712e7728e90d9a30bf8d620af1d54.zip | |
(query-replace-read-args): Use save-excursion.
(map-query-replace-regexp): Use prefix-numeric-value.
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 5fc68fa9408..82dfb0e4056 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -70,10 +70,14 @@ strings or patterns." | |||
| 70 | (let (from to) | 70 | (let (from to) |
| 71 | (if query-replace-interactive | 71 | (if query-replace-interactive |
| 72 | (setq from (car (if regexp-flag regexp-search-ring search-ring))) | 72 | (setq from (car (if regexp-flag regexp-search-ring search-ring))) |
| 73 | (setq from (read-from-minibuffer (format "%s: " string) | 73 | ;; The save-excursion here is in case the user marks and copies |
| 74 | nil nil nil | 74 | ;; a region in order to specify the minibuffer input. |
| 75 | query-replace-from-history-variable | 75 | ;; That should not clobber the region for the query-replace itself. |
| 76 | nil t)) | 76 | (save-excursion |
| 77 | (setq from (read-from-minibuffer (format "%s: " string) | ||
| 78 | nil nil nil | ||
| 79 | query-replace-from-history-variable | ||
| 80 | nil t))) | ||
| 77 | ;; Warn if user types \n or \t, but don't reject the input. | 81 | ;; Warn if user types \n or \t, but don't reject the input. |
| 78 | (if (string-match "\\\\[nt]" from) | 82 | (if (string-match "\\\\[nt]" from) |
| 79 | (let ((match (match-string 0 from))) | 83 | (let ((match (match-string 0 from))) |
| @@ -84,9 +88,10 @@ strings or patterns." | |||
| 84 | (message "Note: `\\t' here doesn't match a tab; to do that, just type TAB"))) | 88 | (message "Note: `\\t' here doesn't match a tab; to do that, just type TAB"))) |
| 85 | (sit-for 2)))) | 89 | (sit-for 2)))) |
| 86 | 90 | ||
| 87 | (setq to (read-from-minibuffer (format "%s %s with: " string from) | 91 | (save-excursion |
| 88 | nil nil nil | 92 | (setq to (read-from-minibuffer (format "%s %s with: " string from) |
| 89 | query-replace-to-history-variable from t)) | 93 | nil nil nil |
| 94 | query-replace-to-history-variable from t))) | ||
| 90 | (list from to current-prefix-arg))) | 95 | (list from to current-prefix-arg))) |
| 91 | 96 | ||
| 92 | (defun query-replace (from-string to-string &optional delimited start end) | 97 | (defun query-replace (from-string to-string &optional delimited start end) |
| @@ -252,7 +257,9 @@ Fourth and fifth arg START and END specify the region to operate on." | |||
| 252 | from) | 257 | from) |
| 253 | nil nil nil | 258 | nil nil nil |
| 254 | 'query-replace-history from t)) | 259 | 'query-replace-history from t)) |
| 255 | (list from to current-prefix-arg | 260 | (list from to |
| 261 | (and current-prefix-arg | ||
| 262 | (prefix-numeric-value current-prefix-arg)) | ||
| 256 | (if (and transient-mark-mode mark-active) | 263 | (if (and transient-mark-mode mark-active) |
| 257 | (region-beginning)) | 264 | (region-beginning)) |
| 258 | (if (and transient-mark-mode mark-active) | 265 | (if (and transient-mark-mode mark-active) |