88 |
(defun query-replace-descr (string) |
(defun query-replace-descr (string) |
89 |
(mapconcat 'isearch-text-char-description string "")) |
(mapconcat 'isearch-text-char-description string "")) |
90 |
|
|
91 |
(defun query-replace-read-from (string regexp-flag) |
(defun query-replace-read-from (prompt regexp-flag) |
92 |
"Query and return the `from' argument of a query-replace operation. |
"Query and return the `from' argument of a query-replace operation. |
93 |
The return value can also be a pair (FROM . TO) indicating that the user |
The return value can also be a pair (FROM . TO) indicating that the user |
94 |
wants to replace FROM with TO." |
wants to replace FROM with TO." |
107 |
query-replace-from-history-variable)))) |
query-replace-from-history-variable)))) |
108 |
(read-from-minibuffer |
(read-from-minibuffer |
109 |
(if (and lastto lastfrom) |
(if (and lastto lastfrom) |
110 |
(format "%s (default %s -> %s): " string |
(format "%s (default %s -> %s): " prompt |
111 |
(query-replace-descr lastfrom) |
(query-replace-descr lastfrom) |
112 |
(query-replace-descr lastto)) |
(query-replace-descr lastto)) |
113 |
(format "%s: " string)) |
(format "%s: " prompt)) |
114 |
nil nil nil |
nil nil nil |
115 |
query-replace-from-history-variable |
query-replace-from-history-variable |
116 |
nil t t)))) |
nil t t)))) |
173 |
to)) |
to)) |
174 |
|
|
175 |
|
|
176 |
(defun query-replace-read-to (from string regexp-flag) |
(defun query-replace-read-to (from prompt regexp-flag) |
177 |
"Query and return the `to' argument of a query-replace operation." |
"Query and return the `to' argument of a query-replace operation." |
178 |
(query-replace-compile-replacement |
(query-replace-compile-replacement |
179 |
(save-excursion |
(save-excursion |
180 |
(read-from-minibuffer |
(read-from-minibuffer |
181 |
(format "%s %s with: " string (query-replace-descr from)) |
(format "%s %s with: " prompt (query-replace-descr from)) |
182 |
nil nil nil |
nil nil nil |
183 |
query-replace-to-history-variable from t t)) |
query-replace-to-history-variable from t t)) |
184 |
regexp-flag)) |
regexp-flag)) |
185 |
|
|
186 |
(defun query-replace-read-args (string regexp-flag &optional noerror) |
(defun query-replace-read-args (prompt regexp-flag &optional noerror) |
187 |
(unless noerror |
(unless noerror |
188 |
(barf-if-buffer-read-only)) |
(barf-if-buffer-read-only)) |
189 |
(let* ((from (query-replace-read-from string regexp-flag)) |
(let* ((from (query-replace-read-from prompt regexp-flag)) |
190 |
(to (if (consp from) (prog1 (cdr from) (setq from (car from))) |
(to (if (consp from) (prog1 (cdr from) (setq from (car from))) |
191 |
(query-replace-read-to from string regexp-flag)))) |
(query-replace-read-to from prompt regexp-flag)))) |
192 |
(list from to current-prefix-arg))) |
(list from to current-prefix-arg))) |
193 |
|
|
194 |
(defun query-replace (from-string to-string &optional delimited start end) |
(defun query-replace (from-string to-string &optional delimited start end) |