diff options
| author | Juri Linkov | 2021-11-07 20:13:01 +0200 |
|---|---|---|
| committer | Juri Linkov | 2021-11-07 20:13:01 +0200 |
| commit | 764341919fc576ca2564b0529ca375d9827a3ea2 (patch) | |
| tree | e90d03a93dc3715887f53c09fc03edc811e5464a | |
| parent | a95520d3dfa1b97f88e51f1ee5ef07e278cb854a (diff) | |
| download | emacs-764341919fc576ca2564b0529ca375d9827a3ea2.tar.gz emacs-764341919fc576ca2564b0529ca375d9827a3ea2.zip | |
Simplify c8acc5fd92ad9979fc5870623014290cad998337
* lisp/isearch.el (isearch-filter-visible): Add check if there are
no properties 'inhibit-isearch' in the search range,
instead of code of c8acc5fd92ad9979fc5870623014290cad998337.
| -rw-r--r-- | lisp/isearch.el | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/lisp/isearch.el b/lisp/isearch.el index 4c4b9474245..dea96624774 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -3536,20 +3536,6 @@ Can be changed via `isearch-search-fun-function' for special needs." | |||
| 3536 | (if isearch-forward #'re-search-forward #'re-search-backward) | 3536 | (if isearch-forward #'re-search-forward #'re-search-backward) |
| 3537 | regexp bound noerror count)))) | 3537 | regexp bound noerror count)))) |
| 3538 | 3538 | ||
| 3539 | (defun isearch--search-skip-inhibited (func string bound noerror) | ||
| 3540 | "Search for STRING with FUNC, but skip areas where isearch is inhibited. | ||
| 3541 | Returns the value of the (final) call to the search function." | ||
| 3542 | (let (pos) | ||
| 3543 | (while (and (setq pos (funcall func string bound noerror)) | ||
| 3544 | ;; If we're inhibited here, skip to the end of that | ||
| 3545 | ;; area and try again. | ||
| 3546 | (get-text-property (match-beginning 0) 'inhibit-isearch) | ||
| 3547 | (goto-char (next-single-property-change | ||
| 3548 | (match-beginning 0) | ||
| 3549 | 'inhibit-isearch | ||
| 3550 | nil (point-max))))) | ||
| 3551 | pos)) | ||
| 3552 | |||
| 3553 | (defun isearch-search-string (string bound noerror) | 3539 | (defun isearch-search-string (string bound noerror) |
| 3554 | "Search for the first occurrence of STRING or its translation. | 3540 | "Search for the first occurrence of STRING or its translation. |
| 3555 | STRING's characters are translated using `translation-table-for-input' | 3541 | STRING's characters are translated using `translation-table-for-input' |
| @@ -3561,8 +3547,7 @@ The match found must not extend after that position. | |||
| 3561 | Optional third argument, if t, means if fail just return nil (no error). | 3547 | Optional third argument, if t, means if fail just return nil (no error). |
| 3562 | If not nil and not t, move to limit of search and return nil." | 3548 | If not nil and not t, move to limit of search and return nil." |
| 3563 | (let* ((func (isearch-search-fun)) | 3549 | (let* ((func (isearch-search-fun)) |
| 3564 | (pos1 (save-excursion | 3550 | (pos1 (save-excursion (funcall func string bound noerror))) |
| 3565 | (isearch--search-skip-inhibited func string bound noerror))) | ||
| 3566 | pos2) | 3551 | pos2) |
| 3567 | (when (and | 3552 | (when (and |
| 3568 | ;; Avoid "obsolete" warnings for translation-table-for-input. | 3553 | ;; Avoid "obsolete" warnings for translation-table-for-input. |
| @@ -3585,8 +3570,7 @@ Optional third argument, if t, means if fail just return nil (no error). | |||
| 3585 | (when translated | 3570 | (when translated |
| 3586 | (save-match-data | 3571 | (save-match-data |
| 3587 | (save-excursion | 3572 | (save-excursion |
| 3588 | (if (setq pos2 (isearch--search-skip-inhibited | 3573 | (if (setq pos2 (funcall func translated bound noerror)) |
| 3589 | func string bound noerror)) | ||
| 3590 | (setq match-data (match-data t))))) | 3574 | (setq match-data (match-data t))))) |
| 3591 | (when (and pos2 | 3575 | (when (and pos2 |
| 3592 | (or (not pos1) | 3576 | (or (not pos1) |
| @@ -3740,15 +3724,6 @@ Optional third argument, if t, means if fail just return nil (no error). | |||
| 3740 | (overlay-put ov 'isearch-invisible nil))))))) | 3724 | (overlay-put ov 'isearch-invisible nil))))))) |
| 3741 | 3725 | ||
| 3742 | 3726 | ||
| 3743 | (defun isearch--invisible-p (val) | ||
| 3744 | "Like `invisible-p', but also takes into account `inhibit-isearch' properties. | ||
| 3745 | If search is inhibited due to the latter, return `inhibit-isearch', and | ||
| 3746 | if it's due to the former, return `invisible'." | ||
| 3747 | (or (and (invisible-p val) | ||
| 3748 | 'invisible) | ||
| 3749 | (and (get-text-property (point) 'inhibit-isearch) | ||
| 3750 | 'inhibit-isearch))) | ||
| 3751 | |||
| 3752 | (defun isearch-range-invisible (beg end) | 3727 | (defun isearch-range-invisible (beg end) |
| 3753 | "Return t if all the text from BEG to END is invisible." | 3728 | "Return t if all the text from BEG to END is invisible." |
| 3754 | (when (/= beg end) | 3729 | (when (/= beg end) |
| @@ -3758,19 +3733,16 @@ if it's due to the former, return `invisible'." | |||
| 3758 | (let (;; can-be-opened keeps track if we can open some overlays. | 3733 | (let (;; can-be-opened keeps track if we can open some overlays. |
| 3759 | (can-be-opened (eq search-invisible 'open)) | 3734 | (can-be-opened (eq search-invisible 'open)) |
| 3760 | ;; the list of overlays that could be opened | 3735 | ;; the list of overlays that could be opened |
| 3761 | (crt-overlays nil) | 3736 | (crt-overlays nil)) |
| 3762 | ii-prop) | ||
| 3763 | (when (and can-be-opened isearch-hide-immediately) | 3737 | (when (and can-be-opened isearch-hide-immediately) |
| 3764 | (isearch-close-unnecessary-overlays beg end)) | 3738 | (isearch-close-unnecessary-overlays beg end)) |
| 3765 | ;; If the following character is currently invisible, | 3739 | ;; If the following character is currently invisible, |
| 3766 | ;; skip all characters with that same `invisible' property value. | 3740 | ;; skip all characters with that same `invisible' property value. |
| 3767 | ;; Do that over and over. | 3741 | ;; Do that over and over. |
| 3768 | (while (and (< (point) end) | 3742 | (while (and (< (point) end) (invisible-p (point))) |
| 3769 | (isearch--invisible-p (point))) | 3743 | (if (invisible-p (get-text-property (point) 'invisible)) |
| 3770 | (if (setq ii-prop (isearch--invisible-p | ||
| 3771 | (get-text-property (point) 'invisible))) | ||
| 3772 | (progn | 3744 | (progn |
| 3773 | (goto-char (next-single-property-change (point) ii-prop | 3745 | (goto-char (next-single-property-change (point) 'invisible |
| 3774 | nil end)) | 3746 | nil end)) |
| 3775 | ;; if text is hidden by an `invisible' text property | 3747 | ;; if text is hidden by an `invisible' text property |
| 3776 | ;; we cannot open it at all. | 3748 | ;; we cannot open it at all. |
| @@ -3815,8 +3787,10 @@ Isearch, at least partially, as determined by `isearch-range-invisible'. | |||
| 3815 | If `search-invisible' is t, which allows Isearch matches inside | 3787 | If `search-invisible' is t, which allows Isearch matches inside |
| 3816 | invisible text, this function will always return non-nil, regardless | 3788 | invisible text, this function will always return non-nil, regardless |
| 3817 | of what `isearch-range-invisible' says." | 3789 | of what `isearch-range-invisible' says." |
| 3818 | (or (eq search-invisible t) | 3790 | (and (or (eq search-invisible t) |
| 3819 | (not (isearch-range-invisible beg end)))) | 3791 | (not (isearch-range-invisible beg end))) |
| 3792 | (not (text-property-not-all (min beg end) (max beg end) | ||
| 3793 | 'inhibit-isearch nil)))) | ||
| 3820 | 3794 | ||
| 3821 | 3795 | ||
| 3822 | ;; General utilities | 3796 | ;; General utilities |