Subject: bug#8174: 24.0.50; `replace-match' doesn't work right with propertized text

From: Stefan Monnier <[email-masked]>
Date: Fri, 04 Mar 2011 23:18:10 -0500

> (defun foo ()
>   (interactive)
>   (require 'image-dired)
>   (save-excursion
>     (goto-char (point-min))
>     (re-search-forward "tata")
>     (let* ((file  "@@@@@")
>     (strg  (apply #'propertize "AAAAAA"
>     `(display ,(image-dired-get-thumbnail-image file)
>        rear-nonsticky (display)))))
>       (replace-match strg))))
> --------------------------------
 
> Replace `@@@@@' in `foo's definition by a real image-file absolute file
> name, and then evaluate the definition.  Then `M-x foo RET'.
 
> I would expect the text `tata' to be replaced by the propertized string,
> whose text is `AAAAAAA' and whose properties are as indicated.  IOW, I
> would expect to see the image displayed in place of `tata'.

First things first: (ignoring the lack of check that re-search-forward
indeed succeeded) the only things allowed between the string match and
the use of the match-data are a few Emacs primitives known to leave the
match-data untouched.  image-dired-get-thumbnail-image is not one of
those primitives.

        Stefan