Mercurial > emacs
diff lisp/isearch.el @ 32402:b8defc3b27e2
(isearch-set-lazy-highlight-faces-at): New function.
(isearch-highlight): Restore lazy-isearch face properties at old
position, and suppress them at new position.
(isearch-dehighlight): Restore lazy-isearch face properties.
(isearch-lazy-highlight-update): Add lazy-isearch overlays even
over the real isearch overlay, but in that case, don't give it a
face property. Use `push'.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 12 Oct 2000 07:38:35 +0000 |
parents | b716f8518dd7 |
children | f14d787f4b33 |
line wrap: on
line diff
--- a/lisp/isearch.el Thu Oct 12 05:22:46 2000 +0000 +++ b/lisp/isearch.el Thu Oct 12 07:38:35 2000 +0000 @@ -1730,16 +1730,47 @@ (defvar isearch-overlay nil) +(defsubst isearch-set-lazy-highlight-faces-at (pos face) + "Set the face property of isearch lazy highlight overlays at POS to FACE. +If POS is nil, nothing is done." + (unless (null pos) + (dolist (ov (overlays-at pos)) + (when (and (not (eq ov isearch-overlay)) + (memq ov isearch-lazy-highlight-overlays) + (not (eq (overlay-get ov 'face) face))) + (overlay-put ov 'face face))))) + (defun isearch-highlight (beg end) - (if (or (null search-highlight) (null (display-color-p))) - nil - (or isearch-overlay (setq isearch-overlay (make-overlay beg end))) - (move-overlay isearch-overlay beg end (current-buffer)) - (overlay-put isearch-overlay 'face isearch))) + (unless (or (null search-highlight) (null (display-color-p))) + (cond (isearch-overlay + ;; Overlay already exists, just move it. + + ;; Check to see if there are any lazy-isearch overlays at + ;; the same position with their face property suppressed + ;; (to avoid face clashes), and if so, give them their face + ;; back. + (isearch-set-lazy-highlight-faces-at (overlay-start isearch-overlay) + isearch-lazy-highlight-face) + + (move-overlay isearch-overlay beg end (current-buffer))) + + (t + ;; Overlay doesn't exist, create it. + (setq isearch-overlay (make-overlay beg end)) + (overlay-put isearch-overlay 'face isearch))) + + ;; Suppress the faces of any lazy-isearch overlays at the new position + (isearch-set-lazy-highlight-faces-at beg nil))) (defun isearch-dehighlight (totally) - (if isearch-overlay - (delete-overlay isearch-overlay))) + (when isearch-overlay + ;; Check to see if there are any lazy-isearch overlays at the same + ;; position with their face property suppressed (to avoid face + ;; clashes), and if so, give them their face back. + (isearch-set-lazy-highlight-faces-at (overlay-start isearch-overlay) + isearch-lazy-highlight-face) + (delete-overlay isearch-overlay))) + ;;; General utilities @@ -1933,21 +1964,20 @@ isearch-lazy-highlight-start)) (let ((found (isearch-lazy-highlight-search))) ;do search (if found - (progn - ;; Don't put a second overlay with a different face - ;; over/under the overlay isearch uses to highlight the - ;; current match. That can lead to odd looking face - ;; combinations. + ;; found the next match + (let ((ov (make-overlay (match-beginning 0) + (match-end 0)))) + ;; If OV overlaps the current isearch overlay, suppress + ;; its face property; otherwise, we sometimes get odd + ;; looking face combinations. (unless (memq isearch-overlay (overlays-at (match-beginning 0))) - ;; found the next match - (let ((ov (make-overlay (match-beginning 0) - (match-end 0)))) - (overlay-put ov 'face isearch-lazy-highlight-face) - (overlay-put ov 'priority 0) - (setq isearch-lazy-highlight-overlays - (cons ov isearch-lazy-highlight-overlays)))) - + (overlay-put ov 'face isearch-lazy-highlight-face)) + + (overlay-put ov 'priority 0) + + (push ov isearch-lazy-highlight-overlays) + (setq isearch-lazy-highlight-timer (run-at-time isearch-lazy-highlight-interval nil 'isearch-lazy-highlight-update))