Cache the original header- and mode-line-format unconditionally

This commit is contained in:
larstvei 2024-09-15 02:05:21 +02:00
parent f1a1c4a172
commit 2d82f55835

View File

@ -69,20 +69,20 @@
"Add overlay for vertical centering relative to CONTENT-HEIGHT."
(let* ((top-margin (center-content--calculate-top-margin content-height)))
;; Save and remap the header-line face to match the default face
(setq center-content--original-header-line-format header-line-format)
(setq center-content--header-line-face-remap-cookie
(face-remap-add-relative 'header-line 'default))
(setq header-line-format (propertize " " 'display `(height ,top-margin)))))
(defun center-content--enable ()
"Enable horizontal and vertical centering of content."
(setq center-content--original-header-line-format header-line-format)
(setq center-content--original-mode-line-format mode-line-format)
(let* ((content-size (center-content--content-pixel-size)))
(when center-content-horizontal
(center-content--horizontal (car content-size)))
(when center-content-vertical
(center-content--vertical (cdr content-size)))
(when center-content-hide-mode-line
(setq center-content--original-mode-line-format mode-line-format)
(setq mode-line-format nil))))
(defun center-content--disable ()