core: re-evaluate layer variables after package configuration
It allows to put package variable with a default value set by spacemacs in the layer variables. For instance to set treemacs position to the right, you can now do it like this: (treemacs :variables treemacs-position 'right)
This commit is contained in:
parent
738b1be5c3
commit
92fac263a8
|
@ -662,6 +662,9 @@ To prevent package from being installed or uninstalled set the variable
|
|||
(configuration-layer/delete-orphan-packages packages))))
|
||||
;; configure used packages
|
||||
(configuration-layer//configure-packages configuration-layer--used-packages)
|
||||
;; evaluate layer variables a second time to override default values set in
|
||||
;; packages configuration above
|
||||
(configuration-layer//set-layers-variables configuration-layer--used-layers)
|
||||
(configuration-layer//load-layers-files configuration-layer--used-layers
|
||||
'("keybindings.el"))
|
||||
(dotspacemacs|call-func dotspacemacs/user-load
|
||||
|
@ -1558,9 +1561,10 @@ RNAME is the name symbol of another existing layer."
|
|||
"Unknown layer %s to declare lshadow relationship."
|
||||
rname)))))
|
||||
|
||||
(defun configuration-layer//set-layers-variables (layers)
|
||||
"Set the configuration variables for the passed LAYERS."
|
||||
(mapc 'configuration-layer//set-layer-variables layers))
|
||||
(defun configuration-layer//set-layers-variables (layer-names)
|
||||
"Set the configuration variables for the passed LAYER-NAMES."
|
||||
(mapc 'configuration-layer//set-layer-variables (mapcar '(lambda (lname) (configuration-layer/get-layer lname))
|
||||
layer-names)))
|
||||
|
||||
(defun configuration-layer//set-layer-variables (layer)
|
||||
"Set the configuration variables for the passed LAYER."
|
||||
|
|
|
@ -1151,47 +1151,55 @@
|
|||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(ert-deftest test-set-layers-variables--none ()
|
||||
(let ((input `(,(cfgl-layer "layer"
|
||||
:name 'layer
|
||||
:dir "/a/path/")))
|
||||
(let ((configuration-layer--indexed-layers (make-hash-table :size 1024))
|
||||
(var 'foo))
|
||||
(configuration-layer//set-layers-variables input)
|
||||
(helper--add-layers
|
||||
`(,(cfgl-layer "layer"
|
||||
:name 'layer
|
||||
:dir "/a/path/")))
|
||||
(configuration-layer//set-layers-variables '(layer))
|
||||
(should (eq var 'foo))))
|
||||
|
||||
(ert-deftest test-set-layers-variables--one-value ()
|
||||
(let ((input `(,(cfgl-layer "layer"
|
||||
:name 'layer
|
||||
:dir "/a/path/"
|
||||
:variables '(var1 'bar)))))
|
||||
(let ((configuration-layer--indexed-layers (make-hash-table :size 1024)))
|
||||
(helper--add-layers
|
||||
`(,(cfgl-layer "layer"
|
||||
:name 'layer
|
||||
:dir "/a/path/"
|
||||
:variables '(var1 'bar))))
|
||||
(setq var1 'foo)
|
||||
(configuration-layer//set-layers-variables input)
|
||||
(configuration-layer//set-layers-variables '(layer))
|
||||
(should (eq var1 'bar))))
|
||||
|
||||
(ert-deftest test-set-layers-variables--multiple-values ()
|
||||
(let ((input `(,(cfgl-layer "layer"
|
||||
:name 'layer
|
||||
:dir "/a/path/"
|
||||
:variables '(var1 'bar1 var2 'bar2 var3 'bar3)))))
|
||||
(let ((configuration-layer--indexed-layers (make-hash-table :size 1024)))
|
||||
(helper--add-layers
|
||||
`(,(cfgl-layer "layer"
|
||||
:name 'layer
|
||||
:dir "/a/path/"
|
||||
:variables '(var1 'bar1 var2 'bar2 var3 'bar3))))
|
||||
(setq var1 'foo)
|
||||
(setq var2 'foo)
|
||||
(setq var3 'foo)
|
||||
(configuration-layer//set-layers-variables input)
|
||||
(configuration-layer//set-layers-variables '(layer))
|
||||
(should (eq var1 'bar1))
|
||||
(should (eq var2 'bar2))
|
||||
(should (eq var3 'bar3))))
|
||||
|
||||
(ert-deftest test-set-layers-variables--odd-number-of-values ()
|
||||
(let ((input `(,(cfgl-layer "layer"
|
||||
:name 'layer
|
||||
:dir "/a/path/"
|
||||
:variables '(var1 'bar var2)))))
|
||||
(let ((configuration-layer--indexed-layers (make-hash-table :size 1024)))
|
||||
(helper--add-layers
|
||||
`(,(cfgl-layer "layer"
|
||||
:name 'layer
|
||||
:dir "/a/path/"
|
||||
:variables '(var1 'bar var2))))
|
||||
(mocker-let
|
||||
((configuration-layer//warning
|
||||
(msg &rest args)
|
||||
((:record-cls 'mocker-stub-record :output nil :occur 1))))
|
||||
(setq var1 'foo)
|
||||
(setq var2 'foo)
|
||||
(configuration-layer//set-layers-variables input)
|
||||
(configuration-layer//set-layers-variables '(layer))
|
||||
(should (eq var1 'bar))
|
||||
(should (eq var2 'foo)))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue