core: new package keyword :toggle
This new keyword allows to add all the packages to the <layer>-packages even when a package is not toggled on by a given layer variable. This fixes an issue of the layer system where we had to choose between discoverability (ie. the list of package in helm or ivy with SPC h SPC) and installation of package (because any package listed in the variable <layer>-packages were installed).
This commit is contained in:
parent
308fb1118d
commit
e4447264d9
|
@ -316,8 +316,11 @@ This file containes the change log for the next major version of Spacemacs.
|
|||
=packages-funcs.el= files
|
||||
- New functions =configuration-layer/remove-layer= and
|
||||
=configuration-layer/remove-layers=.
|
||||
- New package location =site=, a site package is a package installed on the
|
||||
host by a third party (ie. =mu4e= which is installed by =mu=)
|
||||
- New package keyword =:toggle= which can be a symbol or a list. A package is
|
||||
considered to be used if the toggle evaluates to non nil. By default =:toggle=
|
||||
is =t=.
|
||||
- New value =site= for package =:location= keyword, a site package is a package
|
||||
installed on the host by a third party (ie. =mu4e= which is installed by =mu=)
|
||||
- Improve =spacemacs|diminish= function (thanks to TheBB)
|
||||
*** Other fixes and improvements
|
||||
- Typos and documentation improvements (thanks to adrsta, andreas-h,
|
||||
|
|
|
@ -92,11 +92,11 @@
|
|||
(pre-layers :initarg :pre-layers
|
||||
:initform '()
|
||||
:type list
|
||||
:documentation "Layers with a pre-init function.")
|
||||
:documentation "List of layers with a pre-init function.")
|
||||
(post-layers :initarg :post-layers
|
||||
:initform '()
|
||||
:type list
|
||||
:documentation "Layers with a post-init function.")
|
||||
:documentation "List of layers with a post-init function.")
|
||||
(location :initarg :location
|
||||
:initform elpa
|
||||
:type (satisfies (lambda (x)
|
||||
|
@ -104,6 +104,11 @@
|
|||
(member x '(built-in local site elpa))
|
||||
(and (listp x) (eq 'recipe (car x))))))
|
||||
:documentation "Location of the package.")
|
||||
(toggle :initarg :toggle
|
||||
:initform t
|
||||
:type (satisfies (lambda (x) (or (symbolp x) (listp x))))
|
||||
:documentation
|
||||
"Package is enabled/installed if toggle evaluates to non-nil.")
|
||||
(step :initarg :step
|
||||
:initform nil
|
||||
:type (satisfies (lambda (x) (member x '(nil pre))))
|
||||
|
@ -124,6 +129,13 @@
|
|||
:documentation
|
||||
"If non-nil this package is excluded from all layers.")))
|
||||
|
||||
(defmethod cfgl-package-enabledp ((pkg cfgl-package))
|
||||
"Evaluate the `toggle' slot of passed PKG."
|
||||
(let ((toggle (oref pkg :toggle)))
|
||||
(cond
|
||||
((symbolp toggle) (symbol-value toggle))
|
||||
((listp toggle) (eval toggle)))))
|
||||
|
||||
(defvar configuration-layer--elpa-archives
|
||||
'(("melpa" . "melpa.org/packages/")
|
||||
("org" . "orgmode.org/elpa/")
|
||||
|
@ -465,6 +477,7 @@ Properties that can be copied are `:location', `:step' and `:excluded'."
|
|||
packages (lambda (x) (and (not (null (oref x :owner)))
|
||||
(not (memq (oref x :location) '(built-in site local)))
|
||||
(not (stringp (oref x :location)))
|
||||
(cfgl-package-enabledp x)
|
||||
(not (oref x :excluded))))))
|
||||
|
||||
(defun configuration-layer//get-private-layer-dir (name)
|
||||
|
@ -889,6 +902,8 @@ Returns non-nil if the packages have been installed."
|
|||
((null (oref pkg :owner))
|
||||
(spacemacs-buffer/message
|
||||
(format "%S ignored since it has no owner layer." pkg-name)))
|
||||
((not (cfgl-package-enabledp pkg))
|
||||
(spacemacs-buffer/message (format "%S is toggled off." pkg-name)))
|
||||
(t
|
||||
;; load-path
|
||||
(let ((location (oref pkg :location)))
|
||||
|
|
|
@ -11,6 +11,38 @@
|
|||
(require 'mocker)
|
||||
(require 'core-configuration-layer)
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; class cfgl-package
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
(ert-deftest test-cfgl-package-enabledp--default-toggle-eval-non-nil ()
|
||||
(let ((pkg (cfgl-package "testpkg" :name 'testpkg)))
|
||||
(should (cfgl-package-enabledp pkg))))
|
||||
|
||||
(ert-deftest test-cfgl-package-enabledp--symbol-toggle-eval-non-nil-example ()
|
||||
(let ((pkg (cfgl-package "testpkg" :name 'testpkg :toggle 'package-toggle))
|
||||
(package-toggle t))
|
||||
(should (cfgl-package-enabledp pkg))))
|
||||
|
||||
(ert-deftest test-cfgl-package-enabledp--symbol-toggle-eval-nil-example ()
|
||||
(let ((pkg (cfgl-package "testpkg" :name 'testpkg :toggle 'package-toggle))
|
||||
(package-toggle nil))
|
||||
(should (null (cfgl-package-enabledp pkg)))))
|
||||
|
||||
(ert-deftest test-cfgl-package-enabledp--list-toggle-eval-non-nil-example ()
|
||||
(let ((pkg (cfgl-package "testpkg"
|
||||
:name 'testpkg
|
||||
:toggle '(memq package-toggle '(foo bar))))
|
||||
(package-toggle 'foo))
|
||||
(should (cfgl-package-enabledp pkg))))
|
||||
|
||||
(ert-deftest test-cfgl-package-enabledp--list-toggle-eval-nil-example ()
|
||||
(let ((pkg (cfgl-package "testpkg"
|
||||
:name 'testpkg
|
||||
:toggle '(memq package-toggle '(foo bar))))
|
||||
(package-toggle 'other))
|
||||
(should (null (cfgl-package-enabledp pkg)))))
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; configuration-layer//resolve-package-archives
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
@ -501,7 +533,7 @@
|
|||
(layer1/init-pkg nil ((:output nil :occur 1))))
|
||||
(configuration-layer//configure-package pkg))))
|
||||
|
||||
(ert-deftest test-configure-packages--pre-init-is-evaluated ()
|
||||
(ert-deftest test-configure-package--pre-init-is-evaluated ()
|
||||
(let ((pkg (cfgl-package "pkg" :name 'pkg :owner 'layer1 :pre-layers '(layer2)))
|
||||
(configuration-layer--layers
|
||||
`(,(cfgl-layer "layer1" :name 'layer1)
|
||||
|
@ -593,6 +625,23 @@
|
|||
(spacemacs-buffer/loading-animation nil ((:output nil))))
|
||||
(configuration-layer//configure-packages-2 `(,pkg)))))
|
||||
|
||||
(ert-deftest test-configure-packages-2--toggle-t-is-configured ()
|
||||
(let ((pkg (cfgl-package "pkg" :name 'pkg :owner 'layer1 :toggle t))
|
||||
(mocker-mock-default-record-cls 'mocker-stub-record))
|
||||
(mocker-let
|
||||
((configuration-layer//configure-package (p) ((:occur 1)))
|
||||
(spacemacs-buffer/loading-animation nil ((:output nil))))
|
||||
(configuration-layer//configure-packages-2 `(,pkg)))))
|
||||
|
||||
(ert-deftest test-configure-packages-2--toggle-nil-is-not-configured ()
|
||||
(let ((pkg (cfgl-package "pkg" :name 'pkg :owner 'layer1 :toggle nil))
|
||||
(mocker-mock-default-record-cls 'mocker-stub-record))
|
||||
(mocker-let
|
||||
((configuration-layer//configure-package (p) nil)
|
||||
(spacemacs-buffer/loading-animation nil ((:output nil)))
|
||||
(spacemacs-buffer/message (m) ((:output nil))))
|
||||
(configuration-layer//configure-packages-2 `(,pkg)))))
|
||||
|
||||
(ert-deftest test-configure-packages-2--protected-package-is-configured()
|
||||
(let ((pkg (cfgl-package "pkg" :name 'pkg :owner 'layer1 :protected t))
|
||||
(mocker-mock-default-record-cls 'mocker-stub-record))
|
||||
|
|
Loading…
Reference in a new issue