2014-09-24 00:47:20 +00:00
|
|
|
(setq message-log-max 16384)
|
|
|
|
(defconst emacs-start-time (current-time))
|
|
|
|
|
2014-09-27 04:11:37 +00:00
|
|
|
(defvar spacemacs-min-version "24.3"
|
|
|
|
"Mininal required version of Emacs.")
|
|
|
|
|
2014-09-10 03:05:02 +00:00
|
|
|
(define-derived-mode spacemacs-mode special-mode "spacemacs-mode"
|
2014-09-10 03:12:31 +00:00
|
|
|
"Spacemacs major mode for startup screen."
|
|
|
|
:syntax-table nil
|
|
|
|
:abbrev-table nil
|
|
|
|
(setq truncate-lines t)
|
|
|
|
(setq cursor-type nil))
|
2014-09-10 02:02:38 +00:00
|
|
|
|
2014-09-27 04:11:37 +00:00
|
|
|
(defun spacemacs/emacs-version-ok ()
|
|
|
|
(not (version< emacs-version spacemacs-min-version)))
|
|
|
|
|
2014-09-30 02:43:25 +00:00
|
|
|
(defun display-startup-echo-area-message ()
|
|
|
|
"Change the default welcome message of minibuffer to another one."
|
|
|
|
(message "Spacemacs is ready."))
|
|
|
|
|
2014-10-04 02:18:27 +00:00
|
|
|
(defun spacemacs/load-dotfile ()
|
2014-09-07 03:28:13 +00:00
|
|
|
"Load ~/.spacemacs. If it is not found then copy .spacemacs.template to
|
|
|
|
~/.spacemacs"
|
|
|
|
(let ((dotfile (concat user-home-directory ".spacemacs")))
|
|
|
|
(unless (file-exists-p dotfile)
|
|
|
|
(copy-file (concat user-emacs-directory ".spacemacs.template") dotfile))
|
|
|
|
(load dotfile)))
|
|
|
|
|
2014-09-24 00:47:20 +00:00
|
|
|
(defvar spacemacs-title-length 70)
|
2014-10-04 02:18:27 +00:00
|
|
|
(defvar spacemacs-loading-counter 0)
|
|
|
|
(defvar spacemacs-loading-text "Loading")
|
|
|
|
(defvar spacemacs-loading-done-text "Ready!")
|
|
|
|
(defvar spacemacs-loading-dots-chunk-count 3)
|
|
|
|
(defvar spacemacs-loading-dots-count
|
|
|
|
(- spacemacs-title-length
|
|
|
|
(length spacemacs-loading-text)
|
|
|
|
(length spacemacs-loading-done-text)))
|
|
|
|
(defvar spacemacs-loading-dots-chunk-size
|
|
|
|
(/ spacemacs-loading-dots-count spacemacs-loading-dots-chunk-count))
|
|
|
|
(defvar spacemacs-loading-dots-chunk-threshold 0)
|
2014-09-07 03:16:17 +00:00
|
|
|
|
2014-10-04 02:18:27 +00:00
|
|
|
(defun spacemacs/buffer ()
|
2014-09-07 03:16:17 +00:00
|
|
|
"Create and initialize the spacemacs startup buffer."
|
2014-09-10 03:05:02 +00:00
|
|
|
(interactive)
|
2014-09-07 03:16:17 +00:00
|
|
|
(switch-to-buffer (get-buffer-create "*spacemacs*"))
|
2014-09-10 03:05:02 +00:00
|
|
|
(spacemacs-mode)
|
|
|
|
(let ((buffer-read-only nil))
|
2014-09-27 04:11:37 +00:00
|
|
|
(insert-file-contents (concat spacemacs-core-directory "banner.txt"))
|
|
|
|
(unless (spacemacs/emacs-version-ok)
|
2014-10-04 02:18:27 +00:00
|
|
|
(spacemacs/append-to-buffer
|
2014-09-27 04:11:37 +00:00
|
|
|
(format "\nError: Minimal required Emacs version for Spacemacs is %s "
|
|
|
|
spacemacs-min-version))
|
2014-10-04 02:18:27 +00:00
|
|
|
(spacemacs/append-to-buffer (format
|
|
|
|
"whereas current Emacs version is %s.\n"
|
|
|
|
emacs-version))
|
|
|
|
(spacemacs/append-to-buffer "Spacemacs is disabled.\n")
|
2014-09-27 04:11:37 +00:00
|
|
|
(setq inhibit-startup-screen t)
|
|
|
|
(redisplay))))
|
2014-09-07 03:16:17 +00:00
|
|
|
|
2014-10-04 02:18:27 +00:00
|
|
|
(defun spacemacs/append-to-buffer (msg &optional messagebuf)
|
2014-09-26 02:14:57 +00:00
|
|
|
"Append MSG to spacemacs buffer. If MESSAGEBUF is not nil then MSG is
|
|
|
|
also written in message buffer."
|
2014-09-07 03:16:17 +00:00
|
|
|
(with-current-buffer (get-buffer-create "*spacemacs*")
|
|
|
|
(goto-char (point-max))
|
2014-09-10 03:05:02 +00:00
|
|
|
(let ((buffer-read-only nil))
|
2014-09-26 02:14:57 +00:00
|
|
|
(insert msg)
|
|
|
|
(if messagebuf (message "(Spacemacs) %s" msg)))))
|
2014-09-07 03:16:17 +00:00
|
|
|
|
2014-10-04 02:18:27 +00:00
|
|
|
(defun spacemacs/replace-last-line-of-buffer (msg &optional messagebuf)
|
2014-09-26 02:14:57 +00:00
|
|
|
"Replace the last line of the spacemacs buffer with MSG. If MESSAGEBUF is
|
|
|
|
not nil then MSG is also written in message buffer."
|
2014-09-07 03:16:17 +00:00
|
|
|
(with-current-buffer (get-buffer-create "*spacemacs*")
|
|
|
|
(goto-char (point-max))
|
2014-09-10 03:05:02 +00:00
|
|
|
(let ((buffer-read-only nil))
|
|
|
|
(delete-region (line-beginning-position) (point-max))
|
2014-09-26 02:14:57 +00:00
|
|
|
(insert msg)
|
|
|
|
(if messagebuf (message "(Spacemacs) %s" msg)))))
|
2014-09-07 03:16:17 +00:00
|
|
|
|
2014-10-04 02:18:27 +00:00
|
|
|
(defun spacemacs/loading-animation ()
|
2014-09-07 03:16:17 +00:00
|
|
|
"Display LOADING-TITLE with trailing dots of max length
|
|
|
|
SPACEMACS-TITLE-LENGTH. New loading title is displayed by chunk
|
|
|
|
of size LOADING-DOTS-CHUNK-THRESHOLD."
|
2014-10-04 02:18:27 +00:00
|
|
|
(setq spacemacs-loading-counter (1+ spacemacs-loading-counter))
|
|
|
|
(if (>= spacemacs-loading-counter spacemacs-loading-dots-chunk-threshold)
|
2014-09-07 03:16:17 +00:00
|
|
|
(progn
|
2014-10-04 02:18:27 +00:00
|
|
|
(setq spacemacs-loading-counter 0)
|
2014-09-07 03:16:17 +00:00
|
|
|
(let ((i 0))
|
2014-10-04 02:18:27 +00:00
|
|
|
(while (< i spacemacs-loading-dots-chunk-size)
|
|
|
|
(setq spacemacs-loading-text (concat spacemacs-loading-text "."))
|
2014-09-07 03:16:17 +00:00
|
|
|
(setq i (1+ i))))
|
2014-10-04 02:18:27 +00:00
|
|
|
(spacemacs/replace-last-line-of-buffer spacemacs-loading-text)
|
2014-09-07 03:16:17 +00:00
|
|
|
(redisplay))))
|
|
|
|
|
|
|
|
;; Ready message
|
2014-09-27 04:11:37 +00:00
|
|
|
(unless (not (spacemacs/emacs-version-ok))
|
|
|
|
(add-hook 'after-init-hook
|
|
|
|
(lambda ()
|
2014-10-04 02:18:27 +00:00
|
|
|
(spacemacs/append-to-buffer (format "%s\n" spacemacs-loading-done-text))
|
2014-09-27 04:11:37 +00:00
|
|
|
;; from jwiegley
|
|
|
|
;; https://github.com/jwiegley/dot-emacs/blob/master/init.el
|
|
|
|
(let ((elapsed (float-time
|
|
|
|
(time-subtract (current-time) emacs-start-time))))
|
2014-10-04 02:18:27 +00:00
|
|
|
(spacemacs/append-to-buffer
|
2014-10-05 13:39:21 +00:00
|
|
|
(format "[%s packages loaded in %.3fs]\n"
|
|
|
|
(contribsys/initialized-packages-count)
|
|
|
|
elapsed))))))
|
2014-09-07 03:16:17 +00:00
|
|
|
|