summaryrefslogtreecommitdiff
path: root/lisp/isearch.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2000-10-12 07:38:35 +0000
committerMiles Bader <miles@gnu.org>2000-10-12 07:38:35 +0000
commit528b92a760d49d9a2e24f91247a2c82c1ef551fc (patch)
treed0b4bdf807e341297e4ed834bf33c3a4de752be2 /lisp/isearch.el
parent273f4ccf8b50a9f80c2f326246b55d4d405a96ac (diff)
downloademacs-528b92a760d49d9a2e24f91247a2c82c1ef551fc.tar.gz
(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'.
Diffstat (limited to 'lisp/isearch.el')
-rw-r--r--lisp/isearch.el70
1 files changed, 50 insertions, 20 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 8367a3b809a..daccf64145f 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1730,16 +1730,47 @@ If there is no completion possible, say so and continue searching."
(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 @@ Attempt to do the search exactly the way the pending isearch would."
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))