Mercurial > emacs
diff lisp/replace.el @ 90066:fb79180b618d
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-78
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-719
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-732
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-733
Update from CVS: man/calc.texi: Fix some TeX definitions.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-734
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-75
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-76
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-77
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Tue, 14 Dec 2004 07:34:55 +0000 |
parents | f2ebccfa87d4 f55019d052ed |
children | eac554634bfa |
line wrap: on
line diff
--- a/lisp/replace.el Sat Dec 11 02:29:07 2004 +0000 +++ b/lisp/replace.el Tue Dec 14 07:34:55 2004 +0000 @@ -1214,7 +1214,7 @@ (defun replace-match-maybe-edit (newtext fixedcase literal noedit match-data) "Make a replacement with `replace-match', editing `\\?'. -NEXTEXT, FIXEDCASE, LITERAL are just passed on. If NOEDIT is true, no +NEWTEXT, FIXEDCASE, LITERAL are just passed on. If NOEDIT is true, no check for `\\?' is made to save time. MATCH-DATA is used for the replacement. In case editing is done, it is changed to use markers. @@ -1281,6 +1281,8 @@ ;; (match-data); otherwise it is t if a match is possible at point. (match-again t) + (isearch-string isearch-string) + (isearch-regexp isearch-regexp) (message (if query-flag (substitute-command-keys @@ -1313,6 +1315,10 @@ (if regexp-flag from-string (regexp-quote from-string)) "\\b"))) + (if (eq query-replace-highlight 'isearch) + (setq isearch-string search-string + isearch-regexp regexp-flag)) + (push-mark) (undo-boundary) (unwind-protect @@ -1380,7 +1386,7 @@ (if (not query-flag) (let ((inhibit-read-only query-replace-skip-read-only)) - (unless noedit + (unless (or literal noedit) (replace-highlight (nth 0 real-match-data) (nth 1 real-match-data))) (setq noedit @@ -1528,7 +1534,14 @@ (setq unread-command-events (append (listify-key-sequence key) unread-command-events)) - (setq done t)))) + (setq done t))) + (when (eq query-replace-highlight 'isearch) + ;; Force isearch rehighlighting + (if (not (memq def '(skip backup))) + (setq isearch-lazy-highlight-last-string nil)) + ;; Restore isearch data in case of isearching during edit + (setq isearch-string search-string + isearch-regexp regexp-flag))) ;; Record previous position for ^ when we move on. ;; Change markers to numbers in the match data ;; since lots of markers slow down editing. @@ -1563,27 +1576,38 @@ (if (= replace-count 1) "" "s"))) (and keep-going stack))) -(defcustom query-replace-highlight t - "*Non-nil means to highlight words during query replacement." - :type 'boolean +(defcustom query-replace-highlight + (if (and search-highlight isearch-lazy-highlight) 'isearch t) + "*Non-nil means to highlight words during query replacement. +If `isearch', use isearch highlighting for query replacement." + :type '(choice (const :tag "Highlight" t) + (const :tag "No highlighting" nil) + (const :tag "Isearch highlighting" 'isearch)) :group 'matching) (defvar replace-overlay nil) (defun replace-dehighlight () - (and replace-overlay - (progn - (delete-overlay replace-overlay) - (setq replace-overlay nil)))) + (cond ((eq query-replace-highlight 'isearch) + (isearch-dehighlight t) + (isearch-lazy-highlight-cleanup isearch-lazy-highlight-cleanup) + (setq isearch-lazy-highlight-last-string nil)) + (query-replace-highlight + (when replace-overlay + (delete-overlay replace-overlay) + (setq replace-overlay nil))))) (defun replace-highlight (start end) - (and query-replace-highlight - (if replace-overlay - (move-overlay replace-overlay start end (current-buffer)) - (setq replace-overlay (make-overlay start end)) - (overlay-put replace-overlay 'face - (if (facep 'query-replace) - 'query-replace 'region))))) + (cond ((eq query-replace-highlight 'isearch) + (isearch-highlight start end) + (isearch-lazy-highlight-new-loop)) + (query-replace-highlight + (if replace-overlay + (move-overlay replace-overlay start end (current-buffer)) + (setq replace-overlay (make-overlay start end)) + (overlay-put replace-overlay 'face + (if (facep 'query-replace) + 'query-replace 'region)))))) ;; arch-tag: 16b4cd61-fd40-497b-b86f-b667c4cf88e4 ;;; replace.el ends here