[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: |
Juri Linkov |
Subject: |
bug#49534: 26.3; Isearch should support using filter predicates with empty search hits |
Date: |
Tue, 13 Jul 2021 23:20:42 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) |
>>> (= (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))
- bug#49534: 26.3; Isearch should support using filter predicates with empty search hits, Drew Adams, 2021/07/12
- bug#49534: 26.3; Isearch should support using filter predicates with empty search hits, Stefan Monnier, 2021/07/13
- bug#49534: 26.3; Isearch should support using filter predicates with empty search hits, Juri Linkov, 2021/07/13
- bug#49534: [External] : Re: bug#49534: 26.3; Isearch should support using filter predicates with empty search hits, Drew Adams, 2021/07/13
- bug#49534: [External] : Re: bug#49534: 26.3; Isearch should support using filter predicates with empty search hits, Juri Linkov, 2021/07/13
- bug#49534: [External] : Re: bug#49534: 26.3; Isearch should support using filter predicates with empty search hits, Drew Adams, 2021/07/13