doomemacs/modules/editor/file-templates
Henrik Lissner 54d8c49d8b
refactor(file-templates): suppress in indirect buffers
Change how we detect and suppress file template expansion in org-capture
buffers (which are indirect clones). Since 99.99% of the time, an
indirect clone means we're doing something special in that buffer, it
seemed sensible to always suppress file templates in them. Hopefully
this will be more robust than the former advice.
2022-03-21 03:57:02 +01:00
..
templates tweak(file-templates): remove default JSON template 2022-03-19 16:14:53 +01:00
autoload.el fix(file-templates): +file-templates/debug 2021-10-18 01:15:09 +02:00
config.el refactor(file-templates): suppress in indirect buffers 2022-03-21 03:57:02 +01:00
packages.el Bump * 2020-08-19 16:18:11 -04:00
README.org Update TOC format of file-templates README 2020-02-14 15:08:27 +02:00

editor/file-templates

Description

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

Module Flags

This module provides no flags.

Plugins

This module installs no plugins.

Prerequisites

This module has no prerequisites.

Usage

File templates are automatically expanded when opening empty files.

They are also regular yasnippet snippets, which can be expanded by typing their trigger and pressing TAB. By convention, the triggers for file templates are prefixed with two underscores __.

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; shorter versions meant for comment headers in code.

Configuration

Registering a new file template

Look into the documentation of set-file-template! and set-file-templates!.

Changing existing file templates

Simply register a new template (using set-file-template!) that matches the same file. The new template would be pushed to the top of +file-template-alist and thus would take priority while searching for a template to insert.

Adding new OSS licenses

The +file-templates/insert-license command searches for snippets under text-mode that are named __license-ABC, where ABC is the short name of the license. e.g. __license-mit.

So long as these files exist, +file-templates/insert-license will recognize them.

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.

Appendix

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