core: new values for dotspacemacs-enable-lazy-installation

- all
- unused
- nil
- t

Fixed #5608
This commit is contained in:
syl20bnr 2016-03-27 15:55:24 -04:00
parent bf9f281269
commit 5e5b7a6569
3 changed files with 52 additions and 35 deletions

View File

@ -292,8 +292,7 @@ If NO-INSTALL is non nil then install steps are skipped."
(setq configuration-layer--used-distant-packages (setq configuration-layer--used-distant-packages
(configuration-layer//get-distant-used-packages (configuration-layer//get-distant-used-packages
configuration-layer--packages)) configuration-layer--packages))
(when dotspacemacs-enable-lazy-installation (configuration-layer/load-auto-layer-file)
(configuration-layer/load-auto-layer-file))
(unless no-install (unless no-install
(configuration-layer//install-packages (configuration-layer//install-packages
(configuration-layer/filter-objects (configuration-layer/filter-objects
@ -667,34 +666,35 @@ If TOGGLEP is non nil then `:toggle' parameter is ignored."
(defun configuration-layer/lazy-install (layer-name &rest props) (defun configuration-layer/lazy-install (layer-name &rest props)
"Configure auto-installation of layer with name LAYER-NAME." "Configure auto-installation of layer with name LAYER-NAME."
(declare (indent 1)) (declare (indent 1))
(let ((extensions (spacemacs/mplist-get props :extensions))) (when (configuration-layer//lazy-install-p layer-name)
(when (configuration-layer/layer-usedp layer-name) (let ((extensions (spacemacs/mplist-get props :extensions)))
(let* ((layer (object-assoc layer-name (when (configuration-layer/layer-usedp layer-name)
:name configuration-layer--layers)) (let* ((layer (object-assoc layer-name
(packages (when layer (cfgl-layer-owned-packages layer)))) :name configuration-layer--layers))
;; set lazy install flag for a layer if and only if all its owned (packages (when layer (cfgl-layer-owned-packages layer))))
;; distant packages are not already installed ;; set lazy install flag for a layer if and only if all its owned
(let ((lazy (cl-reduce (lambda (x y) (and x y)) ;; distant packages are not already installed
(mapcar (let ((lazy (cl-reduce
(lambda (p) (lambda (x y) (and x y))
(or (not (eq layer-name (oref p :owner))) (mapcar (lambda (p)
(null (package-installed-p (or (not (eq layer-name (oref p :owner)))
(oref p :name))))) (null (package-installed-p
(configuration-layer//get-distant-used-packages (oref p :name)))))
packages)) (configuration-layer//get-distant-used-packages
:initial-value t))) packages))
(oset layer :lazy-install lazy) :initial-value t)))
(dolist (pkg packages) (oset layer :lazy-install lazy)
(oset pkg :lazy-install lazy))))) (dolist (pkg packages)
(dolist (x extensions) (oset pkg :lazy-install lazy)))))
(let ((ext (car x)) (dolist (x extensions)
(mode (cadr x))) (let ((ext (car x))
(add-to-list 'configuration-layer--lazy-mode-alist (cons mode ext)) (mode (cadr x)))
(add-to-list (add-to-list 'configuration-layer--lazy-mode-alist (cons mode ext))
'auto-mode-alist (add-to-list
`(,ext . (lambda () 'auto-mode-alist
(configuration-layer//auto-mode `(,ext . (lambda ()
',layer-name ',mode)))))))) (configuration-layer//auto-mode
',layer-name ',mode)))))))))
(defun configuration-layer//auto-mode (layer-name mode) (defun configuration-layer//auto-mode (layer-name mode)
"Auto mode support of lazily installed layers." "Auto mode support of lazily installed layers."
@ -987,9 +987,9 @@ path."
(defun configuration-layer//lazy-install-p (layer-name) (defun configuration-layer//lazy-install-p (layer-name)
"Return non nil if the layer with LAYER-NAME should be lazy installed." "Return non nil if the layer with LAYER-NAME should be lazy installed."
(let ((layer (object-assoc layer-name :name configuration-layer--layers))) (or (memq dotspacemacs-enable-lazy-installation '(all t))
(or (null layer) (and (eq 'unused dotspacemacs-enable-lazy-installation)
(oref layer :lazy-install)))) (not (configuration-layer/layer-usedp layer-name)))))
(defun configuration-layer//lazy-install-packages (layer-name mode) (defun configuration-layer//lazy-install-packages (layer-name mode)
"Install layer with LAYER-NAME to support MODE." "Install layer with LAYER-NAME to support MODE."

View File

@ -65,8 +65,15 @@ environment, otherwise it is strongly recommended to let it set to t.")
"List of additional paths where to look for configuration layers. "List of additional paths where to look for configuration layers.
Paths must have a trailing slash (ie. `~/.mycontribs/')") Paths must have a trailing slash (ie. `~/.mycontribs/')")
(defvar dotspacemacs-enable-lazy-installation t (defvar dotspacemacs-enable-lazy-installation 'unused
"If non-nil layers with lazy install support are lazy installed.") " Lazy installation of layers (i.e. layers are installed only when a file
with a supported type is opened). Possible values are `all', `unused' and `nil'.
`unused' will lazy install only unused layers (i.e. layers not listed in
variable `dotspacemacs-configuration-layers'), `all' will lazy install any layer
that support lazy installation even the layers listed in
`dotspacemacs-configuration-layers'. `nil' disable the lazy installation feature
and you have to explicitly list a layer in the variable
`dotspacemacs-configuration-layers' to install it.")
(defvar dotspacemacs-additional-packages '() (defvar dotspacemacs-additional-packages '()
"List of additional packages that will be installed wihout being "List of additional packages that will be installed wihout being

View File

@ -11,6 +11,16 @@ values."
;; `+distribution'. For now available distributions are `spacemacs-base' ;; `+distribution'. For now available distributions are `spacemacs-base'
;; or `spacemacs'. (default 'spacemacs) ;; or `spacemacs'. (default 'spacemacs)
dotspacemacs-distribution 'spacemacs dotspacemacs-distribution 'spacemacs
;; Lazy installation of layers (i.e. layers are installed only when a file
;; with a supported type is opened). Possible values are `all', `unused'
;; and `nil'. `unused' will lazy install only unused layers (i.e. layers
;; not listed in variable `dotspacemacs-configuration-layers'), `all' will
;; lazy install any layer that support lazy installation even the layers
;; listed in `dotspacemacs-configuration-layers'. `nil' disable the lazy
;; installation feature and you have to explicitly list a layer in the
;; variable `dotspacemacs-configuration-layers' to install it.
;; (default 'unused)
dotspacemacs-enable-lazy-installation 'unused
;; If non-nil layers with lazy install support are lazy installed. ;; If non-nil layers with lazy install support are lazy installed.
;; (default t) ;; (default t)
dotspacemacs-enable-lazy-installation t dotspacemacs-enable-lazy-installation t