comparison lisp/replace.el @ 64866:6f20cb2a3b72

(query-replace-read-from, query-replace-read-to) (query-replace-read-args): Rename arg `string' to `prompt'.
author Juri Linkov <juri@jurta.org>
date Tue, 09 Aug 2005 21:39:09 +0000
parents 6697c9af3631
children ed770a0a7846 2d92f5c9d6ae
comparison
equal deleted inserted replaced
64865:d080c39bbe58 64866:6f20cb2a3b72
86 :version "22.1") 86 :version "22.1")
87 87
88 (defun query-replace-descr (string) 88 (defun query-replace-descr (string)
89 (mapconcat 'isearch-text-char-description string "")) 89 (mapconcat 'isearch-text-char-description string ""))
90 90
91 (defun query-replace-read-from (string regexp-flag) 91 (defun query-replace-read-from (prompt regexp-flag)
92 "Query and return the `from' argument of a query-replace operation. 92 "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 93 The return value can also be a pair (FROM . TO) indicating that the user
94 wants to replace FROM with TO." 94 wants to replace FROM with TO."
95 (if query-replace-interactive 95 (if query-replace-interactive
96 (car (if regexp-flag regexp-search-ring search-ring)) 96 (car (if regexp-flag regexp-search-ring search-ring))
105 ;; Typically, this is because the two histlists are shared. 105 ;; Typically, this is because the two histlists are shared.
106 (setq lastfrom (cadr (symbol-value 106 (setq lastfrom (cadr (symbol-value
107 query-replace-from-history-variable)))) 107 query-replace-from-history-variable))))
108 (read-from-minibuffer 108 (read-from-minibuffer
109 (if (and lastto lastfrom) 109 (if (and lastto lastfrom)
110 (format "%s (default %s -> %s): " string 110 (format "%s (default %s -> %s): " prompt
111 (query-replace-descr lastfrom) 111 (query-replace-descr lastfrom)
112 (query-replace-descr lastto)) 112 (query-replace-descr lastto))
113 (format "%s: " string)) 113 (format "%s: " prompt))
114 nil nil nil 114 nil nil nil
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 (progn 118 (progn
171 (cons 'concat to) 171 (cons 'concat to)
172 (car to)))) 172 (car to))))
173 to)) 173 to))
174 174
175 175
176 (defun query-replace-read-to (from string regexp-flag) 176 (defun query-replace-read-to (from prompt regexp-flag)
177 "Query and return the `to' argument of a query-replace operation." 177 "Query and return the `to' argument of a query-replace operation."
178 (query-replace-compile-replacement 178 (query-replace-compile-replacement
179 (save-excursion 179 (save-excursion
180 (read-from-minibuffer 180 (read-from-minibuffer
181 (format "%s %s with: " string (query-replace-descr from)) 181 (format "%s %s with: " prompt (query-replace-descr from))
182 nil nil nil 182 nil nil nil
183 query-replace-to-history-variable from t t)) 183 query-replace-to-history-variable from t t))
184 regexp-flag)) 184 regexp-flag))
185 185
186 (defun query-replace-read-args (string regexp-flag &optional noerror) 186 (defun query-replace-read-args (prompt regexp-flag &optional noerror)
187 (unless noerror 187 (unless noerror
188 (barf-if-buffer-read-only)) 188 (barf-if-buffer-read-only))
189 (let* ((from (query-replace-read-from string regexp-flag)) 189 (let* ((from (query-replace-read-from prompt regexp-flag))
190 (to (if (consp from) (prog1 (cdr from) (setq from (car from))) 190 (to (if (consp from) (prog1 (cdr from) (setq from (car from)))
191 (query-replace-read-to from string regexp-flag)))) 191 (query-replace-read-to from prompt regexp-flag))))
192 (list from to current-prefix-arg))) 192 (list from to current-prefix-arg)))
193 193
194 (defun query-replace (from-string to-string &optional delimited start end) 194 (defun query-replace (from-string to-string &optional delimited start end)
195 "Replace some occurrences of FROM-STRING with TO-STRING. 195 "Replace some occurrences of FROM-STRING with TO-STRING.
196 As each match is found, the user must type a character saying 196 As each match is found, the user must type a character saying