2022-03-28 15:03:21 +02:00
|
|
|
#+title: :config literate
|
|
|
|
#+subtitle: Disguise your config as poor documentation
|
|
|
|
#+created: May 28, 2020
|
|
|
|
#+since: 2.0.9
|
2021-10-16 01:21:52 +02:00
|
|
|
|
|
|
|
* Description :unfold:
|
2020-07-24 15:22:29 -04:00
|
|
|
This module enables support for a literate config.
|
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
A literate config consists of a =$DOOMDIR/config.org=. All src blocks within are
|
|
|
|
tangled =$DOOMDIR/config.el=, by default, when ~$ doom sync~ is executed.
|
2020-05-28 10:43:01 +03:00
|
|
|
|
|
|
|
** Maintainers
|
2021-10-16 01:21:52 +02:00
|
|
|
/This module has no dedicated maintainers./ [[doom-contrib-maintainer:][Become a maintainer?]]
|
2020-05-28 10:43:01 +03:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
** Module flags
|
|
|
|
/This module has no flags./
|
2020-05-28 10:43:01 +03:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
** Packages
|
|
|
|
/This module doesn't install any packages./
|
2020-05-28 10:43:01 +03:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
** Hacks
|
|
|
|
/No hacks documented for this module./
|
2020-05-28 10:43:01 +03:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
** TODO Changelog
|
|
|
|
# This section will be machine generated. Don't edit it by hand.
|
|
|
|
/This module does not have a changelog yet./
|
|
|
|
|
|
|
|
* Installation
|
|
|
|
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
|
|
|
|
|
|
|
This module only requires a =$DOOMDIR/config.org=, which will be tangled into
|
|
|
|
=$DOOMDIR/config.el= when you run ~$ doom sync~.
|
|
|
|
|
|
|
|
#+begin_quote
|
|
|
|
🚧 *Be careful!* Enabling this module will overwrite =$DOOMDIR/config.el=! If
|
|
|
|
you are only trying out the module, *back up this file first!*
|
|
|
|
#+end_quote
|
|
|
|
|
|
|
|
* TODO Usage
|
|
|
|
#+begin_quote
|
|
|
|
🔨 /This module's usage documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
|
|
|
#+end_quote
|
|
|
|
|
|
|
|
- Automatically tangles =$DOOMDIR/config.org= to =$DOOMDIR/config.el= when
|
|
|
|
saving. See [[*Troubleshooting][Troubleshooting]] section belong on how to disable it.
|
|
|
|
|
|
|
|
* TODO Configuration
|
|
|
|
#+begin_quote
|
|
|
|
🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
|
|
|
|
#+end_quote
|
2020-05-28 10:43:01 +03:00
|
|
|
|
2020-07-24 15:22:29 -04:00
|
|
|
** Change the location of config.org
|
2020-07-25 22:38:37 -04:00
|
|
|
The ~+literate-config-file~ variable controls where to look for your config.org.
|
2021-10-16 01:21:52 +02:00
|
|
|
To change this it must be modified early -- in =$DOOMDIR/init.el= or
|
|
|
|
=$DOOMDIR/cli.el=.
|
2020-07-24 15:22:29 -04:00
|
|
|
|
2020-07-25 22:38:37 -04:00
|
|
|
Source blocks needs to be in some language to be automatically tangled, for
|
2021-10-16 01:21:52 +02:00
|
|
|
example ~#+begin_src emacs-lisp~, but it doesn't matter what language is used.
|
|
|
|
All blocks are tangled to ~config.el~, but ~elisp~ gives correct syntax
|
2020-07-25 22:38:37 -04:00
|
|
|
highlighting. If you don't want to specify language in block you can also
|
2021-10-16 01:21:52 +02:00
|
|
|
enforce tangling by adding ~#+begin_src :tangle yes~
|
2020-05-28 10:43:01 +03:00
|
|
|
|
2020-07-24 15:22:29 -04:00
|
|
|
** Change where src blocks are tangled or prevent it entirely
|
2020-08-12 02:42:05 -04:00
|
|
|
By default, this module tangles all src emacs-lisp blocks to config.el unless
|
|
|
|
otherwise specified.
|
2020-07-24 15:22:29 -04:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
To specify otherwise use the ~:tangle~ parameter to:
|
2020-08-12 02:42:05 -04:00
|
|
|
- Specify a destination other than config.el: ~:tangle packages.el~
|
|
|
|
- Disable tangling of the block altogether with ~:tangle no~
|
2020-07-24 15:22:29 -04:00
|
|
|
- Or force non-elisp src blocks to tangle somewhere
|
|
|
|
|
|
|
|
For example:
|
2021-10-16 01:21:52 +02:00
|
|
|
#+begin_src org
|
|
|
|
,#+begin_src emacs-lisp :tangle no
|
2020-07-24 15:22:29 -04:00
|
|
|
(message "Don't tangle me")
|
2021-10-16 01:21:52 +02:00
|
|
|
,#+end_src
|
2020-07-24 15:22:29 -04:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
,#+begin_src emacs-lisp :tangle packages.el
|
2020-07-24 15:22:29 -04:00
|
|
|
(package! my-package)
|
|
|
|
(package! other-package)
|
2021-10-16 01:21:52 +02:00
|
|
|
,#+end_src
|
2020-07-24 15:22:29 -04:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
,#+begin_src sh :tangle ~/.dotfiles/bin/script.sh :tangle-mode (identity #o755)
|
2020-07-24 15:22:29 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
echo Hello world
|
2021-10-16 01:21:52 +02:00
|
|
|
,#+end_src
|
2020-07-31 01:39:24 -04:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
,#+begin_src sh :tangle ~/.dotfiles/bin/script.sh :shebang "#!/usr/bin/env bash"
|
2020-07-31 01:39:24 -04:00
|
|
|
echo Hello world
|
2021-10-16 01:21:52 +02:00
|
|
|
,#+end_src
|
|
|
|
#+end_src
|
2020-07-24 15:22:29 -04:00
|
|
|
|
2020-08-12 02:42:05 -04:00
|
|
|
You'll find more information about babel src blocks and what parameters they
|
2021-10-16 01:21:52 +02:00
|
|
|
support [[https://orgmode.org/manual/Working-with-Source-Code.html][in the Org manual]].
|
2020-08-12 02:42:05 -04:00
|
|
|
|
2020-05-28 10:43:01 +03:00
|
|
|
* Troubleshooting
|
2021-10-16 01:21:52 +02:00
|
|
|
/There are no known problems with this module./ [[doom-report:][Report one?]]
|
|
|
|
|
|
|
|
* Frequently asked questions
|
|
|
|
[[doom-suggest-faq:][Ask a question?]]
|
|
|
|
|
|
|
|
** How do I tangle to =$DOOMDIR/init.el=?
|
2020-07-25 22:38:37 -04:00
|
|
|
If your literate needs are more complex (e.g. you want to make your init.el
|
2021-10-16 01:21:52 +02:00
|
|
|
literate), this module won't cut it. =init.el= files in modules are loaded long
|
|
|
|
before =config.org= is tangled in the ~$ doom sync~ process.
|
2020-07-25 22:38:37 -04:00
|
|
|
|
|
|
|
However, Doom comes with a [[file:../../../bin/org-tangle][bin/org-tangle]] script which can be used to tangle
|
|
|
|
arbitrary org files from the command line. Use it to create your own compilation
|
|
|
|
workflows. This is /much/ faster than using ~org-babel-load-file~ directly to
|
|
|
|
load your literate config every time Doom is started.
|
2020-07-24 15:22:29 -04:00
|
|
|
|
2021-10-16 01:21:52 +02:00
|
|
|
** How do I disable tangle-on-save?
|
2020-07-24 15:22:29 -04:00
|
|
|
There are occasions where tangling on save may be undesirable. Maybe it's too
|
|
|
|
slow, produces too much noise, or happens too often (on unrelated org files in
|
2021-10-16 01:21:52 +02:00
|
|
|
your =$DOOMDIR=). This behavior can be disabled with:
|
|
|
|
#+begin_src emacs-lisp
|
|
|
|
;; add to $DOOMDIR/config.el
|
2020-07-24 15:22:29 -04:00
|
|
|
(remove-hook 'org-mode-hook #'+literate-enable-recompile-h)
|
2021-10-16 01:21:52 +02:00
|
|
|
#+end_src
|
|
|
|
|
|
|
|
* TODO Appendix
|
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
|
|
|
#+end_quote
|