adjust or center startup lists in home buffer
This commit is contained in:
parent
68becc5597
commit
7860804fff
|
@ -17,6 +17,10 @@
|
|||
(defconst spacemacs-buffer-logo-title "[S P A C E M A C S]"
|
||||
"The title displayed beneath the logo.")
|
||||
|
||||
(defconst spacemacs-buffer-buttons-startup-lists-offset 25
|
||||
"Relative position in characters of the home buffer buttons and the home
|
||||
buffer startup lists.")
|
||||
|
||||
(defconst spacemacs-buffer--banner-length 75
|
||||
"Width of a banner.")
|
||||
|
||||
|
@ -43,6 +47,10 @@ version the release note it displayed")
|
|||
(not (file-exists-p dotspacemacs-filepath))
|
||||
"Non-nil if this Emacs instance if a fresh install.")
|
||||
|
||||
(defvar spacemacs-buffer--buttons-position nil
|
||||
"Offset in characters between the edge of the screen and the beginning of the
|
||||
home buffer buttons. Do not set this variable.")
|
||||
|
||||
(defvar spacemacs-buffer-mode-map
|
||||
(let ((map (make-sparse-keymap)))
|
||||
(define-key map [tab] 'widget-forward)
|
||||
|
@ -81,15 +89,15 @@ version the release note it displayed")
|
|||
(insert-file-contents file)
|
||||
(let ((banner-width 0))
|
||||
(while (not (eobp))
|
||||
(let ((line-length (- (line-end-position) (line-beginning-position))))
|
||||
(if (< banner-width line-length)
|
||||
(setq banner-width line-length)))
|
||||
(forward-line 1))
|
||||
(let ((line-length (- (line-end-position) (line-beginning-position))))
|
||||
(if (< banner-width line-length)
|
||||
(setq banner-width line-length)))
|
||||
(forward-line 1))
|
||||
(goto-char 0)
|
||||
(let ((margin (max 0 (floor (/ (- spacemacs-buffer--banner-length banner-width) 2)))))
|
||||
(while (not (eobp))
|
||||
(insert (make-string margin ?\ ))
|
||||
(forward-line 1))))
|
||||
(while (not (eobp))
|
||||
(insert (make-string margin ?\ ))
|
||||
(forward-line 1))))
|
||||
(buffer-string))))
|
||||
|
||||
(defun spacemacs-buffer/insert-banner-and-buttons ()
|
||||
|
@ -590,7 +598,12 @@ border."
|
|||
:mouse-face 'highlight
|
||||
:follow-link "\C-m"
|
||||
(propertize "Update Spacemacs" 'face 'font-lock-keyword-face))
|
||||
(spacemacs-buffer//center-line)
|
||||
(let ((len (- (line-end-position)
|
||||
(line-beginning-position))))
|
||||
(spacemacs-buffer//center-line)
|
||||
(setq spacemacs-buffer--buttons-position (- (line-end-position)
|
||||
(line-beginning-position)
|
||||
len)))
|
||||
(insert "\n")
|
||||
(widget-create 'push-button
|
||||
:help-echo "Update all ELPA packages to the latest versions."
|
||||
|
@ -777,14 +790,8 @@ list. Return entire list if `END' is omitted."
|
|||
(cl-subseq seq start (and (number-or-marker-p end)
|
||||
(min len end)))))
|
||||
|
||||
(defun spacemacs-buffer/insert-startupify-lists ()
|
||||
(interactive)
|
||||
(with-current-buffer (get-buffer spacemacs-buffer-name)
|
||||
(let ((buffer-read-only nil)
|
||||
(list-separator "\n\n"))
|
||||
(goto-char (point-max))
|
||||
(spacemacs-buffer/insert-page-break)
|
||||
(insert "\n")
|
||||
(defun spacemacs-buffer//do-insert-startupify-lists ()
|
||||
(let ((list-separator "\n\n"))
|
||||
(mapc (lambda (els)
|
||||
(let ((el (or (car-safe els) els))
|
||||
(list-size
|
||||
|
@ -802,14 +809,14 @@ list. Return entire list if `END' is omitted."
|
|||
(when (spacemacs-buffer//insert-todo-list
|
||||
"ToDo:"
|
||||
(spacemacs//subseq (spacemacs-buffer//todo-list)
|
||||
0 list-size))
|
||||
0 list-size))
|
||||
(spacemacs//insert--shortcut "d" "ToDo:")
|
||||
(insert list-separator)))
|
||||
((eq el 'agenda)
|
||||
(when (spacemacs-buffer//insert-todo-list
|
||||
"Agenda:"
|
||||
(spacemacs//subseq (spacemacs-buffer//agenda-list)
|
||||
0 list-size))
|
||||
0 list-size))
|
||||
(spacemacs//insert--shortcut "c" "Agenda:")
|
||||
(insert list-separator)))
|
||||
((eq el 'bookmarks)
|
||||
|
@ -819,7 +826,7 @@ list. Return entire list if `END' is omitted."
|
|||
(when (spacemacs-buffer//insert-bookmark-list
|
||||
"Bookmarks:"
|
||||
(spacemacs//subseq (bookmark-all-names)
|
||||
0 list-size))
|
||||
0 list-size))
|
||||
(spacemacs//insert--shortcut "b" "Bookmarks:")
|
||||
(insert list-separator)))
|
||||
((and (eq el 'projects)
|
||||
|
@ -828,9 +835,45 @@ list. Return entire list if `END' is omitted."
|
|||
(when (spacemacs-buffer//insert-file-list
|
||||
"Projects:"
|
||||
(spacemacs//subseq (projectile-relevant-known-projects)
|
||||
0 list-size))
|
||||
0 list-size))
|
||||
(spacemacs//insert--shortcut "p" "Projects:")
|
||||
(insert list-separator)))))) dotspacemacs-startup-lists))))
|
||||
(insert list-separator)))))) dotspacemacs-startup-lists)))
|
||||
|
||||
(defun spacemacs-buffer//get-buffer-width ()
|
||||
(save-excursion
|
||||
(goto-char 0)
|
||||
(let ((current-max 0))
|
||||
(while (not (eobp))
|
||||
(let ((line-length (- (line-end-position) (line-beginning-position))))
|
||||
(if (< current-max line-length)
|
||||
(setq current-max line-length)))
|
||||
(forward-line 1))
|
||||
current-max)))
|
||||
|
||||
(defun spacemacs-buffer//center-startupify-lists ()
|
||||
(let* ((lists-width (spacemacs-buffer//get-buffer-width))
|
||||
(margin (max 0 (- spacemacs-buffer--buttons-position
|
||||
spacemacs-buffer-buttons-startup-lists-offset)))
|
||||
(final-padding (if (< spacemacs-buffer--banner-length (+ margin lists-width))
|
||||
(max 0 (floor (/ (- spacemacs-buffer--banner-length lists-width) 2)))
|
||||
margin)))
|
||||
(goto-char 0)
|
||||
(while (not (eobp))
|
||||
(line-beginning-position)
|
||||
(insert (make-string final-padding ?\ ))
|
||||
(forward-line))))
|
||||
|
||||
(defun spacemacs-buffer/insert-startupify-lists ()
|
||||
(interactive)
|
||||
(with-current-buffer (get-buffer spacemacs-buffer-name)
|
||||
(let ((buffer-read-only nil))
|
||||
(goto-char (point-max))
|
||||
(spacemacs-buffer/insert-page-break)
|
||||
(insert "\n")
|
||||
(save-restriction
|
||||
(narrow-to-region (point) (point))
|
||||
(spacemacs-buffer//do-insert-startupify-lists)
|
||||
(spacemacs-buffer//center-startupify-lists)))))
|
||||
|
||||
(defun spacemacs-buffer/goto-link-line ()
|
||||
"Set point to the beginning of the link line."
|
||||
|
|
Loading…
Reference in New Issue