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: Re: Is it valid to call isearch-filter-predicate outside isearch? Date: Thu, 01 Jun 2023 11:42:25 +0000 Message-ID: <87v8g79zoe.fsf@localhost> References: <875y8nks9t.fsf@localhost> <87fs7c10cq.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39265"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jun 01 13:38:21 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 1q4gdI-000A1X-OP for ged-emacs-devel@m.gmane-mx.org; Thu, 01 Jun 2023 13:38:20 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4gd2-0003ib-6A; Thu, 01 Jun 2023 07:38:04 -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 1q4gd0-0003iP-DF for emacs-devel@gnu.org; Thu, 01 Jun 2023 07:38:02 -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 1q4gcy-0005aa-63 for emacs-devel@gnu.org; Thu, 01 Jun 2023 07:38:02 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 82A68240027 for ; Thu, 1 Jun 2023 13:37:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1685619476; bh=SIKZwQT5Ys1a4lRS/8+WnSdOTj8PioT8HFCxSs7pDEc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=ZH24EhVMIEWBxnfC+QcILHBSZ+Zosh0xXFM1/aafaUmdiA6ZvZuEkG4ZfhAd+PMAZ n1FG20SD/6CF9FctdaV9uTqvMh9fetqhongewd/SaB0N88c6tuxQ864bqGnDHXTD6k 16DKqds28u9khyUDMPl5+K9Ultphqt+NetpjEd5nR3ko0F5SeNhMCKDigdJbdgMDHl f03TVvtcvVJNANgev8OZpX81S0uj4Z6KD4ePhEUMh5xSwqLiBvOXvGsR1QurGI8HgI +QiWogtPMWiA2dya8XsjbzSbgCfE86u6fKsSfNp6nvDoXUIx5Idl2ZexwpC2H+hV67 n20IO3tDtVkIA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QX3z80fhRz9rxB; Thu, 1 Jun 2023 13:37:56 +0200 (CEST) In-Reply-To: <87fs7c10cq.fsf@web.de> 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, 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:306507 Archived-At: Michael Heerdegen writes: >> 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/ > > The answer to the subject is probably: query-replace is also ok, else > "no". AFAIK, at least evil does it: https://github.com/emacs-evil/evil/blob/be736b8dbc468d53e6cb3e76db66c1141330b030/evil-search.el#L183 I asked them to respect `isearch-mode-end-hook' in https://github.com/emacs-evil/evil/issues/1630, but after seeing `query-replace' I started to doubt my confidence. >> 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. > > (if (org-fold-core-get-folding-spec-property spec :isearch-open) > (overlay-put o 'isearch-open-invisible #'delete-overlay) > (overlay-put o 'isearch-open-invisible #'ignore) > (overlay-put o 'isearch-open-invisible-temporary #'ignore)) > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > Can't you bind this to a function that does what you want? AFAIU it is > called with two arguments - the overlay itself and a bool saying "open" > (nil) or "re-hide" (non-nil). That should allow to not rely on any > hooks to remove your helper overlays. Unless, maybe, not all of them > are opened. Can that happen? I tried... But it is prohibited to remove overlays when isearch is tracking them: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60399 Also, closing an overlay does not necessarily mean that isearch is over - Org cannot yet convert it back to text properties. That said, the idea is good for other reasons. > If it does, maybe using `post-command-hook' would be a better choice > than `isearch-end-hook' (which is, obviously, not a good choice)? Surely not. `post-command-hook' is triggered after each `self-insert-command' during isearch/query-replace. I had to advice `isearch-clean-overlays', which appears to be called by all the users of `isearch-filter-predicate' (replace-regexp, evil-mode, and swipet). Still a workaround. Ugly. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7dee2c07f -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at