unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Locating matches in isearch-open-invisible-temporary callback
@ 2020-12-26 14:58 Kévin Le Gouguec
  0 siblings, 0 replies; only message in thread
From: Kévin Le Gouguec @ 2020-12-26 14:58 UTC (permalink / raw)
  To: help-gnu-emacs

Hello Emacs,

Org 9.4 (to be shipped in Emacs 27.2) comes with a minor annoyance for
me: Isearch opens drawers even though they don't contain matches[1][2].

(Caveat: all my assertions about how Org and overlays work ought to be
prefixed with "IIUC, ")

Org≤9.3 used to setup invisible overlays like this:

* header 1                      
** subheader 1.1                ╮ (1)
:LOGBOOK:               ╮ (2)   │
…               ╮ (3)   │       │
:END:           ╯       │       │
notes go here           ╯       ╯
* header 2

When isearching for "sub", only overlay (1) was revealed since nothing
matched within overlays (2) and (3).

To improve performance by reducing the number of overlays, Org 9.4 no
longer bothers with overlays (2) and (3).  This means that when
isearching for "sub", the content of neighboring :LOGBOOK:s is revealed,
adding lots of distracting visual noise.

(This is only an issue *while* isearching; when exiting Isearch, the
drawers become folded)

The resolution that was suggested on emacs-orgmode is to use the
isearch-open-invisible-temporary property[3], setting it to a callback
that should do the following:

1. when Isearch asks us to reveal the span of an invisible overlay,
    1. remove the overlay (or set the 'invisible property to nil)
    2. identify the drawers within that span that do not contain
       matches,
    3. fold these drawers with temporary invisible overlays;

2. when Isearch asks us to hide a span,
    1. remove the temporary invisible overlays inside that span,
    2. restore the original overlay.

I've tried looking at isearch-open-invisible-temporary callbacks in
Emacs core (AFAICT hs-isearch-show-temporary is the only example), but I
could not find ways to perform step 1.1: how can I know whether a drawer
contains a search result?

Empirically and by looking at Isearch's code, it seems that
(match-beginning 0) and (match-end 0) give me the information I need,
but is that something I can rely on or is it an implementation detail?


Thanks for your time.


[1] bug-gnu-emacs <87wny723u0.fsf@gmail.com>
[2] emacs-orgmode <87r1nrdl5o.fsf_-_@gmail.com>
[3] emacs-orgmode <87sg7th8mh.fsf@gmail.com>



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-26 14:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-26 14:58 Locating matches in isearch-open-invisible-temporary callback Kévin Le Gouguec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).