diff options
| author | Juri Linkov | 2023-11-20 19:57:57 +0200 |
|---|---|---|
| committer | Juri Linkov | 2023-11-20 19:57:57 +0200 |
| commit | 9d292262f55cd016a1a59f4d4ef31446bb2ba9c6 (patch) | |
| tree | f7def64147b0769a09687741c4df871e8d1a5a2f /lisp | |
| parent | 5024ee1ad18904bc0a0e7a8f740164157649af5e (diff) | |
| download | emacs-9d292262f55cd016a1a59f4d4ef31446bb2ba9c6.tar.gz emacs-9d292262f55cd016a1a59f4d4ef31446bb2ba9c6.zip | |
Improve invisibility handling in isearch-lazy-highlight (bug#40808)
* lisp/isearch.el (isearch-lazy-highlight-invisible): New variable.
(isearch-lazy-highlight-new-loop, isearch-lazy-highlight-search)
(isearch-lazy-highlight-match, isearch-lazy-highlight-buffer-update): Use it.
* lisp/replace.el (replace-highlight): Let-bind isearch-invisible
to search-invisible.
* test/lisp/isearch-tests.el (isearch--test-invisible): New test.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/isearch.el | 18 | ||||
| -rw-r--r-- | lisp/replace.el | 1 |
2 files changed, 14 insertions, 5 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 4d231fba469..4672440bdff 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -4054,6 +4054,7 @@ since they have special meaning in a regexp." | |||
| 4054 | (defvar isearch-lazy-highlight-point-max nil) | 4054 | (defvar isearch-lazy-highlight-point-max nil) |
| 4055 | (defvar isearch-lazy-highlight-buffer nil) | 4055 | (defvar isearch-lazy-highlight-buffer nil) |
| 4056 | (defvar isearch-lazy-highlight-case-fold-search nil) | 4056 | (defvar isearch-lazy-highlight-case-fold-search nil) |
| 4057 | (defvar isearch-lazy-highlight-invisible nil) | ||
| 4057 | (defvar isearch-lazy-highlight-regexp nil) | 4058 | (defvar isearch-lazy-highlight-regexp nil) |
| 4058 | (defvar isearch-lazy-highlight-lax-whitespace nil) | 4059 | (defvar isearch-lazy-highlight-lax-whitespace nil) |
| 4059 | (defvar isearch-lazy-highlight-regexp-lax-whitespace nil) | 4060 | (defvar isearch-lazy-highlight-regexp-lax-whitespace nil) |
| @@ -4099,6 +4100,8 @@ by other Emacs features." | |||
| 4099 | isearch-lazy-highlight-window-group)) | 4100 | isearch-lazy-highlight-window-group)) |
| 4100 | (not (eq isearch-lazy-highlight-case-fold-search | 4101 | (not (eq isearch-lazy-highlight-case-fold-search |
| 4101 | isearch-case-fold-search)) | 4102 | isearch-case-fold-search)) |
| 4103 | (not (eq isearch-lazy-highlight-invisible | ||
| 4104 | isearch-invisible)) | ||
| 4102 | (not (eq isearch-lazy-highlight-regexp | 4105 | (not (eq isearch-lazy-highlight-regexp |
| 4103 | isearch-regexp)) | 4106 | isearch-regexp)) |
| 4104 | (not (eq isearch-lazy-highlight-regexp-function | 4107 | (not (eq isearch-lazy-highlight-regexp-function |
| @@ -4177,6 +4180,7 @@ by other Emacs features." | |||
| 4177 | isearch-lazy-highlight-wrapped nil | 4180 | isearch-lazy-highlight-wrapped nil |
| 4178 | isearch-lazy-highlight-last-string isearch-string | 4181 | isearch-lazy-highlight-last-string isearch-string |
| 4179 | isearch-lazy-highlight-case-fold-search isearch-case-fold-search | 4182 | isearch-lazy-highlight-case-fold-search isearch-case-fold-search |
| 4183 | isearch-lazy-highlight-invisible isearch-invisible | ||
| 4180 | isearch-lazy-highlight-regexp isearch-regexp | 4184 | isearch-lazy-highlight-regexp isearch-regexp |
| 4181 | isearch-lazy-highlight-lax-whitespace isearch-lax-whitespace | 4185 | isearch-lazy-highlight-lax-whitespace isearch-lax-whitespace |
| 4182 | isearch-lazy-highlight-regexp-lax-whitespace isearch-regexp-lax-whitespace | 4186 | isearch-lazy-highlight-regexp-lax-whitespace isearch-regexp-lax-whitespace |
| @@ -4226,8 +4230,10 @@ Attempt to do the search exactly the way the pending Isearch would." | |||
| 4226 | (isearch-forward isearch-lazy-highlight-forward) | 4230 | (isearch-forward isearch-lazy-highlight-forward) |
| 4227 | ;; Count all invisible matches, but highlight only | 4231 | ;; Count all invisible matches, but highlight only |
| 4228 | ;; matches that can be opened by visiting them later | 4232 | ;; matches that can be opened by visiting them later |
| 4229 | (search-invisible (or (not (null isearch-lazy-count)) | 4233 | (search-invisible |
| 4230 | 'can-be-opened)) | 4234 | (or (not (null isearch-lazy-count)) |
| 4235 | (and (eq isearch-lazy-highlight-invisible 'open) | ||
| 4236 | 'can-be-opened))) | ||
| 4231 | (retry t) | 4237 | (retry t) |
| 4232 | (success nil)) | 4238 | (success nil)) |
| 4233 | ;; Use a loop like in `isearch-search'. | 4239 | ;; Use a loop like in `isearch-search'. |
| @@ -4247,7 +4253,9 @@ Attempt to do the search exactly the way the pending Isearch would." | |||
| 4247 | (when (or (not isearch-lazy-count) | 4253 | (when (or (not isearch-lazy-count) |
| 4248 | ;; Recheck the match that possibly was intended | 4254 | ;; Recheck the match that possibly was intended |
| 4249 | ;; for counting only, but not for highlighting | 4255 | ;; for counting only, but not for highlighting |
| 4250 | (let ((search-invisible 'can-be-opened)) | 4256 | (let ((search-invisible |
| 4257 | (and (eq isearch-lazy-highlight-invisible 'open) | ||
| 4258 | 'can-be-opened))) | ||
| 4251 | (funcall isearch-filter-predicate mb me))) | 4259 | (funcall isearch-filter-predicate mb me))) |
| 4252 | (let ((ov (make-overlay mb me))) | 4260 | (let ((ov (make-overlay mb me))) |
| 4253 | (push ov isearch-lazy-highlight-overlays) | 4261 | (push ov isearch-lazy-highlight-overlays) |
| @@ -4396,9 +4404,9 @@ Attempt to do the search exactly the way the pending Isearch would." | |||
| 4396 | ;; value `open' since then lazy-highlight | 4404 | ;; value `open' since then lazy-highlight |
| 4397 | ;; will open all overlays with matches. | 4405 | ;; will open all overlays with matches. |
| 4398 | (if (not (let ((search-invisible | 4406 | (if (not (let ((search-invisible |
| 4399 | (if (eq search-invisible 'open) | 4407 | (if (eq isearch-lazy-highlight-invisible 'open) |
| 4400 | 'can-be-opened | 4408 | 'can-be-opened |
| 4401 | search-invisible))) | 4409 | isearch-lazy-highlight-invisible))) |
| 4402 | (funcall isearch-filter-predicate mb me))) | 4410 | (funcall isearch-filter-predicate mb me))) |
| 4403 | (setq isearch-lazy-count-invisible | 4411 | (setq isearch-lazy-count-invisible |
| 4404 | (1+ (or isearch-lazy-count-invisible 0))) | 4412 | (1+ (or isearch-lazy-count-invisible 0))) |
diff --git a/lisp/replace.el b/lisp/replace.el index ac677db2feb..ff7ca1145b8 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -2755,6 +2755,7 @@ to a regexp that is actually used for the search.") | |||
| 2755 | (isearch-regexp-lax-whitespace | 2755 | (isearch-regexp-lax-whitespace |
| 2756 | replace-regexp-lax-whitespace) | 2756 | replace-regexp-lax-whitespace) |
| 2757 | (isearch-case-fold-search case-fold) | 2757 | (isearch-case-fold-search case-fold) |
| 2758 | (isearch-invisible search-invisible) | ||
| 2758 | (isearch-forward (not backward)) | 2759 | (isearch-forward (not backward)) |
| 2759 | (isearch-other-end match-beg) | 2760 | (isearch-other-end match-beg) |
| 2760 | (isearch-error nil) | 2761 | (isearch-error nil) |