]> code.delx.au - gnu-emacs/commitdiff
(isearch-intersects-p): New function.
authorGerd Moellmann <gerd@gnu.org>
Fri, 7 Sep 2001 16:17:54 +0000 (16:17 +0000)
committerGerd Moellmann <gerd@gnu.org>
Fri, 7 Sep 2001 16:17:54 +0000 (16:17 +0000)
(isearch-close-unnecessary-overlays): Renamed from *unecessary*,
use isearch-intersects-p, and clean up.

lisp/ChangeLog
lisp/isearch.el

index cf718738e661b33972b1b1726c939fe116d259d7..dc4b8e4f2027ba428ba549c8b45924c4aacfbd91 100644 (file)
@@ -1,3 +1,9 @@
+2001-09-07  Gerd Moellmann  <gerd@gnu.org>
+
+       * isearch.el (isearch-intersects-p): New function.
+       (isearch-close-unnecessary-overlays): Renamed from *unecessary*,
+       use isearch-intersects-p, and clean up.
+
 2001-09-07  Eli Zaretskii  <eliz@is.elta.co.il>
 
        * textmodes/ispell.el (ispell-dictionary-alist-4): Add "german"
index 2392bf2935b833a4b9f19686b4d0b44279f7ad74..a125f7ab053f566b5af46f9778642545dfddefba 100644 (file)
@@ -1680,32 +1680,35 @@ If there is no completion possible, say so and continue searching."
     (mapc 'isearch-open-necessary-overlays isearch-opened-overlays)
     (setq isearch-opened-overlays nil)))
 
+
+(defun isearch-intersects-p (start0 end0 start1 end1)
+  "Return t if regions START0..END0 and START1..END1 intersect."
+  (or (and (>= start0 start1) (< start0 end1))
+      (and (>= end0 start1)   (< end0 end1))
+      (and (>= start1 start0) (< start1 end0))
+      (and (>= end1 start0)   (< end1 end0))))
+
+
 ;;; Verify if the current match is outside of each element of
 ;;; `isearch-opened-overlays', if so close that overlay.
-(defun isearch-close-unecessary-overlays (begin end)
-  (let ((ov-list isearch-opened-overlays)
-       ov
-       inside-overlay
-       fct-temp)
+
+(defun isearch-close-unnecessary-overlays (begin end)
+  (let ((overlays isearch-opened-overlays))
     (setq isearch-opened-overlays nil)
-    (while ov-list
-      (setq ov (car ov-list))
-      (setq ov-list (cdr ov-list))
-      (setq inside-overlay (or (and  (> begin (overlay-start ov)) 
-                                    (< begin (overlay-end ov)))
-                              (and  (> end (overlay-start ov)) 
-                                    (< end (overlay-end ov)))))
-      ;; If this exists it means that the overlay was opened using
-      ;; this function, not by us tweaking the overlay properties.
-      (setq fct-temp (overlay-get ov 'isearch-open-invisible-temporary))
-      (if inside-overlay
-         (setq isearch-opened-overlays (cons ov isearch-opened-overlays))
-       (if fct-temp
-           (funcall fct-temp ov t)
-         (overlay-put ov 'invisible (overlay-get ov 'isearch-invisible))
-         (overlay-put ov 'intangible (overlay-get ov 'isearch-intangible))
-         (overlay-put ov 'isearch-invisible nil)
-         (overlay-put ov 'isearch-intangible nil))))))
+    (dolist (ov overlays)
+      (if (isearch-intersects-p begin end (overlay-start ov) (overlay-end ov))
+         (push ov isearch-opened-overlays)
+       (let ((fct-temp (overlay-get ov 'isearch-open-invisible-temporary)))
+         (if fct-temp
+             ;; If this exists it means that the overlay was opened
+             ;; using this function, not by us tweaking the overlay
+             ;; properties.
+             (funcall fct-temp ov t)
+           (overlay-put ov 'invisible (overlay-get ov 'isearch-invisible))
+           (overlay-put ov 'intangible (overlay-get ov 'isearch-intangible))
+           (overlay-put ov 'isearch-invisible nil)
+           (overlay-put ov 'isearch-intangible nil)))))))
+
 
 (defun isearch-range-invisible (beg end)
   "Return t if all the text from BEG to END is invisible."
@@ -1719,7 +1722,7 @@ If there is no completion possible, say so and continue searching."
               ;; the list of overlays that could be opened
               (crt-overlays nil))
           (when (and can-be-opened isearch-hide-immediately) 
-            (isearch-close-unecessary-overlays beg end))
+            (isearch-close-unnecessary-overlays beg end))
           ;; If the following character is currently invisible,
           ;; skip all characters with that same `invisible' property value.
           ;; Do that over and over.