bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#40053: 28.0; text-property-search-forward skips first region


From: Stephen Berman
Subject: bug#40053: 28.0; text-property-search-forward skips first region
Date: Fri, 13 Mar 2020 19:46:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

On Fri, 13 Mar 2020 12:35:25 -0500 Dustin Lacewell <dlacewell@gmail.com> wrote:

> The following code does not do what I would expect:
>
> (with-current-buffer (get-buffer-create "*Test*")
>   (erase-buffer)
>   (insert "   ")
>   (insert-text-button "Button1"
>                       'foo 'bar)
>   (insert "   ")
>   (insert-text-button "Button2"
>                       'foo 'bar)
>   (beginning-of-buffer)
>   (text-property-search-forward 'foo 'bar nil t)
>   (display-buffer (current-buffer)))
>
> I would expect the point to land on the first button. However, it
> lands on the second.

Actually, if text-property-search-forward succeeds it moves to the end
of the propertized region, so in this case, just after the first
button.  And that's what happens with this sexp:

(text-property-search-forward 'foo 'bar t t)

But you've called it with the argument PREDICATE nil, which means the
search succeeds if the value of the propertized text does not match the
VALUE argument, i.e. in this case if 'bar does not match 'bar.  Since
this is false, the search stops, leaving point at the last position
where the value of 'foo changed, which is the beginning of the second
button.

Steve Berman





reply via email to

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