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)) |
741 |
#'previous-single-property-change |
#'previous-single-property-change |
742 |
#'next-single-property-change) |
#'next-single-property-change) |
743 |
"No more matches") |
"No more matches") |
744 |
|
;; In case the *Occur* buffer is visible in a nonselected window. |
745 |
|
(set-window-point (get-buffer-window (current-buffer)) (point)) |
746 |
(occur-mode-goto-occurrence)) |
(occur-mode-goto-occurrence)) |
747 |
|
|
748 |
|
|
1020 |
;; concatenate them all together. |
;; concatenate them all together. |
1021 |
(apply #'concat |
(apply #'concat |
1022 |
(nconc |
(nconc |
1023 |
(occur-engine-add-prefix (nreverse (cdr (occur-accumulate-lines (- (1+ nlines)) keep-props)))) |
(occur-engine-add-prefix (nreverse (cdr (occur-accumulate-lines (- (1+ (abs nlines))) keep-props)))) |
1024 |
(list out-line) |
(list out-line) |
1025 |
(occur-engine-add-prefix (cdr (occur-accumulate-lines (1+ nlines) keep-props)))))))) |
(if (> nlines 0) |
1026 |
|
(occur-engine-add-prefix |
1027 |
|
(cdr (occur-accumulate-lines (1+ nlines) keep-props))))))))) |
1028 |
;; Actually insert the match display data |
;; Actually insert the match display data |
1029 |
(with-current-buffer out-buf |
(with-current-buffer out-buf |
1030 |
(let ((beg (point)) |
(let ((beg (point)) |