From: Juri Linkov Date: Tue, 13 Jul 2021 19:25:05 +0000 (+0300) Subject: Support Isearch filter predicates with empty search hits (bug#49534) X-Git-Tag: emacs-28.0.90~1886 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=35a8861619d4a5038ff37aa9fbeb995bc9b861a7;p=emacs.git Support Isearch filter predicates with empty search hits (bug#49534) * lisp/isearch.el (isearch-search): Move (= (match-beginning 0) (match-end 0)) and (bobp)/(eobp) outside the call to isearch-filter-predicate. Use forward-char 1/-1 on empty matches only when going to retry search. (isearch-lazy-highlight-search): Remove (= (point) bound), but leave (= (match-beginning 0) (match-end 0)) since empty matches make no sense in lazy-highlighting. --- diff --git a/lisp/isearch.el b/lisp/isearch.el index c8bd62875f4..d1b9f2c4397 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -3529,11 +3529,14 @@ Optional third argument, if t, means if fail just return nil (no error). ;; 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))) + (setq retry nil) + ;; Advance point on empty matches before retrying + (when (= (match-beginning 0) (match-end 0)) + (if (if isearch-forward (eobp) (bobp)) + (setq retry nil isearch-success nil) + (forward-char (if isearch-forward 1 -1)))))) (setq isearch-just-started nil) (when isearch-success (setq isearch-other-end @@ -4044,7 +4047,6 @@ Attempt to do the search exactly the way the pending Isearch would." ;; Clear RETRY unless the search predicate says ;; to skip this search hit. (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)))