A loader inspired by init-loader.
It loads split configuration files with require
instead of load
.
- anaphora
- cl-lib
- Emacs 24 or later
For example, there are configuration files like below,
~/.emacs.d/inits ├── ext/ │ └── init-helm.el ├── lang/ │ ├── init-emacs-lisp.el │ └── init-javascript.el └── init-package.el
you load them with following code.
(require 'el-init)
(el-init-load "~/.emacs.d/inits"
:subdirectories '("." "ext" "lang"))
el-init-load
adds the elements of subdirectories
argument to load-path
.
Then, el-init-load
calls require
for all the configuration files in all the
directories of subdirectories
argument.
So you have to call provide
or el-init-provide
in configuration files.
el-init-provide
is an utility to call provide
with the file name as a
feature name.
- Determination of non-numbering loading order
- User extensible
require
wrapper system
There are two ways to determination of loading order.
el-init-load
loads configuration files in order of subdirectories
parameter.
So if you want to load some configuration files earlier, put them into
the directory top of subdirectories
.
If a configuration file depends on other configuration files, load requirements
with require
in the configuration file.
You can customize require
used by el-init-load
to whatever you want,
for example measuring load times and catching errors.
If you want to set wrappers for loading of el-init-load
, use wrappers
parameter of el-init-load
.
For example, you want to use el-init-require/record-error
and
el-init-require/record-eval-after-load-error
, call el-init-load
like below.
(el-init-load "~/.emacs.d/inits"
:subdirectories '("." "ext" "lang")
:wrappers '(el-init-require/record-error
el-init-require/record-eval-after-load-error))
A require
wrapper is a function which has the same parameters as require
and calls el-init-next
like require
.
If you want to ignore errors, write a wrapper like below.
(defun my-require/ignore-errors (feature &optional filename noerror)
(ignore-errors (el-init-next feature filename noerror)))
el-init-next
calls the next wrapper.
If there are no wrappers to call, el-init-next
calls require
.
So a wrapper can skip loading by not calling el-init-next
.
Benchmarks loading configuration files.
Records errors while loading configuration files.
Ignores errors while loading configuration files.
Records errors which occur in eval-after-load
form.
Switches configuration files to load by the execution environment.
Records whether a configuration file has an old .elc file.
Compiles old .elc files of configuration files.
Provides lazy loading for configuration files.
Add provide
to the end of file of each configuration file which is
loaded by init-loader.
(provide 'CONFIGURATION-FILE-NAME)
;; EOF
You can also use el-init-provide
instead of provide
, like below.
(require 'el-init) ; It works without this line, but recommended.
(el-init-provide)
;; EOF
If a configuration file depends on other configuration files,
add require
to the beginning of the configuration file.
Because el-init doesn’t determine the loading order by the file name.
For example, if 30-foo.el
depends on 20-bar.el
,
you have to add (require '20-bar)
to the beginning of 30-foo.el
.
;; BOF
(require '20-bar)
This will probably be hard work. If so, go to the next step and do this step gradually.
If your setting of init-loader like below,
(require 'init-loader)
(init-loader-load "~/.emacs.d/init")
change it to the code below.
(require 'el-init)
(setq el-init-meadow-regexp "\\`meadow-"
el-init-carbon-emacs-regexp "\\`carbon-emacs-"
el-init-cocoa-emacs-regexp "\\`cocoa-emacs-"
el-init-nw-regexp "\\`nw-"
el-init-mac-regexp "\\`mac-"
el-init-windows-regexp "\\`windows-"
el-init-linux-regexp "\\`linux-"
el-init-freebsd-regexp "\\`freebsd-")
(el-init-load "~/.emacs.d/init"
:subdirectories '(".")
:wrappers '(el-init-require/record-error
el-init-require/system-case))