core: Factor out spacemacs-buffer creation
Factor out the code related to creating the spacemacs buffer, so that it can be recreated easily if it gets deleted.
This commit is contained in:
parent
8fb3af3e56
commit
f2878d594a
|
@ -549,4 +549,40 @@ HPADDING is the horizontal spacing betwee the content line and the frame border.
|
|||
(beginning-of-line)
|
||||
(widget-forward 1)))
|
||||
|
||||
(defun spacemacs-buffer/goto-buffer ()
|
||||
"Create the special buffer for `spacemacs-mode' if it doesn't
|
||||
already exist, and switch to it."
|
||||
(interactive)
|
||||
(unless (buffer-live-p (get-buffer spacemacs-buffer-name))
|
||||
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
||||
(save-excursion
|
||||
(spacemacs-buffer/set-mode-line "")
|
||||
;; needed in case the buffer was deleted and we are recreating it
|
||||
(setq spacemacs-buffer--note-widgets nil)
|
||||
(spacemacs-buffer/insert-banner-and-buttons)
|
||||
;; non-nil if emacs is loaded
|
||||
(if after-init-time
|
||||
(progn
|
||||
(when dotspacemacs-startup-lists
|
||||
(spacemacs-buffer/insert-startupify-lists))
|
||||
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line)
|
||||
(force-mode-line-update)
|
||||
(spacemacs-buffer-mode))
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
||||
(when dotspacemacs-startup-lists
|
||||
(spacemacs-buffer/insert-startupify-lists))
|
||||
(if configuration-layer-error-count
|
||||
(spacemacs-buffer/set-mode-line
|
||||
(format (concat "%s error(s) at startup! "
|
||||
"Spacemacs may not be able to operate properly.")
|
||||
configuration-layer-error-count))
|
||||
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line))
|
||||
(force-mode-line-update)
|
||||
(spacemacs-buffer-mode)
|
||||
(spacemacs-buffer/goto-link-line))))))))
|
||||
(spacemacs-buffer/goto-link-line)
|
||||
(switch-to-buffer spacemacs-buffer-name))
|
||||
|
||||
(provide 'core-spacemacs-buffer)
|
||||
|
|
|
@ -67,8 +67,7 @@
|
|||
(add-to-list 'evil-motion-state-modes 'spacemacs-mode))
|
||||
|
||||
(defun spacemacs/init ()
|
||||
"Create the special buffer for `spacemacs-mode' and perform startup
|
||||
initialization."
|
||||
"Perform startup initialization."
|
||||
;; explicitly set the prefered coding systems to avoid annoying prompt
|
||||
;; from emacs (especially on Microsoft Windows)
|
||||
(prefer-coding-system 'utf-8)
|
||||
|
@ -79,11 +78,8 @@ initialization."
|
|||
(dotspacemacs|call-func dotspacemacs/init "Calling dotfile init...")
|
||||
(dotspacemacs|call-func dotspacemacs/user-init "Calling dotfile user init...")
|
||||
;; spacemacs init
|
||||
(switch-to-buffer (get-buffer-create spacemacs-buffer-name))
|
||||
(spacemacs-buffer/goto-buffer)
|
||||
(setq initial-buffer-choice (lambda () (get-buffer spacemacs-buffer-name)))
|
||||
(spacemacs-buffer/set-mode-line "")
|
||||
;; no welcome buffer
|
||||
(setq inhibit-startup-screen t)
|
||||
;; silence ad-handle-definition about advised functions getting redefined
|
||||
(setq ad-redefinition-action 'accept)
|
||||
;; removes the GUI elements
|
||||
|
@ -121,8 +117,6 @@ initialization."
|
|||
(spacemacs/set-default-font dotspacemacs-default-font)
|
||||
(spacemacs-buffer/warning "Cannot find font \"%s\"!"
|
||||
(car dotspacemacs-default-font)))
|
||||
;; banner
|
||||
(spacemacs-buffer/insert-banner-and-buttons)
|
||||
;; mandatory dependencies
|
||||
;; dash is required to prevent a package.el bug with f on 24.3.1
|
||||
(spacemacs/load-or-install-protected-package 'dash t)
|
||||
|
@ -153,9 +147,7 @@ initialization."
|
|||
;; check for new version
|
||||
(if dotspacemacs-mode-line-unicode-symbols
|
||||
(setq-default spacemacs-version-check-lighter "[⇪]"))
|
||||
(spacemacs/set-new-version-lighter-mode-line-faces)
|
||||
(add-hook 'emacs-startup-hook 'spacemacs-buffer/goto-link-line)
|
||||
(spacemacs-mode))
|
||||
(spacemacs/set-new-version-lighter-mode-line-faces))
|
||||
|
||||
(defun spacemacs/maybe-install-dotfile ()
|
||||
"Install the dotfile if it does not exist."
|
||||
|
@ -199,16 +191,6 @@ initialization."
|
|||
(format "\n[%s packages loaded in %.3fs]\n"
|
||||
(configuration-layer/configured-packages-count)
|
||||
elapsed)))
|
||||
;; Display useful lists of items
|
||||
(when dotspacemacs-startup-lists
|
||||
(spacemacs-buffer/insert-startupify-lists))
|
||||
(if configuration-layer-error-count
|
||||
(spacemacs-buffer/set-mode-line
|
||||
(format (concat "%s error(s) at startup! "
|
||||
"Spacemacs may not be able to operate properly.")
|
||||
configuration-layer-error-count))
|
||||
(spacemacs-buffer/set-mode-line spacemacs--default-mode-line))
|
||||
(force-mode-line-update)
|
||||
(spacemacs/check-for-new-version spacemacs-version-check-interval))))
|
||||
|
||||
(defun spacemacs/describe-system-info ()
|
||||
|
|
|
@ -405,10 +405,8 @@ argument takes the kindows rotate backwards."
|
|||
(delete-other-windows)
|
||||
(split-window-right))
|
||||
|
||||
(defun spacemacs/home ()
|
||||
"Go to home Spacemacs buffer"
|
||||
(interactive)
|
||||
(switch-to-buffer "*spacemacs*"))
|
||||
(defalias 'spacemacs/home 'spacemacs-buffer/goto-buffer
|
||||
"Go to home Spacemacs buffer")
|
||||
|
||||
(defun spacemacs/insert-line-above-no-indent (count)
|
||||
(interactive "p")
|
||||
|
|
Loading…
Reference in New Issue