bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40808: 27.0.91; inaccuracy in isearch-lazy-count


From: Juri Linkov
Subject: bug#40808: 27.0.91; inaccuracy in isearch-lazy-count
Date: Wed, 29 Apr 2020 02:54:06 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> So, what is decided. Is it getting patched for emacs-27?
>
> Yes, it's fine with me.  Thanks.

Now pushed to emacs-27.

But there is still one corner case I'm worried about:
isearch-lazy-count still counts matches that can't be opened
and can't be visited, such as hidden links in org-mode.

To not count them we need to bind 'search-invisible' to 'open'
in isearch-lazy-highlight-search, but the problem is that
isearch-filter-predicate and isearch-range-invisible will
temporarily open them, whereas we need just to check
whether they can be opened.

So in the following patch I added a new variable isearch-check-overlays
that could instruct isearch-range-invisible to not open overlays
when it's non-nil that means we need only to check them, not open:

diff --git a/lisp/isearch.el b/lisp/isearch.el
index e13a4dda83..0ad97a092f 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -3535,6 +3535,7 @@ isearch-close-unnecessary-overlays
            (overlay-put ov 'invisible (overlay-get ov 'isearch-invisible))
            (overlay-put ov 'isearch-invisible nil)))))))
 
+(defvar isearch-check-overlays nil)
 
 (defun isearch-range-invisible (beg end)
   "Return t if all the text from BEG to END is invisible."
@@ -3546,7 +3547,7 @@ isearch-range-invisible
            (can-be-opened (eq search-invisible 'open))
            ;; the list of overlays that could be opened
            (crt-overlays nil))
-       (when (and can-be-opened isearch-hide-immediately)
+       (when (and can-be-opened isearch-hide-immediately (not 
isearch-check-overlays))
          (isearch-close-unnecessary-overlays beg end))
        ;; If the following character is currently invisible,
        ;; skip all characters with that same `invisible' property value.
@@ -3585,9 +3586,10 @@ isearch-range-invisible
        (if (>= (point) end)
            (if (and can-be-opened (consp crt-overlays))
                (progn
-                 (setq isearch-opened-overlays
-                       (append isearch-opened-overlays crt-overlays))
-                 (mapc 'isearch-open-overlay-temporary crt-overlays)
+                 (unless isearch-check-overlays
+                   (setq isearch-opened-overlays
+                         (append isearch-opened-overlays crt-overlays))
+                   (mapc 'isearch-open-overlay-temporary crt-overlays))
                  nil)
              (setq isearch-hidden t)))))))
 
@@ -3880,8 +3885,10 @@ isearch-lazy-highlight-search
          (if (or (not success)
                  (= (point) bound) ; like (bobp) (eobp) in `isearch-search'.
                  (= (match-beginning 0) (match-end 0))
-                 (funcall isearch-filter-predicate
-                          (match-beginning 0) (match-end 0)))
+                 (let ((search-invisible (and search-invisible 'open))
+                       (isearch-check-overlays t))
+                   (funcall isearch-filter-predicate
+                            (match-beginning 0) (match-end 0))))
              (setq retry nil)))
        success)
     (error nil)))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]