diff options
| author | Juri Linkov | 2004-12-15 10:10:54 +0000 |
|---|---|---|
| committer | Juri Linkov | 2004-12-15 10:10:54 +0000 |
| commit | ccec9764dcf01131e1d10c2b525a3ba68ac4c227 (patch) | |
| tree | e6bdbbac6dff73c18c0dcd52a11b943bcef9d72d /lisp/replace.el | |
| parent | da79720c9e2256e62b9dfb1436e8d83b40ab5045 (diff) | |
| download | emacs-ccec9764dcf01131e1d10c2b525a3ba68ac4c227.tar.gz emacs-ccec9764dcf01131e1d10c2b525a3ba68ac4c227.zip | |
(perform-replace): Add isearch-case-fold-search.
Use delimited-flag for isearch-regexp.
Reset isearch-lazy-highlight-last-string to force lazy
highlighting when called from isearch mode.
(query-replace-highlight): Revert defcustom type to boolean.
(query-replace-lazy-highlight): New defcustom.
(query-replace): New face.
(perform-replace, replace-highlight, replace-dehighlight):
Test query-replace-lazy-highlight instead of special value
`isearch' of query-replace-highlight.
(replace-dehighlight): Don't call isearch-dehighlight.
(replace-highlight): Don't call isearch-highlight.
Use face `query-replace' unconditionally.
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 646f693cd7f..6ba2e7e9aa8 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -1283,6 +1283,7 @@ make, or the user didn't cancel the call." | |||
| 1283 | 1283 | ||
| 1284 | (isearch-string isearch-string) | 1284 | (isearch-string isearch-string) |
| 1285 | (isearch-regexp isearch-regexp) | 1285 | (isearch-regexp isearch-regexp) |
| 1286 | (isearch-case-fold-search isearch-case-fold-search) | ||
| 1286 | (message | 1287 | (message |
| 1287 | (if query-flag | 1288 | (if query-flag |
| 1288 | (substitute-command-keys | 1289 | (substitute-command-keys |
| @@ -1315,9 +1316,11 @@ make, or the user didn't cancel the call." | |||
| 1315 | (if regexp-flag from-string | 1316 | (if regexp-flag from-string |
| 1316 | (regexp-quote from-string)) | 1317 | (regexp-quote from-string)) |
| 1317 | "\\b"))) | 1318 | "\\b"))) |
| 1318 | (if (eq query-replace-highlight 'isearch) | 1319 | (when query-replace-lazy-highlight |
| 1319 | (setq isearch-string search-string | 1320 | (setq isearch-string search-string |
| 1320 | isearch-regexp regexp-flag)) | 1321 | isearch-regexp (or delimited-flag regexp-flag) |
| 1322 | isearch-case-fold-search case-fold-search | ||
| 1323 | isearch-lazy-highlight-last-string nil)) | ||
| 1321 | 1324 | ||
| 1322 | (push-mark) | 1325 | (push-mark) |
| 1323 | (undo-boundary) | 1326 | (undo-boundary) |
| @@ -1535,13 +1538,15 @@ make, or the user didn't cancel the call." | |||
| 1535 | (append (listify-key-sequence key) | 1538 | (append (listify-key-sequence key) |
| 1536 | unread-command-events)) | 1539 | unread-command-events)) |
| 1537 | (setq done t))) | 1540 | (setq done t))) |
| 1538 | (when (eq query-replace-highlight 'isearch) | 1541 | (when query-replace-lazy-highlight |
| 1539 | ;; Force isearch rehighlighting | 1542 | ;; Restore isearch data for lazy highlighting |
| 1540 | (if (not (memq def '(skip backup))) | 1543 | ;; in case of isearching during recursive edit |
| 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 | (setq isearch-string search-string |
| 1544 | isearch-regexp regexp-flag))) | 1545 | isearch-regexp (or delimited-flag regexp-flag) |
| 1546 | isearch-case-fold-search case-fold-search) | ||
| 1547 | ;; Force lazy rehighlighting only after replacements | ||
| 1548 | (if (not (memq def '(skip backup))) | ||
| 1549 | (setq isearch-lazy-highlight-last-string nil)))) | ||
| 1545 | ;; Record previous position for ^ when we move on. | 1550 | ;; Record previous position for ^ when we move on. |
| 1546 | ;; Change markers to numbers in the match data | 1551 | ;; Change markers to numbers in the match data |
| 1547 | ;; since lots of markers slow down editing. | 1552 | ;; since lots of markers slow down editing. |
| @@ -1576,38 +1581,45 @@ make, or the user didn't cancel the call." | |||
| 1576 | (if (= replace-count 1) "" "s"))) | 1581 | (if (= replace-count 1) "" "s"))) |
| 1577 | (and keep-going stack))) | 1582 | (and keep-going stack))) |
| 1578 | 1583 | ||
| 1579 | (defcustom query-replace-highlight | 1584 | (defcustom query-replace-highlight t |
| 1580 | (if (and search-highlight isearch-lazy-highlight) 'isearch t) | 1585 | "*Non-nil means to highlight matches during query replacement." |
| 1581 | "*Non-nil means to highlight words during query replacement. | 1586 | :type 'boolean |
| 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) | 1587 | :group 'matching) |
| 1587 | 1588 | ||
| 1589 | (defcustom query-replace-lazy-highlight t | ||
| 1590 | "*Controls the lazy-highlighting during query replacements. | ||
| 1591 | When non-nil, all text in the buffer matching the current match | ||
| 1592 | is highlighted lazily using isearch lazy highlighting (see | ||
| 1593 | `isearch-lazy-highlight-initial-delay' and | ||
| 1594 | `isearch-lazy-highlight-interval')." | ||
| 1595 | :type 'boolean | ||
| 1596 | :group 'matching | ||
| 1597 | :version "21.4") | ||
| 1598 | |||
| 1599 | (defface query-replace | ||
| 1600 | '((t (:inherit isearch))) | ||
| 1601 | "Face for highlighting query replacement matches." | ||
| 1602 | :group 'matching | ||
| 1603 | :version "21.4") | ||
| 1604 | |||
| 1588 | (defvar replace-overlay nil) | 1605 | (defvar replace-overlay nil) |
| 1589 | 1606 | ||
| 1607 | (defun replace-highlight (beg end) | ||
| 1608 | (if query-replace-highlight | ||
| 1609 | (if replace-overlay | ||
| 1610 | (move-overlay replace-overlay beg end (current-buffer)) | ||
| 1611 | (setq replace-overlay (make-overlay beg end)) | ||
| 1612 | (overlay-put replace-overlay 'priority 1) ;higher than lazy overlays | ||
| 1613 | (overlay-put replace-overlay 'face 'query-replace))) | ||
| 1614 | (if query-replace-lazy-highlight | ||
| 1615 | (isearch-lazy-highlight-new-loop))) | ||
| 1616 | |||
| 1590 | (defun replace-dehighlight () | 1617 | (defun replace-dehighlight () |
| 1591 | (cond ((eq query-replace-highlight 'isearch) | 1618 | (when replace-overlay |
| 1592 | (isearch-dehighlight t) | 1619 | (delete-overlay replace-overlay)) |
| 1593 | (isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup) | 1620 | (when query-replace-lazy-highlight |
| 1594 | (setq isearch-lazy-highlight-last-string nil)) | 1621 | (isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup) |
| 1595 | (query-replace-highlight | 1622 | (setq isearch-lazy-highlight-last-string nil))) |
| 1596 | (when replace-overlay | ||
| 1597 | (delete-overlay replace-overlay) | ||
| 1598 | (setq replace-overlay nil))))) | ||
| 1599 | |||
| 1600 | (defun replace-highlight (start end) | ||
| 1601 | (cond ((eq query-replace-highlight 'isearch) | ||
| 1602 | (isearch-highlight start end) | ||
| 1603 | (isearch-lazy-highlight-new-loop)) | ||
| 1604 | (query-replace-highlight | ||
| 1605 | (if replace-overlay | ||
| 1606 | (move-overlay replace-overlay start end (current-buffer)) | ||
| 1607 | (setq replace-overlay (make-overlay start end)) | ||
| 1608 | (overlay-put replace-overlay 'face | ||
| 1609 | (if (facep 'query-replace) | ||
| 1610 | 'query-replace 'region)))))) | ||
| 1611 | 1623 | ||
| 1612 | ;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4 | 1624 | ;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4 |
| 1613 | ;;; replace.el ends here | 1625 | ;;; replace.el ends here |