From a29f3c0b2b43af6b9c283205643a1e2ac43030b7 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Fri, 12 Feb 2021 19:37:14 +0100 Subject: [PATCH] Make `isearch-del-char' backtrack the search more aggressively This allows to always find the first occurrence of the search string after the last `isearch-repeat' or the start of search. * lisp/isearch.el (isearch-del-char): Go to barrier before updating the search. --- lisp/isearch.el | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lisp/isearch.el b/lisp/isearch.el index 9f3cfd70fb..f6a55c7918 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2505,13 +2505,12 @@ isearch-del-char isearch-string ""))) ;; Do the following before moving point. (funcall (or isearch-message-function #'isearch-message) nil t) - ;; Use the isearch-other-end as new starting point to be able - ;; to find the remaining part of the search string again. - ;; This is like what `isearch-search-and-update' does, - ;; but currently it doesn't support deletion of characters - ;; for the case where unsuccessful search may become successful - ;; by deletion of characters. - (if isearch-other-end (goto-char isearch-other-end)) + ;; Go to `isearch-barrier' to be able to find an earlier occurrence + ;; of the remaining part of the search string. + (if isearch-regexp + (isearch-fallback nil nil t) + (goto-char isearch-barrier) + (setq isearch-adjusted t)) (isearch-search) (isearch-push-state) (isearch-update)) -- 2.30.2