From fc0eccfcce909af0162f59425c8090ba3cf03057 Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Fri, 7 Sep 2001 16:17:54 +0000 Subject: [PATCH] (isearch-intersects-p): New function. (isearch-close-unnecessary-overlays): Renamed from *unecessary*, use isearch-intersects-p, and clean up. --- lisp/ChangeLog | 6 ++++++ lisp/isearch.el | 51 ++++++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cf718738e66..dc4b8e4f202 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2001-09-07 Gerd Moellmann + + * 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 * textmodes/ispell.el (ispell-dictionary-alist-4): Add "german" diff --git a/lisp/isearch.el b/lisp/isearch.el index 2392bf2935b..a125f7ab053 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -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. -- 2.39.2