From ccedc5fd5efb6377fecbb735e7ccc71b61815194 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Wed, 20 Aug 2025 09:34:06 +0800 Subject: modeline: account for eldoc length as well * modeline.el (modeline-right-offset): Adjust this value a little. (modeline-format-main, modeline-format-dashboard): Include the length of eldoc modeline string in the calculations of the middle space of the modeline, so that we can try to keep the right information visible in the presence of ELDOC. --- modeline.el | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modeline.el b/modeline.el index 09ef407..3af386b 100644 --- a/modeline.el +++ b/modeline.el @@ -24,7 +24,7 @@ ;;; Code: -(defvar modeline-right-offset 6 +(defvar modeline-right-offset 15 "An offset to adjust the modeline alignment.") ;;;###autoload @@ -34,15 +34,17 @@ (right (string-trim-right (modeline-format-right))) (left-len (string-pixel-width left)) (right-len (string-pixel-width right)) + (el-doc-len (string-pixel-width eldoc-mode-line-string)) + (middle-len (max (- (window-pixel-width) + left-len right-len el-doc-len + (- modeline-right-offset)) + 0)) (middle (propertize (string 32) 'display (list 'space - :width - (list - (- (window-pixel-width) left-len right-len - (- modeline-right-offset))))))) + :width (list middle-len))))) (concat left middle right))) (setq-default mode-line-format '("%e" (:eval (modeline-format-main)))) @@ -54,15 +56,18 @@ (right (string-trim-right (modeline-dashboard-format-right))) (left-len (string-pixel-width left)) (right-len (string-pixel-width right)) + (el-doc-len (string-pixel-width eldoc-mode-line-string)) + (middle-len (max (- (window-pixel-width) + left-len right-len el-doc-len + (- modeline-right-offset)) + 0)) (middle (propertize (string 32) 'display (list 'space :width - (list - (- (window-pixel-width) left-len right-len - (- modeline-right-offset))))))) + (list middle-len))))) (concat left middle right))) ;;;###autoload -- cgit v1.2.3-18-g5258