seagle0128/doom-modeline

Height below 25 not working anymore

hubisan opened this issue ยท 11 comments

Describe
After updating from 20190516 to the newest version setting a height below 25 doesn't have any effect anymore.

Steps and Expected
Steps to reproduce the behavior:

  • Launch emacs -q
  • Require doom-modeline
  • M-x doom-modeline-mode
  • (setq doom-modeline-height 18)
  • M-x to update the height: not working, height still 25
  • (setq doom-modeline-height 40)
  • M-x to update the height: works, modeline gets bigger

Environment:

  • Ubuntu 18.04
  • Emacs 26.2
  • Package version 20190614

I think it's as designed.

The doom-modeline-height respects the font height. That means the height of mode-line should be the max value of doom-modeline-height and the font height. Otherwise the bar and other elements may be ugly.

So, if you want to set doom-modeline-height to 18, you should keep the font height of mode-line smaller than 18.

Thanks for the reply. That should be okay for most users.

For anyone else who wants to force the height to be like doom-modeline-height if set here is the solution for that:

[Update: advising doom-modeline--font-height was not reliable prolly cos it's a defsubst]

(defun doom-modeline--make-xpm-filter-args (args)
  "Force function to use `doom-modeline-height'.
Instead of the calculation done in `doom-modeline-refresh-bars'.
The minimum height is set to `frame-char-height' + 2."
  (list (car args) (cadr args) (max (+ (frame-char-height) 2) doom-modeline-height)))

(advice-add 'doom-modeline--make-xpm :filter-args
            #'my-ui-modeline/doom-modeline--make-xpm-filter-args)

For me setting it to 18 instead of 27 looks fine:

image

And that's what I get with default calculation (27):

modeline-27

@hubisan I changed doom-modeline--font-height to function, so the advising doom-modeline--font-height should work now.

(defun my-doom-modeline--font-height ()
  "Calculate the actual char height of the mode-line."
  (+ (frame-char-height) 2)))
(advice-add #'doom-modeline--font-height :override #'my-doom-modeline--font-height)

Cool, thx.

I happen to experience the same "issue".
However a very easy fix for me was just to set the height of themode-line face to 1.0.

If anyone else is using use-package, just add the following.
:custom-face (mode-line ((t (:height 1.0))))

or

M-x > customize-face > mode-line and adjust your height from there.

@Shourai Thank you! It's definitely a simple way.

  :custom-face
  (mode-line ((t (:height 0.95))))
  (mode-line-inactive ((t (:height 0.95))))

I've updated the README.

@hubisan I changed doom-modeline--font-height to function, so the advising doom-modeline--font-height should work now.

(defun my-doom-modeline--font-height ()
  "Calculate the actual char height of the mode-line."
  (+ (frame-char-height) 2)))
(advice-add #'doom-modeline--font-height :override #'my-doom-modeline--font-height)

this is the best solution for me. In my case the modeline is too tall compare to the font size.
i add this config in my config.el. by the way (+ (frame-char-height) 2))) should be (+ (frame-char-height) 2))

It is no longer working. I had the following set but now only the text size decreases and there is no change in modeline's height.

(custom-set-faces
 '(mode-line ((t (:family "Operator Mono SSm" :height 0.1))))
 '(mode-line-inactive ((t (:family "Operator Mono SSm" :height 0.1)))))
(advice-add #'doom-modeline--font-height :override #'(lambda () (progn 0.1)))

@tejasvi Use the solution with the advice instead. Still works with newest version.

@hubisan I changed doom-modeline--font-height to function, so the advising doom-modeline--font-height should work now.

(defun my-doom-modeline--font-height ()
  "Calculate the actual char height of the mode-line."
  (+ (frame-char-height) 2)))
(advice-add #'doom-modeline--font-height :override #'my-doom-modeline--font-height)

Using a 4k monitor, (frame-char-height) return 38, with advice-add i set it to 32 which is much better.

Thanks for the advice-add trick. It works well, but I notice that the height of the modeline increases when the buffer is not saved. My elisp knowledge is quite low, so I did not find the origin of the problem or how to override it.