TL;DR Should get 20~25% speed improvement on startup, should get a big
improvement when using ivy or helm SPC h SPC. Users with layers.el files
in their layers must use `configuration-layer/declare-used-layer`
instead of `configuration-layer/declare-layer`
The implementation of the layer system made heavy use of `object-assoc`
and `object-assoc-list` functions which are not efficient. This PR
mainly replaces those object lists with hash maps in order to index the
objects by their name and achieve an O(1) access time.
The old object lists `configuration-layer--layers` and
`configuration-layer--packages` have been each by two variables each:
- `configuration-layer--indexed-layers` which is a hash-map of all the
layer objects and `configuration-layer--used-layers` which is a list of
all _used_ layers symbols,
- symmetrically `configuration-layer--indexed-packages` which is a
hash-map of all the package objects and
`configuration-layer--used-packages` which is a list of all _used_
packages symbols.
The hash map `configuration-layer--layer-paths` is gone, now we create
directly layer objects when discovering the layers and set the :dir
property. Note that previously the layer paths were the parent directory
of the layer, now :dir is the layer path.
The function `configuration-layer//make-layer` is now similar to its
counterpart `configuration-layer//make-package` in the sense that it
takes an optional `obj` to be able to override its properties.
The functions `configuration-layer/declare-layer` and
`configuration-layer/declare-layers` now takes an optional parameter
`usedp` in order to declare used or not used layers. For convenience
new functions have been added: `configuration-layer/declare-used-layer`
and `configuration-layer/declare-used-layers`, users _must_ update all
occurrences of `configuration-layer/declare-layer` by
`configuration-layer/declare-used-layers` in their `layers.el` files.
`helm-spacemacs-help` and `ivy-spacemacs-help` are updated to match the
changes in `core-configuration-layer.el`.
Rename some variables to make them more explicit:
`configuration-layer-no-layer` -> `configuration-layer-exclude-all-layers`
`configuration-layer-distribution` -> `configuration-layer-force-distribution`
Old implementation excluded package that were not selected, this
implementation does not excluded them, it simply ignore it in the
layer where they are not selected. This reimplementation comes from
a refactor of the way packages.el files are loaded, instead of loading
these files at the moment of resolving the list of used packages, they
are now loaded when making the layer objects. A neat consequence is that
side effects is better confined and the configuration-layer/get-packages
is now pure (at least a lot more pure than before).
In the `cfgl-layer` class the slot `:user-packages` has been renamed
to `:selected-packages` which defaults to `'all` meaning that all
the packages in `:packages` are selected. `:selected-packages` value
is given by the new function `configuration-layer//select-packages`.
Effectively selected packages are given by a new method for `cfgl-layer`
class called `cfgl-layer-get-packages`.
Tests have been updated to reflect the changes.
Also documentation on configuration layer declaration in the dotfile
section of DOCUMENTATION.org has been greatly improved (I hope) and
reflect the last feature added to the
`dotspacemacs-configuration-layers` list.
The car of :owners is the real owner.
Now we can easily gather the list of all owners of a package.
Also fix unit tests about missing spacemacs-insecure variable.
This new variable replace dotspacemacs-delete-orphan-packages
It defines the behaviour of Spacemacs when downloading packages.
Possible values are `used', `used-but-keep-unused' and `all'.
- `used' will download only explicitly used packages and remove any
unused packages as well as their dependencies.
- `used-but-keep-unused' will download only the used packages but won't
delete them if they become unused.
- `all' will download all the packages regardless if they are used or
not and packages won't be deleted by Spacemacs.
Default value is `used`.
The new layer file `layers.el` is used to declared additional layers.
It is like the sibling of packages.el except that for now it does not
take a list (can do this in a futur commit).
The new order for file loading is the following:
layers.el > packages.el > funcs.el > config.el > keybindings.el
Since packages.el relies on some undefined stuff encapsulated
in init functions, it is not meant to be byte compiled. OTOH funcs.el
(where lies most of the computation added by a package config) should
be compilable.
Since we load packages.el very early it is not possible to use
`configuration-layer/package-usedp` in funcs.el.
This commit also fixes the tests.
New package :step 'bootstrap', this step happens before 'pre' packages.
A new layer names 'spacemacs-bootstrap' gather all the ':step bootstrap'
packages. This layer is special and is always the first element of
the variable 'configuration-layer--layers' which assure that all
bootstrap packages are configured first.
This new layer leverages the configuration layer system, removes the
clutter of package installations in the function 'spacemacs/init' and
isolate the bootstrap packages in one place.
Make cfgl-layer-owned-packages return a list of package objects instead
of just package names.
Use this function to correctly excluded non owned package when flagging
package for lazy installation.
Fixes#5608
New function configuration-layer/insert-lazy-install-configuration
This function asks for a layer and then insert the lazy configuration
for all the packages owned by this layer.
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).
Add request.el to core/libs
Refactor package.el initialization in configuration-layer.el
Cosmetic improvements to loading messages
Remove redefinition of package-refresh-packages
post value for package :step property is both useless and considered
harmful. It would hijack the determinism of the loading order.
'pre value is used very very rarely and I even think it is not even
used since most of the time a package that must be loaded in pre step
is a bootstrap package. But we keep 'pre since it can be useful to
have it for _exceptional_ cases.
While doing the tests I encountered an edge case where a package owned
by the dotfile could be passed either a 'private or 'local location
which is ambiguous (moreover where do we put packages with 'local
location ?).
We remove the ambiguity by removing the 'private value and push the
path ~/.emacs.d/private/local/pkg/ when the owner of a local
package PKG is the dotfile.
When the owner of a local package is a layer then the load path is
in the "local" subdirectory of the layer directory. It adds no value
to use the old 'private location in this case.
Helm seems to treat "!" specially in pattern matching, so having a ! in
the pattern string when traversing directories is problematic. This
change fixes#2737, because as far as I can tell "+" has no special
meaning in a helm pattern.
Of course, we can choose a different character, but I'm fond of "+" as
representing "more layers here".
- Rename contrib directory to layers
- Add new variable dotspacemacs-distribution
- Move spacemacs layer to layers/!distribution
- New layer spacemacs-core in layers/!distribution
- User can now set dotspacemacs-distribution to spacemacs or
spacemacs-core (default spacemacs)
spacemacs-core is very lightweight layer sufficient to build upon
spacemacs.
Also it is not need to pass a list, example:
```
(setq dotspacemacs-configuration-layers
'((auto-completion :disabled-for org git)))
```
Will disable auto-completion for org and git layers.
Example:
(setq dotspacemacs-configuration-layers
'((auto-completion :disabled-for (org))))
Will not run any org/pre-init-xxx or org/post-init-xxx functions where
xxx is a package owned by the auto-completion layer.
Limitation:
If ownership of an auto-completion package P is stolen by another layer L
then :disabled-for must also be declared with L, otherwise the P will
be configured for org.
(setq dotspacemacs-configuration-layers
'((auto-completion :disabled-for (org))
(L :disabled-for (org)))
The user should not change the default owner of a layer unless really
required (for instance to use his own fork).