Subject: bug#25863: 25.1; garbage display by small image

From: Eli Zaretskii <[email-masked]>
Date: Sat, 25 Feb 2017 16:05:54 +0200

severity 25863 minor
thanks

> Date: Sat, 25 Feb 2017 14:19:19 +0200
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> > (let ((h 16))
> >   (switch-to-buffer (generate-new-buffer "temp"))
> >   (insert-image (create-image (concat (format "P4\n8 %d\n" h)
> >                                       (make-string h 127))
> >                               'pbm t))
> >   (insert ?g)
> >   (redisplay)
> >   (delete-char -1))
> 
> Thanks, I see it now.

Looks like a basic deficiency in the design of the Emacs redisplay,
and in particular the way screen lines are redrawn when they have
variable-height glyphs.

Fortunately, this is a fairly rare situation.  In the recipe above,
it's enough to make a very small change to make the problem go away:

(let ((h 16))
  (switch-to-buffer (generate-new-buffer "temp"))
  (insert "x")     ;; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  (insert-image (create-image (concat (format "P4\n8 %d\n" h)
                                      (make-string h 127))
                              'pbm t))
  (insert ?g)
  (redisplay)
  (delete-char -1))

Or maybe I'm missing something; ideas are welcome.