diff --git a/core/core-spacemacs-buffer.el b/core/core-spacemacs-buffer.el index 726523e96..fee973438 100644 --- a/core/core-spacemacs-buffer.el +++ b/core/core-spacemacs-buffer.el @@ -78,9 +78,7 @@ Internal use, do not set this variable.") (evil-make-overriding-map spacemacs-buffer-mode-map 'motion)) (define-derived-mode spacemacs-buffer-mode fundamental-mode "Spacemacs buffer" - "Spacemacs major mode for startup screen. -\\ -" + "Spacemacs major mode for startup screen." :group 'spacemacs :syntax-table nil :abbrev-table nil @@ -109,7 +107,7 @@ FILE: the path to the file containing the banner." (let ((margin (max 0 (floor (/ (- spacemacs-buffer--window-width banner-width) 2))))) (while (not (eobp)) - (insert (make-string margin ?\ )) + (insert (make-string margin ?\s)) (forward-line 1)))) (buffer-string)))) @@ -208,11 +206,11 @@ BANNER: the path to an ascii banner file." (left-margin (max 0 (floor (- spacemacs-buffer--window-width width) 2)))) (goto-char (point-min)) (insert "\n") - (insert (make-string left-margin ?\ )) + (insert (make-string left-margin ?\s)) (insert-image spec) (insert "\n\n") (insert (make-string (max 0 (floor (/ (- spacemacs-buffer--window-width - (+ (length title) 1)) 2))) ?\ )) + (+ (length title) 1)) 2))) ?\s)) (insert (format "%s\n\n" title))))) (defun spacemacs-buffer//inject-version () @@ -220,21 +218,21 @@ BANNER: the path to an ascii banner file." Insert it in the first line of the buffer, right justified." (with-current-buffer (get-buffer-create spacemacs-buffer-name) (save-excursion - (let ((maxcol spacemacs-buffer--window-width) - (version (format "%s@%s (%s)" + (let ((version (format "%s@%s (%s)" spacemacs-version emacs-version dotspacemacs-distribution)) (buffer-read-only nil)) (goto-char (point-min)) (delete-region (point) (progn (end-of-line) (point))) - (insert (format (format "%%%ds" maxcol) version)))))) + (insert (format (format "%%%ds" + spacemacs-buffer--window-width) + version)))))) (defun spacemacs-buffer//insert-footer () "Insert the footer of the home buffer." (save-excursion - (let* ((maxcol spacemacs-buffer--window-width) - (badge-path spacemacs-badge-official-png) + (let* ((badge-path spacemacs-badge-official-png) (badge (when (and (display-graphic-p) (image-type-available-p (intern (file-name-extension badge-path)))) @@ -254,17 +252,16 @@ Insert it in the first line of the buffer, right justified." (spacemacs-buffer/insert-page-break) (insert "\n") (when badge - (insert (make-string (floor (/ (- maxcol badge-size) 2)) ?\ )) - (insert-image badge)) + (insert-image badge) + (spacemacs-buffer//center-line badge-size)) (when heart (when badge (insert "\n\n")) - (insert (make-string (floor (/ (- maxcol - (length build-lhs) - heart-size - (length build-rhs)) 2)) ?\ )) (insert build-lhs) (insert-image heart) (insert build-rhs) + (spacemacs-buffer//center-line (+ (length build-lhs) + heart-size + (length build-rhs))) (insert "\n")))))) (defun spacemacs-buffer//notes-render-framed-text @@ -599,13 +596,19 @@ NO-NEXT-LINE: if nil the cursor is brought under the searched word." '((forward-line 1))) (back-to-indentation)))) -(defun spacemacs-buffer//center-line () - "When point is at the end of a line, center it." - (let* ((width (current-column)) - (margin (max 0 (floor (/ (- spacemacs-buffer--window-width width) +(defun spacemacs-buffer//center-line (&optional real-width) + "When point is at the end of a line, center it. +REAL-WIDTH: the real width of the line. If the line contains an image, the size + of that image will be considered to be 1 by the calculation method + used in this function. As a consequence, the caller must calculate + himself the correct length of the line taking into account the + images he inserted in it." + (let* ((width (or real-width (current-column))) + (margin (max 0 (floor (/ (- spacemacs-buffer--window-width + width) 2))))) (beginning-of-line) - (insert (make-string margin ?\ )) + (insert (make-string margin ?\s)) (end-of-line))) (defun spacemacs-buffer//insert-buttons () @@ -1015,10 +1018,9 @@ REFRESH if the buffer should be redrawn." (when (or (not (eq spacemacs-buffer--last-width (window-width))) (not buffer-exists) refresh) - (setq spacemacs-buffer--window-width - (if (bound-and-true-p dotspacemacs-startup-buffer-responsive) - (window-width) - 80) + (setq spacemacs-buffer--window-width (if dotspacemacs-startup-buffer-responsive + (window-width) + 80) spacemacs-buffer--last-width spacemacs-buffer--window-width) (with-current-buffer (get-buffer-create spacemacs-buffer-name) (page-break-lines-mode)