1281 |
;; (match-data); otherwise it is t if a match is possible at point. |
;; (match-data); otherwise it is t if a match is possible at point. |
1282 |
(match-again t) |
(match-again t) |
1283 |
|
|
1284 |
|
(isearch-string isearch-string) |
1285 |
|
(isearch-regexp isearch-regexp) |
1286 |
(message |
(message |
1287 |
(if query-flag |
(if query-flag |
1288 |
(substitute-command-keys |
(substitute-command-keys |
1315 |
(if regexp-flag from-string |
(if regexp-flag from-string |
1316 |
(regexp-quote from-string)) |
(regexp-quote from-string)) |
1317 |
"\\b"))) |
"\\b"))) |
1318 |
|
(if (eq query-replace-highlight 'isearch) |
1319 |
|
(setq isearch-string search-string |
1320 |
|
isearch-regexp regexp-flag)) |
1321 |
|
|
1322 |
(push-mark) |
(push-mark) |
1323 |
(undo-boundary) |
(undo-boundary) |
1324 |
(unwind-protect |
(unwind-protect |
1534 |
(setq unread-command-events |
(setq unread-command-events |
1535 |
(append (listify-key-sequence key) |
(append (listify-key-sequence key) |
1536 |
unread-command-events)) |
unread-command-events)) |
1537 |
(setq done t)))) |
(setq done t))) |
1538 |
|
(when (eq query-replace-highlight 'isearch) |
1539 |
|
;; Force isearch rehighlighting |
1540 |
|
(if (not (memq def '(skip backup))) |
1541 |
|
(setq isearch-lazy-highlight-last-string nil)) |
1542 |
|
;; Restore isearch data in case of isearching during edit |
1543 |
|
(setq isearch-string search-string |
1544 |
|
isearch-regexp regexp-flag))) |
1545 |
;; Record previous position for ^ when we move on. |
;; Record previous position for ^ when we move on. |
1546 |
;; Change markers to numbers in the match data |
;; Change markers to numbers in the match data |
1547 |
;; since lots of markers slow down editing. |
;; since lots of markers slow down editing. |
1576 |
(if (= replace-count 1) "" "s"))) |
(if (= replace-count 1) "" "s"))) |
1577 |
(and keep-going stack))) |
(and keep-going stack))) |
1578 |
|
|
1579 |
(defcustom query-replace-highlight t |
(defcustom query-replace-highlight |
1580 |
"*Non-nil means to highlight words during query replacement." |
(if (and search-highlight isearch-lazy-highlight) 'isearch t) |
1581 |
:type 'boolean |
"*Non-nil means to highlight words during query replacement. |
1582 |
|
If `isearch', use isearch highlighting for query replacement." |
1583 |
|
:type '(choice (const :tag "Highlight" t) |
1584 |
|
(const :tag "No highlighting" nil) |
1585 |
|
(const :tag "Isearch highlighting" 'isearch)) |
1586 |
:group 'matching) |
:group 'matching) |
1587 |
|
|
1588 |
(defvar replace-overlay nil) |
(defvar replace-overlay nil) |
1589 |
|
|
1590 |
(defun replace-dehighlight () |
(defun replace-dehighlight () |
1591 |
(and replace-overlay |
(cond ((eq query-replace-highlight 'isearch) |
1592 |
(progn |
(isearch-dehighlight t) |
1593 |
(delete-overlay replace-overlay) |
(isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup) |
1594 |
(setq replace-overlay nil)))) |
(setq isearch-lazy-highlight-last-string nil)) |
1595 |
|
(query-replace-highlight |
1596 |
|
(when replace-overlay |
1597 |
|
(delete-overlay replace-overlay) |
1598 |
|
(setq replace-overlay nil))))) |
1599 |
|
|
1600 |
(defun replace-highlight (start end) |
(defun replace-highlight (start end) |
1601 |
(and query-replace-highlight |
(cond ((eq query-replace-highlight 'isearch) |
1602 |
(if replace-overlay |
(isearch-highlight start end) |
1603 |
(move-overlay replace-overlay start end (current-buffer)) |
(isearch-lazy-highlight-new-loop)) |
1604 |
(setq replace-overlay (make-overlay start end)) |
(query-replace-highlight |
1605 |
(overlay-put replace-overlay 'face |
(if replace-overlay |
1606 |
(if (facep 'query-replace) |
(move-overlay replace-overlay start end (current-buffer)) |
1607 |
'query-replace 'region))))) |
(setq replace-overlay (make-overlay start end)) |
1608 |
|
(overlay-put replace-overlay 'face |
1609 |
|
(if (facep 'query-replace) |
1610 |
|
'query-replace 'region)))))) |
1611 |
|
|
1612 |
;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4 |
;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4 |
1613 |
;;; replace.el ends here |
;;; replace.el ends here |