unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Juri Linkov <juri@linkov.net>, Lars Ingebrigtsen <larsi@gnus.org>
Cc: "49534@debbugs.gnu.org" <49534@debbugs.gnu.org>,
	"Richard M. Stallman" <rms@gnu.org>
Subject: bug#49534: [External] : Re: bug#49534: 26.3; Isearch should support using filter predicates with empty search hits
Date: Tue, 13 Jul 2021 21:44:41 +0000	[thread overview]
Message-ID: <SJ0PR10MB5488468CDEAA55D69A557410F3149@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <87zguq6mof.fsf@mail.linkov.net>

> 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.

Yes, my code does that.

> Also I noticed that Drew's test case matches at 'eob'
> that is wrong.  So I moved checks for bobp/eobp outside.

What do you mean by Drew's test case?

Do you mean the updated isearch+.el definition of `isearch-search', with the bug fix?  That is, do you mean this code?

 (when (or (not isearch-success)
           (isearchp-reached-limit-p) ; <==============
           (funcall isearch-filter-predicate
                    (match-beginning 0)
                    (match-end 0)))
   (setq retry  nil))

where

(defun isearchp-reached-limit-p ()
  "Return non-nil if at search-boundary limit in current search direction."
  (if isearch-forward
      (or (eobp) ; <==================
          (and isearchp-reg-end
               (> (point) isearchp-reg-end)))
      (or (bobp) ; <==================
          (and isearchp-reg-beg
               (< (point) isearchp-reg-beg)))))

Is that the use of `eobp' you're talking about?
(If not, what is?)  That `isearchp-reached-limit-p'
just replaces the original isearch.el code, which
just tested (or (bobp) (eobp)):

(or (not isearch-success)
    (bobp) (eobp) ; <=================
    (= (match-beginning 0) (match-end 0))
    (funcall isearch-filter-predicate
             (match-beginning 0) (match-end 0))) 

My code just uses the (original) region limits
instead of the buffer limits, when searching the
active region.

Your code (in master) removes that boundary test
altogether (no `bobp' or `eobp' test).  Why is
that the right thing?  Is it because the match
should be allowed to match up to `bobp' or `eobp'?
If so, why was that test in isearch.el in the
first place?

Actually, you do still test for reaching the
boundary, but only for an empty match and after
filter failure.  Why is that?

And why do you not need to back up a char after
the loop, if the match was empty the last time
around and the next time it fails?  It'll have
advanced a char; should it stay there instead
of backing up?  (Dunno, but I supposed not.)

Our code in those spots is slightly different.
I'd like to know why you did just as you did.

> The third problem I noticed thanks to Drew's test case
> is that lazy-highlighting incorrectly highlights empty matches.
> Fixed as well.

Yes, I left that code alone for the moment, but
your change is no doubt the right thing there.





  parent reply	other threads:[~2021-07-13 21:44 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12 14:34 bug#49534: 26.3; Isearch should support using filter predicates with empty search hits Drew Adams
2021-07-13 16:27 ` Lars Ingebrigtsen
2021-07-13 19:25   ` Juri Linkov
2021-07-13 20:20     ` Juri Linkov
2021-07-13 20:41       ` Lars Ingebrigtsen
2021-07-13 22:30         ` Juri Linkov
2021-07-13 21:42       ` bug#49534: [External] : " Drew Adams
2021-07-13 22:30         ` Juri Linkov
2021-07-13 23:00           ` Drew Adams
2021-07-13 22:48       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-07-13 23:21         ` Juri Linkov
2021-07-13 21:44     ` Drew Adams [this message]
2021-07-13 22:31       ` bug#49534: [External] : " Juri Linkov
2021-07-13 23:04         ` Drew Adams
2022-02-16  4:20 ` Drew Adams
2022-02-16 18:20   ` Juri Linkov
2022-02-16 18:54     ` bug#49534: [External] : " Drew Adams
2022-02-16 19:09       ` Juri Linkov
2022-02-16 19:17         ` Drew Adams
2022-02-16 19:25           ` 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=SJ0PR10MB5488468CDEAA55D69A557410F3149@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=49534@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    --cc=rms@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).