Subject: bug#45646: 28.0.50; Last character of mode-line-format is dropped with mode-line-compact of t

From: Amin Bandali <[email-masked]>
Date: Sun, 03 Jan 2021 22:12:31 -0500

I've noticed that the last (non-space) character of the mode-line-format
string is dropped when I set the newly-introduced  mode-line-compact
setting to t.

The following appears to fix the issue for me, but I'm not sure if it's
the best/correct way to fix it (this is my first time touching any of
Emacs's C bits).

--8<---------------cut here---------------start------------->8---
diff --git a/src/xdisp.c b/src/xdisp.c
index 749893baad..2e564d536d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25503,7 +25503,7 @@ display_mode_line (struct window *w, enum face_id face_id, Lisp_Object format)
 	  if (start < i)
 	    display_string (NULL,
 			    Fsubstring (mode_string, make_fixnum (start),
-					make_fixnum (i - 1)),
+					make_fixnum (i)),
 			    Qnil, 0, 0, &it, 0, 0, 0,
 			    STRING_MULTIBYTE (mode_string));
 	}
--8<---------------cut here---------------end--------------->8---

In GNU Emacs 28.0.50 (build 20, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.10, Xaw3d scroll bars)
 of 2021-01-03 built on trisquel
Repository revision: 20ad0cc03b73f6576ece195bb16878415c313d45
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
System Description: Trisquel GNU/Linux Etiona (9.0)

Configured using:
 'configure --without-gconf --without-gsettings --without-gpm
 --with-x-toolkit=lucid --with-xaw3d --with-mailutils'

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

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

Major mode: Group

Minor modes in effect:
  gnus-topic-mode: t
  gnus-undo-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  global-hl-todo-mode: t
  recentf-mode: t
  display-battery-mode: t
  display-time-mode: t
  save-place-mode: t
  savehist-mode: t
  show-paren-mode: t
  icomplete-mode: t
  fido-mode: t
  server-mode: t
  winner-mode: t
  global-auto-revert-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
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  buffer-read-only: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(char-fold misearch multi-isearch mailalias dabbrev pp shadow sort
gnus-cite orgalist org ob ob-tangle ob-ref ob-lob ob-table ob-exp
org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint
ansi-color org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table ol org-keys org-compat org-macs
org-loaddefs flyspell ispell mail-extr emacsbug gnus-topic nndraft nnmh
gnutls utf-7 epa-file network-stream nsm nnfolder nnnil gnus-agent
gnus-srvr gnus-score score-mode nnvirtual nntp gnus-cache ebdb-gnus
gnus-msg gnus-art mm-uu mml2015 mm-view mml-smime smime dig gnus-sum shr
kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus gnus-cloud
nnimap nnmail mail-source utf7 netrc nnoo parse-time iso8601 gnus-spec
gnus-int gnus-range gnus-win ebdb-message sendmail message rmc puny
dired-x dired dired-loaddefs rfc822 mml mml-sec epa derived epg
epg-config mm-decode mm-bodies mm-encode mail-parse rfc2231 gmm-utils
mailheader ebdb-mua ebdb-com crm ebdb-format ebdb mailabbrev eieio-opt
speedbar ezimage dframe find-func eieio-base cal-menu calendar
cal-loaddefs timezone gnus nnheader gnus-util rmail rmail-loaddefs
rfc2047 rfc2045 ietf-drums text-property-search time-date mail-utils
mm-util mail-prsvr smerge-mode diff cc-mode cc-fonts cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs whitespace vc-mtn
vc-hg vc-git diff-mode vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs vc-dir
ewoc vc vc-dispatcher boxquote rect yasnippet hl-todo pcase easy-mmode
delight recentf tree-widget wid-edit format-spec battery dbus time xml
finder-inf info package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie url-domsuf url-util mailcap
url-handlers url-parse auth-source password-cache json subr-x map
url-vars cl-extra help-mode saveplace savehist paren bandali-erc
bandali-ebdb bandali-message bandali-gnus bandali-dired bandali-ibuffer
ibuf-macs bandali-eshell icomplete bandali-org bandali-exwm exwm-edit
exwm-systemtray xcb-systemtray xcb-xembed exwm-randr xcb-randr
exwm-config ido seq exwm exwm-input xcb-keysyms xcb-xkb exwm-manage
exwm-floating xcb-cursor xcb-render exwm-layout exwm-workspace exwm-core
easymenu xcb-ewmh xcb-icccm xcb xcb-xproto xcb-types cl-seq xcb-debug
eieio byte-opt bytecomp byte-compile cconv eieio-core eieio-loaddefs
server edmacro kmacro advice winner ring autorevert filenotify cl-macs
gv 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 timer
select scroll-bar mouse jit-lock font-lock syntax facemenu 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 font-render-setting cairo x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 401169 41320)
 (symbols 48 38210 4)
 (strings 32 124258 4175)
 (string-bytes 1 4069135)
 (vectors 16 73360)
 (vector-slots 8 1160672 44596)
 (floats 8 396 1693)
 (intervals 56 7442 891)
 (buffers 984 29))

-- 
https://bndl.org
Free Software activist | GNU maintainer & webmaster
GPG: BE62 7373 8E61 6D6D 1B3A  08E8 A21A 0202 4881 6103