[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is it valid to call isearch-filter-predicate outside isearch?

From: Juri Linkov
Subject: Re: Is it valid to call isearch-filter-predicate outside isearch?
Date: Mon, 22 May 2023 21:12:55 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)

> I am now investigating an Org mode issue related to interaction between
> Org mode folding and isearch.
> https://list.orgmode.org/orgmode/CAP7OBx+L11ck3Ni6rv94HGU3otdj6C4rG-rMDzkwR1LTj=BWiw@mail.gmail.com/
> Org mode overrides the default value of isearch-filter-predicate with
> (defun org-fold-core--isearch-filter-predicate-overlays (beg end)
>   "Return non-nil if text between BEG and END is deemed visible by isearch.
> This function is intended to be used as `isearch-filter-predicate'."
>   (org-fold-core--create-isearch-overlays beg end) ;; trick isearch by 
> creating overlays in place of invisible text
>   (isearch-filter-visible beg end))
> As you can see, Org produces side effects when the predicate is called.
> I thought that side effects are acceptable since
> `isearch-filter-visible' itself also manipulates buffer visibility in
> `isearch-range-invisible' - it calls
> `isearch-close-unnecessary-overlays' and
> `isearch-open-overlay-temporary' for side effects.
> However, we have found that `query-replace' calls
> `isearch-filter-predicate' outside isearch, and it may not be safe to
> assume that isearch hooks will be executed.

Emacs 29 introduced a new value 'can-be-opened' of the variable
'search-invisible' for side-effect-free uses.

Probably you can bind it to this value in Org mode functions.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]