From 6259ba91147d57f0a9ab685ca7cf0d23f7107ce2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 29 Sep 2017 02:41:48 +0200 Subject: [PATCH] Dynamic vertical alignment of the dashboard #192 --- modules/ui/doom-dashboard/config.el | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules/ui/doom-dashboard/config.el b/modules/ui/doom-dashboard/config.el index ad9195a0b..e663c97db 100644 --- a/modules/ui/doom-dashboard/config.el +++ b/modules/ui/doom-dashboard/config.el @@ -116,11 +116,19 @@ whose dimensions may not be fully initialized by the time this is run." (+doom-dashboard-mode)) (erase-buffer) (setq default-directory old-pwd) - (let ((+doom-dashboard--height (window-height (get-buffer-window fallback-buffer)))) - (insert (make-string (max 0 (- (truncate (/ +doom-dashboard--height 2)) 16)) ?\n)) - (dolist (widget-name +doom-dashboard-widgets) - (funcall (intern (format "doom-dashboard-widget--%s" widget-name))) - (insert "\n"))) + (let ((+doom-dashboard--height (window-height (get-buffer-window fallback-buffer))) + (lines 1) + content) + (with-temp-buffer + (dolist (widget-name +doom-dashboard-widgets) + (funcall (intern (format "doom-dashboard-widget--%s" widget-name))) + (insert "\n")) + (setq content (buffer-string) + lines (count-lines (point-min) (point-max)))) + (insert (make-string (max 0 (- (/ +doom-dashboard--height 2) + (/ lines 2))) + ?\n) + content)) (unless (button-at (point)) (goto-char (next-button (point-min)))))))) ;; Update all dashboard windows