From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko Newsgroups: gmane.emacs.devel Subject: Is it valid to call isearch-filter-predicate outside isearch? Date: Sat, 20 May 2023 14:10:38 +0000 Message-ID: <875y8nks9t.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6442"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat May 20 16:07:39 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q0NFB-0001U0-RB for ged-emacs-devel@m.gmane-mx.org; Sat, 20 May 2023 16:07:37 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q0NEW-0005v2-5z; Sat, 20 May 2023 10:06:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0NEU-0005tn-0Z for emacs-devel@gnu.org; Sat, 20 May 2023 10:06:54 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q0NER-0002HV-VH for emacs-devel@gnu.org; Sat, 20 May 2023 10:06:53 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id EFEDC240028 for ; Sat, 20 May 2023 16:06:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1684591610; bh=VyLno7XfU/HCR5WTbm/pxPHjnZpuI3UsuZSPJb5hgnc=; h=From:To:Subject:Date:Message-ID:MIME-Version:From; b=QFhjFxc2TNa2xNTRAODv/pwjOPIWgrU1TVEMfvcY8bYyhum3CQ/FcqZ851Msoo6W+ 33VczewhiwMNKW0jQdLtEMKthcbXP4WFHj0xF5QqcDFTb6WlNYO+Ji+RWvMXuaiw8S LKbZu5NfAN/h37Ha/U1m08zyAkQ0jYeJO37/qSJ+vqzXZikV2xbSGECSLgW8DGOAc4 //6Q3J6DrWGp6mgg9otXohFlaU8hbjR5P29lhy+QyduBIPSojyFZ/xxldPJhNkl5rZ lQwQyCnBwz+Za1iquXgV9L3N0eFkKDxlArCDdQQqkLeEA29CdrM1wp/UVGVEFOyGQu 7Ey8KAL1ylInw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QNlrT49pJz9rxL for ; Sat, 20 May 2023 16:06:49 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306232 Archived-At: 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 . Support Org development at , or support my work at