[Top][All Lists]

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

bug#49534: 26.3; Isearch should support using filter predicates with emp

From: Lars Ingebrigtsen
Subject: bug#49534: 26.3; Isearch should support using filter predicates with empty search hits
Date: Tue, 13 Jul 2021 18:27:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Drew Adams <drew.adams@oracle.com> writes:

> That won't work.  Isearch is unnecessarily restrictive because of this
> test in `isearch-search', which if non-nil prevents invoking
> `isearch-filter-predicate'.
>  (= (match-beginning 0) (match-end 0))

The code is:

        (while retry
          (setq isearch-success
                (isearch-search-string isearch-string nil t))
          ;; Clear RETRY unless the search predicate says
          ;; to skip this search hit.
          (if (or (not isearch-success)
                  (bobp) (eobp)
                  (= (match-beginning 0) (match-end 0))
                  (funcall isearch-filter-predicate
                           (match-beginning 0) (match-end 0)))
              (setq retry nil)))

I've tried following the logic here, but I'm not sure why we never retry
if the match is zero length.  It looks like this was introduced here:

commit 86bfaffe409c6f7398bcf2144fa8d9f436bd4002
Author:     Richard M. Stallman <rms@gnu.org>
AuthorDate: Mon Feb 10 09:41:31 1997 +0000

    (isearch-search): Refuse to match invisible text.
    (isearch-range-invisible): New function.
    (search-invisible): New user option.

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

So I've added Richard to the CCs -- Richard, you don't happen to recall
the meaning of that apparently duplicated test in a patch that's only 24
years old?

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

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