From 5ca627fe4fa9685090ceea961a4dde339c4245e0 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Mon, 4 Mar 2024 16:58:33 +0800 Subject: dashboard: center the image correctly * dashboard.el (dashboard): My dashboard has an image at the center of the buffer. Since I now know how to center the image at the center with pixel-level precision, this is updated. --- dashboard.el | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/dashboard.el b/dashboard.el index 4e1914e..1abc53d 100644 --- a/dashboard.el +++ b/dashboard.el @@ -42,13 +42,26 @@ If FORCE is non-nil, re-gerenate the dashboard buffer." (erase-buffer) (cond ((display-graphic-p) - (let ((image (create-image (expand-file-name "cat.png" user-emacs-directory)))) + (let* ((image + (create-image + (expand-file-name + "cat.png" + user-emacs-directory))) + (str (propertize + " " + 'display image + 'rear-nonsticky '(display))) + (str-width (string-pixel-width str))) (insert (make-string 3 10) - (center-string-in-width - (propertize " " 'display image 'rear-nonsticky '(display)) - (round (- (window-body-width) - (* (car (image-size image)) 1))))))) + (propertize + (string 32) + 'display + (list + 'space + :width + (list (floor (- (window-body-width nil t) str-width) 2)))) + str))) ((mapc (function (lambda (str) (insert -- cgit v1.2.3-18-g5258