comparison lisp/isearch.el @ 39189:45d6d104c4f2

(isearch-intersects-p): New function. (isearch-close-unnecessary-overlays): Renamed from *unecessary*, use isearch-intersects-p, and clean up.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 07 Sep 2001 16:16:28 +0000
parents d177c68813c0
children cc4b3cf1bfcd
comparison
equal deleted inserted replaced
39188:9b80cbcb8915 39189:45d6d104c4f2
1678 (defun isearch-clean-overlays () 1678 (defun isearch-clean-overlays ()
1679 (when isearch-opened-overlays 1679 (when isearch-opened-overlays
1680 (mapc 'isearch-open-necessary-overlays isearch-opened-overlays) 1680 (mapc 'isearch-open-necessary-overlays isearch-opened-overlays)
1681 (setq isearch-opened-overlays nil))) 1681 (setq isearch-opened-overlays nil)))
1682 1682
1683
1684 (defun isearch-intersects-p (start0 end0 start1 end1)
1685 "Return t if regions START0..END0 and START1..END1 intersect."
1686 (or (and (>= start0 start1) (< start0 end1))
1687 (and (>= end0 start1) (< end0 end1))
1688 (and (>= start1 start0) (< start1 end0))
1689 (and (>= end1 start0) (< end1 end0))))
1690
1691
1683 ;;; Verify if the current match is outside of each element of 1692 ;;; Verify if the current match is outside of each element of
1684 ;;; `isearch-opened-overlays', if so close that overlay. 1693 ;;; `isearch-opened-overlays', if so close that overlay.
1685 (defun isearch-close-unecessary-overlays (begin end) 1694
1686 (let ((ov-list isearch-opened-overlays) 1695 (defun isearch-close-unnecessary-overlays (begin end)
1687 ov 1696 (let ((overlays isearch-opened-overlays))
1688 inside-overlay
1689 fct-temp)
1690 (setq isearch-opened-overlays nil) 1697 (setq isearch-opened-overlays nil)
1691 (while ov-list 1698 (dolist (ov overlays)
1692 (setq ov (car ov-list)) 1699 (if (isearch-intersects-p begin end (overlay-start ov) (overlay-end ov))
1693 (setq ov-list (cdr ov-list)) 1700 (push ov isearch-opened-overlays)
1694 (setq inside-overlay (or (and (> begin (overlay-start ov)) 1701 (let ((fct-temp (overlay-get ov 'isearch-open-invisible-temporary)))
1695 (< begin (overlay-end ov))) 1702 (if fct-temp
1696 (and (> end (overlay-start ov)) 1703 ;; If this exists it means that the overlay was opened
1697 (< end (overlay-end ov))))) 1704 ;; using this function, not by us tweaking the overlay
1698 ;; If this exists it means that the overlay was opened using 1705 ;; properties.
1699 ;; this function, not by us tweaking the overlay properties. 1706 (funcall fct-temp ov t)
1700 (setq fct-temp (overlay-get ov 'isearch-open-invisible-temporary)) 1707 (overlay-put ov 'invisible (overlay-get ov 'isearch-invisible))
1701 (if inside-overlay 1708 (overlay-put ov 'intangible (overlay-get ov 'isearch-intangible))
1702 (setq isearch-opened-overlays (cons ov isearch-opened-overlays)) 1709 (overlay-put ov 'isearch-invisible nil)
1703 (if fct-temp 1710 (overlay-put ov 'isearch-intangible nil)))))))
1704 (funcall fct-temp ov t) 1711
1705 (overlay-put ov 'invisible (overlay-get ov 'isearch-invisible))
1706 (overlay-put ov 'intangible (overlay-get ov 'isearch-intangible))
1707 (overlay-put ov 'isearch-invisible nil)
1708 (overlay-put ov 'isearch-intangible nil))))))
1709 1712
1710 (defun isearch-range-invisible (beg end) 1713 (defun isearch-range-invisible (beg end)
1711 "Return t if all the text from BEG to END is invisible." 1714 "Return t if all the text from BEG to END is invisible."
1712 (and (/= beg end) 1715 (and (/= beg end)
1713 ;; Check that invisibility runs up to END. 1716 ;; Check that invisibility runs up to END.
1717 ;; can-be-opened keeps track if we can open some overlays. 1720 ;; can-be-opened keeps track if we can open some overlays.
1718 (can-be-opened (eq search-invisible 'open)) 1721 (can-be-opened (eq search-invisible 'open))
1719 ;; the list of overlays that could be opened 1722 ;; the list of overlays that could be opened
1720 (crt-overlays nil)) 1723 (crt-overlays nil))
1721 (when (and can-be-opened isearch-hide-immediately) 1724 (when (and can-be-opened isearch-hide-immediately)
1722 (isearch-close-unecessary-overlays beg end)) 1725 (isearch-close-unnecessary-overlays beg end))
1723 ;; If the following character is currently invisible, 1726 ;; If the following character is currently invisible,
1724 ;; skip all characters with that same `invisible' property value. 1727 ;; skip all characters with that same `invisible' property value.
1725 ;; Do that over and over. 1728 ;; Do that over and over.
1726 (while (and (< (point) end) 1729 (while (and (< (point) end)
1727 (let ((prop 1730 (let ((prop