736 |
(interactive "p") |
(interactive "p") |
737 |
;; we need to run occur-find-match from within the Occur buffer |
;; we need to run occur-find-match from within the Occur buffer |
738 |
(with-current-buffer |
(with-current-buffer |
739 |
|
;; Choose the buffer and make it current. |
740 |
(if (next-error-buffer-p (current-buffer)) |
(if (next-error-buffer-p (current-buffer)) |
741 |
(current-buffer) |
(current-buffer) |
742 |
(next-error-find-buffer nil nil (lambda() (eq major-mode 'occur-mode)))) |
(next-error-find-buffer nil nil |
743 |
|
(lambda () |
744 |
|
(eq major-mode 'occur-mode)))) |
745 |
|
|
746 |
(goto-char (cond (reset (point-min)) |
(goto-char (cond (reset (point-min)) |
747 |
((< argp 0) (line-beginning-position)) |
((< argp 0) (line-beginning-position)) |
921 |
(defun occur-1 (regexp nlines bufs &optional buf-name) |
(defun occur-1 (regexp nlines bufs &optional buf-name) |
922 |
(unless buf-name |
(unless buf-name |
923 |
(setq buf-name "*Occur*")) |
(setq buf-name "*Occur*")) |
924 |
(let ((occur-buf (get-buffer-create buf-name)) |
(let (occur-buf |
|
(made-temp-buf nil) |
|
925 |
(active-bufs (delq nil (mapcar #'(lambda (buf) |
(active-bufs (delq nil (mapcar #'(lambda (buf) |
926 |
(when (buffer-live-p buf) buf)) |
(when (buffer-live-p buf) buf)) |
927 |
bufs)))) |
bufs)))) |
928 |
;; Handle the case where one of the buffers we're searching is the |
;; Handle the case where one of the buffers we're searching is the |
929 |
;; *Occur* buffer itself. |
;; output buffer. Just rename it. |
930 |
(when (memq occur-buf bufs) |
(when (member buf-name (mapcar 'buffer-name active-bufs)) |
931 |
(setq occur-buf (with-current-buffer occur-buf |
(with-current-buffer (get-buffer buf-name) |
932 |
(clone-buffer "*Occur-temp*")) |
(rename-uniquely))) |
933 |
made-temp-buf t)) |
|
934 |
|
;; Now find or create the output buffer. |
935 |
|
;; If we just renamed that buffer, we will make a new one here. |
936 |
|
(setq occur-buf (get-buffer-create buf-name)) |
937 |
|
|
938 |
(with-current-buffer occur-buf |
(with-current-buffer occur-buf |
939 |
(setq buffer-read-only nil) |
(setq buffer-read-only nil) |
940 |
(occur-mode) |
(occur-mode) |
954 |
(if (zerop count) "no" (format "%d" count)) |
(if (zerop count) "no" (format "%d" count)) |
955 |
(if (= count 1) "" "es") |
(if (= count 1) "" "es") |
956 |
regexp)) |
regexp)) |
|
;; If we had to make a temporary buffer, make it the *Occur* |
|
|
;; buffer now. |
|
|
(when made-temp-buf |
|
|
(with-current-buffer (get-buffer buf-name) |
|
|
(kill-buffer (current-buffer))) |
|
|
(rename-buffer buf-name)) |
|
957 |
(setq occur-revert-arguments (list regexp nlines bufs) |
(setq occur-revert-arguments (list regexp nlines bufs) |
958 |
buffer-read-only t) |
buffer-read-only t) |
959 |
(if (> count 0) |
(if (> count 0) |
1258 |
(replace-match newtext fixedcase literal) |
(replace-match newtext fixedcase literal) |
1259 |
noedit) |
noedit) |
1260 |
|
|
1261 |
|
(defcustom query-replace-highlight t |
1262 |
|
"*Non-nil means to highlight matches during query replacement." |
1263 |
|
:type 'boolean |
1264 |
|
:group 'matching) |
1265 |
|
|
1266 |
|
(defcustom query-replace-lazy-highlight t |
1267 |
|
"*Controls the lazy-highlighting during query replacements. |
1268 |
|
When non-nil, all text in the buffer matching the current match |
1269 |
|
is highlighted lazily using isearch lazy highlighting (see |
1270 |
|
`isearch-lazy-highlight-initial-delay' and |
1271 |
|
`isearch-lazy-highlight-interval')." |
1272 |
|
:type 'boolean |
1273 |
|
:group 'matching |
1274 |
|
:version "21.4") |
1275 |
|
|
1276 |
|
(defface query-replace |
1277 |
|
'((t (:inherit isearch))) |
1278 |
|
"Face for highlighting query replacement matches." |
1279 |
|
:group 'matching |
1280 |
|
:version "21.4") |
1281 |
|
|
1282 |
(defun perform-replace (from-string replacements |
(defun perform-replace (from-string replacements |
1283 |
query-flag regexp-flag delimited-flag |
query-flag regexp-flag delimited-flag |
1284 |
&optional repeat-count map start end) |
&optional repeat-count map start end) |
1622 |
(if (= replace-count 1) "" "s"))) |
(if (= replace-count 1) "" "s"))) |
1623 |
(and keep-going stack))) |
(and keep-going stack))) |
1624 |
|
|
|
(defcustom query-replace-highlight t |
|
|
"*Non-nil means to highlight matches during query replacement." |
|
|
:type 'boolean |
|
|
:group 'matching) |
|
|
|
|
|
(defcustom query-replace-lazy-highlight t |
|
|
"*Controls the lazy-highlighting during query replacements. |
|
|
When non-nil, all text in the buffer matching the current match |
|
|
is highlighted lazily using isearch lazy highlighting (see |
|
|
`isearch-lazy-highlight-initial-delay' and |
|
|
`isearch-lazy-highlight-interval')." |
|
|
:type 'boolean |
|
|
:group 'matching |
|
|
:version "21.4") |
|
|
|
|
|
(defface query-replace |
|
|
'((t (:inherit isearch))) |
|
|
"Face for highlighting query replacement matches." |
|
|
:group 'matching |
|
|
:version "21.4") |
|
|
|
|
1625 |
(defvar replace-overlay nil) |
(defvar replace-overlay nil) |
1626 |
|
|
1627 |
(defun replace-highlight (beg end) |
(defun replace-highlight (beg end) |
1638 |
(when replace-overlay |
(when replace-overlay |
1639 |
(delete-overlay replace-overlay)) |
(delete-overlay replace-overlay)) |
1640 |
(when query-replace-lazy-highlight |
(when query-replace-lazy-highlight |
1641 |
(isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup) |
(isearch-lazy-highlight-cleanup lazy-highlight-cleanup) |
1642 |
(setq isearch-lazy-highlight-last-string nil))) |
(setq isearch-lazy-highlight-last-string nil))) |
1643 |
|
|
1644 |
;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4 |
;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4 |