Merge branch 'smooth-startup' into develop

This commit is contained in:
syl20bnr 2014-11-16 22:45:28 -05:00
commit d7c8cf147d
6 changed files with 137 additions and 120 deletions

View file

@ -1,19 +1,4 @@
;; Spacemacs Contribution System
(require 'package)
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
(setq warning-minimum-level :error)
;; Emacs 24.3 and above ships with python.el but in some Emacs 24.3.1 packages
;; for Ubuntu, python.el seems to be missing.
;; This hack adds marmalade repository for this case only.
(unless (or (package-installed-p 'python) (version< emacs-version "24.3"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/")))
(load (concat spacemacs-core-directory "ht.el"))
(defconst spacemacs-dotspacemacs-version "1.0"
"Minimum Version exepected for ~/.spacemacs file.")
@ -78,6 +63,23 @@ NOT USED FOR NOW :-)"
(defvar dotspacemacs-excluded-packages '()
"A list of packages and/or extensions that will not be install and loaded.")
(defun contribsys/package.el-initialize ()
"Initialize package.el"
(require 'package)
(unless package--initialized
(load (concat spacemacs-core-directory "ht.el"))
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("melpa" . "http://melpa.org/packages/")))
(package-initialize)
;; Emacs 24.3 and above ships with python.el but in some Emacs 24.3.1 packages
;; for Ubuntu, python.el seems to be missing.
;; This hack adds marmalade repository for this case only.
(unless (or (package-installed-p 'python) (version< emacs-version "24.3"))
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/")))
(setq warning-minimum-level :error)))
(defun contribsys/dotfile-location ()
"Return the absolute path to the spacemacs dotfile."
(concat user-home-directory ".spacemacs"))

View file

@ -4,25 +4,6 @@
(defvar spacemacs-min-version "24.3"
"Mininal required version of Emacs.")
(define-derived-mode spacemacs-mode special-mode "spacemacs-mode"
"Spacemacs major mode for startup screen."
:syntax-table nil
:abbrev-table nil
(setq truncate-lines t)
(setq cursor-type nil)
;; no welcome buffer
(setq inhibit-startup-screen t)
;; motion state since this is a special mode
(eval-after-load 'evil
'(add-to-list 'evil-motion-state-modes 'spacemacs-mode)))
(defun spacemacs/emacs-version-ok ()
(not (version< emacs-version spacemacs-min-version)))
(defun display-startup-echo-area-message ()
"Change the default welcome message of minibuffer to another one."
(message "Spacemacs is ready."))
(defvar spacemacs-title-length 70)
(defvar spacemacs-loading-counter 0)
(defvar spacemacs-loading-text "Loading")
@ -35,6 +16,81 @@
(defvar spacemacs-loading-dots-chunk-size
(/ spacemacs-loading-dots-count spacemacs-loading-dots-chunk-count))
(defvar spacemacs-loading-dots-chunk-threshold 0)
(defvar spacemacs-solarized-dark-createdp nil)
(define-derived-mode spacemacs-mode special-mode "spacemacs-mode"
"Spacemacs major mode for startup screen."
:syntax-table nil
:abbrev-table nil
(setq truncate-lines t)
(setq cursor-type nil)
;; no welcome buffer
(setq inhibit-startup-screen t)
;; load the default theme manually to give a smooth startup experience
(spacemacs/load-or-install-package 'dash)
(add-to-list 'load-path "~/.emacs.d/spacemacs/extensions/solarized-theme/")
(require 'solarized)
(deftheme solarized-dark "The dark variant of the Solarized colour theme")
(deftheme solarized-light "The light variant of the Solarized colour theme")
(create-solarized-theme 'light 'solarized-light)
;; font
;; Dynamic font size depending on the system
(let ((font "Source Code Pro"))
(when (member font (font-family-list))
(pcase window-system
(`x (spacemacs/set-font font 10))
(`mac (spacemacs/set-font font 12))
(`w32 (spacemacs/set-font font 9))
(other (spacemacs/set-font font 10)))))
;; edit area full screen
(tool-bar-mode -1)
(when (not (eq window-system 'mac))
(menu-bar-mode -1))
(scroll-bar-mode -1)
;; motion state since this is a special mode
(eval-after-load 'evil
'(add-to-list 'evil-motion-state-modes 'spacemacs-mode)))
(defun spacemacs/load-or-install-package (pkg)
"Load PKG package. PKG will be installed if it is not already
installed."
(condition-case nil
(require pkg)
(error
;; not installed, we try to initialize package.el only if required to
;; precious seconds during boot time
(require 'cl)
(let* ((elpa-dir (concat user-emacs-directory "elpa/"))
(pkg-elpa-dir
(if (file-exists-p elpa-dir)
(reduce (lambda (x y) (if x x y))
(mapcar (lambda (x)
(if (string-match (symbol-name pkg) x) x))
(directory-files elpa-dir))
:initial-value nil))))
(if pkg-elpa-dir
(add-to-list 'load-path (concat user-emacs-directory "elpa/"
pkg-elpa-dir))
;; install the package
(contribsys/package.el-initialize)
(package-refresh-contents)
(package-install pkg))
(require pkg)))))
(defun spacemacs/emacs-version-ok ()
(not (version< emacs-version spacemacs-min-version)))
(defun display-startup-echo-area-message ()
"Change the default welcome message of minibuffer to another one."
(message "Spacemacs is ready."))
(defun spacemacs/set-font (font size &optional options)
(let* ((fontstr (if options
(format "%s-%s:%s" font size options)
(format "%s-%s" font size))))
(message (format "Set default font: %s" fontstr))
(add-to-list 'default-frame-alist (cons 'font fontstr))
(set-default-font fontstr)))
(defun spacemacs/buffer ()
"Create and initialize the spacemacs startup buffer."

View file

@ -2,6 +2,7 @@
(defconst spacemacs-core-directory
(expand-file-name (concat user-emacs-directory "core/"))
"Spacemacs core directory.")
(load (concat spacemacs-core-directory "contribsys.el"))
(load (concat spacemacs-core-directory "spacemacs-mode.el"))
(spacemacs/buffer)
@ -31,7 +32,7 @@
"Dropbox directory.")
;; if you have a dropbox, then ~/Dropbox/emacs is added to load path
(add-to-list 'load-path (concat user-dropbox-directory "emacs/"))
(load (concat spacemacs-core-directory "contribsys.el"))
(contribsys/package.el-initialize)
;; User configuration file for Spacemacs: ~/.spacemacs
(contribsys/load-dotfile)
(contribsys/call-dotfile-func dotspacemacs/init)

View file

@ -22,17 +22,9 @@
;; Edit
;; ---------------------------------------------------------------------------
;; set the 2 keys sequence to return to normal state
;; default is "fd"
(defvar spacemacs-normal-state-sequence '(?f . ?d)
"Two keys sequence to return to normal state.")
(defvar spacemacs-normal-state-sequence-delay 0.2
"Maximum delay between the two keys to trigger the normal state.")
;; start scratch in text mode (usefull to get a faster Emacs load time
;; because it avoids autoloads of elisp modes)
(setq initial-major-mode 'text-mode)
;; font size
;;(set-face-attribute 'default nil :height 110)
;; whitespace-mode
(setq-default show-trailing-whitespace nil)
;; When point is on paranthesis, highlight the matching one
@ -52,11 +44,6 @@
(lambda () (setq mode-name "Elisp")))
;; important for golden-ratio to better work
(setq window-combination-resize t)
;; edit area full screen
(tool-bar-mode -1)
(when (not (eq window-system 'mac))
(menu-bar-mode -1))
(scroll-bar-mode -1)
;; fringes
(setq-default fringe-indicator-alist
'((truncation . nil) (continuation . nil)))
@ -73,16 +60,6 @@
(setq tooltip-use-echo-area t)
;; When emacs asks for "yes" or "no", let "y" or "n" sufficide
(fset 'yes-or-no-p 'y-or-n-p)
;; font
;; (set-default-font "DejaVu Sans Mono-10")
;; Dynamic font size depending on the system
(let ((font "Source Code Pro"))
(when (member font (font-family-list))
(pcase window-system
(`x (spacemacs/set-font font 10))
(`mac (spacemacs/set-font font 12))
(`w32 (spacemacs/set-font font 9))
(other (spacemacs/set-font font 10)))))
;; draw underline lower
(setq x-underline-at-descent-line t)
;; setup right and left margins
@ -239,4 +216,3 @@
(defun server-remove-kill-buffer-hook ()
(remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function))
(add-hook 'server-visit-hook 'server-remove-kill-buffer-hook)

View file

@ -4,7 +4,6 @@
(defvar spacemacs-pre-extensions
'(
use-package
solarized-theme
))
;; Post extensions are loaded *after* the packages
@ -99,20 +98,3 @@
(spray-quit)
(set-default-evil-insert-state-cursor)
(evil-normal-state))))))
;; solarized theme dependencies
(unless (package-installed-p 'dash)
(package-refresh-contents)
(package-install 'dash))
(defun spacemacs/init-solarized-theme ()
;; different method used than the documented one in order to speed up the
;; loading of emacs
(use-package solarized
:init
(progn
(deftheme solarized-dark "The dark variant of the Solarized colour theme")
(create-solarized-theme 'dark 'solarized-dark)
(deftheme solarized-light "The light variant of the Solarized colour theme")
(create-solarized-theme 'light 'solarized-light)
(spacemacs/post-theme-init 'solarized-light)
(redisplay))))

View file

@ -51,6 +51,49 @@
(interactive)
(string-equal system-type "windows-nt"))
;; From http://stackoverflow.com/a/18796138
;; Cycle through this set of themes
(defvar spacemacs-themes '(solarized-light
solarized-dark
monokai
zenburn)
"Themes officially supported by spacemacs.")
(defvar spacemacs-cur-theme (pop spacemacs-themes)
"Current spacemacs theme.")
(defun spacemacs/cycle-spacemacs-theme ()
"Cycle through themes defined in spacemacs-themes."
(interactive)
(when spacemacs-cur-theme
(disable-theme spacemacs-cur-theme)
(setq spacemacs-themes (append spacemacs-themes
(list spacemacs-cur-theme))))
(setq spacemacs-cur-theme (pop spacemacs-themes))
(message "Loading theme %s..." spacemacs-cur-theme)
(load-theme spacemacs-cur-theme t))
(defadvice load-theme (around spacemacs/load-theme-adv activate)
"Perform post load processing."
(let ((theme (ad-get-arg 0)))
(if (and spacemacs-solarized-dark-createdp
(eq 'solarized-dark theme))
(create-solarized-theme 'dark 'solarized-dark))
ad-do-it
(setq spacemacs-cur-theme theme)
(spacemacs/post-theme-init theme)))
(defun spacemacs/post-theme-init (theme)
" Some processing that needs to be done when the current theme has been
changed to THEME."
(interactive)
;; Define a face for each state
(if (fboundp 'spacemacs/set-state-faces)
(spacemacs/set-state-faces))
(if (fboundp 'spacemacs/set-flycheck-mode-line-faces)
(spacemacs/set-flycheck-mode-line-faces))
(if (fboundp 'powerline-reset)
(powerline-reset)))
;; insert one or several line below without changing current evil state
(defun evil-insert-line-below (count)
"Insert one of several lines below the current point's line without changing
@ -302,41 +345,6 @@ argument takes the kindows rotate backwards."
"Edit the `file' in the spacemacs base directory, in the current window."
(ido-find-file-in-dir spacemacs-contrib-config-directory))
;; From http://stackoverflow.com/a/18796138
;; Cycle through this set of themes
(setq spacemacs-themes '(solarized-light
solarized-dark
monokai
zenburn))
(defvar spacemacs-cur-theme (pop spacemacs-themes))
(defun spacemacs/cycle-spacemacs-theme ()
"Cycle through themes defined in spacemacs-themes."
(interactive)
(when spacemacs-cur-theme
(disable-theme spacemacs-cur-theme)
(setq spacemacs-themes (append spacemacs-themes
(list spacemacs-cur-theme))))
(setq spacemacs-cur-theme (pop spacemacs-themes))
(message "Loading theme %s..." spacemacs-cur-theme)
(load-theme spacemacs-cur-theme t))
(defadvice load-theme (after spacemacs/load-theme-adv activate)
"Perform post load processing."
(setq spacemacs-cur-theme (ad-get-arg 0))
(spacemacs/post-theme-init spacemacs-cur-theme))
(defun spacemacs/post-theme-init (theme)
" Some processing that needs to be done when the current theme has been
changed to THEME."
(interactive)
;; Define a face for each state
(if (fboundp 'spacemacs/set-state-faces)
(spacemacs/set-state-faces))
(if (fboundp 'spacemacs/set-flycheck-mode-line-faces)
(spacemacs/set-flycheck-mode-line-faces))
(if (fboundp 'powerline-reset)
(powerline-reset)))
;; From http://xugx2007.blogspot.ca/2007/06/benjamin-rutts-emacs-c-development-tips.html
(setq compilation-finish-function
(lambda (buf str)
@ -548,14 +556,6 @@ kill internal buffers too."
(when (not (frame-parameter nil 'fullscreen)) 'fullscreen)))
))
(defun spacemacs/set-font (font size &optional options)
(let* ((fontstr (if options
(format "%s-%s:%s" font size options)
(format "%s-%s" font size))))
(message (format "Set default font: %s" fontstr))
(add-to-list 'default-frame-alist (cons 'font fontstr))
(set-default-font fontstr)))
(defun spacemacs/scale-font-size-overlay-map ()
"Set a temporary overlay map to easily change the font size."
(set-temporary-overlay-map