emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: search-invisible and friends


From: Juri Linkov
Subject: Re: search-invisible and friends
Date: Thu, 10 Sep 2020 21:11:07 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>>> Ah, yeah, that sounds quite useful and natural.  We could even have a
>>> standard property like `no-search' that could be part of the default
>>> `search-invisible' value, so that modes can easily mark out regions that
>>> shouldn't be searched for.  In which case, the whole `display' thing
>>> becomes moot -- in my mode, I could just slap the `no-search' property
>>> on all the image display bits that I want isearch to avoid?
>> Yes, those were my thoughts.
>
> It'd be good to have such a `no-search` property,

Like dired-isearch-filter-filenames adds own filter,
this could be implemented like:

(defun isearch-filter-no-search (beg end)
  (not (text-property-not-all (min beg end) (max beg end)
                              'no-search nil)))

(add-function :before-while (local 'isearch-filter-predicate)
              #'isearch-filter-no-search)

(insert (propertize "foo" 'display "bar" 'no-search t))

> but I think it's also important to make the `search-invisible`
> automatically handle text that's hidden by a `display` property,
> without having to add an explicit `no-search`.

Maybe like this:

(defun isearch-filter-display (beg end)
  (not (text-property-not-all (min beg end) (max beg end)
                              'display nil)))

(add-function :before-while (local 'isearch-filter-predicate)
              #'isearch-filter-display)

(insert (propertize "foo" 'display "bar"))

> OTOH, maybe there could be unusual circumstances where it would make
> sense to consider hidden text as "visible" (e.g. if the `display`
> property replaces the text with something that looks very much like the
> same text, tho maybe rendered a bit differently).

Do you mean to match text in the display replacement, i.e. the string "bar"?
This is more complicated but it's possible by using get-text-property and
string-match to match the search string in the display property.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]