94 |
query-replace-from-history-variable |
query-replace-from-history-variable |
95 |
nil t)))) |
nil t)))) |
96 |
(if (and (zerop (length from)) lastto lastfrom) |
(if (and (zerop (length from)) lastto lastfrom) |
97 |
(cons lastfrom lastto) |
(cons lastfrom |
98 |
|
(query-replace-compile-replacement lastto regexp-flag)) |
99 |
;; Warn if user types \n or \t, but don't reject the input. |
;; Warn if user types \n or \t, but don't reject the input. |
100 |
(and regexp-flag |
(and regexp-flag |
101 |
(string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) |
(string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\(\\\\[nt]\\)" from) |
108 |
(sit-for 2))) |
(sit-for 2))) |
109 |
from)))) |
from)))) |
110 |
|
|
111 |
(defun query-replace-read-to (from string regexp-flag) |
(defun query-replace-compile-replacement (to regexp-flag) |
112 |
"Query and return the `from' argument of a query-replace operation." |
"Maybe convert a regexp replacement TO to Lisp. |
113 |
(let ((to (save-excursion |
Returns a list suitable for `perform-replace' if necessary, |
114 |
(read-from-minibuffer |
the original string if not." |
115 |
(format "%s %s with: " string (query-replace-descr from)) |
(if (and regexp-flag |
116 |
nil nil nil |
(string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to)) |
|
query-replace-to-history-variable from t)))) |
|
|
(when (and regexp-flag |
|
|
(string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to)) |
|
117 |
(let (pos list char) |
(let (pos list char) |
118 |
(while |
(while |
119 |
(progn |
(progn |
140 |
(cdr pos)))) |
(cdr pos)))) |
141 |
(setq to (substring to end))))) |
(setq to (substring to end))))) |
142 |
(string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to))) |
(string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\[,#]" to))) |
143 |
(setq to (nreverse (delete "" (cons to list))))) |
(setq to (nreverse (delete "" (cons to list)))) |
144 |
(replace-match-string-symbols to) |
(replace-match-string-symbols to) |
145 |
(setq to (cons 'replace-eval-replacement |
(cons 'replace-eval-replacement |
146 |
(if (> (length to) 1) |
(if (cdr to) |
147 |
(cons 'concat to) |
(cons 'concat to) |
148 |
(car to))))) |
(car to)))) |
149 |
to)) |
to)) |
150 |
|
|
151 |
|
|
152 |
|
(defun query-replace-read-to (from string regexp-flag) |
153 |
|
"Query and return the `to' argument of a query-replace operation." |
154 |
|
(query-replace-compile-replacement |
155 |
|
(save-excursion |
156 |
|
(read-from-minibuffer |
157 |
|
(format "%s %s with: " string (query-replace-descr from)) |
158 |
|
nil nil nil |
159 |
|
query-replace-to-history-variable from t)) |
160 |
|
regexp-flag)) |
161 |
|
|
162 |
(defun query-replace-read-args (string regexp-flag &optional noerror) |
(defun query-replace-read-args (string regexp-flag &optional noerror) |
163 |
(unless noerror |
(unless noerror |
164 |
(barf-if-buffer-read-only)) |
(barf-if-buffer-read-only)) |