From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#40808: 27.0.91; inaccuracy in isearch-lazy-count Date: Wed, 29 Apr 2020 02:54:06 +0300 Organization: LINKOV.NET Message-ID: <87mu6vkvz5.fsf@mail.linkov.net> References: <41ce1bd9-2ddb-a46b-3cb9-2b1b25e48438@net-c.com> <87ftcrux08.fsf@mail.linkov.net> <83o8rb1kra.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="89702"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: 40808@debbugs.gnu.org, Abdullah Asad To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 29 01:59:14 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jTa89-000ND7-Iw for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 29 Apr 2020 01:59:13 +0200 Original-Received: from localhost ([::1]:48682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTa88-0001V4-JX for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 28 Apr 2020 19:59:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36228) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jTa7y-0001SI-TZ for bug-gnu-emacs@gnu.org; Tue, 28 Apr 2020 19:59:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jTa7y-0007TI-I2 for bug-gnu-emacs@gnu.org; Tue, 28 Apr 2020 19:59:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jTa7y-0007T7-5l for bug-gnu-emacs@gnu.org; Tue, 28 Apr 2020 19:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jTa7y-0000cK-4n for bug-gnu-emacs@gnu.org; Tue, 28 Apr 2020 19:59:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 28 Apr 2020 23:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40808 X-GNU-PR-Package: emacs Original-Received: via spool by 40808-submit@debbugs.gnu.org id=B40808.15881183052330 (code B ref 40808); Tue, 28 Apr 2020 23:59:02 +0000 Original-Received: (at 40808) by debbugs.gnu.org; 28 Apr 2020 23:58:25 +0000 Original-Received: from localhost ([127.0.0.1]:41905 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTa78-0000bF-KU for submit@debbugs.gnu.org; Tue, 28 Apr 2020 19:58:25 -0400 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:35009) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jTa77-0000an-6e for 40808@debbugs.gnu.org; Tue, 28 Apr 2020 19:58:09 -0400 Original-Received: from mail.gandi.net (m91-129-106-11.cust.tele2.ee [91.129.106.11]) (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id C52D024000B; Tue, 28 Apr 2020 23:58:01 +0000 (UTC) In-Reply-To: <83o8rb1kra.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 28 Apr 2020 22:19:05 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:179260 Archived-At: --=-=-= Content-Type: text/plain >> 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=isearch-check-overlays.patch 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))) --=-=-=--