mirror of
https://github.com/vale981/doom-modeline
synced 2025-03-04 17:01:39 -05:00
Improve force redisplay advice (#484)
* Improve force redisplay advice By unconditionally advising `split-window' we ensure that redisplay: 1. Always triggers in the right window, so it solves an issue with `org-attach' calling `fit-window-to-buffer' from a different window. 2. It's not tied to a buffer that may outlive its popup, so it solves the issue with `org-set-tags-command' which buffer kept lurking around with `doom-modeline--size-hacked-p' set to t. As all known workarounds, this will trigger a quick sequence redisplay -> fit -> redisplay that causes some little flickering when the window effectively changes size in-between (which is usually the case with popups). Moreover, `fit-window-to-buffer' always transforms a height in pixels to a height in characters and this operation unavoidably rounds up to the next integer height in characters when the mode-line is of a different size than the default character, hence introducing some small amount of padding at the bottom of the window. In order to avoid small but yet unpleasant visual artifacts whenever possible, we only trigger a redisplay when it is strictly required, that is when the mode-line height effectively differs from the default character height. To facilitate the construction of a "vanilla height" modeline when `doom-modeline-height' <= 0 and `doom-modeline-icon' is nil we ensure that this simpler modeline will be created, no matter the platform. * Allow unhacked modeline with icons Allow a modeline with default height to have icons. It's recommended to also set `all-the-icons-scale-factor' to 1 in order to ensure that the modeline will indeed have default height.
This commit is contained in:
parent
2a0eb1f800
commit
084370d7a9
1 changed files with 13 additions and 15 deletions
|
@ -146,10 +146,9 @@ It returns a file name which can be used directly as argument of
|
|||
|
||||
(defcustom doom-modeline-height 25
|
||||
"How tall the mode-line should be. It's only respected in GUI.
|
||||
If the actual char height is larger, it respects the actual char height."
|
||||
If the actual char height is larger, it respects the actual char height.
|
||||
If `doom-modeline-height' is <= 0 the modeline will have default height."
|
||||
:type 'integer
|
||||
:set (lambda (sym val)
|
||||
(set sym (if (> val 0) val 1)))
|
||||
:group 'doom-modeline)
|
||||
|
||||
(defcustom doom-modeline-bar-width 4
|
||||
|
@ -803,7 +802,7 @@ etc. (also see the face `doom-modeline-unread-number')."
|
|||
|
||||
;; FIXME #183: Force to calculate mode-line height
|
||||
;; @see https://github.com/seagle0128/doom-modeline/issues/183
|
||||
(defvar-local doom-modeline--size-hacked-p nil)
|
||||
;; @see https://github.com/seagle0128/doom-modeline/issues/483
|
||||
(defun doom-modeline-redisplay (&rest _)
|
||||
"Call `redisplay' to trigger mode-line height calculations.
|
||||
|
||||
|
@ -817,18 +816,16 @@ These calculations can be triggered by calling `redisplay'
|
|||
explicitly at the appropriate time and this functions purpose
|
||||
is to make it easier to do so.
|
||||
|
||||
This function is like `redisplay' with non-nil FORCE argument.
|
||||
It accepts an arbitrary number of arguments making it suitable
|
||||
as a `:before' advice for any function. If the current buffer
|
||||
has no mode-line or this function has already been called in it,
|
||||
then this function does nothing."
|
||||
This function is like `redisplay' with non-nil FORCE argument,
|
||||
but it will only trigger a redisplay when there is a non nil
|
||||
`mode-line-format' and the height of the mode-line is different
|
||||
from that of the `default' face. This function is intended to be
|
||||
used as an advice to window creation functions."
|
||||
(when (and (bound-and-true-p doom-modeline-mode)
|
||||
mode-line-format
|
||||
(not doom-modeline--size-hacked-p))
|
||||
(setq doom-modeline--size-hacked-p t)
|
||||
(/= (frame-char-height) (window-mode-line-height)))
|
||||
(redisplay t)))
|
||||
(advice-add #'fit-window-to-buffer :before #'doom-modeline-redisplay)
|
||||
(advice-add #'resize-temp-buffer-window :before #'doom-modeline-redisplay)
|
||||
(advice-add 'split-window :after #'doom-modeline-redisplay)
|
||||
|
||||
;; Keep `doom-modeline-current-window' up-to-date
|
||||
(defun doom-modeline--get-current-window (&optional frame)
|
||||
|
@ -1042,8 +1039,9 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
|
|||
;; WORKAROUND: Fix tall issue of 27 on Linux
|
||||
;; @see https://github.com/seagle0128/doom-modeline/issues/271
|
||||
(round
|
||||
(* (if (and (>= emacs-major-version 27)
|
||||
(not (eq system-type 'darwin)))
|
||||
(* (if (or (<= doom-modeline-height 0)
|
||||
(and (>= emacs-major-version 27)
|
||||
(not (eq system-type 'darwin))))
|
||||
1.0
|
||||
(if doom-modeline-icon 1.68 1.25))
|
||||
(cond ((integerp height) (/ height 10))
|
||||
|
|
Loading…
Add table
Reference in a new issue