2017-02-20 00:19:12 -05:00
|
|
|
# Modules
|
|
|
|
|
2017-04-05 15:33:29 -04:00
|
|
|
Modules are made up of four parts, **all of which are optional**:
|
|
|
|
|
|
|
|
```text
|
|
|
|
modules/category/submodule/
|
|
|
|
modules/category/submodule/config.el
|
|
|
|
modules/category/submodule/packages.el
|
|
|
|
modules/category/submodule/autoload.el
|
|
|
|
modules/category/submodule/autoload/*.el
|
|
|
|
```
|
|
|
|
|
|
|
|
## config.el
|
|
|
|
|
2017-05-04 10:53:11 +02:00
|
|
|
The main configuration file and the first loaded when the module is activated
|
|
|
|
(using `doom!` or `require!`).
|
2017-04-05 15:33:29 -04:00
|
|
|
|
|
|
|
## packages.el
|
|
|
|
|
2017-05-04 10:53:11 +02:00
|
|
|
How modules inform DOOM what packages to install and where from. These should be
|
|
|
|
declarative, pure and idempotent. That means running them directly should have
|
|
|
|
no side-effects (besides affecting the variables `doom-modules` and
|
|
|
|
`doom-packages`) and whose results should alway be deterministic.
|
2017-04-05 15:33:29 -04:00
|
|
|
|
|
|
|
By default, packages are retrieved from ELPA. Otherwise, a MELPA-style recipe
|
2017-05-04 10:53:11 +02:00
|
|
|
can determine how to fetch it:
|
2017-04-05 15:33:29 -04:00
|
|
|
|
|
|
|
```emacs-lisp
|
|
|
|
;; from modules/tools/rotate-text/packages.el
|
|
|
|
(package! rotate-text :recipe (:fetcher github :repo "debug-ito/rotate-text.el"))
|
|
|
|
```
|
|
|
|
|
|
|
|
Other modules' packages.el files can be depended on, through `depends-on!`:
|
|
|
|
|
|
|
|
```emacs-lisp
|
|
|
|
;; from modules/feature/file-templates/packages.el
|
|
|
|
(depends-on! :feature snippets)
|
|
|
|
```
|
|
|
|
|
|
|
|
## autoload.el OR autoload/*.el
|
|
|
|
|
|
|
|
These are scanned by `doom/reload-autoloads`, whose functions are lazily-loaded,
|
|
|
|
given that they're marked with an `;;;###autoload` cookie:
|
|
|
|
|
|
|
|
```emacs-lisp
|
|
|
|
;; from modules/lang/org/autoload/org.el
|
|
|
|
;;;###autoload
|
|
|
|
(defun +org/toggle-checkbox ()
|
|
|
|
(interactive)
|
|
|
|
[...])
|
|
|
|
|
|
|
|
;; from modules/lang/org/autoload/evil.el
|
|
|
|
;;;###autoload (autoload '+org:attach "lang/org/autoload/evil" nil t)
|
|
|
|
(evil-define-command +org:attach (&optional uri)
|
|
|
|
(interactive "<a>")
|
|
|
|
[...])
|
|
|
|
```
|
|
|
|
|
|
|
|
## Other files
|
|
|
|
|
|
|
|
My convention for extra configuration files is a `+` prefix, e.g.
|
|
|
|
`modules/feature/version-control/+git.el`. These are **not** automatically
|
2017-05-04 10:53:11 +02:00
|
|
|
loaded, and must be loaded manually with `load!` from within `config.el`:
|
2017-04-05 15:33:29 -04:00
|
|
|
|
|
|
|
```emacs-lisp
|
|
|
|
;; from modules/feature/version-control/config.el
|
|
|
|
(load +git)
|
|
|
|
```
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
# What modules aren't
|
|
|
|
|
|
|
|
Modules loosely take after Spacemacs' notion of layers, but are not intended to
|
|
|
|
be interchangeable. Their purpose is _almost_ purely organizational.
|
|
|
|
|
2017-05-04 10:53:11 +02:00
|
|
|
Use `featurep!` to check for module availability:
|
2017-04-05 15:33:29 -04:00
|
|
|
|
|
|
|
```emacs-lisp
|
|
|
|
;; from modules/lang/go/packages.el
|
|
|
|
(when (featurep! :completion company)
|
|
|
|
(package! company-go))
|
|
|
|
|
|
|
|
;; from modules/lang/go/config.el
|
|
|
|
(def-package! company-go
|
|
|
|
:when (featurep! :completion company)
|
|
|
|
[...])
|
|
|
|
```
|