Subject: bug#40375: 27.0.50; yank unexpectedly depends on progn

From: Markus Triska <[email-masked]>
Date: Wed, 01 Apr 2020 18:14:46 +0200

Suppose yank.el comprises the following forms:

    (erase-buffer)
    (let* ((size 144)
           (data (with-temp-buffer
                   (insert (format "P1\n%s %s\n" size size))
                   (dotimes (_ size)
                     (dotimes (_ size)
                       (insert "1 "))
                     (insert "\n"))
                   (buffer-string))))
      (insert-image `(image :type pbm :data ,data :ascent center) "t"))
    (kill-new (buffer-string))
    (erase-buffer)
    (yank)

When I start Emacs with:

    $ emacs -Q yank.el --eval='(eval-buffer)'

then Emacs starts, and I see an empty buffer.

However, when I embed the entire contents of yank.el in (progn ...),
i.e., if yank.el consists of the following form:

    (progn
      (erase-buffer)
      (let* ((size 144)
             (data (with-temp-buffer
                     (insert (format "P1\n%s %s\n" size size))
                     (dotimes (_ size)
                       (dotimes (_ size)
                         (insert "1 "))
                       (insert "\n"))
                     (buffer-string))))
        (insert-image `(image :type pbm :data ,data :ascent center) "t"))
      (kill-new (buffer-string))
      (erase-buffer)
      (yank))

and I then start Emacs (again) with:

    $ emacs -Q yank.el --eval='(eval-buffer)'

Then I see a black box in the buffer.

Hence, what (yank) inserts seems to unexpectedly depend on whether progn
is used. Is there a way to get the same result also if progn is not used?

Thank you and all the best!
Markus

In GNU Emacs 27.0.50 (build 1, x86_64-apple-darwin18.0.0, X toolkit, Xaw scroll bars)
 of 2018-11-15 built on mts-mac
Repository revision: b4eb908f858284a7962851fd99c94598f76afa6f
Windowing system distributor 'The X.Org Foundation', version 11.0.11804000
System Description:  Mac OS X 10.14.2

Configured using:
 'configure --prefix=/opt/local --without-ns --without-dbus
 --without-gconf --without-libotf --without-m17n-flt --without-gpm
 --with-gnutls --with-xml2 --with-modules --infodir
 /opt/local/share/info/emacs --with-json --with-x-toolkit=lucid
 --without-xaw3d --without-imagemagick --with-xpm --with-jpeg
 --with-tiff --with-gif --with-png --with-lcms2 --without-rsvg
 --with-xft 'CFLAGS=-pipe -Os
 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 -arch x86_64' 'CPPFLAGS=-I/opt/local/include
 -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk'
 'LDFLAGS=-L/opt/local/lib -Wl,-headerpad_max_install_names -lfreetype
 -lfontconfig -Wl,-no_pie
 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
 -arch x86_64''

Configured features:
XPM JPEG TIFF GIF PNG NOTIFY KQUEUE ACL GNUTLS LIBXML2 FREETYPE XFT ZLIB
TOOLKIT_SCROLL_BARS LUCID X11 XDBE XIM MODULES THREADS JSON LCMS2 GMP

Important settings:
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix