From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Is it valid to call isearch-filter-predicate outside isearch? Date: Mon, 22 May 2023 21:12:55 +0300 Organization: LINKOV.NET Message-ID: <86pm6sb5g8.fsf@mail.linkov.net> References: <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="7840"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon May 22 20:14:53 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 1q1A3Z-0001kS-AF for ged-emacs-devel@m.gmane-mx.org; Mon, 22 May 2023 20:14:53 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1A2g-0008RZ-Eq; Mon, 22 May 2023 14:13:58 -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 1q1A2e-0008NU-K8 for emacs-devel@gnu.org; Mon, 22 May 2023 14:13:56 -0400 Original-Received: from relay8-d.mail.gandi.net ([217.70.183.201]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1A2c-0001py-Fl for emacs-devel@gnu.org; Mon, 22 May 2023 14:13:56 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 603311BF20A; Mon, 22 May 2023 18:13:49 +0000 (UTC) In-Reply-To: <875y8nks9t.fsf@localhost> (Ihor Radchenko's message of "Sat, 20 May 2023 14:10:38 +0000") Received-SPF: pass client-ip=217.70.183.201; envelope-from=juri@linkov.net; helo=relay8-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, 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:306274 Archived-At: > 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.