home-buffer: fix error on footer insertion when window is narrow
This commit is contained in:
parent
3e60792136
commit
f8cb17eaf4
|
@ -78,9 +78,7 @@ Internal use, do not set this variable.")
|
||||||
(evil-make-overriding-map spacemacs-buffer-mode-map 'motion))
|
(evil-make-overriding-map spacemacs-buffer-mode-map 'motion))
|
||||||
|
|
||||||
(define-derived-mode spacemacs-buffer-mode fundamental-mode "Spacemacs buffer"
|
(define-derived-mode spacemacs-buffer-mode fundamental-mode "Spacemacs buffer"
|
||||||
"Spacemacs major mode for startup screen.
|
"Spacemacs major mode for startup screen."
|
||||||
\\<spacemacs-buffer-mode-map>
|
|
||||||
"
|
|
||||||
:group 'spacemacs
|
:group 'spacemacs
|
||||||
:syntax-table nil
|
:syntax-table nil
|
||||||
:abbrev-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
|
(let ((margin (max 0 (floor (/ (- spacemacs-buffer--window-width
|
||||||
banner-width) 2)))))
|
banner-width) 2)))))
|
||||||
(while (not (eobp))
|
(while (not (eobp))
|
||||||
(insert (make-string margin ?\ ))
|
(insert (make-string margin ?\s))
|
||||||
(forward-line 1))))
|
(forward-line 1))))
|
||||||
(buffer-string))))
|
(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))))
|
(left-margin (max 0 (floor (- spacemacs-buffer--window-width width) 2))))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(insert "\n")
|
(insert "\n")
|
||||||
(insert (make-string left-margin ?\ ))
|
(insert (make-string left-margin ?\s))
|
||||||
(insert-image spec)
|
(insert-image spec)
|
||||||
(insert "\n\n")
|
(insert "\n\n")
|
||||||
(insert (make-string (max 0 (floor (/ (- spacemacs-buffer--window-width
|
(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)))))
|
(insert (format "%s\n\n" title)))))
|
||||||
|
|
||||||
(defun spacemacs-buffer//inject-version ()
|
(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."
|
Insert it in the first line of the buffer, right justified."
|
||||||
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((maxcol spacemacs-buffer--window-width)
|
(let ((version (format "%s@%s (%s)"
|
||||||
(version (format "%s@%s (%s)"
|
|
||||||
spacemacs-version
|
spacemacs-version
|
||||||
emacs-version
|
emacs-version
|
||||||
dotspacemacs-distribution))
|
dotspacemacs-distribution))
|
||||||
(buffer-read-only nil))
|
(buffer-read-only nil))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(delete-region (point) (progn (end-of-line) (point)))
|
(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 ()
|
(defun spacemacs-buffer//insert-footer ()
|
||||||
"Insert the footer of the home buffer."
|
"Insert the footer of the home buffer."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let* ((maxcol spacemacs-buffer--window-width)
|
(let* ((badge-path spacemacs-badge-official-png)
|
||||||
(badge-path spacemacs-badge-official-png)
|
|
||||||
(badge (when (and (display-graphic-p)
|
(badge (when (and (display-graphic-p)
|
||||||
(image-type-available-p
|
(image-type-available-p
|
||||||
(intern (file-name-extension badge-path))))
|
(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)
|
(spacemacs-buffer/insert-page-break)
|
||||||
(insert "\n")
|
(insert "\n")
|
||||||
(when badge
|
(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 heart
|
||||||
(when badge (insert "\n\n"))
|
(when badge (insert "\n\n"))
|
||||||
(insert (make-string (floor (/ (- maxcol
|
|
||||||
(length build-lhs)
|
|
||||||
heart-size
|
|
||||||
(length build-rhs)) 2)) ?\ ))
|
|
||||||
(insert build-lhs)
|
(insert build-lhs)
|
||||||
(insert-image heart)
|
(insert-image heart)
|
||||||
(insert build-rhs)
|
(insert build-rhs)
|
||||||
|
(spacemacs-buffer//center-line (+ (length build-lhs)
|
||||||
|
heart-size
|
||||||
|
(length build-rhs)))
|
||||||
(insert "\n"))))))
|
(insert "\n"))))))
|
||||||
|
|
||||||
(defun spacemacs-buffer//notes-render-framed-text
|
(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)))
|
'((forward-line 1)))
|
||||||
(back-to-indentation))))
|
(back-to-indentation))))
|
||||||
|
|
||||||
(defun spacemacs-buffer//center-line ()
|
(defun spacemacs-buffer//center-line (&optional real-width)
|
||||||
"When point is at the end of a line, center it."
|
"When point is at the end of a line, center it.
|
||||||
(let* ((width (current-column))
|
REAL-WIDTH: the real width of the line. If the line contains an image, the size
|
||||||
(margin (max 0 (floor (/ (- spacemacs-buffer--window-width width)
|
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)))))
|
2)))))
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(insert (make-string margin ?\ ))
|
(insert (make-string margin ?\s))
|
||||||
(end-of-line)))
|
(end-of-line)))
|
||||||
|
|
||||||
(defun spacemacs-buffer//insert-buttons ()
|
(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)))
|
(when (or (not (eq spacemacs-buffer--last-width (window-width)))
|
||||||
(not buffer-exists)
|
(not buffer-exists)
|
||||||
refresh)
|
refresh)
|
||||||
(setq spacemacs-buffer--window-width
|
(setq spacemacs-buffer--window-width (if dotspacemacs-startup-buffer-responsive
|
||||||
(if (bound-and-true-p dotspacemacs-startup-buffer-responsive)
|
(window-width)
|
||||||
(window-width)
|
80)
|
||||||
80)
|
|
||||||
spacemacs-buffer--last-width spacemacs-buffer--window-width)
|
spacemacs-buffer--last-width spacemacs-buffer--window-width)
|
||||||
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
||||||
(page-break-lines-mode)
|
(page-break-lines-mode)
|
||||||
|
|
Loading…
Reference in a new issue