all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>,
	emacs-devel@gnu.org, Lars Ingebrigtsen <larsi@gnus.org>,
	Juri Linkov <juri@linkov.net>
Subject: Re: search-invisible and friends
Date: Fri, 11 Sep 2020 09:03:11 +0800	[thread overview]
Message-ID: <87sgbpi0q8.fsf@localhost> (raw)
In-Reply-To: <jwvv9glfdlb.fsf-monnier+emacs@gnu.org>

> Note that what I'm suggesting is somewhat orthogonal since it's about
> making it possible for a text (or overlay) property to say not to skip
> over a particular (hidden) chunk of text, regardless of whether (and
> how) we'd open the text to show it or not.

Isn't 'isearch-open-invisible property doing it already? If it is
non-nil, the hidden text is not skipped by isearch.

-----

Also, adding on the initial topic of skipping some technically not
invisible text. Similar functionality is required by org-mode branch I
am working on - some folded (temporarily hidden) may better not be
searchable. I implemented it by defining custom
`isearch-filter-predicate'.

The code I used is below. For context, org-fold--isearch-specs lists
'invisible property values that should be searchable.
org-fold-get-folding-specs-in-region retrieves all 'invisible property
values in region.

The code decides if isearch can search in region depending on the value
of 'invisible property, but it can generally be any property.

(defun org-fold--isearch-filter-predicate-text-properties (beg end)
  "Make sure that text hidden by any means other than `org-fold--isearch-specs' is not searchable.
This function is intended to be used as `isearch-filter-predicate'."
  (and
   ;; Check folding specs that cannot be searched
   (seq-every-p (lambda (spec) (member spec org-fold--isearch-specs)) (org-fold-get-folding-specs-in-region beg end))
   ;; Check 'invisible properties that are not folding specs
   (or (eq search-invisible t) ; User wants to search, allow it
       (let ((pos beg)
	     unknown-invisible-property)
	 (while (and (< pos end)
		     (not unknown-invisible-property))
	   (when (and (get-text-property pos 'invisible)
		      (not (member (get-text-property pos 'invisible) org-fold--isearch-specs)))
	     (setq unknown-invisible-property t))
	   (setq pos (next-single-char-property-change pos 'invisible)))
	 (not unknown-invisible-property)))
   (or (and (eq search-invisible t)
	    ;; FIXME: this opens regions permanenly for now.
            ;; I also tried to force search-invisible 'open-all around
            ;; `isearch-range-invisible', but that somehow causes
            ;; infinite loop in `isearch-lazy-highlight'.
            (prog1 t
	      ;; We still need to reveal the folded location
	      (org-fold--isearch-show-temporary (cons beg end) nil)))
       (not (isearch-range-invisible beg end)))))

Best,
Ihor

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>>> Do you mean to match text in the display replacement,
>>> No, I mean to ignore `search-invisible` on those specific chunks (but
>>> still only do the search on the buffer text).
>> FYI, I proposed similar patch earlier:
>> https://lists.gnu.org/archive/html/emacs-devel/2020-07/msg00679.html
>
> OMG, yes, it's still in my TODO.
>
> Note that what I'm suggesting is somewhat orthogonal since it's about
> making it possible for a text (or overlay) property to say not to skip
> over a particular (hidden) chunk of text, regardless of whether (and
> how) we'd open the text to show it or not.
>
>
>         Stefan



  reply	other threads:[~2020-09-11  1:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 12:39 search-invisible and friends Lars Ingebrigtsen
2020-09-09 14:43 ` Eli Zaretskii
2020-09-10 12:38   ` Lars Ingebrigtsen
2020-09-10 14:29     ` Eli Zaretskii
2020-09-10 15:03       ` Stefan Monnier
2020-09-10 18:11         ` Juri Linkov
2020-09-10 20:47           ` Stefan Monnier
2020-09-10 22:10             ` Ihor Radchenko
2020-09-10 22:55               ` Stefan Monnier
2020-09-11  1:03                 ` Ihor Radchenko [this message]
2020-09-11  1:42                   ` Stefan Monnier
2020-09-11  5:35         ` Yuri Khan
2020-09-11 11:46           ` Lars Ingebrigtsen
2020-09-11 12:29             ` Eli Zaretskii
2020-09-11 14:40               ` Lars Ingebrigtsen
2020-09-11 14:50                 ` Eli Zaretskii
2020-09-11 14:56                   ` Lars Ingebrigtsen
2020-09-11 15:14                     ` Eli Zaretskii
2020-09-12 11:48                       ` Lars Ingebrigtsen
2020-09-12 15:29               ` Stefan Monnier
2020-09-11 11:41         ` Lars Ingebrigtsen
2020-09-10 18:12     ` Drew Adams
2020-09-09 15:10 ` Stefan Monnier
2020-09-09 15:26   ` Eli Zaretskii
2020-09-09 16:11     ` Stefan Monnier
2020-09-09 16:25       ` Eli Zaretskii
2020-09-10 12:35         ` Lars Ingebrigtsen
2020-09-10 12:42           ` Eli Zaretskii
2020-09-10 13:21             ` Stefan Monnier
2020-09-10 14:42               ` Eli Zaretskii
2020-09-11 11:37             ` Lars Ingebrigtsen
2020-09-11 12:25               ` Eli Zaretskii
2020-09-09 18:48 ` Juri Linkov
2020-09-10 12:01   ` Lars Ingebrigtsen

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=87sgbpi0q8.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    --cc=monnier@iro.umontreal.ca \
    /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.