Mercurial > emacs
comparison lisp/replace.el @ 71125:21306dd42b3c
(query-replace-read-from, query-replace-read-to):
Bind `history-add-new-input' to nil. Call `add-to-history'.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Wed, 31 May 2006 22:48:31 +0000 |
parents | b5294b4387c4 |
children | 2a66d3b6c808 a8190f7e546e |
comparison
equal
deleted
inserted
replaced
71124:a85189d6eb4c | 71125:21306dd42b3c |
---|---|
97 "Query and return the `from' argument of a query-replace operation. | 97 "Query and return the `from' argument of a query-replace operation. |
98 The return value can also be a pair (FROM . TO) indicating that the user | 98 The return value can also be a pair (FROM . TO) indicating that the user |
99 wants to replace FROM with TO." | 99 wants to replace FROM with TO." |
100 (if query-replace-interactive | 100 (if query-replace-interactive |
101 (car (if regexp-flag regexp-search-ring search-ring)) | 101 (car (if regexp-flag regexp-search-ring search-ring)) |
102 (let ((from | 102 (let* ((history-add-new-input nil) |
103 (from | |
103 ;; The save-excursion here is in case the user marks and copies | 104 ;; The save-excursion here is in case the user marks and copies |
104 ;; a region in order to specify the minibuffer input. | 105 ;; a region in order to specify the minibuffer input. |
105 ;; That should not clobber the region for the query-replace itself. | 106 ;; That should not clobber the region for the query-replace itself. |
106 (save-excursion | 107 (save-excursion |
107 (read-from-minibuffer | 108 (read-from-minibuffer |
115 nil t)))) | 116 nil t)))) |
116 (if (and (zerop (length from)) query-replace-defaults) | 117 (if (and (zerop (length from)) query-replace-defaults) |
117 (cons (car query-replace-defaults) | 118 (cons (car query-replace-defaults) |
118 (query-replace-compile-replacement | 119 (query-replace-compile-replacement |
119 (cdr query-replace-defaults) regexp-flag)) | 120 (cdr query-replace-defaults) regexp-flag)) |
121 (add-to-history query-replace-from-history-variable from nil t) | |
120 ;; Warn if user types \n or \t, but don't reject the input. | 122 ;; Warn if user types \n or \t, but don't reject the input. |
121 (and regexp-flag | 123 (and regexp-flag |
122 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) | 124 (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) |
123 (let ((match (match-string 3 from))) | 125 (let ((match (match-string 3 from))) |
124 (cond | 126 (cond |
172 | 174 |
173 (defun query-replace-read-to (from prompt regexp-flag) | 175 (defun query-replace-read-to (from prompt regexp-flag) |
174 "Query and return the `to' argument of a query-replace operation." | 176 "Query and return the `to' argument of a query-replace operation." |
175 (query-replace-compile-replacement | 177 (query-replace-compile-replacement |
176 (save-excursion | 178 (save-excursion |
177 (let ((to (read-from-minibuffer | 179 (let* ((history-add-new-input nil) |
178 (format "%s %s with: " prompt (query-replace-descr from)) | 180 (to (read-from-minibuffer |
179 nil nil nil | 181 (format "%s %s with: " prompt (query-replace-descr from)) |
180 query-replace-to-history-variable from t))) | 182 nil nil nil |
183 query-replace-to-history-variable from t))) | |
184 (add-to-history query-replace-to-history-variable to nil t) | |
181 (setq query-replace-defaults (cons from to)) | 185 (setq query-replace-defaults (cons from to)) |
182 to)) | 186 to)) |
183 regexp-flag)) | 187 regexp-flag)) |
184 | 188 |
185 (defun query-replace-read-args (prompt regexp-flag &optional noerror) | 189 (defun query-replace-read-args (prompt regexp-flag &optional noerror) |