core: rename configuration-layer/sync to configuration-layer/load

Replace the optional argument `no-install` by a global variable named
`spacemacs-sync-packages`.
Rename the hooks to reflect the renaming of the function.
Rename the flag `--no-sync` to the more explicit `--no-package-sync`
This commit is contained in:
syl20bnr 2017-07-01 10:54:37 -04:00
parent 1e340f62f3
commit cc0d8cafb2
6 changed files with 24 additions and 21 deletions

View File

@ -17,7 +17,8 @@
"If non-nil force Spacemacs to operate without secured protocols.")
(defvar spacemacs-sync-packages t
"If non-nil synchronize packages on startup")
"If non-nil packages are synchronized when the configuration layer system is
loaded.")
(defun spacemacs//parse-command-line (args)
"Handle Spacemacs specific command line arguments.
@ -56,7 +57,7 @@ arguments is that we want to process these arguments as soon as possible."
i (1+ i)))
("--resume-layouts"
(setq spacemacs-force-resume-layouts t))
("--no-sync"
("--no-package-sync"
(setq spacemacs-sync-packages nil))
(_ (push arg new-args))))
(setq i (1+ i)))

View File

@ -69,11 +69,11 @@ ROOT is returned."
(dir (car (directory-files elpa-dir 'full pkg-match))))
(when dir (file-name-as-directory dir))))))
(defvar configuration-layer-pre-sync-hook nil
"Hook executed at the beginning of configuration synchronization.")
(defvar configuration-layer-pre-load-hook nil
"Hook executed at the beginning of configuration loading.")
(defvar configuration-layer-post-sync-hook nil
"Hook executed at the end of configuration synchronization.")
(defvar configuration-layer-post-load-hook nil
"Hook executed at the end of configuration loading.")
(defvar configuration-layer-rollback-directory
(concat spacemacs-cache-directory ".rollback/")
@ -436,10 +436,11 @@ refreshed during the current session."
(package-read-all-archive-contents)
(unless quiet (spacemacs-buffer/append "\n")))))
(defun configuration-layer/sync (&optional install)
"Synchronize declared layers in dotfile with spacemacs.
If INSTALL is non nil then install missing packages."
(run-hooks 'configuration-layer-pre-sync-hook)
(defun configuration-layer/load ()
"Load layers declared in dotfile and install associated packages.
To prevent package from being installed or uninstalled set the variable
`spacemacs-sync-packages' to nil."
(run-hooks 'configuration-layer-pre-load-hook)
(dotspacemacs|call-func dotspacemacs/layers "Calling dotfile layers...")
(setq dotspacemacs--configuration-layers-saved
dotspacemacs-configuration-layers)
@ -461,7 +462,7 @@ If INSTALL is non nil then install missing packages."
;; load layers lazy settings
(configuration-layer/load-auto-layer-file)
;; install and/or uninstall packages
(when install
(when spacemacs-sync-packages
(let ((packages
(append
;; install used packages
@ -496,7 +497,7 @@ If INSTALL is non nil then install missing packages."
(configuration-layer//configure-packages configuration-layer--used-packages)
(configuration-layer//load-layers-files configuration-layer--used-layers
'("keybindings.el"))
(run-hooks 'configuration-layer-post-sync-hook))
(run-hooks 'configuration-layer-post-load-hook))
(defun configuration-layer/load-auto-layer-file ()
"Load `auto-layer.el' file"
@ -1440,7 +1441,8 @@ wether the declared layer is an used one or not."
"layer %s, do you want to install it?")
mode layer-name)))
(when (dotspacemacs/add-layer layer-name)
(configuration-layer/sync 'no-install))
(let (spacemacs-sync-packages)
(configuration-layer/load)))
(let* ((layer (configuration-layer/get-layer layer-name))
(inst-pkgs
(delq nil

View File

@ -136,12 +136,12 @@ seconds to load")
(advice-add 'package-initialize
:around
(spacemacs||make-function-timer package-intialize))
(advice-add 'configuration-layer/sync
(advice-add 'configuration-layer/load
:around
(spacemacs||make-function-timer configuration-layer/sync))
;; (advice-add 'configuration-layer/sync
(spacemacs||make-function-timer configuration-layer/load))
;; (advice-add 'configuration-layer/load
;; :around
;; (spacemacs||make-function-profiler configuration-layer/sync))
;; (spacemacs||make-function-profiler configuration-layer/load))
(advice-add 'configuration-layer//configure-package
:around
(spacemacs||make-function-timer configuration-layer//configure-package)))

View File

@ -493,7 +493,7 @@ Called with `C-u C-u' skips `dotspacemacs/user-config' _and_ preleminary tests."
(setq dotspacemacs-editing-style
(dotspacemacs//read-editing-style-config
dotspacemacs-editing-style))
(configuration-layer/sync)
(configuration-layer/load)
(if (member arg '((4) (16)))
(message (concat "Done (`dotspacemacs/user-config' "
"function has been skipped)."))
@ -557,7 +557,7 @@ a display strng and the value is the actual value to return."
(spacemacs-buffer/set-mode-line "Dotfile wizard installer")
(spacemacs//redisplay)
(when (dotspacemacs/install 'with-wizard)
(configuration-layer/sync))))
(configuration-layer/load))))
(defun dotspacemacs/install (arg)
"Install the dotfile, return non nil if the doftile has been installed.

View File

@ -323,7 +323,7 @@ has been changed to THEME."
(setcar theme2 pkg-name)
(setq theme2 pkg-name))
(add-to-list 'dotspacemacs--additional-theme-packages theme2)))))
(add-hook 'configuration-layer-pre-sync-hook
(add-hook 'configuration-layer-pre-load-hook
'spacemacs//add-theme-packages-to-additional-packages)
(provide 'core-themes-support)

View File

@ -27,7 +27,7 @@
"core/core-load-paths.el"))
(require 'core-spacemacs)
(spacemacs/init)
(configuration-layer/sync spacemacs-sync-packages)
(configuration-layer/load)
(spacemacs-buffer/display-startup-note)
(spacemacs/setup-startup-hook)
(require 'server)