aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/modeline-config.el19
-rw-r--r--tests/test-modeline-config-segments.el26
2 files changed, 30 insertions, 15 deletions
diff --git a/modules/modeline-config.el b/modules/modeline-config.el
index be7f72e5..6ba6efca 100644
--- a/modules/modeline-config.el
+++ b/modules/modeline-config.el
@@ -126,12 +126,19 @@ kills the buffer-local value so the default format returns."
(defun cj/--modeline-padding ()
"Return the leading modeline space, taller per `cj/modeline-height-factor'.
-A display height property on a single space pads the whole modeline
-vertically without touching the mode-line faces the theme owns."
- (if (and cj/modeline-height-factor
- (/= cj/modeline-height-factor 1.0))
- (propertize " " 'display `(height ,cj/modeline-height-factor))
- " "))
+An absolute :height face on a single space pads the whole modeline
+vertically. The height is anchored to the frame's default face rather
+than the current buffer's, so a buffer that remaps `default' larger —
+nov-mode's reading view, `text-scale-mode' — no longer inflates the bar.
+A `display (height FACTOR)' property would scale with the buffer's default
+face and blow the modeline up in those buffers."
+ (let ((base (face-attribute 'default :height nil t)))
+ (if (and cj/modeline-height-factor
+ (/= cj/modeline-height-factor 1.0)
+ (integerp base))
+ (propertize " " 'face
+ (list :height (round (* cj/modeline-height-factor base))))
+ " ")))
(defvar-local cj/--modeline-mode-icon-cache nil
"Cons of (MAJOR-MODE . GRAPHIC-P) paired with the rendered mode segment.
diff --git a/tests/test-modeline-config-segments.el b/tests/test-modeline-config-segments.el
index 580a7711..0245749d 100644
--- a/tests/test-modeline-config-segments.el
+++ b/tests/test-modeline-config-segments.el
@@ -104,19 +104,27 @@
;; ------------------------------- Padding --------------------------------------
-(ert-deftest test-modeline-config-padding-carries-height-display ()
- "Normal: padding space carries a display height property."
+(ert-deftest test-modeline-config-padding-absolute-height-face ()
+ "Normal: padding space carries a face with an absolute integer :height.
+The height is anchored to the frame default (not the current buffer's
+`default'), so a buffer that remaps `default' larger — nov's reading view,
+`text-scale-mode' — no longer inflates the modeline."
(let ((cj/modeline-height-factor 1.2))
- (let ((s (cj/--modeline-padding)))
+ (let* ((s (cj/--modeline-padding))
+ (face (get-text-property 0 'face s))
+ (h (plist-get face :height)))
(should (stringp s))
- (should (get-text-property 0 'display s)))))
+ (should (integerp h))
+ (should (= h (round (* 1.2 (face-attribute 'default :height nil t))))))))
(ert-deftest test-modeline-config-padding-plain-at-factor-one ()
- "Boundary: factor 1.0 (or nil) yields a plain space, no display prop."
- (let ((cj/modeline-height-factor 1.0))
- (let ((s (cj/--modeline-padding)))
- (should (stringp s))
- (should-not (get-text-property 0 'display s)))))
+ "Boundary: factor 1.0 (or nil) yields a plain space, no height styling."
+ (dolist (factor (list 1.0 nil))
+ (let ((cj/modeline-height-factor factor))
+ (let ((s (cj/--modeline-padding)))
+ (should (stringp s))
+ (should-not (get-text-property 0 'display s))
+ (should-not (get-text-property 0 'face s))))))
(provide 'test-modeline-config-segments)
;;; test-modeline-config-segments.el ends here