Subject: bug#49215: 28.0.50; 'display-time-mode' and 'which-function-mode' not interacting well with 'tab-bar-format-global'

From: Martin Marshall <[email-masked]>
Date: Thu, 24 Jun 2021 20:20:26 -0400

Hello, I'm trying use 'which-function-mode' and also have time appear on
the right end of the tab-bar but not in the modeline per documentation for
the 'tab-bar-format' variable:

    When you add more items ‘tab-bar-format-align-right’ and
    ‘tab-bar-format-global’ to the end, then after enabling
    ‘display-time-mode’ (or any other mode that uses ‘global-mode-string’)
    it will display time aligned to the right on the tab bar instead of
    the mode line.

It seems this only works without 'which-function-mode'.  If I enable
'which-function-mode' after tab-bar-mode, time unexpectedly reappears in
the modeline.

Alternatively, if I enable 'which-function-mode' before 'tab-bar-mode',
then time appears only in the tab-bar, as expected.  But then the
information provided by 'which-function-mode' also stops appearing in the
modeline.

Steps to reproduce:
1. Start Emacs with "emacs -Q".
2. Paste into scratch buffer:

   (setq tab-bar-format
    '(tab-bar-format-tabs
     tab-bar-separator
     tab-bar-format-align-right
     Tab-bar-format-global))

   (tab-bar-mode t)

   (display-time-mode t)

   (which-function-mode t)

3. "M-x eval-buffer RET"

To reproduce the other result---wherein 'which-function-mode'
disappears from the modeline and will not return---simply repeat the
above steps with the "(which-function-mode t)" line placed above the
"(tab-bar-mode t)" line instead of beneath it.

With warm regards,
Martin Marshall

In GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.29, cairo version 1.17.4)
 of 2021-06-24 built on machine
Repository revision: 1283e1db9b7750a90472e7d557fdd75fcaff6446
Repository branch: makepkg
Windowing system distributor 'The X.Org Foundation', version 11.0.12101001
System Description: EndeavourOS

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-sound=alsa --with-modules --without-gconf --with-gsettings
 --enable-link-time-optimization --with-native-compilation
 --with-x-toolkit=gtk3 --without-xaw3d --with-xwidgets
 --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions
 -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -flto -fuse-linker-plugin'
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

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

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

Major mode: Lisp Interaction

Minor modes in effect:
  display-time-mode: t
  which-function-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  tab-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 message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source eieio eieio-core cl-macs eieio-loaddefs
password-cache json map mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils pp cl-print time cl-seq find-func cl-extra
shortdoc text-property-search seq byte-opt gv bytecomp byte-compile
cconv help-fns radix-tree help-mode add-log which-func imenu time-date
subr-x 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 xwidget-internal dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 85954 5287)
 (symbols 48 7128 0)
 (strings 32 21905 1841)
 (string-bytes 1 724005)
 (vectors 16 14068)
 (vector-slots 8 261486 10398)
 (floats 8 82 28)
 (intervals 56 621 0)
 (buffers 992 13))