Subject: bug#34771: 27.0.50; object is a window sometimes although it should be a buffer in conditional display spec

From: Tassilo Horn <[email-masked]>
Date: Wed, 06 Mar 2019 18:42:19 +0100

The docs state:

,----[ (info "(elisp)Other Display Specs") ]
|    You can make any display specification conditional.  To do that,
| package it in another list of the form ‘(when CONDITION . SPEC)’.  Then
| the specification SPEC applies only when CONDITION evaluates to a
| non-‘nil’ value.  During the evaluation, ‘object’ is bound to the string
| or buffer having the conditional ‘display’ property.  ‘position’ and
| ‘buffer-position’ are bound to the position within ‘object’ and the
| buffer position where the ‘display’ property was found, respectively.
| Both positions can be different when ‘object’ is a string.
`----

So in a conditional display spec, object should always be a buffer.
However, that doesn't seem to be the reality.  Sometimes, it is also a
window.

Here's a recipe for the current master:

$ emacs -q

In *scratch* insert and evaluate:

(insert (propertize "foobar" 'display
		    `(when (get-buffer-window object)
		       . ,(format "%s" (random)))) "\n")

Now move point over the displayed random number, hit and hold C-l, or
do whatever triggers redisplay.

Now I have this in *Messages*:

Error during redisplay: (eval (get-buffer-window object)) signaled (wrong-type-argument stringp #<window 3 on *scratch*>) [33 times]

In GNU Emacs 27.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.24.5)
 of 2019-03-06 built on thinkpad-t440p
Repository revision: 2260e48d2eeaa9ea2b9c17389cc25d00f85c414c
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12004000
System Description: Arch Linux

Recent messages:
20190306T182620.294> nnimap read 0k from imap.fastmail.com
20190306T182623.263> Exiting summary buffer and applying spam rules
20190306T182623.788> Expiring articles...
20190306T182624.202> Expiring articles...done
20190306T182625.333> Saving Gnus registry (9449 entries) to ~/.gnus.d/.gnus.registry.eieio...
20190306T182626.824> Saving Gnus registry (size 9449) to ~/.gnus.d/.gnus.registry.eieio...done
20190306T182626.828> Saving /home/horn/.gnus.d/.newsrc.eld...
Saving file /home/horn/.gnus.d/.newsrc.eld...
Wrote /home/horn/.gnus.d/.newsrc.eld
20190306T182626.864> Saving /home/horn/.gnus.d/.newsrc.eld...done

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB
NOTIFY INOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM THREADS LIBSYSTEMD JSON PDUMPER
LCMS2 GMP

Important settings:
  value of $LC_MONETARY: de_DE.utf8
  value of $LC_NUMERIC: de_DE.utf8
  value of $LC_TIME: de_DE.utf8
  value of $LANG: en_US.utf8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Group

Minor modes in effect:
  hl-line-mode: t
  cursor-sensor-mode: t
  gnus-topic-mode: t
  intero-global-mode: t
  global-aggressive-indent-mode: t
  pdf-occur-global-minor-mode: t
  recentf-mode: t
  which-key-mode: t
  beacon-mode: t
  global-company-mode: t
  global-magit-file-mode: t
  magit-auto-revert-mode: t
  global-git-commit-mode: t
  async-bytecomp-package-mode: t
  override-global-mode: t
  minibuffer-depth-indicate-mode: t
  electric-pair-mode: t
  global-subword-mode: t
  subword-mode: t
  save-place-mode: t
  savehist-mode: t
  show-paren-mode: t
  gnus-undo-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  global-prettify-symbols-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort gnus-cite emacsbug qp gnus-async gnus-ml hl-line
cursor-sensor nndraft nnmh rot13 utf-7 gnutls network-stream nnml nnnil
gnus-agent gnus-srvr gnus-score score-mode nnvirtual gnus-cache
gnus-demon nntp spam spam-stat gnus-uu yenc gnus-msg gnus-gravatar
mail-extr gravatar url-cache gnus-topic gnus-registry registry
eieio-base th-private debug misearch multi-isearch descr-text help-fns
radix-tree cl-print backtrace ace-window avy find-dired grep
visual-file-name-abbrev company-oddmuse company-keywords company-etags
company-gtags company-dabbrev-code company-dabbrev company-files
company-capf company-cmake company-xcode company-clang company-semantic
company-eclim company-template company-bbdb highlight-symbol org-rmail
org-mhe org-irc org-info org-gnus nnir org-docview doc-view org-bibtex
bibtex org-bbdb org-w3m paredit bug-reference generic fish-mode cargo
cargo-process markdown-mode rust-mode idris-mode idris-commands
idris-hole-list idris-ipkg-mode idris-tree-info idris-warnings-tree
idris-info idris-repl idris-highlight-input idris-prover inferior-idris
idris-warnings idris-log idris-events idris-simple-indent idris-syntax
idris-common-utils idris-settings idris-keys idris-core idris-compat
prop-menu intero flycheck hindent haskell-mode haskell-cabal
haskell-utils haskell-font-lock haskell-indentation haskell-string
haskell-sort-imports haskell-lexeme haskell-align-imports haskell-compat
haskell-complete-module haskell-ghc-support flymake-proc flymake
thingatpt etags fileloop xref project dabbrev haskell-customize web-mode
disp-table preview-latex auto-loads tex-site aggressive-indent
rainbow-mode color vc-git vc-dir ewoc vc vc-dispatcher epa-file
org-element avl-tree generator org org-macro org-footnote org-pcomplete
org-list org-faces org-entities org-version ob-emacs-lisp ob ob-tangle
org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint ob-core ob-eval
org-compat org-macs org-loaddefs cal-menu calendar cal-loaddefs dired-x
boxquote rect smtpmail-multi smtpmail sendmail ecomplete yasnippet
auto-dictionary flyspell ispell pdf-occur ibuf-ext ibuffer
ibuffer-loaddefs tablist tablist-filter semantic/wisent/comp
semantic/wisent semantic/wisent/wisent semantic/util-modes semantic/util
semantic semantic/tag semantic/lex semantic/fw mode-local find-func
cedet pdf-isearch let-alist pdf-misc pdf-tools compile cus-edit
cus-start cus-load pdf-view magit-bookmark bookmark pp jka-compr
pdf-cache pdf-info tq pdf-util image-mode recentf tree-widget which-key
moody beacon highlight-parentheses cl company-restclient
know-your-http-well http-status-codes http-relations http-methods
http-headers company pcase restclient noutline outline magit-submodule
magit-obsolete magit-blame magit-stash magit-bisect magit-push
magit-pull magit-fetch magit-clone magit-remote magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge
magit-branch magit-reset magit-files magit-refs magit-status magit
magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff
smerge-mode diff-mode magit-core magit-autorevert autorevert filenotify
magit-margin magit-transient magit-process magit-mode transient
git-commit magit-git magit-section magit-utils crm log-edit pcvs-util
add-log with-editor async-bytecomp async server debbugs soap-client
url-http url-auth url-gw nsm url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util warnings rng-xsd
rng-dt rng-util xsd-regexp xml use-package-bind-key bind-key mb-depth rx
bs windmove elec-pair cap-words superword subword saveplace savehist
paren smiley gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap
gnus-sum gnus-group gnus-undo gnus-start gnus-cloud nnimap nnmail
mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range message rmc
puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
gnus-win gnus wid-edit nnheader gnus-util rmail rmail-loaddefs rfc2047
rfc2045 ietf-drums time-date mm-util mail-prsvr mail-utils edmacro
kmacro dracula-theme auto-package-update easy-mmode finder-inf dash
cl-extra help-mode use-package-ensure use-package-core tramp
tramp-loaddefs trampver tramp-integration tramp-compat ucs-normalize
shell pcomplete comint ansi-color ring parse-time format-spec advice
mule-util info package easymenu epg-config url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json subr-x map url-vars seq byte-opt gv bytecomp
byte-compile cconv cl-loaddefs cl-lib tooltip eldoc electric uniquify
ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page menu-bar rfn-eshadow isearch timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite charscript charprop case-table epa-hook jka-cmpr-hook
help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads dbusbind inotify lcms2 dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty make-network-process emacs)

Memory information:
((conses 16 995158 269302)
 (symbols 48 66241 18)
 (strings 32 316037 17771)
 (string-bytes 1 9802325)
 (vectors 16 94279)
 (vector-slots 8 1961351 141790)
 (floats 8 681 1337)
 (intervals 56 8836 2355)
 (buffers 992 32))