Speed up boot time by lazy activating of packages
This commit is contained in:
parent
a7e071c3b8
commit
402d6e9267
|
@ -1,5 +1,20 @@
|
|||
(require 'dotspacemacs)
|
||||
(require 'ht)
|
||||
(require 'package)
|
||||
|
||||
(unless package--initialized
|
||||
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/")
|
||||
("gnu" . "http://elpa.gnu.org/packages/")
|
||||
("melpa" . "http://melpa.org/packages/")))
|
||||
;; optimization, no need to activate all the packages so early
|
||||
(package-initialize 'noactivate)
|
||||
;; 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))
|
||||
|
||||
(defconst configuration-layer-template-directory
|
||||
(expand-file-name (concat spacemacs-core-directory "templates/"))
|
||||
|
@ -54,22 +69,6 @@ sub-directory of the contribution directory.")
|
|||
(defvar configuration-layer--loaded-files '()
|
||||
"List of loaded files.")
|
||||
|
||||
(defun configuration-layer/package.el-initialize ()
|
||||
"Initialize package.el"
|
||||
(require 'package)
|
||||
(unless package--initialized
|
||||
(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 configuration-layer/create-layer (name)
|
||||
"Ask the user for a configuration layer name and create a layer with this
|
||||
name in the private layers directory."
|
||||
|
@ -399,8 +398,10 @@ If PRE is non nil then `layer-pre-extensions' is read instead of
|
|||
(let* ((init-func (intern (format "%s/init-%s" layer pkg))))
|
||||
(spacemacs/loading-animation)
|
||||
(if (and (package-installed-p pkg) (fboundp init-func))
|
||||
(progn (spacemacs/message "Package: Initializing %s:%s..." layer pkg)
|
||||
(funcall init-func))))))
|
||||
(progn
|
||||
(spacemacs/message "Package: Initializing %s:%s..." layer pkg)
|
||||
(package-activate pkg)
|
||||
(funcall init-func))))))
|
||||
|
||||
(defun configuration-layer//initialize-pre-extension (ext layers)
|
||||
"Initialize the pre-extensions EXT from configuration layers LAYERS."
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
(defconst spacemacs-min-version "24.3"
|
||||
"Mininal required version of Emacs.")
|
||||
|
||||
;; paths
|
||||
(defconst spacemacs-core-directory
|
||||
(expand-file-name (concat user-emacs-directory "core/"))
|
||||
"Spacemacs core directory.")
|
||||
(defconst spacemacs-banner-directory
|
||||
(expand-file-name (concat spacemacs-core-directory "banners/"))
|
||||
"Spacemacs banners directory.")
|
||||
|
||||
;; additional paths
|
||||
(defconst user-home-directory
|
||||
(expand-file-name "~/")
|
||||
"User home directory (~/).")
|
||||
|
@ -32,6 +34,7 @@
|
|||
;; if you have a dropbox, then ~/Dropbox/emacs is added to load path
|
||||
(add-to-list 'load-path (concat user-dropbox-directory "emacs/"))
|
||||
|
||||
;; loading progress bar variables
|
||||
(defvar spacemacs-title-length 75)
|
||||
(defvar spacemacs-loading-counter 0)
|
||||
(defvar spacemacs-loading-text "Loading")
|
||||
|
@ -152,7 +155,6 @@ FILE-TO-LOAD is an explicit file to load after the installation."
|
|||
(spacemacs/append-to-buffer
|
||||
(format "(Bootstrap) Installing %s...\n" pkg))
|
||||
(redisplay))
|
||||
(configuration-layer/package.el-initialize)
|
||||
(package-refresh-contents)
|
||||
(package-install pkg)
|
||||
(setq pkg-elpa-dir (spacemacs//get-package-directory pkg)))
|
||||
|
|
6
init.el
6
init.el
|
@ -1,7 +1,4 @@
|
|||
(defconst spacemacs-core-directory
|
||||
(expand-file-name (concat user-emacs-directory "core/"))
|
||||
"Spacemacs core directory.")
|
||||
(add-to-list 'load-path spacemacs-core-directory)
|
||||
(add-to-list 'load-path (concat user-emacs-directory "core/"))
|
||||
|
||||
(require 'spacemacs-mode)
|
||||
(require 'configuration-layer)
|
||||
|
@ -9,7 +6,6 @@
|
|||
(when (spacemacs/emacs-version-ok)
|
||||
(dotspacemacs/load)
|
||||
(spacemacs/initialize)
|
||||
(configuration-layer/package.el-initialize)
|
||||
;; Initializing configuration from ~/.spacemacs
|
||||
(dotspacemacs|call-func dotspacemacs/init)
|
||||
;; synchronize and load configuration layers
|
||||
|
|
Loading…
Reference in a new issue