Subject: 28.0.50; whitespace-mode does not remember previous display table

From: Sebastian Miele <[email-masked]>
Date: Sat, 22 May 2021 11:54:36 +0200

In an emacs -Q set ‘org-ellispis’ to, e.g., "---".  Create a buffer in
Org mode that contains a headline with content below.  Have that
headline folded.  Then turn ‘whitespace-mode’ on and off again.  Turning
‘whitespace-mode’ off changes the ellipsis character to the standard
"...".

That happens, because the previous ‘buffer-display-table’ does not get
restored.  However, in principle ‘whitespace-mode’ does have provisions
to restore the previous ‘buffer-display-table’.  The problem probably is
in ‘whitespace-display-char-on’.  It contains the following code:

  (unless (or whitespace-mode global-whitespace-mode)
    (setq whitespace-display-table
    (copy-sequence buffer-display-table)))

That has no effect (‘whitespace-display-table’ remains nil), because
somehow the variable ‘whitespace-mode’ already is non-nil when
‘whitespace-display-char-on’ gets called.

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.29, cairo version 1.17.4)
 of 2021-05-22 built on huette
Repository revision: a3de48687eb28121f3dbfc20be19bd06c4cd6e98
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Arch Linux

Configured using:
 'configure --with-x-toolkit=gtk3 --with-mailutils --with-cairo'

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

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

Major mode: Org

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-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
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug sendmail pp whitespace shortdoc
org-element avl-tree generator disp-table ol-eww eww xdg url-queue
mm-url ol-rmail ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search
eieio-opt cl-extra speedbar ezimage dframe gnus-art mm-uu mml2015
mm-view mml-smime smime dig gnus-sum shr kinsoku svg dom browse-url url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util url-parse url-vars mailcap gnus-group gnus-undo
gnus-start gnus-dbus dbus xml gnus-cloud nnimap nnmail mail-source utf7
netrc nnoo parse-time gnus-spec gnus-int gnus-range message rmc puny
rfc822 mml mml-sec epa derived epg epg-config mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader gnus-win
gnus nnheader gnus-util rmail rmail-loaddefs auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json map rfc2047
rfc2045 ietf-drums text-property-search seq byte-opt gv bytecomp
byte-compile cconv mail-utils mm-util mail-prsvr wid-edit ol-docview
doc-view jka-compr image-mode exif dired dired-loaddefs ol-bbdb ol-w3m
kmacro cl-print org-clock org-colview ob-ditaa ob-plantuml ol-bibtex
bibtex iso8601 org-crypt org-habit org-agenda org-refile org ob
ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-list
org-faces org-entities time-date subr-x noutline outline easy-mmode
org-version ob-emacs-lisp org-table ol org-loaddefs find-func cal-menu
calendar cal-loaddefs org-pcomplete pcomplete org-src org-keys ob-comint
comint ansi-color ring ob-core org-compat advice ob-eval org-macs
format-spec thingatpt help-fns radix-tree help-mode cl-loaddefs cl-lib
iso-transl 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 tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer 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
cl-preloaded nadvice button loaddefs faces cus-face macroexp files
window 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
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 196784 13653)
 (symbols 48 21052 1)
 (strings 32 74068 2440)
 (string-bytes 1 2443498)
 (vectors 16 38836)
 (vector-slots 8 415855 17943)
 (floats 8 303 290)
 (intervals 56 370 0)
 (buffers 992 14))