doomemacs/modules/editor/file-templates
Henrik Lissner 1abcf913aa
revert: fix(docs): set mode in file-local vars
emacs-straight/org-mode@e22b4eb7aa introduced a breaking change that
made it impossible to rely on .dir-locals.el to change org-mode buffers
in $EMACSDIR to doom-docs-org-mode (without infinite recursion), so we
used file-local variables in 7e400ab.

emacs-straight/org-mode@215de6176b reverted that change, so we can use
.dir-locals.el again, and this is my preference, since it requires less
boilerplate across our hundreds of org files.

Ref: emacs-straight/org-mode@215de6176b
Ref: emacs-straight/org-mode@e22b4eb7aa
Revert: 7e400abdc0
2022-08-07 19:08:07 +02:00
..
templates revert: fix(docs): set mode in file-local vars 2022-08-07 19:08:07 +02:00
autoload.el refactor(file-templates): doom readme templates 2021-11-21 20:04:28 +01:00
config.el merge: rewrite-docs 2022-08-03 03:27:50 +02:00
packages.el Bump * 2020-08-19 16:18:11 -04:00
README.org revert: fix(docs): set mode in file-local vars 2022-08-07 19:08:07 +02:00

:editor file-templates

Description   unfold

This module adds file templates for blank files, powered by yasnippet.

Module flags

This module has no flags.

Packages

This module doesn't install any packages.

Hacks

TODO Changelog

This module does not have a changelog yet.

Installation

Enable this module in your doom! block.

This module has no external requirements.

TODO Usage

🔨 This module's usage documentation is incomplete. Complete it?

File templates are automatically expanded when opening empty files who match one of the rules in the +file-templates-alist variable.

These templates are simply yasnippet snippets, which can also be expanded by typing their trigger and pressing TAB. By convention, the triggers for file templates are prefixed with two underscores __ (the trigger for the default file template of a major mode is almost always __).

Inserting OSS licenses

A special command is available for inserting software licenses: M-x +file-templates/insert-license.

📌 Licenses with a -bp suffix are boilerplate templates; i.e. shorter versions intended for comment headers in code files.

TODO Configuration

🔨 This module's configuration documentation is incomplete. Complete it?

Adding new or changing existing file templates

New file templates can be added to $DOOMDIR/snippets/{major-mode}/{snippet-name}. The yasnippet documentation covers how to write a snippet. You can map a snippet to a file path, major mode, or another arbitrary predicate using set-file-template!.

Look into its documentation with <help> f set-file-template\!.

Adding new OSS licenses

Add snippet files to $DOOMDIR/snippets/text-mode/ with the __licenses- prefix and +file-templates/insert-license will recognize them. E.g. $DOOMDIR/snippets/text-mode/__license-mit.

Troubleshooting

  • If a file template isn't expanding where you expect it to, run M-x +file-templates/debug. This will report to you what file template rule would apply for the correct file.

Frequently asked questions

This module has no FAQs yet. Ask one?

TODO Appendix

🔨 This module's appendix is incomplete. Write more?

API

  • set-file-template! PRED &rest PLIST
  • set-file-templates! &rest TEMPLATES

Commands

  • +file-templates/insert-license
  • +file-templates/debug

Variables

  • +file-templates-dir
  • +file-templates-default-trigger
  • +file-templates-alist