all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: emacs-devel@gnu.org
Subject: Is it valid to call isearch-filter-predicate outside isearch?
Date: Sat, 20 May 2023 14:10:38 +0000	[thread overview]
Message-ID: <875y8nks9t.fsf@localhost> (raw)

Hi,

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.

The documentation for `isearch-filter-visible' sounds like no side
effects are expected:

    Predicate to filter hits of Isearch and replace commands.
    
    Isearch hits that don't satisfy the predicate will be skipped.
    The value should be a function of two arguments; it will be
    called with the positions of the start and the end of the text
    matched by Isearch and replace commands.  If this function
    returns nil, Isearch and replace commands will continue searching
    without stopping at resp. replacing this match.
    This function is expected to be careful not to clobber the match data.
    
Either the docstring is not accurate or the implementation of
`isearch-range-invisible' is not safe.

Am I missing something?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



             reply	other threads:[~2023-05-20 14:10 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-20 14:10 Ihor Radchenko [this message]
2023-05-22 18:12 ` Is it valid to call isearch-filter-predicate outside isearch? Juri Linkov
2023-05-31 10:08   ` Ihor Radchenko
2023-05-31 12:44     ` Eli Zaretskii
2023-05-31 12:56       ` Ihor Radchenko
2023-05-31 14:21         ` Eli Zaretskii
2023-05-31 14:38           ` Ihor Radchenko
2023-05-31 15:22             ` [External] : " Drew Adams
2023-06-01  8:10               ` Ihor Radchenko
2023-05-31 23:10             ` Michael Heerdegen
2023-06-01 11:48               ` Ihor Radchenko
2023-06-01 23:30                 ` Michael Heerdegen
2023-06-02  8:58                   ` Ihor Radchenko
2023-06-01  6:38     ` Juri Linkov
2023-06-01 11:44       ` Ihor Radchenko
2023-05-31 23:17 ` Michael Heerdegen
2023-06-01  5:55   ` Eli Zaretskii
2023-06-01 23:13     ` Michael Heerdegen
2023-06-01  0:40 ` Michael Heerdegen
2023-06-01 11:42   ` Ihor Radchenko
2023-06-01 16:21     ` Juri Linkov
2023-06-02  8:56       ` Ihor Radchenko
2023-06-01 23:22     ` Michael Heerdegen
2023-06-02  9:07       ` Ihor Radchenko
2023-06-02 13:36         ` [External] : " Drew Adams
2023-06-02 23:06         ` Michael Heerdegen
2023-06-03  8:35           ` Ihor Radchenko
2023-06-04  0:06             ` Michael Heerdegen
2023-06-17 13:05               ` Ihor Radchenko
2023-06-18  2:48                 ` Michael Heerdegen
2023-06-18 11:31                   ` Ihor Radchenko
2023-06-04  2:06             ` Michael Heerdegen
2023-06-18 10:31           ` Ihor Radchenko
2023-06-18 21:39             ` Michael Heerdegen
2023-06-19 10:44               ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875y8nks9t.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.