bug#81539: 29.3; text-property-search-backward skips a matching region
Sean Whitton <[email protected]> Wed, 05 Aug 2026 12:29:31 +0100
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Version: 31.1 Scott Guest [02/Aug 9:20pm -07] wrote: > `text-property-search-backward' can skip a matching property region when it > is followed by a one-character non-matching region. > > Run this command: > > emacs -Q --batch --eval "(progn (require 'text-property-search) > (with-temp-buffer (insert \"zxx-y\") (put-text-property 1 2 'p 'z) > (put-text-property 2 4 'p 'x) (put-text-property 5 6 'p 'y) (goto-char > (point-min)) (message \"forward: %S\" (text-property-search-forward > 'p 'x t)) (goto-char (point-max)) (message \"backward: %S\" > (text-property-search-backward 'p 'x t))))" > > The output is: > > forward: #s(prop-match 2 4 x) > backward: nil > > The backward result should also describe [2,4). Predicate t means that the > property value must be `equal' to x, and both characters in [2,4) have that > value. The region is wholly before point, which is at point-max. > > The skip occurs in the non-matching branch of > `text-property-search-backward'. After it examines position 4, > `previous-single-property-change' returns 2, but point remains at 4. The > next loop iteration repeats the call from position 4 and then examines > position 1, skipping [2,4). > > This is distinct from Bug#58937: the matching region here is two characters > wide; it is the following non-matching region that is one character wide. > > Reproduced in Emacs 29.3 and in Emacs 32.0.50 master at > 1095d63d28fcdfd64a723efaaa4b965e5d846159. Thanks, should be fixed on the emacs-31 branch. -- Sean Whitton