seagle0128 / doom-modeline

A fancy and fast mode-line inspired by minimalism design.
https://seagle0128.github.io/doom-modeline/
GNU General Public License v3.0
1.27k stars 157 forks source link

[Bug] Setting a left window margin clips the modeline on the right #701

Closed Horrih closed 6 months ago

Horrih commented 6 months ago

Thank you for the bug report

Bug description

Hello, I use margins to center the main window. This has the effect of clipping the modeline on the right. Substracting the left margin in doom-modeline-def-modeline() seems to fix the issue, however I am not confident enough to submit a PR, this function looks a bit tricky I'd mess it up.

Without margins : image With margins : image

A partial work-around in the meantime is setting the following, but it does not look good :

 (mode-line-right-align-edge 'right-margin)

Steps to reproduce

I use emacs 29.2 in TUI, on RHEL 9, doom-modeline from MELPA (20240307.717) Start emacs in TUI (emacs -nw) with the following init.el, then press Ctrl+r to apply a left margin

(require 'package)
(package-initialize)
(use-package doom-modeline
  :init (doom-modeline-mode))

(defun my/add-left-margin()
  (interactive)
  (set-window-margins (selected-window) 20 0))

(keymap-global-set "C-r" #'my/add-left-margin)

Expected behavior

Have the right modeline segments align to the right of the window instead of being clipped.

OS

Linux

Emacs Version

29 (gccemacs)

Emacs Configurations

Vanilla + basic config

Error callstack

No response

Anything else

No response

seagle0128 commented 6 months ago

Please check mode-line-right-align-edge and try right-margin.

Horrih commented 6 months ago

Please check mode-line-right-align-edge and try right-margin.

Thank you for your answer. Setting this does take into account the right margin, but even then the results are weird. I used the following minimalist init.el

(require 'package)
(package-initialize)
(use-package doom-modeline
  :custom (mode-line-right-align-edge 'window)
  :init (doom-modeline-mode))

(defun my/add-margins()
  (interactive)
  (set-window-margins (selected-window) 0 10))

(keymap-global-set "C-r" #'my/add-margins)

In the following screenshots I used the following margins : 0 on the left 10 on the right

With (mode-line-right-align-edge 'window), it aligns with the right margin image

With (mode-line-right-align-edge 'right-margin), it aligns with twice the right margin image

Now if I set the margins the other way : 10 on the left 0 on the right

With both settings, it aligns with the window on the left, gets clipped by 10 on the right image

Naively, I would expect the 'window setting to ignore margins for the modeline, and the 'right-margin setting to align the modeline with the margins on the right-side or both.

seagle0128 commented 6 months ago

Thie behavior is exactly same as Emacs 30. See the documentation below.

mode-line-right-align-edge

Where mode-line should align to.

Internally, that function uses :align-to in a display property, so aligns to the left edge of the given area. See info node (elisp)Pixel Specification.

Must be set to a symbol. Acceptable values are:

  • window: align to extreme right of window, regardless of margins or fringes
  • right-fringe: align to right-fringe
  • right-margin: align to right-margin

And I tried olivetti-mode and it seemes working as expected.

Horrih commented 6 months ago

With olivetti it works because they use the same margin on the left and the right, the margins move the modeline equally left and right, they cancel each other out so in this particular case it works.

Anyway if this is emacs 30's default behavior for aligning I'll close the request. Thank you for your time