From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#49534: 26.3; Isearch should support using filter predicates with empty search hits Date: Tue, 13 Jul 2021 23:20:42 +0300 Organization: LINKOV.NET Message-ID: <874kcy6k4l.fsf@mail.linkov.net> References: <87czrmrxfv.fsf@gnus.org> <87zguq6mof.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30868"; 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: 49534@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jul 13 22:22:11 2021 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 1m3Ouw-0007tq-SP for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Jul 2021 22:22:10 +0200 Original-Received: from localhost ([::1]:48108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3Ouv-00019T-Te for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Jul 2021 16:22:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3Oun-00015V-Td for bug-gnu-emacs@gnu.org; Tue, 13 Jul 2021 16:22:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58807) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3Oun-0000TL-LP for bug-gnu-emacs@gnu.org; Tue, 13 Jul 2021 16:22:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m3Oun-0003ru-IV for bug-gnu-emacs@gnu.org; Tue, 13 Jul 2021 16:22:01 -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, 13 Jul 2021 20:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49534 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 49534-submit@debbugs.gnu.org id=B49534.162620770814852 (code B ref 49534); Tue, 13 Jul 2021 20:22:01 +0000 Original-Received: (at 49534) by debbugs.gnu.org; 13 Jul 2021 20:21:48 +0000 Original-Received: from localhost ([127.0.0.1]:42120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3Oua-0003rT-4R for submit@debbugs.gnu.org; Tue, 13 Jul 2021 16:21:48 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:37567) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3OuW-0003rF-VI for 49534@debbugs.gnu.org; Tue, 13 Jul 2021 16:21:46 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id AA724FF807; Tue, 13 Jul 2021 20:21:37 +0000 (UTC) In-Reply-To: <87zguq6mof.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 13 Jul 2021 22:25:36 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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:209876 Archived-At: >>> (= (match-beginning 0) (match-end 0)) >> >> And, indeed, the default predicate doesn't match on invisible text... >> but I'm not sure why it's also testing the length of the match. (The >> default predicate also checks this, so removing the test seems to >> produce identical results by default.) > > I've tried to remove (= (match-beginning 0) (match-end 0)) > and then tried the test case provided by Drew, > but it goes into an infinite loop. > > So it requires advancing by 1 char - the same trick as it's used > in query-replace, etc. Oh, I realized that (= (match-beginning 0) (match-end 0)) was moved below after (funcall isearch-filter-predicate (match-beginning 0) (match-end 0)) This means that if isearch-filter-predicate does own matching, it will break later (= (match-beginning 0) (match-end 0)). What would be better: to remember its result in a let-bound variable, or to use save-match-data? Probably, save-match-data: diff --git a/lisp/isearch.el b/lisp/isearch.el index 3337d9be68..9113e94c3b 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -3591,8 +3591,9 @@ isearch-search ;; Clear RETRY unless the search predicate says ;; to skip this search hit. (if (or (not isearch-success) - (funcall isearch-filter-predicate - (match-beginning 0) (match-end 0))) + (save-match-data + (funcall isearch-filter-predicate + (match-beginning 0) (match-end 0)))) (setq retry nil) ;; Advance point on empty matches before retrying (when (= (match-beginning 0) (match-end 0))