Don't redisplay if mode-line-format is nil.

This commit is contained in:
Vincent Zhang 2020-01-14 13:22:57 +08:00
parent 5fef621061
commit 4cc375ac73

View file

@ -683,24 +683,31 @@ If DEFAULT is non-nil, set the default mode-line for all buffers."
;; Plugins ;; Plugins
;; ;;
;; FIXME #183: Force to caculate mode-line height
;; @see https://github.com/seagle0128/doom-modeline/issues/183
(defvar-local doom-modeline--size-hacked-p nil) (defvar-local doom-modeline--size-hacked-p nil)
(defun doom-modeline-redisplay (&rest _) (defun doom-modeline-redisplay (&rest _)
"Call `redisplay' to trigger mode-line height calculations. "Call `redisplay' to trigger mode-line height calculations.
Certain functions, including e.g. `fit-window-to-buffer', base
their size calculations on values which are incorrect if the Certain functions, including e.g. `fit-window-to-buffer', base
mode-line has a height different from that of the `default' face their size calculations on values which are incorrect if the
and certain other calculations have not yet taken place for the mode-line has a height different from that of the `default' face
window in question. and certain other calculations have not yet taken place for the
These calculations can be triggered by calling `redisplay' window in question.
explicitly at the appropriate time and this functions purpose
is to make it easier to do so. These calculations can be triggered by calling `redisplay'
This function is like `redisplay' with non-nil FORCE argument. explicitly at the appropriate time and this functions purpose
It accepts an arbitrary number of arguments making it suitable is to make it easier to do so.
as a `:before' advice for any function."
(unless doom-modeline--size-hacked-p 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 calle in it,
then this function does nothing."
(when (and mode-line-format (not doom-modeline--size-hacked-p))
(setq doom-modeline--size-hacked-p t) (setq doom-modeline--size-hacked-p t)
(redisplay t))) (redisplay t)))
;; (advice-add #'fit-window-to-buffer :before #'doom-modeline-redisplay) (advice-add #'fit-window-to-buffer :before #'doom-modeline-redisplay)
(advice-add #'resize-temp-buffer-window :before #'doom-modeline-redisplay) (advice-add #'resize-temp-buffer-window :before #'doom-modeline-redisplay)
;; Keep `doom-modeline-current-window' up-to-date ;; Keep `doom-modeline-current-window' up-to-date