Subject: 30.0.50; Asymetrical margins break mode-line-right-align-edge
From: Charles Gonnaud <[email-masked]>
To: [email-masked]
Date: Sat, 20 Apr 2024 23:38:18 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello to all,
Thank you for your work maintaining emacs, this is my first bug report
so please be indulgent.

*** Bug description

I use a minor-mode similar to olivetti
(https://github.com/rnkn/olivetti), which uses margins to center the
text in the window.

Playing around with the doom modeline, which copied emacs 30's
implementation of `mode-line-right-align-edge', I noticed that setting
a different margin on the left and right resulted in a cropped modeline
to the right.

*** Suggested patch

In mode--line-format-right-align() (lisp/bindings.el:384)
- (* (or (cdr (window-margins)) 1)
+ (* (or (car (window-margins)) 0)

*** Minimal init.el to reproduce

;; Use a custom mode-line with text aligned to the right
;;|foo bar|
(setq-default mode-line-format
(list "foo" 'mode-line-format-right-align "bar" ))

;; Helper commands to set a margin left, right, or reset to nil.
;; Cycle between those and see the mayhem happen on the modeline.
;; Reset margins
(keymap-global-set "<f1>"
(lambda()
(interactive)
(set-window-margins (selected-window) nil)))

;; Set margin to the left only
(keymap-global-set "<f2>"
(lambda()
(interactive)
(set-window-margins (selected-window) 10 0)))

;; Set margin to the right only
(keymap-global-set "<f3>"
(lambda()
(interactive)
(set-window-margins (selected-window) 0 10)))

Thank you for your time,
Cheers,
Charles

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.41, cairo version 1.18.0) of 2024-04-20 built on archcharles
Repository revision: 21e33567fabdc1310005ff6f96684be514527e8d
Repository branch: master
System Description: Arch Linux

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

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

Major mode: ELisp/l

Minor modes in effect:
recentf-mode: t
outline-minor-faces-mode: t
outline-minor-mode: t
electric-pair-mode: t
rainbow-delimiters-mode: t
ijkl-mode: t
ijkl-local-mode: t
corfu-terminal-mode: t
global-corfu-mode: t
corfu-mode: t
my/clang-format-auto-mode: t
yas-global-mode: t
yas-minor-mode: t
marginalia-mode: t
vertico-mode: t
key-chord-mode: t
which-key-mode: t
delete-selection-mode: t
global-auto-revert-mode: t
savehist-mode: t
display-time-mode: t
display-battery-mode: t
my/keys-mode: t
override-global-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
minibuffer-regexp-mode: t
size-indication-mode: t
column-number-mode: t
line-number-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
hs-minor-mode: t

Load-path shadows:
/home/charles/.config/emacs/elpa/transient-20240415.1548/transient hides 
/usr/local/share/emacs/30.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug message yank-media puny rfc822 mml
mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils comp-common
texinfo texinfo-loaddefs emacs-news-mode expand-region
text-mode-expansions er-basic-expansions expand-region-core
expand-region-custom cus-start tramp-sh tramp trampver tramp-integration
tramp-message tramp-compat xdg shell pcomplete parse-time iso8601
tramp-loaddefs jka-compr vc-git diff-mode track-changes vc-dispatcher
bug-reference files-x grep compile comint ansi-osc ansi-color find-file
xref face-remap time-date misearch multi-isearch recentf tree-widget
consult project bookmark text-property-search mule-util orderless
thingatpt helpful cc-langs cc-vars cc-defs imenu trace cl-print edebug
debug backtrace info-look advice find-func help-fns radix-tree
elisp-refs display-fill-column-indicator pulse color term/xterm xterm
outline-minor-faces noutline outline elec-pair rainbow-delimiters
hideshow dired-aux dired dired-loaddefs transient hydra ring lv
corfu-terminal popon corfu-info corfu treesit yasnippet edmacro kmacro
marginalia vertico key-chord which-key delsel display-line-numbers
autorevert filenotify savehist cus-edit pp cus-load wid-edit time
format-spec battery dbus xml doom-modeline doom-modeline-segments
doom-modeline-env doom-modeline-core shrink-path rx f s dash nerd-icons
nerd-icons-faces nerd-icons-data nerd-icons-data-mdicon
nerd-icons-data-flicon nerd-icons-data-codicon nerd-icons-data-devicon
nerd-icons-data-sucicon nerd-icons-data-wicon nerd-icons-data-faicon
nerd-icons-data-powerline nerd-icons-data-octicon
nerd-icons-data-pomicon nerd-icons-data-ipsicon compat
vscode-dark-plus-theme diminish use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode cl-extra help-mode use-package-core finder-inf
clang-format-autoloads consult-autoloads corfu-terminal-autoloads
corfu-autoloads csv-mode-autoloads diminish-autoloads
doom-modeline-autoloads evil-autoloads expand-region-autoloads
goto-chg-autoloads helpful-autoloads elisp-refs-autoloads
hydra-autoloads key-chord-autoloads lv-autoloads magit-autoloads pcase
git-commit-autoloads marginalia-autoloads markdown-mode-autoloads
nerd-icons-autoloads olivetti-autoloads orderless-autoloads
org-bullets-autoloads org-download-autoloads async-autoloads
org-present-autoloads org-roam-autoloads magit-section-autoloads
emacsql-autoloads outline-minor-faces-autoloads popon-autoloads
prettier-js-autoloads python-coverage-autoloads
rainbow-delimiters-autoloads shrink-path-autoloads f-autoloads
s-autoloads telephone-line-autoloads transient-autoloads
vertico-autoloads visual-fill-column-autoloads
vscode-dark-plus-theme-autoloads web-mode-autoloads which-key-autoloads
with-editor-autoloads xml+-autoloads info dash-autoloads
yasnippet-autoloads package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie generate-lisp-file
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs icons password-cache json subr-x map byte-opt
gv bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl
tooltip cconv eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
touch-screen tool-bar dnd fontset image regexp-opt fringe tabulated-list
replace newcomment text-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
nadvice seq simple cl-generic indonesian philippine 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 emoji-zwj charscript charprop
case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process emacs)

Memory information:
((conses 16 551922 121165) (symbols 48 29879 12)
(strings 32 175254 6561) (string-bytes 1 4198058) (vectors 16 50184)
(vector-slots 8 1132229 191276) (floats 8 356 762)
(intervals 56 12770 574) (buffers 992 29))