From: Juri Linkov <juri@linkov.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 40808@debbugs.gnu.org, Abdullah Asad <abdullah@net-c.com>
Subject: bug#40808: 27.0.91; inaccuracy in isearch-lazy-count
Date: Wed, 29 Apr 2020 02:54:06 +0300 [thread overview]
Message-ID: <87mu6vkvz5.fsf@mail.linkov.net> (raw)
In-Reply-To: <83o8rb1kra.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 28 Apr 2020 22:19:05 +0300")
[-- Attachment #1: Type: text/plain, Size: 761 bytes --]
>> 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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: isearch-check-overlays.patch --]
[-- Type: text/x-diff, Size: 1952 bytes --]
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)))
next prev parent reply other threads:[~2020-04-28 23:54 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 6:42 bug#40808: 27.0.91; inaccuracy in isearch-lazy-count Abdullah Asad
2020-04-25 20:53 ` Juri Linkov
2020-04-28 18:46 ` Abdullah Asad
2020-04-28 19:19 ` Eli Zaretskii
2020-04-28 23:54 ` Juri Linkov [this message]
2020-04-29 7:11 ` Eli Zaretskii
2020-04-29 20:56 ` Juri Linkov
2020-04-30 20:18 ` Juri Linkov
2020-05-01 5:58 ` Eli Zaretskii
2020-05-03 22:33 ` Juri Linkov
2020-05-24 21:45 ` bug#40808: Org-mode " Juri Linkov
2020-05-25 8:49 ` Bastien
2020-08-26 12:40 ` Stefan Kangas
-- strict thread matches above, loose matches on Subject: below --
2021-07-12 1:58 bug#40808: 27.0.91; " Drew Adams
2022-07-07 17:09 ` Juri Linkov
2022-07-08 17:48 ` Juri Linkov
2022-12-10 17:51 ` Juri Linkov
2022-12-12 17:44 ` Juri Linkov
2022-12-28 18:54 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mu6vkvz5.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=40808@debbugs.gnu.org \
--cc=abdullah@net-c.com \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).